当前位置: 首页>>代码示例>>C#>>正文


C# BsonArray.OrderBy方法代码示例

本文整理汇总了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();
        }
开发者ID:Zane0816,项目名称:Mail-.Net,代码行数:82,代码来源:CaseManager.cs


注:本文中的BsonArray.OrderBy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。