public void Insert(GatherFileRuleInfo gatherFileRuleInfo) { var insertParms = new IDataParameter[] { GetParameter(ParmGatherFileRuleName, EDataType.NVarChar, 50, gatherFileRuleInfo.GatherRuleName), GetParameter(ParmPublishmentSystemId, EDataType.Integer, gatherFileRuleInfo.PublishmentSystemId), GetParameter(ParmGatherUrl, EDataType.NVarChar, 255, gatherFileRuleInfo.GatherUrl), GetParameter(ParmCharset, EDataType.VarChar, 50, ECharsetUtils.GetValue(gatherFileRuleInfo.Charset)), GetParameter(ParmLastGatherDate, EDataType.DateTime, gatherFileRuleInfo.LastGatherDate), GetParameter(ParmIsToFile, EDataType.VarChar, 18, gatherFileRuleInfo.IsToFile.ToString()), GetParameter(ParmFilePath, EDataType.NVarChar, 255, gatherFileRuleInfo.FilePath), GetParameter(ParmIsSaveRelatedFiles, EDataType.VarChar, 18, gatherFileRuleInfo.IsSaveRelatedFiles.ToString()), GetParameter(ParmIsRemoveScripts, EDataType.VarChar, 18, gatherFileRuleInfo.IsRemoveScripts.ToString()), GetParameter(ParmStyleDirectoryPath, EDataType.NVarChar, 255, gatherFileRuleInfo.StyleDirectoryPath), GetParameter(ParmScriptDirectoryPath, EDataType.NVarChar, 255, gatherFileRuleInfo.ScriptDirectoryPath), GetParameter(ParmImageDirectoryPath, EDataType.NVarChar, 255, gatherFileRuleInfo.ImageDirectoryPath), GetParameter(ParmNodeId, EDataType.Integer, gatherFileRuleInfo.NodeId), GetParameter(ParmIsSaveImage, EDataType.VarChar, 18, gatherFileRuleInfo.IsSaveImage.ToString()), GetParameter(ParmIsChecked, EDataType.VarChar, 18, gatherFileRuleInfo.IsChecked.ToString()), GetParameter(ParmContentExclude, EDataType.NText, gatherFileRuleInfo.ContentExclude), GetParameter(ParmContentHtmlClearCollection, EDataType.NVarChar, 255, gatherFileRuleInfo.ContentHtmlClearCollection), GetParameter(ParmContentHtmlClearTagCollection, EDataType.NVarChar, 255, gatherFileRuleInfo.ContentHtmlClearTagCollection), GetParameter(ParmContentTitleStart, EDataType.NText, gatherFileRuleInfo.ContentTitleStart), GetParameter(ParmContentTitleEnd, EDataType.NText, gatherFileRuleInfo.ContentTitleEnd), GetParameter(ParmContentContentStart, EDataType.NText, gatherFileRuleInfo.ContentContentStart), GetParameter(ParmContentContentEnd, EDataType.NText, gatherFileRuleInfo.ContentContentEnd), GetParameter(ParmContentAttributes, EDataType.NText, gatherFileRuleInfo.ContentAttributes), GetParameter(ParmContentAttributesXml, EDataType.NText, gatherFileRuleInfo.ContentAttributesXml), GetParameter(ParmIsAutoCreate, EDataType.VarChar, 18, gatherFileRuleInfo.IsAutoCreate.ToString()) }; ExecuteNonQuery(SqlInsertGatherFileRule, insertParms); }
public GatherFileRuleInfo GetGatherFileRuleInfo(string gatherRuleName, int publishmentSystemId) { GatherFileRuleInfo gatherFileRuleInfo = null; var parms = new IDataParameter[] { GetParameter(ParmGatherFileRuleName, EDataType.NVarChar, 50, gatherRuleName), GetParameter(ParmPublishmentSystemId, EDataType.Integer, publishmentSystemId) }; using (var rdr = ExecuteReader(SqlSelectGatherFileRule, parms)) { if (rdr.Read()) { var i = 0; gatherFileRuleInfo = new GatherFileRuleInfo(GetString(rdr, i++), GetInt(rdr, i++), GetString(rdr, i++), ECharsetUtils.GetEnumType(GetString(rdr, i++)), GetDateTime(rdr, i++), GetBool(rdr, i++), GetString(rdr, i++), GetBool(rdr, i++), GetBool(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetInt(rdr, i++), GetBool(rdr, i++), GetBool(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetBool(rdr, i)); } rdr.Close(); } return(gatherFileRuleInfo); }
public ArrayList GetGatherFileRuleInfoArrayList(int publishmentSystemId) { var list = new ArrayList(); var parms = new IDataParameter[] { GetParameter(ParmPublishmentSystemId, EDataType.Integer, publishmentSystemId) }; using (var rdr = ExecuteReader(SqlSelectAllGatherFileRuleByPsId, parms)) { while (rdr.Read()) { var i = 0; var gatherFileRuleInfo = new GatherFileRuleInfo(GetString(rdr, i++), GetInt(rdr, i++), GetString(rdr, i++), ECharsetUtils.GetEnumType(GetString(rdr, i++)), GetDateTime(rdr, i++), GetBool(rdr, i++), GetString(rdr, i++), GetBool(rdr, i++), GetBool(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetInt(rdr, i++), GetBool(rdr, i++), GetBool(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetBool(rdr, i)); list.Add(gatherFileRuleInfo); } rdr.Close(); } return(list); }
public bool Validate_InsertGatherRule(out string errorMessage) { try { var isNeedAdd = false; if (_isEdit) { if (_theGatherRuleName != GatherRuleName.Text) { isNeedAdd = true; DataProvider.GatherDatabaseRuleDao.Delete(_theGatherRuleName, PublishmentSystemId); } else { var gatherFileRuleInfo = DataProvider.GatherFileRuleDao.GetGatherFileRuleInfo(_theGatherRuleName, PublishmentSystemId); gatherFileRuleInfo.GatherUrl = GatherUrl.Text; gatherFileRuleInfo.Charset = ECharsetUtils.GetEnumType(Charset.SelectedValue); gatherFileRuleInfo.IsToFile = TranslateUtils.ToBool(IsToFile.SelectedValue); gatherFileRuleInfo.FilePath = FilePath.Text; gatherFileRuleInfo.IsSaveRelatedFiles = TranslateUtils.ToBool(IsSaveRelatedFiles.SelectedValue); gatherFileRuleInfo.IsRemoveScripts = TranslateUtils.ToBool(IsRemoveScripts.SelectedValue); gatherFileRuleInfo.StyleDirectoryPath = StyleDirectoryPath.Text; gatherFileRuleInfo.ScriptDirectoryPath = ScriptDirectoryPath.Text; gatherFileRuleInfo.ImageDirectoryPath = ImageDirectoryPath.Text; if (NodeIDDropDownList.SelectedValue != null) { gatherFileRuleInfo.NodeId = int.Parse(NodeIDDropDownList.SelectedValue); } gatherFileRuleInfo.IsSaveImage = TranslateUtils.ToBool(IsSaveImage.SelectedValue); gatherFileRuleInfo.IsChecked = TranslateUtils.ToBool(IsChecked.SelectedValue); gatherFileRuleInfo.IsAutoCreate = TranslateUtils.ToBool(IsAutoCreate.SelectedValue); gatherFileRuleInfo.ContentExclude = ContentExclude.Text; var htmlClearArrayList = new ArrayList(); foreach (ListItem item in ContentHtmlClearCollection.Items) { if (item.Selected) { htmlClearArrayList.Add(item.Value); } } gatherFileRuleInfo.ContentHtmlClearCollection = TranslateUtils.ObjectCollectionToString(htmlClearArrayList); var htmlClearTagArrayList = new ArrayList(); foreach (ListItem item in ContentHtmlClearTagCollection.Items) { if (item.Selected) { htmlClearTagArrayList.Add(item.Value); } } gatherFileRuleInfo.ContentHtmlClearTagCollection = TranslateUtils.ObjectCollectionToString(htmlClearTagArrayList); gatherFileRuleInfo.ContentTitleStart = ContentTitleStart.Text; gatherFileRuleInfo.ContentTitleEnd = ContentTitleEnd.Text; gatherFileRuleInfo.ContentContentStart = ContentContentStart.Text; gatherFileRuleInfo.ContentContentEnd = ContentContentEnd.Text; var valueArrayList = ControlUtils.GetSelectedListControlValueArrayList(ContentAttributes); gatherFileRuleInfo.ContentAttributes = TranslateUtils.ObjectCollectionToString(valueArrayList); var attributesXML = new NameValueCollection(); for (var i = 0; i < valueArrayList.Count; i++) { var attributeName = valueArrayList[i] as string; foreach (RepeaterItem item in ContentAttributesRepeater.Items) { if (item.ItemIndex == i) { var contentStart = (TextBox)item.FindControl("ContentStart"); var contentEnd = (TextBox)item.FindControl("ContentEnd"); attributesXML[attributeName + "_ContentStart"] = StringUtils.ValueToUrl(contentStart.Text); attributesXML[attributeName + "_ContentEnd"] = StringUtils.ValueToUrl(contentEnd.Text); } } } gatherFileRuleInfo.ContentAttributesXml = TranslateUtils.NameValueCollectionToString(attributesXML); DataProvider.GatherFileRuleDao.Update(gatherFileRuleInfo); } } else { isNeedAdd = true; } if (isNeedAdd) { var gatherFileRuleInfo = new GatherFileRuleInfo(); gatherFileRuleInfo.GatherRuleName = GatherRuleName.Text; gatherFileRuleInfo.PublishmentSystemId = PublishmentSystemId; if (NodeIDDropDownList.SelectedValue != null) { gatherFileRuleInfo.NodeId = int.Parse(NodeIDDropDownList.SelectedValue); } gatherFileRuleInfo.GatherUrl = GatherUrl.Text; gatherFileRuleInfo.Charset = ECharsetUtils.GetEnumType(Charset.SelectedValue); gatherFileRuleInfo.IsToFile = TranslateUtils.ToBool(IsToFile.SelectedValue); gatherFileRuleInfo.FilePath = FilePath.Text; gatherFileRuleInfo.IsSaveRelatedFiles = TranslateUtils.ToBool(IsSaveRelatedFiles.SelectedValue); gatherFileRuleInfo.IsRemoveScripts = TranslateUtils.ToBool(IsRemoveScripts.SelectedValue); gatherFileRuleInfo.StyleDirectoryPath = StyleDirectoryPath.Text; gatherFileRuleInfo.ScriptDirectoryPath = ScriptDirectoryPath.Text; gatherFileRuleInfo.ImageDirectoryPath = ImageDirectoryPath.Text; if (NodeIDDropDownList.SelectedValue != null) { gatherFileRuleInfo.NodeId = int.Parse(NodeIDDropDownList.SelectedValue); } gatherFileRuleInfo.IsSaveImage = TranslateUtils.ToBool(IsSaveImage.SelectedValue); gatherFileRuleInfo.IsChecked = TranslateUtils.ToBool(IsChecked.SelectedValue); gatherFileRuleInfo.IsAutoCreate = TranslateUtils.ToBool(IsAutoCreate.SelectedValue); gatherFileRuleInfo.ContentExclude = ContentExclude.Text; var htmlClearArrayList = new ArrayList(); foreach (ListItem item in ContentHtmlClearCollection.Items) { if (item.Selected) { htmlClearArrayList.Add(item.Value); } } gatherFileRuleInfo.ContentHtmlClearCollection = TranslateUtils.ObjectCollectionToString(htmlClearArrayList); var htmlClearTagArrayList = new ArrayList(); foreach (ListItem item in ContentHtmlClearTagCollection.Items) { if (item.Selected) { htmlClearTagArrayList.Add(item.Value); } } gatherFileRuleInfo.ContentHtmlClearTagCollection = TranslateUtils.ObjectCollectionToString(htmlClearTagArrayList); gatherFileRuleInfo.LastGatherDate = DateUtils.SqlMinValue; gatherFileRuleInfo.ContentTitleStart = ContentTitleStart.Text; gatherFileRuleInfo.ContentTitleEnd = ContentTitleEnd.Text; gatherFileRuleInfo.ContentContentStart = ContentContentStart.Text; gatherFileRuleInfo.ContentContentEnd = ContentContentEnd.Text; var valueArrayList = ControlUtils.GetSelectedListControlValueArrayList(ContentAttributes); gatherFileRuleInfo.ContentAttributes = TranslateUtils.ObjectCollectionToString(valueArrayList); var attributesXML = new NameValueCollection(); for (var i = 0; i < valueArrayList.Count; i++) { var attributeName = valueArrayList[i] as string; foreach (RepeaterItem item in ContentAttributesRepeater.Items) { if (item.ItemIndex == i) { var contentStart = (TextBox)item.FindControl("ContentStart"); var contentEnd = (TextBox)item.FindControl("ContentEnd"); attributesXML[attributeName + "_ContentStart"] = StringUtils.ValueToUrl(contentStart.Text); attributesXML[attributeName + "_ContentEnd"] = StringUtils.ValueToUrl(contentEnd.Text); } } } gatherFileRuleInfo.ContentAttributesXml = TranslateUtils.NameValueCollectionToString(attributesXML); DataProvider.GatherFileRuleDao.Insert(gatherFileRuleInfo); } if (isNeedAdd) { Body.AddSiteLog(PublishmentSystemId, "添加单文件页采集规则", $"采集规则:{GatherRuleName.Text}"); } else { Body.AddSiteLog(PublishmentSystemId, "编辑单文件页采集规则", $"采集规则:{GatherRuleName.Text}"); } errorMessage = string.Empty; return(true); } catch { errorMessage = "操作失败!"; return(false); } }