public ArrayList GetGatherDatabaseRuleInfoArrayList(int publishmentSystemId) { var list = new ArrayList(); var parms = new IDataParameter[] { GetParameter(ParmPublishmentSystemId, EDataType.Integer, publishmentSystemId) }; using (var rdr = ExecuteReader(SqlSelectAllGatherRuleByPsId, parms)) { while (rdr.Read()) { var i = 0; var gatherDatabaseRuleInfo = new GatherDatabaseRuleInfo(GetString(rdr, i++), GetInt(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetInt(rdr, i++), GetInt(rdr, i++), GetInt(rdr, i++), GetBool(rdr, i++), GetBool(rdr, i++), GetDateTime(rdr, i++), GetBool(rdr, i)); list.Add(gatherDatabaseRuleInfo); } rdr.Close(); } return(list); }
public void Update(GatherDatabaseRuleInfo gatherDatabaseRuleInfo) { var updateParms = new IDataParameter[] { GetParameter(ParmConnectionString, EDataType.VarChar, 255, gatherDatabaseRuleInfo.ConnectionString), GetParameter(ParmRelatedTableName, EDataType.VarChar, 255, gatherDatabaseRuleInfo.RelatedTableName), GetParameter(ParmRelatedIdentity, EDataType.VarChar, 255, gatherDatabaseRuleInfo.RelatedIdentity), GetParameter(ParmRelatedOrderBy, EDataType.VarChar, 255, gatherDatabaseRuleInfo.RelatedOrderBy), GetParameter(ParmWhereString, EDataType.NVarChar, 255, gatherDatabaseRuleInfo.WhereString), GetParameter(ParmTableMatchId, EDataType.Integer, gatherDatabaseRuleInfo.TableMatchId), GetParameter(ParmNodeId, EDataType.Integer, gatherDatabaseRuleInfo.NodeId), GetParameter(ParmGatherNum, EDataType.Integer, gatherDatabaseRuleInfo.GatherNum), GetParameter(ParmIsChecked, EDataType.VarChar, 18, gatherDatabaseRuleInfo.IsChecked.ToString()), GetParameter(ParmIsOrderByDesc, EDataType.VarChar, 18, gatherDatabaseRuleInfo.IsOrderByDesc.ToString()), GetParameter(ParmLastGatherDate, EDataType.DateTime, gatherDatabaseRuleInfo.LastGatherDate), GetParameter(ParmGatherRuleName, EDataType.NVarChar, 50, gatherDatabaseRuleInfo.GatherRuleName), GetParameter(ParmIsAutoCreate, EDataType.VarChar, 18, gatherDatabaseRuleInfo.IsAutoCreate.ToString()), GetParameter(ParmPublishmentSystemId, EDataType.Integer, gatherDatabaseRuleInfo.PublishmentSystemId) }; ExecuteNonQuery(SqlUpdateGatherRule, updateParms); }
public GatherDatabaseRuleInfo GetGatherDatabaseRuleInfo(string gatherRuleName, int publishmentSystemId) { GatherDatabaseRuleInfo gatherDatabaseRuleInfo = null; var parms = new IDataParameter[] { GetParameter(ParmGatherRuleName, EDataType.NVarChar, 50, gatherRuleName), GetParameter(ParmPublishmentSystemId, EDataType.Integer, publishmentSystemId) }; using (var rdr = ExecuteReader(SqlSelectGatherRule, parms)) { if (rdr.Read()) { var i = 0; gatherDatabaseRuleInfo = new GatherDatabaseRuleInfo(GetString(rdr, i++), GetInt(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetInt(rdr, i++), GetInt(rdr, i++), GetInt(rdr, i++), GetBool(rdr, i++), GetBool(rdr, i++), GetDateTime(rdr, i++), GetBool(rdr, i)); } rdr.Close(); } return(gatherDatabaseRuleInfo); }
private bool Validate_InsertGatherDatabaseRule(out string errorMessage) { try { var isNeedAdd = false; if (_isEdit) { if (_theGatherRuleName != GatherRuleName.Text) { isNeedAdd = true; DataProvider.GatherDatabaseRuleDao.Delete(_theGatherRuleName, PublishmentSystemId); } else { var gatherDatabaseRuleInfo = DataProvider.GatherDatabaseRuleDao.GetGatherDatabaseRuleInfo(_theGatherRuleName, PublishmentSystemId); gatherDatabaseRuleInfo.ConnectionString = GetDatabaseConnectionString(); gatherDatabaseRuleInfo.RelatedTableName = TableName.Text; gatherDatabaseRuleInfo.RelatedIdentity = RelatedIdentity.SelectedValue; gatherDatabaseRuleInfo.RelatedOrderBy = RelatedOrderBy.SelectedValue; gatherDatabaseRuleInfo.WhereString = WhereString.Text; if (NodeIDDropDownList.SelectedValue != null) { gatherDatabaseRuleInfo.NodeId = int.Parse(NodeIDDropDownList.SelectedValue); } gatherDatabaseRuleInfo.GatherNum = int.Parse(GatherNum.Text); gatherDatabaseRuleInfo.IsChecked = TranslateUtils.ToBool(IsChecked.SelectedValue); gatherDatabaseRuleInfo.IsAutoCreate = TranslateUtils.ToBool(IsAutoCreate.SelectedValue); gatherDatabaseRuleInfo.IsOrderByDesc = TranslateUtils.ToBool(IsOrderByDesc.SelectedValue); gatherDatabaseRuleInfo.LastGatherDate = DateUtils.SqlMinValue; var tableMatchInfo = BaiRongDataProvider.TableMatchDao.GetTableMatchInfo(gatherDatabaseRuleInfo.TableMatchId); if (tableMatchInfo == null) { tableMatchInfo = new TableMatchInfo(0, gatherDatabaseRuleInfo.ConnectionString, TableName.Text, WebConfigUtils.ConnectionString, TableNameToMatch.Text, GetColumnsMap()); gatherDatabaseRuleInfo.TableMatchId = BaiRongDataProvider.TableMatchDao.Insert(tableMatchInfo); } else { tableMatchInfo.ConnectionString = gatherDatabaseRuleInfo.ConnectionString; tableMatchInfo.TableName = TableName.Text; tableMatchInfo.ConnectionStringToMatch = WebConfigUtils.ConnectionString; tableMatchInfo.TableNameToMatch = TableNameToMatch.Text; tableMatchInfo.ColumnsMap = GetColumnsMap(); BaiRongDataProvider.TableMatchDao.Update(tableMatchInfo); } DataProvider.GatherDatabaseRuleDao.Update(gatherDatabaseRuleInfo); } } else { isNeedAdd = true; } if (isNeedAdd) { var gatherDatabaseRuleInfo = new GatherDatabaseRuleInfo(); gatherDatabaseRuleInfo.GatherRuleName = GatherRuleName.Text; gatherDatabaseRuleInfo.PublishmentSystemId = PublishmentSystemId; gatherDatabaseRuleInfo.ConnectionString = GetDatabaseConnectionString(); gatherDatabaseRuleInfo.RelatedTableName = TableName.Text; gatherDatabaseRuleInfo.RelatedIdentity = RelatedIdentity.SelectedValue; gatherDatabaseRuleInfo.RelatedOrderBy = RelatedOrderBy.SelectedValue; gatherDatabaseRuleInfo.WhereString = WhereString.Text; if (NodeIDDropDownList.SelectedValue != null) { gatherDatabaseRuleInfo.NodeId = int.Parse(NodeIDDropDownList.SelectedValue); } gatherDatabaseRuleInfo.GatherNum = int.Parse(GatherNum.Text); gatherDatabaseRuleInfo.IsChecked = TranslateUtils.ToBool(IsChecked.SelectedValue); gatherDatabaseRuleInfo.IsAutoCreate = TranslateUtils.ToBool(IsAutoCreate.SelectedValue); gatherDatabaseRuleInfo.IsOrderByDesc = TranslateUtils.ToBool(IsOrderByDesc.SelectedValue); gatherDatabaseRuleInfo.LastGatherDate = DateUtils.SqlMinValue; var tableMatchInfo = new TableMatchInfo(0, gatherDatabaseRuleInfo.ConnectionString, TableName.Text, WebConfigUtils.ConnectionString, TableNameToMatch.Text, GetColumnsMap()); gatherDatabaseRuleInfo.TableMatchId = BaiRongDataProvider.TableMatchDao.Insert(tableMatchInfo); DataProvider.GatherDatabaseRuleDao.Insert(gatherDatabaseRuleInfo); } if (isNeedAdd) { Body.AddSiteLog(PublishmentSystemId, "添加数据库采集规则", $"采集规则:{GatherRuleName.Text}"); } else { Body.AddSiteLog(PublishmentSystemId, "编辑数据库采集规则", $"采集规则:{GatherRuleName.Text}"); } errorMessage = string.Empty; return(true); } catch { errorMessage = "操作失败!"; return(false); } }