コード例 #1
0
        //互动模型需要扩展
        public void RestoreByName(string name)
        {
            B_Model      modelBll = new B_Model();
            B_ModelField fieldBll = new B_ModelField();
            B_Pub        pubBll   = new B_Pub();
            string       ppath    = SafeSC.PathDeal(pdir + name);

            if (!File.Exists(ppath))
            {
                function.WriteErrMsg("备份文件[" + name + "]不存在");
            }
            //清空数据
            modelBll.DeleteAll();
            foreach (string tbname in tbnames)
            {
                SqlHelper.ExecuteSql("TRUNCATE TABLE " + tbname);
            }
            SqlHelper.ExecuteSql("TRUNCATE TABLE ZL_CommonModel");
            //开始恢复
            DataSet ds = new DataSet();

            ds.ReadXml(ppath);
            //批量导入部分数据
            SqlHelper.Insert_Bat(ds.Tables["ZL_Node"], SqlHelper.ConnectionString);
            if (ds.Tables["ZL_Pub"] != null)
            {
                SqlHelper.Insert_Bat(ds.Tables["ZL_Pub"], SqlHelper.ConnectionString);
            }
            if (ds.Tables["ZL_Node_ModelTemplate"] != null)
            {
                SqlHelper.Insert_Bat(ds.Tables["ZL_Node_ModelTemplate"], SqlHelper.ConnectionString);
            }
            if (ds.Tables["ZL_UserPromotions"] != null)
            {
                SqlHelper.Insert_Bat(ds.Tables["ZL_UserPromotions"], SqlHelper.ConnectionString);
            }
            if (ds.Tables["ZL_NodeRole"] != null)
            {
                SqlHelper.Insert_Bat(ds.Tables["ZL_NodeRole"], SqlHelper.ConnectionString);
            }
            //恢复模型数据与其对应的表
            DataTable modelDT = ds.Tables["ZL_Model"];
            DataTable fieldDT = ds.Tables["ZL_ModelField"];
            DataTable pubDT   = ds.Tables["ZL_Pub"];

            foreach (DataRow dr in modelDT.Rows)
            {
                M_ModelInfo modelMod = new M_ModelInfo().GetModelFromReader(dr);
                ZoomLa.SQLDAL.DBHelper.Table_Del(modelMod.TableName);
                switch (modelMod.ModelType.ToString())
                {
                case "3":    //用户模型和黄页申请模型
                    modelBll.AddUserModel(modelMod);
                    break;

                case "6":    //店铺申请模型
                    modelBll.AddStoreModel(modelMod);
                    break;

                case "7":    //互动模型
                    if (pubDT == null)
                    {
                        break;
                    }
                    M_Pub pubmodel = new M_Pub();
                    pubmodel.PubName      = modelMod.ModelName;
                    pubmodel.PubTableName = modelMod.TableName;
                    DataRow[] drs = pubDT.Select("PubModelID=" + modelMod.ModelID);
                    pubmodel.PubType = drs.Length > 0 ? DataConvert.CLng(drs[0]["PubType"]) : 0;
                    pubBll.CreateModelInfo(pubmodel);
                    break;

                case "8":    //功能模型
                    modelBll.AddFunModel(modelMod);
                    break;

                default:    //内容模型、商城模型、黄页内容模型、店铺商品模型
                    modelBll.AddModel(modelMod);
                    break;
                }
            }
            //恢复字段
            if (fieldDT != null && fieldDT.Rows.Count > 0)
            {
                fieldDT.DefaultView.RowFilter = "sys_type ='false'";
                foreach (DataRow dr in fieldDT.DefaultView.ToTable().Rows)
                {
                    int modelID = DataConvert.CLng(dr["ModelID"]);
                    if (modelID < 1)
                    {
                        continue;
                    }
                    DataRow[] drs = modelDT.Select("ModelID='" + modelID + "'");
                    //OA不处理,未找到不处理
                    if (drs.Length < 1 || drs[0]["ModelType"].ToString().Equals("12"))
                    {
                        continue;
                    }
                    M_ModelInfo  modelMod = new M_ModelInfo().GetModelFromReader(drs[0]);
                    M_ModelField fieldMod = new M_ModelField().GetModelFromReader(dr);
                    //Pub表会报重复
                    if (fieldBll.IsExists(modelMod.ModelID, fieldMod.FieldName))
                    {
                        continue;
                    }
                    if (DBCenter.DB.Table_Exist(modelMod.TableName)) //互动表可能未创建,忽略
                    {
                        fieldBll.AddModelField(modelMod, fieldMod);
                    }
                }
                SqlHelper.ExecuteSql("TRUNCATE TABLE ZL_ModelField");
                SqlHelper.Insert_Bat(fieldDT, SqlHelper.ConnectionString);
            }
        }
コード例 #2
0
ファイル: ModelController.cs プロジェクト: baixue001/IPS
        public IActionResult ModelAdd_Submit()
        {
            string modelName = RequestEx["TxtModelName"];

            if (string.IsNullOrEmpty(modelName))
            {
                return(WriteErr("模型名称不能为空"));
            }
            //----------------------------------------
            M_ModelInfo info = new M_ModelInfo();

            if (Mid < 1)
            {
                string modelTbName = (bll.GetTablePrefix(ModelType) + RequestEx["TxtTableName"]).Replace(" ", "");
                info.MultiFlag = true;
                info.TableName = modelTbName;
                if (bll.isExistTableName(modelTbName))
                {
                    return(WriteErr("数据库表名已存在,请重新输入!"));
                }
            }
            else
            {
                info = bll.SelReturnModel(Mid);
                //info.TableName = TxtTableName.Text;
            }
            info.ModelName   = modelName;
            info.ItemName    = RequestEx["TxtItemName"];
            info.ItemUnit    = RequestEx["TxtItemUnit"];
            info.ItemIcon    = RequestEx["ItemIcon_T"];
            info.Description = RequestEx["TxtDescription"];
            info.ModelType   = ModelType;
            info.SysModel    = DataConvert.CLng(RequestEx["rblCopy"]);
            info.Islotsize   = DataConverter.CLng(RequestEx["rblIslotsize"]) == 1;
            //info.Thumbnail = FileFactory.Checked ? "1" : "0";
            if (info.ModelID < 1)
            {
                info.FromModel = 0;
                switch (ModelType.ToString())
                {
                case "3":    //用户模型和黄页申请模型
                    bll.AddUserModel(info);
                    break;

                case "6":    //店铺申请模型
                    bll.AddStoreModel(info);
                    break;

                case "7":    //互动模型
                {
                    B_Pub pll      = new B_Pub();
                    M_Pub pubmodel = new M_Pub();
                    pubmodel.PubName      = info.ModelName;
                    pubmodel.PubTableName = info.TableName;
                    pubmodel.PubType      = DataConverter.CLng(GetParam("PubType"));
                    if (string.IsNullOrEmpty(info.ItemIcon))
                    {
                        info.ItemIcon = "zi zi_comment";
                    }
                    pll.CreateModelInfo(pubmodel, info);
                }
                break;

                case "8":    //功能模型
                    bll.AddFunModel(info);
                    break;

                case "12":              //OA办公模型
                    bll.AddModel(info); //基于内容模型,增加自定义字段
                    break;

                default:    //内容模型、商城模型、黄页内容模型、店铺商品模型
                    if (bll.IsExistModelName(info.ModelName))
                    {
                        return(WriteErr("模型名称[" + info.ModelName + "]已存在"));
                    }
                    //CreateDataLabel(info);
                    bll.AddModel(info);
                    break;
                }
            }
            else
            {
                bll.UpdateByID(info);
            }
            return(RedirectToAction("ModelManage"));
        }