Пример #1
0
        public static void InitBaseAccess()
        {
            DBHelper db  = new DBHelper();
            var      tbs = RPTableSetting.GetTables();

            //清空Fields表
            DeleteField();

            int num = 0;

            foreach (var tb in tbs)
            {
                var       sql    = string.Format("select name from syscolumns WHERE (id = OBJECT_ID('{0}'))", tb.TableName);
                var       cmd    = db.GetSqlStringCommond(sql);
                DataTable fields = db.ExecuteDataTable(cmd);
                if (fields != null && fields.Rows.Count > 0)
                {
                    var data = new List <RPFieldSetting>();
                    for (int i = 0; i < fields.Rows.Count; i++)
                    {
                        var fieldName = fields.Rows[i][0].ToString();
                        var model     = new RPFieldSetting();
                        model.TableID       = tb.ID;
                        model.FieldName     = fieldName;
                        model.OtherZHCN     = fieldName;
                        model.OtherENUS     = fieldName;
                        model.DispZHCN      = fieldName;
                        model.DispENUS      = fieldName;
                        model.OrderBy       = i;
                        model.GlobalBy      = num;
                        model.ConditionType = FieldConditionType.None;
                        data.Add(model);
                        num++;
                    }
                    using (var scope = new TransactionScope())
                    {
                        RPFieldSetting.Add(data.ToArray());
                        scope.Complete();
                    }
                }
            }
        }
Пример #2
0
 public IHttpActionResult GetTableFields(int tableId)
 {
     return(Ok(RPFieldSetting.GetFieldsByTableID(tableId)));
 }