protected void CreateAllModel(object sender, CommandEventArgs e) { BLL.Content.ParseModel model; BLL.Content.ModelManage modelManage; DataTable dtModel; string faileModelName; StringBuilder sbMsg; bool isValidate; isValidate = IsHaveRightByOperCode("CreateModel"); sbMsg = new StringBuilder(); if (isValidate) { faileModelName = string.Empty; modelManage = new BLL.Content.ModelManage(); dtModel = modelManage.GetList("IDANDNAME", new Model.SelectParams()); foreach (DataRow dr in dtModel.Rows) // 遍历生成所有模型 { model = new ParseModel(dr["ID"].ToString(), BLL.Content.ParserType.Content); try { model.Create(); } catch (Exception ex) { if (string.IsNullOrEmpty(faileModelName)) { faileModelName = dr["Title"].ToString(); } else { faileModelName += "," + dr["Title"].ToString(); } sbMsg.Append(ex.Message); } } if (string.IsNullOrEmpty(faileModelName)) { jsMessage = "alert({ msg: '全部生成成功,禁用和删除在回收站的模型除外!', title: '操作结果' })"; WriteLog("全部生成成功,禁用和删除在回收站的模型除外!", null, 2); } else { jsMessage = "alert({ msg: '对不起,以下模型生成失败 " + faileModelName + "。', title: '操作提示' })"; WriteLog("以下模型生成失败 " + faileModelName, sbMsg.ToString(), 3); } } else { jsMessage += "alert({msg:\"对不起,您没有创建模型属性的操作权限,请与管理员联系!\",title:\"操作提示\"});"; } }
protected void CreateModel(object sender, CommandEventArgs e) { string strModelId; // 模型ID string browseUrl; // 浏览模型地址 bool isValidate; isValidate = IsHaveRightByOperCode("CreateModel"); if (isValidate) { strModelId = e.CommandArgument.ToString(); if (Utils.ParseBool(e.CommandName)) { BLL.Content.ParseModel model = new ParseModel(strModelId, BLL.Content.ParserType.Content); browseUrl = model.CutTableNamePreFix(((Button)sender).ToolTip) + "edit.aspx?Action=browse&NodeCode=" + NodeCode; try { model.Create(); jsMessage = "CreateModelConfirm(\"" + browseUrl + "\", \"恭喜您,创建成功,是否浏览生成后的模型!\")"; } catch (Exception ex) { jsMessage = "alert({ msg: '操作失败,请重试。', title: '操作结果' })"; WriteLog("生成模型 " + LogTitle + " 失败", ex.Message, 3); } WriteLog("生成模型 " + LogTitle + " 成功", string.Empty, 2); } else { jsMessage = "alert({ msg: '对不起,当前模型已被禁用,如需使用请先解禁当前模型。', title: '操作提示' })"; } } else { jsMessage += "alert({msg:\"对不起,您没有创建模型属性的操作权限,请与管理员联系!\",title:\"操作提示\"});"; } }