本文整理汇总了C#中Newtonsoft.Json.Linq.JObject.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# JObject.AddRange方法的具体用法?C# JObject.AddRange怎么用?C# JObject.AddRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Newtonsoft.Json.Linq.JObject
的用法示例。
在下文中一共展示了JObject.AddRange方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: document
/// <summary>
/// Retrieve document, or prepare new one
/// </summary>
public JObject document(int id, DocType type)
{
Title = Title.Replace("Document", type.UnCamel());
Extended_Document header = getDocument<Extended_Document>(id);
if (header.idDocument == null) {
header.DocumentTypeId = (int)type;
header.DocType = type.UnCamel();
header.DocumentDate = Utils.Today;
header.DocumentName = "";
header.DocumentIdentifier = Settings.NextNumber(type).ToString();
if (GetParameters["name"].IsInteger()) {
JObject name = Database.QueryOne("*", "WHERE Type = " + Database.Quote(NameType) + " AND idNameAddress = " + GetParameters["name"], "NameAddress");
if (name != null) {
checkNameType(name.AsString("Type"), NameType);
header.DocumentNameAddressId = name.AsInt("idNameAddress");
header.DocumentAddress = name.AsString("Address");
header.DocumentName = name.AsString("Name");
}
}
} else {
checkDocType(header.DocumentTypeId, type);
checkNameType(header.DocumentNameAddressId, NameType);
}
JObject record = new JObject().AddRange("header", header);
Database.NextPreviousDocument(record, "WHERE DocumentTypeId = " + (int)type);
Select s = new Select();
record.AddRange("VatCodes", s.VatCode(""),
"Names", s.Name(NameType, ""));
return record;
}
示例2: Document
/// <summary>
/// Get a Buy or Sell document for editing
/// </summary>
public void Document(int id, DocType type)
{
Title = Title.Replace("Document", type.UnCamel());
InvestmentDocument header = getDocument<InvestmentDocument>(id);
if (header.idDocument == null) {
header.DocumentTypeId = (int)type;
header.DocType = type.UnCamel();
header.DocumentDate = Utils.Today;
header.DocumentName = "";
if (GetParameters["acct"].IsInteger()) {
FullAccount acct = Database.QueryOne<FullAccount>("*", "WHERE idAccount = " + GetParameters["acct"], "Account");
if (acct.idAccount != null) {
header.DocumentAccountId = (int)acct.idAccount;
header.DocumentAccountName = acct.AccountName;
header.FeeAccount = Database.QueryOne("SELECT idAccount FROM Account WHERE AccountName = " + Database.Quote(acct.AccountName + " fees")).AsInt("idAccount");
}
}
} else {
checkDocType(header.DocumentTypeId, DocType.Buy, DocType.Sell);
List<JObject> journals = Database.Query(@"SELECT *
FROM Journal
LEFT JOIN StockTransaction ON idStockTransaction = idJournal
LEFT JOIN Security ON idSecurity = SecurityId
WHERE JournalNum > 1
AND DocumentId = " + id).ToList();
header.SecurityId = journals[0].AsInt("SecurityId");
header.SecurityName = journals[0].AsString("SecurityName");
header.Quantity = journals[0].AsDouble("Quantity");
header.Price = journals[0].AsDouble("Price");
if (journals.Count > 1) {
header.FeeAccount = journals[1].AsInt("AccountId");
header.Fee = journals[1].AsDecimal("Amount");
header.FeeMemo = journals[1].AsString("Memo");
}
if (type == DocType.Sell)
header.Quantity = -header.Quantity;
}
JObject record = new JObject().AddRange("header", header);
Database.NextPreviousDocument(record, "JOIN Journal ON DocumentId = idDocument WHERE DocumentTypeId "
+ Database.In(DocType.Buy, DocType.Sell)
+ (header.DocumentAccountId > 0 ? " AND AccountId = " + header.DocumentAccountId : ""));
Select s = new Select();
record.AddRange("Accounts", s.ExpenseAccount(""),
"Names", s.Other(""),
"Securities", s.Security(""));
Record = record;
}
示例3: auditFlatten
/// <summary>
/// Flatten an audit header-detail set into multiple records containing the header and 1 detail
/// </summary>
IEnumerable<JObject> auditFlatten(IEnumerable<JObject> data)
{
foreach (JObject record in data) {
JObject r = JObject.Parse(record.AsString("Record"));
record.Remove("Record");
JObject header = (JObject)r["header"];
if (header == null) {
record.AddRange(r);
yield return record;
} else {
if(header["DocumentAmount"] == null) header["DocumentAmount"] = header["Amount"];
if (header["DocumentName"] == null) header["DocumentName"] = header["Name"];
if (header["DocumentOutstanding"] == null) header["DocumentOutstanding"] = header["Outstanding"];
foreach (JObject detail in (JArray)r["detail"]) {
JObject result = new JObject();
result.AddRange(record, header, detail);
yield return result;
}
}
}
}