public void ddlIdentifierType_SelectedIndexChanged(object sender, EventArgs e) { var identifierType = EGovPublicIdentifierTypeUtils.GetEnumType(ddlIdentifierType.SelectedValue); if (identifierType == EGovPublicIdentifierType.Department || identifierType == EGovPublicIdentifierType.Channel) { phAttributeName.Visible = false; phFormatString.Visible = false; phMinLength.Visible = true; phSequence.Visible = false; } else if (identifierType == EGovPublicIdentifierType.Sequence) { phAttributeName.Visible = false; phFormatString.Visible = false; phMinLength.Visible = true; phSequence.Visible = true; } else if (identifierType == EGovPublicIdentifierType.Attribute) { phAttributeName.Visible = true; phFormatString.Visible = true; phMinLength.Visible = true; phSequence.Visible = false; } }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } _ruleId = TranslateUtils.ToInt(Request.QueryString["RuleID"]); if (!IsPostBack) { EGovPublicIdentifierTypeUtils.AddListItems(ddlIdentifierType); var styleInfoList = TableStyleManager.GetTableStyleInfoList(ETableStyle.GovPublicContent, PublishmentSystemInfo.AuxiliaryTableForGovPublic, null); foreach (var tableStyleInfo in styleInfoList) { if (tableStyleInfo.AttributeName == ContentAttribute.Title || tableStyleInfo.AttributeName == GovPublicContentAttribute.Content || tableStyleInfo.AttributeName == GovPublicContentAttribute.DepartmentId || tableStyleInfo.AttributeName == GovPublicContentAttribute.Description || tableStyleInfo.AttributeName == GovPublicContentAttribute.ImageUrl || tableStyleInfo.AttributeName == GovPublicContentAttribute.FileUrl || tableStyleInfo.AttributeName == GovPublicContentAttribute.Identifier || tableStyleInfo.AttributeName == GovPublicContentAttribute.Keywords || tableStyleInfo.AttributeName == GovPublicContentAttribute.DocumentNo || tableStyleInfo.AttributeName == GovPublicContentAttribute.Publisher) { continue; } ddlAttributeName.Items.Add(new ListItem(tableStyleInfo.DisplayName + "(" + tableStyleInfo.AttributeName + ")", tableStyleInfo.AttributeName)); } EBooleanUtils.AddListItems(rblIsSequenceChannelZero); EBooleanUtils.AddListItems(rblIsSequenceDepartmentZero); EBooleanUtils.AddListItems(rblIsSequenceYearZero); ControlUtils.SelectListItemsIgnoreCase(rblIsSequenceChannelZero, true.ToString()); ControlUtils.SelectListItemsIgnoreCase(rblIsSequenceDepartmentZero, false.ToString()); ControlUtils.SelectListItemsIgnoreCase(rblIsSequenceYearZero, true.ToString()); if (_ruleId > 0) { var ruleInfo = DataProvider.GovPublicIdentifierRuleDao.GetIdentifierRuleInfo(_ruleId); if (ruleInfo != null) { tbRuleName.Text = ruleInfo.RuleName; ControlUtils.SelectListItems(ddlIdentifierType, EGovPublicIdentifierTypeUtils.GetValue(ruleInfo.IdentifierType)); ControlUtils.SelectListItems(ddlAttributeName, ruleInfo.AttributeName); tbMinLength.Text = ruleInfo.MinLength.ToString(); tbFormatString.Text = ruleInfo.FormatString; tbSuffix.Text = ruleInfo.Suffix; tbSequence.Text = ruleInfo.Sequence.ToString(); ControlUtils.SelectListItemsIgnoreCase(rblIsSequenceChannelZero, ruleInfo.Additional.IsSequenceChannelZero.ToString()); ControlUtils.SelectListItemsIgnoreCase(rblIsSequenceDepartmentZero, ruleInfo.Additional.IsSequenceDepartmentZero.ToString()); ControlUtils.SelectListItemsIgnoreCase(rblIsSequenceYearZero, ruleInfo.Additional.IsSequenceYearZero.ToString()); } } ddlIdentifierType.SelectedIndexChanged += ddlIdentifierType_SelectedIndexChanged; ddlIdentifierType_SelectedIndexChanged(null, EventArgs.Empty); } }
public void Update(GovPublicIdentifierRuleInfo ruleInfo) { var parms = new IDataParameter[] { GetParameter(ParmRuleName, EDataType.NVarChar, 255, ruleInfo.RuleName), GetParameter(ParmIdentifierType, EDataType.VarChar, 50, EGovPublicIdentifierTypeUtils.GetValue(ruleInfo.IdentifierType)), GetParameter(ParmMinLength, EDataType.Integer, ruleInfo.MinLength), GetParameter(ParmSuffix, EDataType.VarChar, 50, ruleInfo.Suffix), GetParameter(ParmFormatString, EDataType.VarChar, 50, ruleInfo.FormatString), GetParameter(ParmAttributeName, EDataType.VarChar, 50, ruleInfo.AttributeName), GetParameter(ParmSequence, EDataType.Integer, ruleInfo.Sequence), GetParameter(ParmSettingsXml, EDataType.NText, ruleInfo.Additional.ToString()), GetParameter(ParmRuleId, EDataType.Integer, ruleInfo.RuleID) }; ExecuteNonQuery(SqlUpdate, parms); }
public void Insert(GovPublicIdentifierRuleInfo ruleInfo) { var taxis = GetMaxTaxis(ruleInfo.PublishmentSystemID) + 1; var sqlInsert = "INSERT INTO wcm_GovPublicIdentifierRule (RuleName, PublishmentSystemID, IdentifierType, MinLength, Suffix, FormatString, AttributeName, Sequence, Taxis, SettingsXML) VALUES (@RuleName, @PublishmentSystemID, @IdentifierType, @MinLength, @Suffix, @FormatString, @AttributeName, @Sequence, @Taxis, @SettingsXML)"; var parms = new IDataParameter[] { GetParameter(ParmRuleName, EDataType.NVarChar, 255, ruleInfo.RuleName), GetParameter(ParmPublishmentsystemid, EDataType.Integer, ruleInfo.PublishmentSystemID), GetParameter(ParmIdentifierType, EDataType.VarChar, 50, EGovPublicIdentifierTypeUtils.GetValue(ruleInfo.IdentifierType)), GetParameter(ParmMinLength, EDataType.Integer, ruleInfo.MinLength), GetParameter(ParmSuffix, EDataType.VarChar, 50, ruleInfo.Suffix), GetParameter(ParmFormatString, EDataType.VarChar, 50, ruleInfo.FormatString), GetParameter(ParmAttributeName, EDataType.VarChar, 50, ruleInfo.AttributeName), GetParameter(ParmSequence, EDataType.Integer, ruleInfo.Sequence), GetParameter(ParmTaxis, EDataType.Integer, taxis), GetParameter(ParmSettingsXml, EDataType.NText, ruleInfo.Additional.ToString()) }; ExecuteNonQuery(sqlInsert, parms); }
public override void Submit_OnClick(object sender, EventArgs e) { var isChanged = false; var ruleInfoArrayList = DataProvider.GovPublicIdentifierRuleDao.GetRuleInfoArrayList(PublishmentSystemId); if (_ruleId > 0) { try { var ruleInfo = DataProvider.GovPublicIdentifierRuleDao.GetIdentifierRuleInfo(_ruleId); ruleInfo.RuleName = tbRuleName.Text; ruleInfo.IdentifierType = EGovPublicIdentifierTypeUtils.GetEnumType(ddlIdentifierType.SelectedValue); ruleInfo.MinLength = TranslateUtils.ToInt(tbMinLength.Text); ruleInfo.Suffix = tbSuffix.Text; ruleInfo.FormatString = tbFormatString.Text; ruleInfo.AttributeName = ddlAttributeName.SelectedValue; ruleInfo.Sequence = TranslateUtils.ToInt(tbSequence.Text); if (ruleInfo.IdentifierType == EGovPublicIdentifierType.Sequence) { ruleInfo.Additional.IsSequenceChannelZero = TranslateUtils.ToBool(rblIsSequenceChannelZero.SelectedValue); ruleInfo.Additional.IsSequenceDepartmentZero = TranslateUtils.ToBool(rblIsSequenceDepartmentZero.SelectedValue); ruleInfo.Additional.IsSequenceYearZero = TranslateUtils.ToBool(rblIsSequenceYearZero.SelectedValue); } foreach (GovPublicIdentifierRuleInfo identifierRuleInfo in ruleInfoArrayList) { if (identifierRuleInfo.RuleID == ruleInfo.RuleID) { continue; } if (identifierRuleInfo.IdentifierType != EGovPublicIdentifierType.Attribute && identifierRuleInfo.IdentifierType == ruleInfo.IdentifierType) { FailMessage("规则修改失败,本类型规则只能添加一次!"); return; } if (identifierRuleInfo.RuleName == tbRuleName.Text) { FailMessage("规则修改失败,规则名称已存在!"); return; } } DataProvider.GovPublicIdentifierRuleDao.Update(ruleInfo); Body.AddSiteLog(PublishmentSystemId, "修改规则", $"规则:{ruleInfo.RuleName}"); isChanged = true; } catch (Exception ex) { FailMessage(ex, "规则修改失败!"); } } else { var identifierType = EGovPublicIdentifierTypeUtils.GetEnumType(ddlIdentifierType.SelectedValue); foreach (GovPublicIdentifierRuleInfo ruleInfo in ruleInfoArrayList) { if (ruleInfo.IdentifierType != EGovPublicIdentifierType.Attribute && ruleInfo.IdentifierType == identifierType) { FailMessage("规则添加失败,本类型规则只能添加一次!"); return; } if (ruleInfo.RuleName == tbRuleName.Text) { FailMessage("规则添加失败,规则名称已存在!"); return; } } try { var ruleInfo = new GovPublicIdentifierRuleInfo(0, tbRuleName.Text, PublishmentSystemId, identifierType, TranslateUtils.ToInt(tbMinLength.Text), tbSuffix.Text, tbFormatString.Text, ddlAttributeName.SelectedValue, TranslateUtils.ToInt(tbSequence.Text), 0, string.Empty); if (ruleInfo.IdentifierType == EGovPublicIdentifierType.Sequence) { ruleInfo.Additional.IsSequenceChannelZero = TranslateUtils.ToBool(rblIsSequenceChannelZero.SelectedValue); ruleInfo.Additional.IsSequenceDepartmentZero = TranslateUtils.ToBool(rblIsSequenceDepartmentZero.SelectedValue); ruleInfo.Additional.IsSequenceYearZero = TranslateUtils.ToBool(rblIsSequenceYearZero.SelectedValue); } DataProvider.GovPublicIdentifierRuleDao.Insert(ruleInfo); Body.AddSiteLog(PublishmentSystemId, "添加规则", $"规则:{ruleInfo.RuleName}"); isChanged = true; } catch (Exception ex) { FailMessage(ex, "规则添加失败!"); } } if (isChanged) { PageUtils.CloseModalPageAndRedirect(Page, PageGovPublicIdentifierRule.GetRedirectUrl(PublishmentSystemId)); } }
void dgContents_ItemDataBound(object sender, DataGridItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { var ruleInfo = e.Item.DataItem as GovPublicIdentifierRuleInfo; var ltlIndex = e.Item.FindControl("ltlIndex") as Literal; var ltlRuleName = e.Item.FindControl("ltlRuleName") as Literal; var ltlIdentifierType = e.Item.FindControl("ltlIdentifierType") as Literal; var ltlMinLength = e.Item.FindControl("ltlMinLength") as Literal; var ltlSuffix = e.Item.FindControl("ltlSuffix") as Literal; var hlUpLinkButton = e.Item.FindControl("hlUpLinkButton") as HyperLink; var hlDownLinkButton = e.Item.FindControl("hlDownLinkButton") as HyperLink; var ltlSettingUrl = e.Item.FindControl("ltlSettingUrl") as Literal; var ltlEditUrl = e.Item.FindControl("ltlEditUrl") as Literal; var ltlDeleteUrl = e.Item.FindControl("ltlDeleteUrl") as Literal; ltlIndex.Text = (e.Item.ItemIndex + 1).ToString(); ltlRuleName.Text = ruleInfo.RuleName; ltlIdentifierType.Text = EGovPublicIdentifierTypeUtils.GetText(ruleInfo.IdentifierType); ltlMinLength.Text = ruleInfo.MinLength.ToString(); ltlSuffix.Text = ruleInfo.Suffix; hlUpLinkButton.NavigateUrl = PageUtils.GetWcmUrl(nameof(PageGovPublicIdentifierRule), new NameValueCollection { { "siteId", PublishmentSystemId.ToString() }, { "RuleID", ruleInfo.RuleID.ToString() }, { "Up", true.ToString() } }); hlDownLinkButton.NavigateUrl = PageUtils.GetWcmUrl(nameof(PageGovPublicIdentifierRule), new NameValueCollection { { "siteId", PublishmentSystemId.ToString() }, { "RuleID", ruleInfo.RuleID.ToString() }, { "Down", true.ToString() } }); if (ruleInfo.IdentifierType == EGovPublicIdentifierType.Department) { var urlSetting = PageGovPublicDepartment.GetRedirectUrl(PublishmentSystemId); ltlSettingUrl.Text = $@"<a href=""{urlSetting}"">机构分类设置</a>"; } else if (ruleInfo.IdentifierType == EGovPublicIdentifierType.Channel) { ltlSettingUrl.Text = $@"<a href=""{PageGovPublicChannel.GetRedirectUrl(PublishmentSystemId)}"">主题分类设置</a>"; } ltlEditUrl.Text = $@"<a href='javascript:;' onclick=""{ModalGovPublicIdentifierRuleAdd.GetOpenWindowStringToEdit( PublishmentSystemId, ruleInfo.RuleID)}"">编辑</a>"; var urlDelete = PageUtils.GetWcmUrl(nameof(PageGovPublicIdentifierRule), new NameValueCollection { { "siteId", PublishmentSystemId.ToString() }, { "RuleID", ruleInfo.RuleID.ToString() }, { "Delete", true.ToString() } }); ltlDeleteUrl.Text = $@"<a href=""{urlDelete}"" onClick=""javascript:return confirm('此操作将删除规则“{ruleInfo.RuleName}”,确认吗?');"">删除</a>"; } }
public GovPublicIdentifierRuleInfo GetIdentifierRuleInfo(int ruleId) { GovPublicIdentifierRuleInfo ruleInfo = null; var parms = new IDataParameter[] { GetParameter(ParmRuleId, EDataType.Integer, ruleId) }; using (var rdr = ExecuteReader(SqlSelect, parms)) { if (rdr.Read()) { var i = 0; ruleInfo = new GovPublicIdentifierRuleInfo(GetInt(rdr, i++), GetString(rdr, i++), GetInt(rdr, i++), EGovPublicIdentifierTypeUtils.GetEnumType(GetString(rdr, i++)), GetInt(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetInt(rdr, i++), GetInt(rdr, i++), GetString(rdr, i)); } rdr.Close(); } return(ruleInfo); }
public ArrayList GetRuleInfoArrayList(int publishmentSystemId) { var arraylist = new ArrayList(); var selectParms = new IDataParameter[] { GetParameter(ParmPublishmentsystemid, EDataType.Integer, publishmentSystemId) }; using (var rdr = ExecuteReader(SqlSelectAll, selectParms)) { while (rdr.Read()) { var i = 0; var ruleInfo = new GovPublicIdentifierRuleInfo(GetInt(rdr, i++), GetString(rdr, i++), GetInt(rdr, i++), EGovPublicIdentifierTypeUtils.GetEnumType(GetString(rdr, i++)), GetInt(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetInt(rdr, i++), GetInt(rdr, i++), GetString(rdr, i)); arraylist.Add(ruleInfo); } rdr.Close(); } return(arraylist); }