protected DataSourceValidationTable Copy(DataSourceTable table) { DataSourceValidationTable newTable = new DataSourceValidationTable(); newTable.TableName = table.TableName; newTable.TableSchema = table.TableSchema; foreach (Model.DataColumn col in table.DataColumns) { Model.ValidatorColumn validatorCol = new ValidatorColumn(); validatorCol.ColumnName = col.ColumnName; string[] words = Regex.Matches(validatorCol.ColumnName, "(^[a-z]+|[A-Z]+(?![a-z])|[A-Z][a-z]+)") .OfType <Match>() .Select(m => m.Value) .ToArray(); string result = string.Join(" ", words); validatorCol.ColumnText = result; validatorCol.DataType = col.DataType; validatorCol.Key = col.Key; validatorCol.Use = col.Use; validatorCol.Size = col.Size; validatorCol.ConfigContent = new ValidationIsEmpty(); Dictionary <string, object> dict = new Dictionary <string, object>(); dict.Add("InvalidMessage", "Please fill " + result); validatorCol.ConfigContent.DisplayConfiguration(dict); validatorCol.ValidationTypeList.Add(new ModelItemType(validatorCol.ConfigContent.GetControlType(), validatorCol.ConfigContent)); newTable.DataColumns.Add(validatorCol); } return(newTable); }
public void InitFromDatasource(DataSourceTable table) { gridColumns.AutoGenerateColumns = false; DataSourceValidationTable newTable = Copy(table); gridColumns.DataSource = newTable.DataColumns.ConvertAll(c => c as ValidatorColumn); CurrentTable = newTable; }
public void UpdateDatasource(object table) { //At first it will load from Json and Json will be serialized into DataColumns as DataColumn item, not UIColumn item as expected. That is why we need //DataColumns2, to store its UIColumn list, and copy it to DataColumns if (table.GetType() != typeof(DataSourceValidationTable)) { string json = Utility.Serializer.Json.Serialize(table); json = json.Replace("DataColumns", "DataColumns2"); //json = json.Replace("DataColumns22", "DataColumns2"); DataSourceValidationTable tbl = Utility.Serializer.Json.Deserialize <DataSourceValidationTable>(json); foreach (ValidatorColumn col in tbl.DataColumns2) { tbl.DataColumns.Add(col); } CurrentTable = tbl; } else { CurrentTable = (DataSourceValidationTable)table; } gridColumns.AutoGenerateColumns = false; gridColumns.DataSource = CurrentTable.DataColumns.ConvertAll(c => c as ValidatorColumn); }
public void RenderPage() { me.say(SectionText0); me.say(Project.CompanyName); me.say(SectionText2); me.say(Project.ProjectName); me.say(SectionText4); me.say(Module.ModuleName); me.say(SectionText6); DataSourceTable table = (DataSourceTable)Module.Datasource; string tableName = table.TableName; string keyColumnName = table.KeyColumn.ColumnName; string keyColumnVar = StrUtil.LowFirst(keyColumnName); DataSourceValidationTable uiTable = (DataSourceValidationTable)Module.ModelType.Datasource; me.say(SectionText8); me.say(Project.CompanyName); me.say(SectionText10); me.say(Project.ProjectName); me.say(SectionText12); me.say(Module.ModuleName); me.say(SectionText14); me.say(tableName); me.say(SectionText16); me.say(tableName); me.say(SectionText18); me.say(tableName); me.say(SectionText20); me.say(StrUtil.LowFirst(tableName)); me.say(SectionText22); me.say(tableName); me.say(SectionText24); foreach(ValidatorColumn column in uiTable.DataColumns) { if(column.Use) { me.say(SectionText26); me.say(column.ColumnName); me.say(SectionText28); me.say(StrUtil.LowFirst(tableName)); me.say(SectionText30); me.say(column.ColumnName); me.say(SectionText32); } } me.say(SectionText34); me.say(tableName); me.say(SectionText36); me.say(StrUtil.LowFirst(tableName)); me.say(SectionText38); me.say(tableName); me.say(SectionText40); foreach(ValidatorColumn column in uiTable.DataColumns) { if(column.Use) { me.say(SectionText42); me.say(column.ColumnName); me.say(SectionText44); me.say(StrUtil.LowFirst(tableName)); me.say(SectionText46); me.say(column.ColumnName); me.say(SectionText48); } } me.say(SectionText50); foreach(ValidatorColumn column in uiTable.DataColumns) { me.say(SectionText52); me.say(column.ColumnName); me.say(SectionText54); me.say(DatabaseMapper.MapType( column.DataType )); me.say(SectionText56); me.say(StrUtil.LowFirst(column.ColumnName)); me.say(SectionText58); if(column.Use) { me.say(SectionText60); me.say(StrUtil.LowFirst(column.ColumnName)); me.say(SectionText62); me.say(StrUtil.SplitCamelCase( column.ColumnName)); me.say(SectionText64); } me.say(SectionText66); } }