Ejemplo n.º 1
0
        /// <summary>
        /// 清單查詢
        /// </summary>
        public void FindData()
        {
            var bl     = BusinessFunc.CreateBusinessLogic(this.SessionGuid, "Employee");
            var result = bl.Find(new GFindInputArgs());
            var table  = result.EntityTable;
            var json   = JsonConvert.SerializeObject(table, Formatting.Indented);

            FileFunc.FileWriteAllText($@"{CurrentPath}\DemoData\FindData", "Employee.json", json);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 刪除資料
        /// </summary>
        public void DeleteData()
        {
            var bl     = BusinessFunc.CreateBusinessLogic(this.SessionGuid, "Employee");
            var result = bl.Find(new GFindInputArgs());
            var table  = result.EntityTable;

            foreach (GEntityRow row in result.EntityTable.Rows)
            {
                bl.Delete(new GDeleteInputArgs {
                    FormID = row.ValueAsString(SysFields.ID)
                });
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 修改資料
        /// </summary>
        public void EditData()
        {
            var bl     = BusinessFunc.CreateBusinessLogic(this.SessionGuid, "Employee");
            var result = bl.Find(new GFindInputArgs());
            var table  = result.EntityTable;

            foreach (GEntityRow row in result.EntityTable.Rows)
            {
                row.SetValue(SysFields.ViewID, row.ValueAsString(SysFields.ViewID) + "_2");
            }
            var dataSet = new GEntitySet(table.TableName);

            dataSet.Tables.Add(table);
            var saveResult = bl.Save(new GSaveInputArgs {
                EntitySet = dataSet, SaveMode = ESaveMode.Edit
            });
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 新增資料
        /// </summary>
        public void AddData()
        {
            var files = from f in Directory.EnumerateFiles($@"{this.CurrentPath}\DemoData\ImportData", "*.json", SearchOption.TopDirectoryOnly)
                        select new { FileName = FileFunc.GetFileName(f).Replace(".json", ""), Text = FileFunc.FileReadAllText(f) };

            foreach (var file in files)
            {
                var dt = JsonConvert.DeserializeObject <DataTable>(file.Text);
                dt.TableName = file.FileName;
                var table   = new GEntityTable(dt);
                var dataSet = new GEntitySet(file.FileName);

                dataSet.Tables.Add(table);
                var bl     = BusinessFunc.CreateBusinessLogic(this.SessionGuid, file.FileName);
                var result = bl.Save(new GSaveInputArgs {
                    EntitySet = dataSet, SaveMode = ESaveMode.Add
                });
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 查詢單一資料
 /// </summary>
 public void FindSingleData()
 {
     var bl     = BusinessFunc.CreateBusinessLogic(this.SessionGuid, "Employee");
     var result = bl.Find(new GFindInputArgs());
 }