private static string ForeignKeyPickerWindows(TableSetting tableSetting, string baseTab)
        {
            var columnSettings = tableSetting.ColumnSettings.Where(p => p.IsNeedNavigationData).OrderBy(p => p.Order);

            if (columnSettings.Count() == 0)
            {
                return(string.Empty);
            }

            var sb = new StringBuilder();

            var tab1 = baseTab + Constant.Tab;

            foreach (var item in columnSettings)
            {
                var columnName = item.GetColumnNameForCodeGen();
                if (columnName == "ID" || columnName == "TenantID" || columnName == "CreateTime" || columnName == "LastUpdateTime")
                {
                    continue;
                }

                var lowerFirstCharColumnName = ToLowerFirstChar(columnName);
                var foreignKeyTableName      = item.DbColumn.ForeignKeyTableName;
                var tableName = tableSetting.TableName;
                sb.AppendLineExWithTab(baseTab, $"<h-window [name]=\"'window_{lowerFirstCharColumnName}Of{tableName}'\" #{lowerFirstCharColumnName}Window [visible]=\"false\" [ngContent]=\"{lowerFirstCharColumnName}\" [hasOkButton]=\"true\" [hasCancelButton]=\"true\" [hasCloseButton]=\"false\" [width]=\"500\" [height]=\"200\">");

                sb.AppendLineExWithTab(tab1, $"<app-{foreignKeyTableName} [name]=\"'view_{foreignKeyTableName}Of{tableName}'\" #{lowerFirstCharColumnName}></app-{foreignKeyTableName}>");
                sb.AppendLineExWithTab(baseTab, "</h-window>");

                sb.AppendLineEx();
            }

            return(sb.ToString());
        }
        private static string OverrideUpdateEntityEFFull(TableSetting tableSetting, string baseTab)
        {
            if (tableSetting.ColumnSettings.Count() == 0)
            {
                return(string.Empty);
            }

            var sb   = new StringBuilder();
            var list = tableSetting.ColumnSettings.Where(item => item.IsReadOnly == true && item.DbColumn.IsIdentity == false && item.IsSmtColumn() == false).ToList();

            if (list.Count > 0)
            {
                var tab1 = baseTab + Constant.Tab;

                sb.AppendLineExWithTabAndFormat(baseTab, "protected override void UpdateEntity(SqlDbContext context, {0} entity)", tableSetting.TableName);
                sb.AppendLineExWithTab(baseTab, "{");
                sb.AppendLineExWithTabAndFormat(tab1, "var entry = context.Entry(entity);");
                foreach (var item in list)
                {
                    sb.AppendLineExWithTabAndFormat(tab1, "entry.Property(p => p.{0}).IsModified = false;", item.ColumnName);
                }
                sb.AppendLineExWithTab(baseTab, "}");
            }
            return(sb.ToString());
        }
예제 #3
0
        public void LoadJson(string path)
        {
            var text = System.IO.File.ReadAllText(path);
            var json = Newtonsoft.Json.JsonConvert.DeserializeObject <JsonViewModel>(text);

            DatabaseTreeVM.DBServer    = json.DBServer;
            DatabaseTreeVM.User        = json.User;
            DatabaseTreeVM.DBName      = json.DBName;
            DatabaseTreeVM.DbTables    = json.DbTableList;
            DatabaseTreeVM.ConnectTime = json.ConnectTime;

            ViewPath       = json.ViewPath;
            ViewModelPath  = json.ViewModelPath;
            TextPath       = json.TextPath;
            ControllerPath = json.ControllerPath;
            DtoPath        = json.DtoPath;
            EntityPath     = json.EntityPath;
            Angular2Path   = json.Angular2Path;
            DataModelPath  = json.DataModelPath;

            int masterDetailListCount = json.MasterDetailList.Count;
            var masterDetailList      = new List <MasterDetail>(masterDetailListCount);

            for (int i = 0; i < masterDetailListCount; i++)
            {
                int levelsCount = json.MasterDetailList[i].Levels.Count;
                var md          = new MasterDetail();
                for (int j = 0; j < levelsCount; j++)
                {
                    md.Levels.Add(json.MasterDetailList[i].Levels[j]);
                }
                md.ViewName       = json.MasterDetailList[i].ViewName;
                md.CanDeleteLevel = (levelsCount > 2);
                masterDetailList.Add(md);
            }
            MasterDetailSelectorVM.MasterDetailList = masterDetailList;

            int tableSettingsCount = json.TableSettingList.Count;
            var tableSettings      = new ObservableCollection <TableSetting>();

            for (int i = 0; i < tableSettingsCount; i++)
            {
                int columnsCount = json.TableSettingList[i].ColumnSettingList.Count;
                var table        = new TableSetting();
                for (int j = 0; j < columnsCount; j++)
                {
                    var column = json.TableSettingList[i].ColumnSettingList[j];
                    table.ColumnSettings.Add(new ColumnSetting()
                    {
                        ColumnName         = column.ColumnName,
                        DataGridColumnType = column.DataGridColumnType,
                        IsReadOnly         = column.IsReadOnly,
                        IsTabStop          = column.IsTabStop,
                        Width   = column.Width,
                        Order   = column.Order,
                        OrderBy = column.OrderBy
                    });
                }
                table.TableName         = json.TableSettingList[i].TableName;
                table.DisplayTextColumn = json.TableSettingList[i].DisplayTextColumn;
                tableSettings.Add(table);
            }
            TableSettingsVM.TableSettings = tableSettings;
        }