public int GetResultsCount() { int count = 0; DbDataReader reader = null; try { string strSql = string.Format("select sum(errorcount) as cout from {0}", COMMONCONST.RESULT_TB_RESULT_ENTRY_RULE); reader = AdoDbHelper.GetQueryReader(m_ResultDbConn, strSql) as DbDataReader; if (reader.HasRows) { reader.Read(); count = int.Parse(reader[0].ToString()); } return(count); } catch { return(count); } finally { reader.Close(); reader.Dispose(); } }
/// <summary> /// 获取任务的编号 /// </summary> /// <param name="strModelTaskNumber"></param> /// <returns></returns> public static bool GetTaskID(out string strModelTaskNumber)//, IDbConnection pConnection) { IDbConnection pConnection = GetSysDbConnection(); IDataReader reader = null; strModelTaskNumber = string.Empty; try { string strdate = DateTime.Today.Year.ToString(); //给任务添加编号 strdate = "T" + strdate; string strSql = string.Format("SELECT max(TaskID) FROM LR_ModelTask where Left(TaskID,5) = '{0}'", strdate); reader = AdoDbHelper.GetQueryReader(pConnection, strSql); //如果为空,表示获取不成功,返回结果 if (reader == null) { return(false); } if (!(reader as System.Data.OleDb.OleDbDataReader).HasRows) { strModelTaskNumber = strdate + "001"; return(true); } while (reader.Read()) { string strNum = reader[0].ToString(); if (string.IsNullOrEmpty(strNum)) { strModelTaskNumber = strdate + "001"; } else { int nID = Convert.ToInt32(strNum.Substring(1)) + 1; strModelTaskNumber = strNum.Substring(0, 1) + nID.ToString(); } return(true); } } catch (Exception exp) //捕捉异常 { Hy.Common.Utility.Log.OperationalLogManager.AppendMessage(exp.ToString()); return(false); } finally { if (reader != null) { reader.Close(); reader.Dispose(); } } return(true); }
/// <summary> /// 获取系统库中的方案信息. /// </summary> /// <returns>Dictionary<SchemaID,SchemaName></returns> public static Dictionary <string, string> GetSchemasInfo(string standardName) { IDataReader reader = null; Dictionary <string, string> schemaInfo = new Dictionary <string, string>(); try { if (string.IsNullOrEmpty(standardName)) { return(null); } string strSql = string.Format("SELECT SchemaID,SchemaName FROM LR_ModelSchema where standardName='{0}'", standardName); reader = AdoDbHelper.GetQueryReader(GetSysDbConnection(), strSql); //如果为空,表示获取不成功,返回结果 if (reader == null) { return(null); } while (reader.Read()) { schemaInfo.Add(reader[0].ToString(), reader[1].ToString()); } return(schemaInfo); } catch (Exception exp) //捕捉异常 { Hy.Common.Utility.Log.OperationalLogManager.AppendMessage(exp.ToString()); return(null); } finally { if (reader != null) { reader.Close(); reader.Dispose(); } } }
/// <summary> /// 获取系统库中的标准信息. /// </summary> /// <returns>Dictionary<standardId,standardName></returns> public static Dictionary <int, string> GetStandardInfo() { IDataReader reader = null; Dictionary <int, string> standardInfo = new Dictionary <int, string>(); try { string strSql = "SELECT StandardID,StandardName FROM LR_DicStandard order by StandardID"; reader = AdoDbHelper.GetQueryReader(GetSysDbConnection(), strSql); //如果为空,表示获取不成功,返回结果 if (reader == null) { return(null); } while (reader.Read()) { standardInfo.Add(Convert.ToInt32(reader[0]), reader[1].ToString()); } return(standardInfo); } catch (Exception exp) //捕捉异常 { Hy.Common.Utility.Log.OperationalLogManager.AppendMessage(exp.ToString()); return(null); } finally { if (reader != null) { reader.Close(); reader.Dispose(); } } }
public override bool Check(ref List <Error> checkResult) { //System.Diagnostics.Stopwatch MyWatch = new System.Diagnostics.Stopwatch(); //MyWatch.Start(); System.Data.OleDb.OleDbDataReader reader = null; try { DataTable pRecordset = new DataTable(); if (m_structPara.strScript == "行政区层中行政区代码与行政区名称不匹配") { string strTemp = "select objectid,BSM,xzqdm, xzqmc,qsdwmc from(select a2.objectid,a2.BSM,a2.xzqdm,a2.xzqmc, a1.qsdwdm,a1.qsdwmc from qsdmb a1 inner join xzq a2 on left(a1.qsdwdm,12)=left(a2.xzqdm,12) where mid(qsdwdm,12,1)<>'0' and right(qsdwdm,7)='0000000') where Trim(a2.xzqmc)<>Trim(a1.qsdwmc)"; pRecordset = AdoDbHelper.GetDataTable(base.m_QueryConnection, strTemp); if (pRecordset == null || pRecordset.Rows.Count == 0) { string strLog = "当前规则的SQL查询语句设置有误,无法执行多表关系检查!"; SendMessage(enumMessageType.RuleError, strLog); return(false); } } else if (m_structPara.strScript.Contains("权属代码表不一致") || m_structPara.strScript.Contains("权属单位代码表不一致")) { reader = AdoDbHelper.GetQueryReader(base.m_QueryConnection, m_structPara.strClause) as OleDbDataReader; if (reader == null) { string strLog = "当前规则的SQL查询语句设置有误,无法执行多表关系检查!"; SendMessage(enumMessageType.RuleError, strLog); return(false); } pRecordset.Load(reader); } else { pRecordset = AdoDbHelper.GetDataTable(base.m_QueryConnection, m_structPara.strClause); if (pRecordset == null || pRecordset.Rows.Count == 0) { string strLog = "当前规则的SQL查询语句设置有误,无法执行多表关系检查!"; SendMessage(enumMessageType.RuleError, strLog); return(false); } } string strSql = ""; bool bTable = false; if (FtName1.Contains("表") || FtName2.Contains("表")) { if (m_structPara.strFtName2.Equals("qsdmb", StringComparison.OrdinalIgnoreCase)) { strSql = "update LR_ResultEntryRule set TargetFeatClass1= '" + FtName1 + "',TargetFeatClass2='" + FtName2 + "|' where RuleInstID='" + base.m_InstanceID + "'"; } else { strSql = "update LR_ResultEntryRule set TargetFeatClass1= '" + COMMONCONST.TABLENAME + "',TargetFeatClass2='|' where RuleInstID='" + base.m_InstanceID + "'"; bTable = true; } } else { strSql = "update LR_ResultEntryRule set TargetFeatClass1= '" + FtName1 + "',TargetFeatClass2='" + FtName2 + "|' where RuleInstID='" + base.m_InstanceID + "'"; } AdoDbHelper.ExecuteSql(m_ResultConnection, strSql); //获取需要特殊处理的规则别名 Hashtable hashtable = GetEnumHash(); if (hashtable.Contains(m_structPara.strAlias)) { if (m_structPara.strAlias.Equals("省级上报田坎系数与上报数据中田坎系数是否一致检查")) { checkResult = GetTKXSResult(pRecordset); } else { checkResult = GetAttrResult(pRecordset); } } else { checkResult = GetResult(pRecordset, bTable); } if (pRecordset != null) { pRecordset.Dispose(); return(true); } } catch (Exception ex) { SendMessage(enumMessageType.RuleError, string.Format("意外失败,信息:{0}", ex.Message)); SendMessage(enumMessageType.Exception, ex.ToString()); return(false); } finally { if (reader != null) { reader.Dispose(); reader.Close(); GC.Collect(); } } //MyWatch.Stop(); //System.Windows.Forms.MessageBox.Show("时间:" + MyWatch.ElapsedMilliseconds.ToString() + "毫秒"); return(true); }