예제 #1
0
        public Boolean DeleteModuleConfiguration(ModuleConfiguration module)
        {
            Boolean Result = true;

            StringBuilder Sql_Delete = new StringBuilder();

            //增加字段Scts_1,Scdel 之后 删除操作只做伪删除,便于数据同步     2013-10-19
            //Sql_Delete.Append("Delete From sys_biz_Module Where ID ='");
            //Sql_Delete.Append(module.Index);
            //Sql_Delete.Append("'");
            Sql_Delete.Append("Update sys_biz_Module Set Scts_1=Getdate(),Scdel=1 Where ID ='");
            Sql_Delete.Append(module.Index);
            Sql_Delete.Append("'");

            StringBuilder Sql_ExtentSheet = new StringBuilder();

            //增加字段Scts_1,Scdel 之后 删除操作只做伪删除,便于数据同步     2013-10-19
            //Sql_ExtentSheet.Append("Delete From sys_Tables Where ID ='");
            //Sql_ExtentSheet.Append(module.ExtentDataSchema.Index);
            //Sql_ExtentSheet.Append("'");
            Sql_ExtentSheet.Append("Update sys_Tables Set Scts_1=Getdate(),Scdel=1 Where ID ='");
            Sql_ExtentSheet.Append(module.ExtentDataSchema.Index);
            Sql_ExtentSheet.Append("'");

            StringBuilder Sql_DeleteField = new StringBuilder();

            //Sql_DeleteField.Append("Delete From sys_Columns Where TableName='");
            //Sql_DeleteField.Append(module.ExtentDataSchema.Name);
            //Sql_DeleteField.Append("'");
            Sql_DeleteField.Append("Update sys_Columns Set Scts_1=Getdate(),Scdel=1 Where TableName='");
            Sql_DeleteField.Append(module.ExtentDataSchema.Name);
            Sql_DeleteField.Append("'");

            StringBuilder Sql_DeleteFunctionInfo = new StringBuilder();

            //Sql_DeleteFunctionInfo.Append("Delete From sys_biz_CrossSheetFormulas Where ModelIndex='");
            //Sql_DeleteFunctionInfo.Append(module.Index);
            //Sql_DeleteFunctionInfo.Append("'");
            Sql_DeleteFunctionInfo.Append("Update sys_biz_CrossSheetFormulas Set Scts_1=Getdate(),Scdel=1 Where ModelIndex='");
            Sql_DeleteFunctionInfo.Append(module.Index);
            Sql_DeleteFunctionInfo.Append("'");

            StringBuilder Sql_DeleteCrossSheetFormulas = new StringBuilder();

            //Sql_DeleteCrossSheetFormulas.Append("Delete from sys_biz_CrossSheetFormulas where ModelIndex='");
            //Sql_DeleteCrossSheetFormulas.Append(module.Index);
            //Sql_DeleteCrossSheetFormulas.Append("'");
            Sql_DeleteCrossSheetFormulas.Append("Update sys_biz_CrossSheetFormulas Set Scts_1=Getdate(),Scdel=1 Where ModelIndex='");
            Sql_DeleteCrossSheetFormulas.Append(module.Index);
            Sql_DeleteCrossSheetFormulas.Append("'");

            StringBuilder Sql_DeleteModuleView = new StringBuilder();

            //Sql_DeleteModuleView.Append("delete sys_moduleview where ModuleID='");
            //Sql_DeleteModuleView.Append(module.Index);
            //Sql_DeleteModuleView.Append("'");
            Sql_DeleteModuleView.Append("Update sys_moduleview Set Scts_1=Getdate(),Scdel=1 where Scdel=0 and ModuleID='");
            Sql_DeleteModuleView.Append(module.Index);
            Sql_DeleteModuleView.Append("'");

            List <String> sql_Commands = new List <string>();

            sql_Commands.Add(Sql_Delete.ToString());
            sql_Commands.Add(Sql_ExtentSheet.ToString());
            sql_Commands.Add(Sql_DeleteField.ToString());
            sql_Commands.Add(Sql_DeleteFunctionInfo.ToString());
            sql_Commands.Add(Sql_DeleteCrossSheetFormulas.ToString());
            sql_Commands.Add(Sql_DeleteModuleView.ToString());

            try
            {
                int[] r = ExcuteCommands(sql_Commands.ToArray());
                for (int i = 0; i < r.Length; i++)
                {
                    Result = Result & (Convert.ToInt32(r[i]) == 1);
                }
                Result = Result & DataSchemaManager.DeleteTableStruct(module.ExtentDataSchema.Name);
            }
            catch (Exception ex)
            {
                logger.Error("删除错误= " + ex.Message);
            }

            try
            {
                PXJZDataManager pxjz = new PXJZDataManager();
                pxjz.DeleteModel(module.Index);
            }
            catch
            {
            }
            return(Result);
        }
예제 #2
0
        public Boolean UpdateModuleConfiguration(ModuleConfiguration module)
        {
            List <String> SheetIndexs = new List <string>();

            foreach (SheetConfiguration Sheet in module.Sheets)
            {
                SheetIndexs.Add(Sheet.Index);
            }

            StringBuilder Sql_Select = new StringBuilder();

            // 增加查询条件 Scdel=0     2013-10-19
            Sql_Select.Append("Select ID,SCTS,Description,CatlogCode,Sheets,Scts_1 From sys_biz_Module Where Scdel=0 and ID='");
            Sql_Select.Append(module.Index);
            Sql_Select.Append("'");

            DataTable Data = GetDataTable(Sql_Select.ToString());

            if (Data != null && Data.Rows.Count > 0)
            {
                DataRow Row = Data.Rows[0];
                Row["ID"]          = module.Index;
                Row["SCTS"]        = DateTime.Now.ToString();
                Row["Description"] = module.Description;
                Row["CatlogCode"]  = module.Code;

                if (SheetIndexs.Count > 0)
                {
                    Row["Sheets"] = "," + String.Join(",", SheetIndexs.ToArray()) + ",";
                }
                else
                {
                    Row["Sheets"] = "";
                }
                Row["Scts_1"] = DateTime.Now.ToString();
            }
            else
            {
                DataRow Row = Data.NewRow();
                Row["ID"]          = module.Index;
                Row["SCTS"]        = DateTime.Now.ToString();
                Row["Description"] = module.Description;
                Row["CatlogCode"]  = module.Code;

                if (SheetIndexs.Count > 0)
                {
                    Row["Sheets"] = "," + String.Join(",", SheetIndexs.ToArray()) + ",";
                }
                else
                {
                    Row["Sheets"] = "";
                }
                Row["Scts_1"] = DateTime.Now.ToString();

                Data.Rows.Add(Row);
            }

            Boolean Result = false;

            try
            {
                logger.Error("begin updage");

                object r = Update(Data);
                logger.Error("end update");

                Result = (Convert.ToInt32(r) == 1);
                if (Result)
                {
                    Result = Result & TableDefineInfoManager.UpdateTableDefineInfo(module.ExtentDataSchema);
                    PXJZDataManager pxjz = new PXJZDataManager();
                    pxjz.RenameModel(module.Description, module.Index);
                }
            }
            catch (Exception e)
            {
                logger.Error(e.ToString());
            }

            return(Result);
        }
예제 #3
0
        public Boolean NewModuleConfiguration(ModuleConfiguration module)
        {
            Boolean Result = false;

            StringBuilder Sql_module = new StringBuilder();

            //增加查询条件Scdel=0     2013-10-19
            Sql_module.Append("Select ID,SCTS,SCTS_1,Description,CatlogCode,Sheets,ExtentSheet From sys_biz_Module Where Scdel=0 and ID='");
            Sql_module.Append(module.Index);
            Sql_module.Append("'");

            StringBuilder Sql_ExtentSheet = new StringBuilder();

            //增加查询条件Scdel=0     2013-10-19
            Sql_ExtentSheet.Append("Select * From sys_Tables Where Scdel=0 and TABLENAME='");
            Sql_ExtentSheet.Append(module.ExtentDataSchema.Name);
            Sql_ExtentSheet.Append("'");

            List <string> sql_Commands = new List <string>();

            sql_Commands.Add(Sql_module.ToString());
            sql_Commands.Add(Sql_ExtentSheet.ToString());

            DataSet dataset = GetDataSet(sql_Commands.ToArray());

            if (dataset != null)
            {
                DataTable data_tables = dataset.Tables["sys_Tables"];
                DataTable data_module = dataset.Tables["sys_biz_Module"];

                if (data_tables != null)
                {
                    DataRow Row = data_tables.NewRow();
                    Row["ID"]          = module.ExtentDataSchema.Index;
                    Row["SCTS"]        = DateTime.Now.ToString();
                    Row["Description"] = module.ExtentDataSchema.Description;
                    Row["TABLENAME"]   = module.ExtentDataSchema.Name;
                    Row["TABLETYPE"]   = module.ExtentDataSchema.Type;
                    Row["SCTS_1"]      = DateTime.Now.ToString();
                    data_tables.Rows.Add(Row);
                }

                if (data_module != null)
                {
                    DataRow Row = data_module.NewRow();
                    Row["ID"]          = module.Index;
                    Row["SCTS"]        = DateTime.Now.ToString();
                    Row["Description"] = module.Description;
                    Row["CatlogCode"]  = module.Code;

                    Row["Sheets"]      = "";
                    Row["ExtentSheet"] = module.ExtentDataSchema.Index;
                    Row["SCTS_1"]      = DateTime.Now.ToString();

                    data_module.Rows.Add(Row);
                }
            }

            try
            {
                object r = Update(dataset);
                Result = (Convert.ToInt32(r) == 1);

                Result = Result & DataSchemaManager.UpdateTableStruct(module.ExtentDataSchema.Name);
                PXJZDataManager pxjz = new PXJZDataManager();
                pxjz.NewModel(module.Description, module.Code, module.Index);
            }
            catch
            { }

            return(Result);
        }