public int InitColumnValueSchema(string initSchemaName)
        {
            string sql = MetadataOperate.DbCreateLoad(BaseConstants.Az_InitColumnValueSchemafile)
                         .ReaplaceTemplate(BaseConstants.Az_Parameters1, initSchemaName.AddSingleQuotes())
                         .ReaplaceTemplate(BaseConstants.AppNameDefautSign, MetadataOperate.GetDefAppNameUpdate(azNormalSet.AzBase.AzTablePrefix));;

            return(repository.ExecuteNonQuerySql().WithSql(sql).Go());
        }
 public int UpdataCodeSetVales()
 {
     return(repository.Update()
            .UsingTableName(azNormalSet.AzMetaTableName)
            .Set(m => m.CodeSetVales, string.Empty)
            .Where(m => m.AppName == MetadataOperate.GetDefAppNameUpdate(azNormalSet.AzBase.AzTablePrefix))
            .Go());
 }
        public List <AzMetaTableEntity> GetDBSchema()
        {
            List <AzMetaTableEntity> result        = new List <AzMetaTableEntity>();
            StringBuilder            stringBuilder = new StringBuilder();

            stringBuilder.Append(" SELECT  TOP (100) PERCENT A.name AS SchemaName, CASE WHEN A.xtype = 'U' THEN 1 WHEN A.xtype = 'V' THEN 2 ELSE 3 END AS ObjDataType, B.value as ClassDisPlay");
            stringBuilder.Append(" FROM sys.sysobjects AS A LEFT OUTER JOIN");
            stringBuilder.Append(" (SELECT     TOP (100) PERCENT value, major_id");
            stringBuilder.Append(" FROM sys.extended_properties");
            stringBuilder.Append(" WHERE (name = N'MS_Description') AND (minor_id = 0)) AS B ON A.id = B.major_id");
            if (string.IsNullOrWhiteSpace(azNormalSet.AzBase.AzTablePrefix))
            {
                stringBuilder.Append(" WHERE (NOT (A.name LIKE N'sys%')) AND (NOT (A.name LIKE N'sp_%')) And(A.xtype = 'U' OR");
            }
            else
            {
                stringBuilder.Append($" WHERE (NOT (A.name LIKE N'sys%')) AND (NOT (A.name LIKE N'sp_%')) And     (A.name LIKE   '{azNormalSet.AzBase.AzTablePrefix}%') AND (A.xtype = 'U' OR");
            }

            stringBuilder.Append($" A.xtype = 'V' OR A.xtype = 'P')  AND (NOT (A.name LIKE N'{BaseConstants.CodeToolName}%'))");
            stringBuilder.Append(" ORDER BY SchemaName");
            string cmdstr             = stringBuilder.ToString();
            string dbConnectionString = azNormalSet.AzConnectionString;

            using (SqlConnection cn = new SqlConnection(dbConnectionString))
            {
                cn.Open();
                using (SqlCommand cmd = new SqlCommand(cmdstr, cn))
                {
                    using (SqlDataReader atkDataReader = cmd.ExecuteReader())
                    {
                        int id = 1;
                        while (atkDataReader.Read())
                        {
                            string            scname       = atkDataReader["SchemaName"] is DBNull ? null : (string)atkDataReader["SchemaName"];
                            string            objname      = ReMovePer(scname);
                            AzMetaTableEntity schemaEntity = new AzMetaTableEntity();


                            schemaEntity.Id           = id;
                            schemaEntity.ClassName    = azNormalSet.AzBase.AzClassPrefix + objname;
                            schemaEntity.ObjModeName  = objname;
                            schemaEntity.SchemaName   = scname;
                            schemaEntity.AppName      = MetadataOperate.GetDefAppNameUpdate(azNormalSet.AzBase.AzTablePrefix);
                            schemaEntity.ObjDataType  = (int)atkDataReader["ObjDataType"];;
                            schemaEntity.ClassDisPlay = atkDataReader["ClassDisPlay"] is DBNull ? null : (string)atkDataReader["ClassDisPlay"];
                            schemaEntity.ObjModeType  = 1;

                            result.Add(schemaEntity);
                            id += 1;
                        }
                    }
                }
            }

            return(result);
        }
        private void SaveMasterInfo()
        {
            JavaScriptSerializer js = new JavaScriptSerializer();

            if (string.IsNullOrWhiteSpace(azClassCreatProperty.ObjPresentation.UpdateTableName))
            {
                azClassCreatProperty.ObjPresentation.UpdateTableName = azMetaTable.SchemaName;
            }
            azMetaTable.CodeSetVales = js.Serialize(azClassCreatProperty);
            if (azMetaTable.ComeFrom == 1)
            {
                azMetaTable.ObjModeType = 1;
                azMetaTable.AppName     = MetadataOperate.GetDefAppNameUpdate(AzNormalSet.GetAzNormalSet().AzBase.AzTablePrefix);
                azMetaTable             = AzMetaTableHandle.Handle().Insert(azMetaTable);
                return;
            }
            AzMetaTableHandle.Handle().Updata(azMetaTable);
            SetSelectedObject(azMetaTable);
            OnMasterSaveNotification?.Invoke();
        }
        private void btSave_Click(object sender, System.EventArgs e)
        {
            if (VerificationText())
            {
                return;
            }

            int objModeType = 1;

            if (rdbMetaChild.Checked)
            {
                objModeType = 4;
            }

            metaTableEntity = new AzMetaTableEntity
            {
                ObjModeName  = textObjModeName.Text,
                ClassName    = textClassName.Text,
                SchemaName   = textTableName.Text,
                SchemaFrom   = textSchemaFrom.Text,
                ClassDisPlay = textClassDisPlay.Text,
                CodeSetVales = "",
                Remark       = textRemark.Text,
                IsCustom     = true,
                ObjDataType  = 1,
                ObjModeType  = objModeType,
                AppName      = MetadataOperate.GetDefAppNameUpdate(azNormalSet.AzBase.AzTablePrefix),
            };
            if (IsEdit)
            {
                metaTableEntity.Id = azId;
                AzMetaTableHandle.Handle().Updata(metaTableEntity);
            }
            else
            {
                AzMetaTableHandle.Handle().Insert(metaTableEntity);
            }
            DialogResult = DialogResult.OK;
        }