Example #1
0
 private void gvdTables_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (this.gvdTables.Columns[e.ColumnIndex].Name == "SetCheck")
     {
         if (!string.IsNullOrEmpty(this.CurrentEditTable))
         {
             List <ColumnRuleSchema> columns    = this._TableRuleSchemaList.First((TableRuleSchema s) => s.TableName == this.CurrentEditTable).Columns;
             IEnumerator             enumerator = ((IEnumerable)this.gvwTableCols.Rows).GetEnumerator();
             {
                 while (enumerator.MoveNext())
                 {
                     DataGridViewRow  dataGridViewRow  = (DataGridViewRow)enumerator.Current;
                     string           FieldName        = dataGridViewRow.ReadCell("FieldName", "");
                     ColumnRuleSchema columnRuleSchema = columns.First((ColumnRuleSchema s) => s.FieldName == FieldName);
                     columnRuleSchema.IsXmlField   = this.CheckIsXmlField(columnRuleSchema, dataGridViewRow);
                     columnRuleSchema.IsCheck      = bool.Parse(dataGridViewRow.ReadCell("IsCheck", ""));
                     columnRuleSchema.ErrorMessage = dataGridViewRow.ReadCell("ErrorMessage", "");
                     columnRuleSchema.FieldTitle   = dataGridViewRow.ReadCell("FieldTitle", "");
                 }
             }
         }
         string TableName = this.gvdTables.Rows[e.RowIndex].ReadCell("TableName", "");
         this.CurrentEditTable = TableName;
         TableRuleSchema tableRuleSchema = this._TableRuleSchemaList.First((TableRuleSchema s) => s.TableName == TableName);
         if (tableRuleSchema.Columns.Count == 0)
         {
             tableRuleSchema.Columns = SqlSchemaHelper.GetTableRuleColumnsSchema(this._ConnectionString, this._Database, TableName, this._CodeConfigHelper);
         }
         this.gvwTableCols.AutoGenerateColumns = false;
         this.gvwTableCols.DataSource          = tableRuleSchema.Columns;
     }
 }
Example #2
0
        private void btnRuleCode_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(this.CurrentEditTable))
            {
                List <ColumnRuleSchema> columns    = this._TableRuleSchemaList.First((TableRuleSchema s) => s.TableName == this.CurrentEditTable).Columns;
                IEnumerator             enumerator = ((IEnumerable)this.gvwTableCols.Rows).GetEnumerator();
                {
                    while (enumerator.MoveNext())
                    {
                        DataGridViewRow  dataGridViewRow  = (DataGridViewRow)enumerator.Current;
                        string           FieldName        = dataGridViewRow.ReadCell("FieldName", "");
                        ColumnRuleSchema columnRuleSchema = columns.First((ColumnRuleSchema s) => s.FieldName == FieldName);
                        columnRuleSchema.IsXmlField   = this.CheckIsXmlField(columnRuleSchema, dataGridViewRow);
                        columnRuleSchema.IsCheck      = bool.Parse(dataGridViewRow.ReadCell("IsCheck", ""));
                        columnRuleSchema.ErrorMessage = dataGridViewRow.ReadCell("ErrorMessage", "");
                        columnRuleSchema.FieldTitle   = dataGridViewRow.ReadCell("FieldTitle", "");
                    }
                }
            }
            IEnumerator enumerator2 = ((IEnumerable)this.gvdTables.Rows).GetEnumerator();
            {
                while (enumerator2.MoveNext())
                {
                    DataGridViewRow dataGridViewRow = (DataGridViewRow)enumerator2.Current;
                    string          TableName       = dataGridViewRow.ReadCell("TableName", "");
                    TableRuleSchema tableRuleSchema = this._TableRuleSchemaList.First((TableRuleSchema s) => s.TableName == TableName);
                    tableRuleSchema.IsCreate           = bool.Parse(dataGridViewRow.ReadCell("IsCreate", ""));
                    tableRuleSchema.Description        = dataGridViewRow.ReadCell("Description", "");
                    tableRuleSchema.EntityName         = dataGridViewRow.ReadCell("EntityName", "");
                    tableRuleSchema.IsMongoDB          = bool.Parse(dataGridViewRow.ReadCell("IsMongoDB", ""));
                    tableRuleSchema.IsCheckFieldLength = bool.Parse(dataGridViewRow.ReadCell("IsCheckFieldLength", ""));
                    tableRuleSchema.ConnectionKeyOrConnectionString = dataGridViewRow.ReadCell("ConnectionKeyOrConnectionString", "");
                    tableRuleSchema.LogModuleType = dataGridViewRow.ReadCell("LogModuleType", "");
                    tableRuleSchema.UIProjectName = dataGridViewRow.ReadCell("UIProjectName", this.txtUIProjectName.Text);
                    tableRuleSchema.UIProjectPath = dataGridViewRow.ReadCell("UIProjectPath", this.txtUIProjectPath.Text);
                    if (tableRuleSchema.IsCreate && tableRuleSchema.Columns.Count == 0)
                    {
                        tableRuleSchema.Columns = SqlSchemaHelper.GetTableRuleColumnsSchema(this._ConnectionString, this._Database, tableRuleSchema.TableName, this._CodeConfigHelper);
                    }
                }
            }
            int num = (from s in this._TableRuleSchemaList
                       where s.IsCreate
                       select s).Count <TableRuleSchema>();

            if (num == 0)
            {
                MessageBox.Show("请要生成的表");
            }
            else
            {
                this._CodeConfigHelper.UpdateXml((from s in this._TableRuleSchemaList
                                                  where s.IsCreate
                                                  select s).ToList <TableRuleSchema>(), this.boxConnectString.SelectedItem.ToString());
                MessageBox.Show("一键生成配置文件成功");
            }
        }
Example #3
0
 private bool CheckIsXmlField(ColumnRuleSchema objColumnRuleSchema, DataGridViewRow objDataRow)
 {
     return(objColumnRuleSchema.IsXmlField || (bool.Parse(objDataRow.ReadCell("IsCheck", "")) || objColumnRuleSchema.OldErrorMessage != objDataRow.ReadCell("ErrorMessage", "") || objColumnRuleSchema.OldFieldTitle != objDataRow.ReadCell("FieldTitle", "")));
 }
Example #4
0
        private List <TableRuleSchema> ProcessData()
        {
            if (!string.IsNullOrEmpty(this.CurrentEditTable))
            {
                List <ColumnRuleSchema> columns    = this._TableRuleSchemaList.First((TableRuleSchema s) => s.TableName == this.CurrentEditTable).Columns;
                IEnumerator             enumerator = ((IEnumerable)this.gvwTableCols.Rows).GetEnumerator();
                while (enumerator.MoveNext())
                {
                    DataGridViewRow  dataGridViewRow  = (DataGridViewRow)enumerator.Current;
                    string           FieldName        = dataGridViewRow.ReadCell("FieldName", "");
                    ColumnRuleSchema columnRuleSchema = columns.First((ColumnRuleSchema s) => s.FieldName == FieldName);
                    columnRuleSchema.IsXmlField   = this.CheckIsXmlField(columnRuleSchema, dataGridViewRow);
                    columnRuleSchema.IsCheck      = bool.Parse(dataGridViewRow.ReadCell("IsCheck", ""));
                    columnRuleSchema.ErrorMessage = dataGridViewRow.ReadCell("ErrorMessage", "");
                    columnRuleSchema.FieldTitle   = dataGridViewRow.ReadCell("FieldTitle", "");
                }
            }
            List <TableRuleSchema> result;
            IEnumerator            enumerator2 = ((IEnumerable)this.gvdTables.Rows).GetEnumerator();

            while (enumerator2.MoveNext())
            {
                DataGridViewRow dataGridViewRow = (DataGridViewRow)enumerator2.Current;
                string          TableName       = dataGridViewRow.ReadCell("TableName", "");
                string          text            = dataGridViewRow.ReadCell("LogModuleType", "");
                text = (string.IsNullOrWhiteSpace(text) ? ((this.boxLogType.SelectedItem == null) ? "" : this.boxLogType.SelectedItem.ToString()) : text);
                string text2 = dataGridViewRow.ReadCell("ConnectionKeyOrConnectionString", "");
                text2 = (string.IsNullOrWhiteSpace(text2) ? this.txtConnectionKey.Text : text2);
                TableRuleSchema tableRuleSchema = this._TableRuleSchemaList.First((TableRuleSchema s) => s.TableName == TableName);
                tableRuleSchema.IsCreate           = bool.Parse(dataGridViewRow.ReadCell("IsCreate", ""));
                tableRuleSchema.Description        = dataGridViewRow.ReadCell("Description", "");
                tableRuleSchema.EntityName         = dataGridViewRow.ReadCell("EntityName", "");
                tableRuleSchema.IsMongoDB          = bool.Parse(dataGridViewRow.ReadCell("IsMongoDB", ""));
                tableRuleSchema.IsCheckFieldLength = bool.Parse(dataGridViewRow.ReadCell("IsCheckFieldLength", ""));
                tableRuleSchema.ConnectionKeyOrConnectionString = text2;
                tableRuleSchema.LogModuleType = text;
                if (tableRuleSchema.IsCreate && string.IsNullOrWhiteSpace(tableRuleSchema.LogModuleType))
                {
                    MessageBox.Show("表名:" + TableName + ",请输入日志类型或选择日志类型");
                    result = null;
                    return(result);
                }
                if (tableRuleSchema.IsCreate && tableRuleSchema.Columns.Count == 0)
                {
                    tableRuleSchema.Columns = SqlSchemaHelper.GetTableRuleColumnsSchema(this._ConnectionString, this._Database, tableRuleSchema.TableName, this._CodeConfigHelper);
                }
            }
            List <TableRuleSchema> list = (from s in this._TableRuleSchemaList
                                           where s.IsCreate
                                           select s).ToList <TableRuleSchema>();

            if (list.Count <TableRuleSchema>() == 0)
            {
                MessageBox.Show("请选择表");
                result = null;
            }
            else
            {
                result = list;
            }
            return(result);
        }