Beispiel #1
0
        protected virtual void CreateGroupColumns(FormConfigView formView, DataFormConfig dataformConfig)
        {
            //dataformConfig.ColumnGroups.ForEach(group =>
            //{
            //    var columnGroup = new ColumnGroupConfigView();
            //    columnGroup.ShowType = group.ShowType == 0 ? "ColShowType".AppKv<int>(4) : group.ShowType;
            //    columnGroup.Name = group.Name;
            //    columnGroup.DisplayName = group.DisplayName;
            //    columnGroup.Columns = new List<ColumnConfigView>();
            //    var hiddenColCount = 0;
            //    group.Columns.ForEach(col =>
            //    {
            //        var colView = formView.Columns.FirstOrDefault(x => x.Name == col.Name);
            //        if (colView != null)
            //        {
            //            columnGroup.Columns.Add(colView);
            //            if (colView.ControlType == ControlType.Hidden)
            //            {
            //                hiddenColCount++;
            //            }
            //        }

            //    });
            //    //组内没有成员,该组移除,若组内所有字段都是隐藏字段,该组隐藏
            //    if (columnGroup.Columns.Count > 0)
            //    {
            //        formView.ColumnGroups.Add(columnGroup);
            //        if (columnGroup.Columns.Count == hiddenColCount)
            //            columnGroup.IsHidden = true;
            //    }
            //});
        }
Beispiel #2
0
 public ModuleFormInfo(DataSet dataSet, int pageSize, string keyValue, string foreignKeyValue,
                       string tableName, string primaryKey, string foreignKey, bool isFillEmpty, DataFormConfig dataFormConfig,
                       string order, FormConfig moduleFormConfig)
 {
     DataSet          = dataSet;
     PageSize         = pageSize;
     KeyValue         = keyValue;
     ForeignKey       = foreignKey;
     ForeignKeyValue  = foreignKeyValue;
     TableName        = tableName;
     PrimaryKey       = primaryKey;
     ForeignKey       = foreignKey;
     IsFillEmpty      = isFillEmpty;
     DataFormConfig   = dataFormConfig;
     Order            = order;
     ModuleFormConfig = moduleFormConfig;
 }
Beispiel #3
0
 public void MergeColumns(FormConfig form, DataFormConfig dataForm, ModuleConfig moduleConfig)
 {
     if (form.FormColumnRight != null)
     {
         ColumnRightConfig columnRight     = null;
         string            columnRightname = form.FormColumnRight.Name;
         if (form.FormColumnRight.RegName.IsEmpty())
         {
             //Debug.AssertArgumentNullOrEmpty(columnRightname, "FormColumnRight中若没指定RegName,Name属性不能为空", moduleConfig);
             columnRight = moduleConfig.Right.ColumnRights.FirstOrDefault(a => a.Name == columnRightname);
             //Debug.AssertArgumentNull(columnRight, string.Format("ModuleXml中必须配置名为'{0}'的ColumnRight", columnRightname), moduleConfig);
         }
         else
         {
             IColumnRight columnRightPlug = provider.GetCodePlugService <IColumnRight>(form.FormColumnRight.RegName); //form.FormColumnRight.RegName.CodePlugIn<IColumnRight>();
             columnRightname = columnRightPlug.GetColumnRightName();
             columnRight     = moduleConfig.Right.ColumnRights.FirstOrDefault(a => a.Name == columnRightname);
             //Debug.AssertArgumentNull(columnRight, string.Format("ModuleXml中必须配置名为'{0}'的ColumnRight", columnRightname), moduleConfig);
         }
         //if (columnRight.Delete != null)
         //{
         //    columnRight.Delete.ForEach(dCol =>
         //    {
         //        var col = dataForm.Columns.FirstOrDefault(baseCol => baseCol.Name.Equals(dCol.Name, StringComparison.OrdinalIgnoreCase));
         //        if (col != null)
         //            dataForm.Columns.Remove(col);
         //    });
         //}
         if (columnRight.Override != null)
         {
             columnRight.Override.ForEach(oCol =>
             {
                 var col = dataForm.Columns.FirstOrDefault(baseCol => baseCol.Name.Equals(oCol.BaseColumnName, StringComparison.OrdinalIgnoreCase));
                 if (col != null)
                 {
                     AssignColumn(oCol, col);
                 }
             });
         }
         if (columnRight.Add != null)
         {
             dataForm.Columns.AddRange(columnRight.Add);
         }
     }
 }
Beispiel #4
0
 private void MergeDelColumns(FormConfig form, DataFormConfig dataForm, ModuleConfig moduleConfig, PageStyle pagestyle)
 {
     if (form.FormColumnRight != null)
     {
         ColumnRightConfig columnRight = GetColumnRight(form, dataForm, moduleConfig, pagestyle);
         if (columnRight.Delete != null)
         {
             columnRight.Delete.ForEach(dCol =>
             {
                 var col = dataForm.Columns.FirstOrDefault(baseCol => baseCol.Name.Equals(dCol.Name, StringComparison.OrdinalIgnoreCase));
                 if (col != null)
                 {
                     dataForm.Columns.Remove(col);
                 }
             });
         }
     }
 }
Beispiel #5
0
        private ColumnRightConfig GetColumnRight(FormConfig form, DataFormConfig dataForm, ModuleConfig moduleConfig, PageStyle pagestyle)
        {
            ColumnRightConfig columnRight     = null;
            string            columnRightname = form.FormColumnRight.Name;

            if (form.FormColumnRight.RegName.IsEmpty())
            {
                //Debug.AssertArgumentNullOrEmpty(columnRightname, "FormColumnRight中若没指定RegName,Name属性不能为空", moduleConfig);

                columnRight = moduleConfig.Right.ColumnRights.FirstOrDefault(a => a.Name == columnRightname);
                //Debug.AssertArgumentNull(columnRight, string.Format("ModuleXml中必须配置名为'{0}'的ColumnRight", columnRightname), moduleConfig);
            }
            else
            {
                IColumnRight columnRightPlug = provider.GetCodePlugService <IColumnRight>(form.FormColumnRight.RegName); //form.FormColumnRight.RegName.CodePlugIn<IColumnRight>();
                columnRightname = columnRightPlug.GetColumnRightName();
                columnRight     = moduleConfig.Right.ColumnRights.FirstOrDefault(a => a.Name == columnRightname);
                //Debug.AssertArgumentNull(columnRight, string.Format("ModuleXml中必须配置名为'{0}'的ColumnRight", columnRightname), moduleConfig);
            }
            return(columnRight);
        }
Beispiel #6
0
        public void MergeColumns(FormConfig form, DataFormConfig dataForm, ModuleConfig moduleConfig, PageStyle pagestyle, out List <ColumnConfig> fullColumns)
        {
            if (form.FormColumnRight != null)
            {
                ColumnRightConfig columnRight = GetColumnRight(form, dataForm, moduleConfig, pagestyle);
                if (columnRight.Delete != null)
                {
                    columnRight.Delete.ForEach(dCol =>
                    {
                        var col = dataForm.Columns.FirstOrDefault(baseCol => baseCol.Name.Equals(dCol.Name, StringComparison.OrdinalIgnoreCase));
                        if (col != null)
                        {
                            dataForm.Columns.Remove(col);
                        }
                    });
                }
                if (columnRight.Override != null)
                {
                    columnRight.Override.ForEach(oCol =>
                    {
                        var col = dataForm.Columns.FirstOrDefault(baseCol => baseCol.Name.Equals(oCol.BaseColumnName, StringComparison.OrdinalIgnoreCase));
                        if (col != null)
                        {
                            AssignColumn(oCol, col);
                        }
                    });
                }
                if (columnRight.Add != null)
                {
                    dataForm.Columns.AddRange(columnRight.Add);
                }
            }

            fullColumns = new List <ColumnConfig>();

            fullColumns = dataForm.Columns;

            dataForm.Columns = dataForm.Columns.Where(a => a.ShowPage.HasFlag(pagestyle)).ToList();
        }
Beispiel #7
0
        protected virtual void CreateColumns(FormConfigView formView, DataFormConfig dataformConfig, FormConfig formConfig)
        {
            foreach (var column in dataformConfig.Columns)
            {
                if ((column.ShowPage & PageStyle) != PageStyle)
                {
                    continue;
                }
                else
                {
                    //var col = CreateColumn(formView, column);
                    ////列表和明细页面的所有字段控件类型为Detail
                    //if (!column.IsKey && (PageStyle == PageStyle.Detail || PageStyle == PageStyle.List))
                    //    col.ControlType = ControlType.Detail;
                    //formView.Columns.Add(col);
                    formView.Columns.Add(CreateColumn(formView, column));

                    //if (column.Navigation != null && column.Navigation.IsAvailable == true)
                    //{
                    //    formView.NavigationColumns.Add(CreateColumnNavigation(formView, column));
                    //}
                }
            }
        }
        private void InternalInitialize(DataSet dataSet, int pageSize, string keyValue, string foreignKeyValue, string tableName, string primaryKey, string foreignKey, bool isFillEmpty, DataFormConfig dataFormConfig)
        {
            // ColumnLegalHashTable = new HashSet<string>();
            this.DataFormConfig = dataFormConfig;

            UniqueList = this.DataFormConfig.Columns.Where(a => a.IsUniqueKey).Select(a => a.Name).ToList();
            //SingleUploadColumns = this.DataFormConfig.Columns.FindAll(
            //    a => (a.ControlType == ControlType.SingleImageUpload || a.ControlType == ControlType.SingleFileUpload) && (a.Upload != null && a.Upload.HasKey)).ToList();
            //MultiUploadColumns = this.DataFormConfig.Columns.FindAll(
            //    a => (a.ControlType == ControlType.MultiImageUpload || a.ControlType == ControlType.MultiFileUpload) && (a.Upload != null && a.Upload.HasKey)).ToList();
            MomeryColumns = this.DataFormConfig.Columns.FindAll(
                a => (a.ControlType == ControlType.Momery && !a.RegName.IsEmpty())
                ).ToList();
            this.KeyValues   = new List <string>();
            this.IsFillEmpty = isFillEmpty;
            this.PostDataSet = dataSet;
            this.KeyValue    = keyValue;
            if (dataSet != null)
            {
                var _dtPageSys = dataSet.Tables["PAGE_SYS"];

                if (_dtPageSys != null && _dtPageSys.Rows.Count > 0)
                {
                    if (_dtPageSys.Columns.Contains("PageStyle"))
                    {
                        this.PageStyle = _dtPageSys.Rows[0]["PageStyle"].Value <PageStyle>();
                    }
                }

                var dt = dataSet.Tables["_KEY"];
                if (dt != null && dt.Rows.Count > 0)
                {
                    List <string> keyValueList = new List <string>();
                    foreach (DataRow row in dt.Rows)
                    {
                        string _key = row["KeyValue"].ToString();
                        keyValueList.Add(_key);
                    }
                    KeyValues = keyValueList;
                }
            }

            // if (dataSet.Tables["PAGE"])
            if (RegName.IsEmpty())
            {
                fRegName = tableName;
            }
            if (PrimaryKey.IsEmpty())
            {
                PrimaryKey = primaryKey;
            }
            if (ForeignKey.IsEmpty())
            {
                ForeignKey = foreignKey;
            }
            if (!ForeignKey.IsEmpty())
            {
                if (foreignKeyValue.IsEmpty())
                {
                    this.ForeignKeyValue = KeyValues.Count() == 1 ? KeyValues.First() : foreignKeyValue;
                }
                else
                {
                    this.ForeignKeyValue = foreignKeyValue;
                }
            }
            if (dataSet != null)
            {
                this.Pagination = new Pagination().FormDataTable(dataSet.Tables["PAGER"]);
            }
            else
            {
                this.Pagination = new Pagination()
                {
                    //TableName = RegName,
                    DataTime = DateTime.Now,
                    PageSize = pageSize
                }
            };
            this.Pagination.TableName = RegName;
            if (this.Pagination.PageSize == 0)
            {
                this.Pagination.PageSize = pageSize;
            }
            if (this.Pagination.PageSize == 0)
            {
                this.Pagination.PageSize = 20;
            }
        }
Beispiel #9
0
        public void Migrations(DataFormConfig dataFormConfig)
        {
            DynamicParameters sqlParameters = new DynamicParameters();

            //dataFormConfig.AddBaseColumns("BaseForm.xml");
            if (dataFormConfig == null)
            {
                return;
            }
            if (dataFormConfig.TableName.IsEmpty())
            {
                dataFormConfig.TableName = dataFormConfig.Name;
            }
            if (dataFormConfig.TableName.ToUpper().IndexOf("VIEW") == 0)
            {
                return;
            }                                                                       //若是试图,不执行任何操作
            if (HaveTable(dataFormConfig.TableName))
            {
                List <string> tableFields = GetTableFields(dataFormConfig.TableName);
                string        sql         = string.Empty;
                string        commentSql  = string.Empty;
                //SqlParameter[] sqlParameters;
                foreach (var column in dataFormConfig.Columns)
                {
                    if (column.Kind == ColumnKind.Data && column.SourceName.IsEmpty())
                    {
                        if (tableFields.FirstOrDefault <string>(n => n == column.Name.Trim().ToUpper()) == default(string))
                        {
                            sql = string.Format(CultureInfo.CurrentCulture, "{0} ALTER TABLE {1} Add {2} {3} COMMENT '{4}' ", sql, dataFormConfig.TableName, column.Name, ConvertToDataBaseType(column), column.DisplayName);
                            //if (column.IsKey)
                            //{
                            //    sql += $" PRIMARY KEY({column.Name})";
                            //}
                            sql = $"{sql};";
                        }
                        //sqlParameters = new SqlParameter[]
                        //{
                        //    new SqlParameter("@tableName",dataFormConfig.TableName),
                        //    new SqlParameter("@fieldName",column.Name),
                        //    new SqlParameter("@fieldType",ConvertToDataBaseType(column.ControlType,column.Length))
                        //};
                    }
                }
                if (!string.IsNullOrEmpty(sql))
                {
                    _unitOfDapper.RegisterSqlCommand(sql, sqlParameters);
                    //_unitOfDapper.RegisterSqlCommand(commentSql,sqlParameters);
                    //this.IsMigrations = true;
                    //logMessages.Add(new SqlLogMessage { SqlStr = sql });
                }
            }
            else
            {
                string commentSql = string.Empty;
                string sql        = "CREATE TABLE " + dataFormConfig.TableName + " (";
                foreach (var column in dataFormConfig.Columns)
                {
                    if (column.Kind == ColumnKind.Data)
                    {
                        if (column.IsKey)
                        {
                            sql = string.Format(CultureInfo.CurrentCulture, "{0} {1} {2}  COMMENT '{3}',", sql, column.Name, ConvertToDataBaseType(column), column.DisplayName);
                            sql = $"{sql} PRIMARY KEY({column.Name}),";
                        }
                        else
                        {
                            sql = string.Format(CultureInfo.CurrentCulture, "{0} {1} {2} COMMENT '{3}',", sql, column.Name, ConvertToDataBaseType(column), column.DisplayName);
                        }
                    }
                }
                sql = sql.Substring(0, sql.Length - 1) + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";

                _unitOfDapper.RegisterSqlCommand(sql, sqlParameters);
                //this.IsMigrations = true;
                //logMessages.Add(new SqlLogMessage { SqlStr = sql });
            }
            _unitOfDapper.Submit();
        }
Beispiel #10
0
        protected FormConfigView CreateFormView(DataFormConfig dataForm, FormConfig formConfig)
        {
            FormConfigView formView = new FormConfigView();

            formView.FormType           = formConfig.FormType;
            formView.ShowKind           = formConfig.ShowKind;
            formView.AfterInitFunName   = formConfig.AfterInitFunName;
            formView.VerticalTab        = formConfig.VerticalTab; //布局方式
            formView.HasBatchInsert     = false;
            formView.HasPager           = false;
            formView.HasSearch          = false;
            formView.ParentFieldName    = formConfig.ParentFieldName;
            formView.TextFieldName      = formConfig.TextFieldName;
            formView.IsParentFieldName  = formConfig.IsParentFieldName;
            formView.IsSafeMode         = formConfig.IsSafeMode;
            formView.HasReview          = formConfig.HasReview;
            formView.Calendar           = formConfig.Calendar;
            formView.ExpandDetailPlug   = formConfig.ExpandDetailPlug;
            formView.RowTpl             = formConfig.RowTpl;
            formView.ContentTpl         = formConfig.ContentTpl;
            formView.DisableColumnGroup = formConfig.Group.IsDisabled.ToLower() == "true" || formConfig.Group.IsDisabled == "1" ? true : false;
            // formView.Tpl = formConfig.Tpl;
            //var _bean = formConfig.Tpls.FirstOrDefault(a => a.PageStyle == PageStyle);
            //if (_bean != null)
            //    formView.Tpl = _bean.Item;


            formView.IsInner          = formConfig.IsInner;
            formView.HaveNoSwitchForm = formConfig.HaveNoSwitchForm;
            formView.HaveNoSortBar    = formConfig.HaveNoSortBar;
            //var NavigationList = dataForm.Columns.Where(a => a.Navigation != null);
            //if (NavigationList.Count() > 0)
            //{
            //    formView.HasNavigation = true;
            //     List<ColumnConfig> columns = NavigationList.ToList();
            //     foreach (var column in columns)
            //     {
            //         ColumnConfigView colView = new ColumnConfigView();
            //         if (column.Navigation != null && column.Navigation.IsAvailable == true && (column.ControlType == ControlType.CheckBox || column.ControlType == ControlType.Combo || column.ControlType == ControlType.Radio || column.ControlType == ControlType.TreeSingleSelector || column.ControlType == ControlType.TreeMultiSelector))
            //         {
            //             if (column.ControlType == ControlType.CheckBox)
            //             {
            //                 colView.ControlType = ControlType.CheckBoxNavi;
            //             }
            //             else if (column.ControlType == ControlType.Radio || column.ControlType == ControlType.Combo)
            //             {
            //                 colView.ControlType = ControlType.RadioNavi;
            //             }
            //             else if (column.ControlType == ControlType.TreeSingleSelector)
            //             {
            //                 colView.ControlType = ControlType.TreeSingleNavi;
            //             }
            //             else
            //             {
            //                 colView.ControlType = ControlType.TreeMultiNavi;
            //             }
            //         }
            //     }
            //}
            formView.TableName = formConfig.TableName;
            //if (formView.TableName.IsEmpty())
            //    formView.TableName = dataForm.TableName;
            //if (formView.TableName.IsEmpty())
            //    formView.TableName = formConfig.DataPlug.PlugInPageGet<IListDataTable>().RegName;

            formView.Title = formConfig.Title;
            //if (formView.Title.IsEmpty())
            //    formView.Title = dataForm.Title;
            //if (formView.Title.IsEmpty())
            //    formView.Title = ModuleConfig.Title;
            if (ModuleConfig.Mode == ModuleMode.None)
            {
                formView.Title = formView.Title;
            }
            else
            {
                switch (PageStyle)
                {
                case PageStyle.List:
                    formView.Title = formView.Title + "列表";
                    break;

                case PageStyle.Detail:
                    formView.Title = formView.Title + "明细";
                    break;

                case PageStyle.Update:
                    formView.Title = formView.Title + "修改";
                    break;

                case PageStyle.Insert:
                    formView.Title = formView.Title + "新增";
                    break;
                }
            }

            formView.Name = formConfig.Name;
            //if (formView.Name.IsEmpty())
            //    formView.Name = dataForm.Name;
            //if (formView.Name.IsEmpty())
            //    formView.Name = formView.TableName;
            //string msg = string.Format("数据源为{0}插件的form的名称不能为空", formConfig.DataPlug);
            //Debug.AssertNotNullOrEmpty(formView.Name, msg, this);
            formView.Columns = new List <ColumnConfigView>();
            CreateColumns(formView, dataForm, formConfig);

            formView.ColumnGroups = new List <ColumnGroupConfigView>();
            CreateGroupColumns(formView, dataForm);

            formView.NavigationColumns = new List <NaviColumnConfigView>(); //可能有多个navi(目前只有一个)
            if (PageStyle == PageStyle.List)
            {
                var navigation = dataForm.Columns.FindAll(a => a.Navigation != null && a.Navigation.IsAvailable);
                foreach (var navi in navigation)
                {
                    if (navigation != null)
                    {
                        var viewColumn = formView.Columns.FirstOrDefault(a => a.Name == navi.Name);
                        var viewNavi   = CreateColumnNavigation(viewColumn, navi);
                        if (viewNavi != null)
                        {
                            formView.NavigationColumns.Add(viewNavi);
                        }
                    }
                }
            }
            return(formView);
        }