Beispiel #1
0
 private void BindPurview()
 {
     System.Text.StringBuilder builder = new System.Text.StringBuilder();
     System.Collections.Generic.IList <CatalogInfo> cacheCatalogList = Catalog.GetCacheCatalogList();
     if (cacheCatalogList != null && cacheCatalogList.Count > 0)
     {
         DataTable dt     = Operate.GetOperateRelation();
         var       source = from t in dt.AsEnumerable()
                            group t by new
         {
             //t1 = t.Field("ModuleName"),
             //t2 = t.Field("ModuleCode")
         } into m
                   select new
         {
             //CatalogID = m.Max((DataRow p) => p.Field("CatalogID")),
             //ModuleName = m.Key.t1,
             //ModuleCode = m.Key.t2
         };
         foreach (CatalogInfo itemCatalog in cacheCatalogList)
         {
             builder.Append(string.Concat(new string[]
             {
                 "{\"CatalogCode\":\"",
                 itemCatalog.CatalogCode,
                 "\",\"CatalogName\":\"",
                 itemCatalog.CatalogName,
                 "\",\"Modules\":["
             }));
             //System.Collections.Generic.IEnumerable<<>f__AnonymousType1<int,string,string>> moduleForCatalog = from p in source
             //where p.CatalogID.Equals(itemCatalog.AutoID)
             //select p;
             //if (moduleForCatalog != null && moduleForCatalog.ToList().Count > 0)
             //{
             //    int counter1 = 0;
             //    moduleForCatalog.ToList().ForEach(delegate(p)
             //    {
             //        if (p.CatalogID == itemCatalog.AutoID)
             //        {
             //            if (counter1 == moduleForCatalog.ToList().Count - 1)
             //            {
             //                builder.Append(string.Concat(new string[]
             //                {
             //                    "{\"ModuleName\":\"",
             //                    p.ModuleName,
             //                    "\",\"ModuleCode\":\"",
             //                    p.ModuleCode,
             //                    "\",\"Operates\":[",
             //                    this.GetOperators(p.ModuleCode, dt),
             //                    "]}"
             //                }));
             //            }
             //            else
             //            {
             //                builder.Append(string.Concat(new string[]
             //                {
             //                    "{\"ModuleName\":\"",
             //                    p.ModuleName,
             //                    "\",\"ModuleCode\":\"",
             //                    p.ModuleCode,
             //                    "\",\"Operates\":[",
             //                    this.GetOperators(p.ModuleCode, dt),
             //                    "]},"
             //                }));
             //            }
             //        }
             //        counter1++;
             //    });
             //}
             builder.Append("]},");
         }
     }
     this.lbtext.Text = (this.jsondata = "[" + builder.ToString().TrimEnd(new char[]
     {
         ','
     }) + "]");
 }