本文整理汇总了C#中BsonArray.OrderBy方法的典型用法代码示例。如果您正苦于以下问题:C# BsonArray.OrderBy方法的具体用法?C# BsonArray.OrderBy怎么用?C# BsonArray.OrderBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BsonArray
的用法示例。
在下文中一共展示了BsonArray.OrderBy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCaseFilter
/// <summary>
/// 获取过滤选项
/// </summary>
/// <param name="ReceiveMessage">回调消息</param>
public void GetCaseFilter(BsonDocument ReceiveMessage)
{
BsonArray TreeArray = new BsonArray();
BsonDocument Case = cs.FindOne(new BsonDocument("CaseName", CaseInfo.CaseName));
BsonDocument DirTreeDoc = new BsonDocument();
DirTreeDoc.Add("text", "目录结构");
DirTreeDoc.Add("children", new BsonArray().Add(Case.GetValue("MailPath")));
TreeArray.Add(DirTreeDoc);
BsonDocument FileTypeTreeDoc = new BsonDocument();
FileTypeTreeDoc.Add("text", "文件类型");
BsonArray FileTypeArray = new BsonArray();
foreach (BsonElement elm in Case.GetValue("FileType").AsBsonDocument)
{
FileTypeArray.Add(new BsonDocument("text", elm.Name).Add("Count", elm.Value));
}
FileTypeTreeDoc.Add("children", new BsonArray(FileTypeArray.OrderBy(t => -t.AsBsonDocument["Count"].AsInt32)));
TreeArray.Add(FileTypeTreeDoc);
BsonDocument MailAddressDoc = new BsonDocument();
MailAddressDoc.Add("text", "邮件地址");
BsonArray MailAddressArray = new BsonArray();
foreach (BsonDocument MailAddress in mas.GetDataForCase(new BsonDocument("ForCase", CaseInfo.CaseName)))
{
BsonDocument Address = new BsonDocument();
Address.Add("text", MailAddress.GetValue("Address"));
Address.Add("Count", MailAddress.GetValue("RepeatTimes"));
Address.Add("searchKey", "Address");
Address.Add("searchValue", MailAddress.GetValue("_id"));
MailAddressArray.Add(Address);
}
MailAddressDoc.Add("children", new BsonArray(MailAddressArray.OrderBy(t => -t.AsBsonDocument["Count"].AsInt32)));
TreeArray.Add(MailAddressDoc);
BsonDocument IpDoc = new BsonDocument();
IpDoc.Add("text", "Ip地址");
BsonArray IpArray = new BsonArray();
foreach (BsonDocument Ip in ips.GetDataForCase(new BsonDocument("ForCase", CaseInfo.CaseName)))
{
IpArray.Add(new BsonDocument("text", Ip.GetValue("Ip")).Add("Count", Ip.GetValue("RepeatTimes")));
}
IpDoc.Add("children", new BsonArray(IpArray.OrderBy(t => -t.AsBsonDocument["Count"].AsInt32)));
TreeArray.Add(IpDoc);
BsonDocument ContainerDoc = new BsonDocument();
ContainerDoc.Add("text", "集装箱编号");
BsonArray ContainerArray = new BsonArray();
foreach (BsonDocument Container in cos.GetData(new BsonDocument("ForCase", CaseInfo.CaseName)))
{
ContainerArray.Add(new BsonDocument("text", Container.GetValue("Container")).Add("Count", Container.GetValue("RepeatTimes")));
}
ContainerDoc.Add("children", new BsonArray(ContainerArray.OrderBy(t => -t.AsBsonDocument["Count"].AsInt32)));
TreeArray.Add(ContainerDoc);
BsonDocument NickNameDoc = new BsonDocument();
NickNameDoc.Add("text", "昵称");
BsonArray NickNameArray = new BsonArray();
foreach (BsonDocument NickName in nns.GetData(new BsonDocument("ForCase", CaseInfo.CaseName)))
{
NickNameArray.Add(new BsonDocument("text", NickName.GetValue("NickName")).Add("Count", NickName.GetValue("RepeatTimes")));
}
NickNameDoc.Add("children", new BsonArray(NickNameArray.OrderBy(t => -t.AsBsonDocument["Count"].AsInt32)));
TreeArray.Add(NickNameDoc);
BsonDocument PhoneDoc = new BsonDocument();
PhoneDoc.Add("text", "电话号码");
BsonArray PhoneArray = new BsonArray();
foreach (BsonDocument Phone in ps.GetData(new BsonDocument("ForCase", CaseInfo.CaseName)))
{
PhoneArray.Add(new BsonDocument("text", Phone.GetValue("Phone")).Add("Count", Phone.GetValue("RepeatTimes")));
}
PhoneDoc.Add("children", new BsonArray(PhoneArray.OrderBy(t => -t.AsBsonDocument["Count"].AsInt32)));
TreeArray.Add(PhoneDoc);
ReceiveMessage.Add("StateCode", 0);
ReceiveMessage.Add("ReData", TreeArray.ToJson(jsonSettings));
CallBack();
}