Beispiel #1
0
        public static void ImportFromJson(this ENV.Data.Entity entity, string json, bool ignoreDuplicateRows = false)
        {
            var vmc = new ViewModel {
                From = entity
            };
            var dl = DataList.FromJson(json);

            vmc.ImportRows(dl, ignoreDuplicateRows: ignoreDuplicateRows);
        }
Beispiel #2
0
        public static DataList ToDataList(this ENV.Data.Entity entity, FilterBase where = null, Sort orderBy = null, params ColumnBase[] columns)
        {
            var result   = new DataList();
            int pageSize = 100;
            int pageNum  = 0;
            {
                var s = System.Web.HttpContext.Current.Request["PageNum"];
                if (!string.IsNullOrEmpty(s))
                {
                    pageNum = int.Parse(s);
                }
            }

            var bp = new BusinessProcess {
                From = entity
            };

            if (where != null)
            {
                bp.Where.Add(where);
            }
            if (orderBy != null)
            {
                bp.OrderBy = orderBy;
            }
            bp.ForEachRow(() =>
            {
                int currentPage = ((int)bp.Counter - 1) / pageSize;
                if (currentPage == pageNum)
                {
                    if (columns != null)
                    {
                        result.AddItem(columns);
                    }
                    else
                    {
                        result.AddItem(entity);
                    }
                }
                else if (currentPage > pageNum)
                {
                    bp.Exit();
                }
            });
            return(result);
        }
Beispiel #3
0
        public static string ExportToJson(this ENV.Data.Entity entity, FilterBase where = null, Sort orderBy = null, params ColumnBase[] columns)
        {
            var vmc = new ViewModel
            {
                From = entity
            };

            if (where != null)
            {
                vmc.Where.Add(where);
            }
            if (orderBy != null)
            {
                vmc.OrderBy = orderBy;
            }
            return(vmc.ExportRows().ToJson());
        }
Beispiel #4
0
 public DataItem AddItem(ENV.Data.Entity e)
 {
     return(AddItem(e.Columns));
 }
 DataResult ToJson(ENV.Data.Entity e)
 {
     return(new ViewModel(e).ExportRows());
 }