} // LoadGrid private ContentResult LoadGrid( GridActions nSpName, bool bIncludeTestCustomers, Func <AGridRow> oFactory, bool?bIncludeAllCustomers, DateTime?now = null, IEnumerable <QueryParameter> oMoreSpArgs = null ) { TimeCounter tc = new TimeCounter("LoadGrid building time for grid " + nSpName); var oRes = new SortedDictionary <long, AGridRow>(); var args = new List <QueryParameter> { new QueryParameter("@WithTest", bIncludeTestCustomers), }; if (bIncludeAllCustomers.HasValue) { args.Add(new QueryParameter("@WithAll", bIncludeAllCustomers)); } if (now.HasValue) { args.Add(new QueryParameter("@Now", now.Value)); } if (oMoreSpArgs != null) { args.AddRange(oMoreSpArgs); } using (tc.AddStep("retrieving from db and processing")) { this.db.ForEachRowSafe( sr => { AGridRow r = oFactory(); long nRowID = sr[r.RowIDFieldName()]; r.Init(nRowID, sr); if (r.IsValid()) { oRes[nRowID] = r; } }, nSpName.ToString(), CommandSpecies.StoredProcedure, args.ToArray() ); // foreach } // using log.Debug("{0}: traversing done.", nSpName); var sb = new StringBuilder(); sb.AppendLine(tc.Title); foreach (var time in tc.Steps) { sb.AppendFormat("\t{0}: {1}ms\n", time.Name, time.Length); } log.Info("{0}", sb); var serializer = new JavaScriptSerializer { MaxJsonLength = Int32.MaxValue, }; return(new ContentResult { Content = serializer.Serialize(new { aaData = oRes.Values }), ContentType = "application/json", }); } // LoadGrid