private void SendPretreatingEvent(ICheckRule pretreatingRule) { if (this.PretreatingRuleChanged != null) { this.PretreatingRuleChanged.Invoke(this, pretreatingRule); } }
private void SendVerifyingEvent(ICheckRule verifyingRule) { if (this.VerifyingRuleChanged != null) { this.VerifyingRuleChanged.Invoke(this, verifyingRule); } }
private void SendRuleCheckedEvent(ICheckRule checkedRule, int errCount) { if (this.RuleChecked != null) { this.RuleChecked.Invoke(this, checkedRule, errCount); } }
/// <summary> /// 執行SQL 作業Does the run SQL. /// </summary> /// <remarks> /// 執行以下項目 /// 1. 執行SQL /// a.若傳回值為0 表示無問題--> 結束 /// b.若傳回值大於0 表示有問題 --> 產生報表 --> 發MAIL 通知 /// </remarks> private bool DoRunSQL(ICheckRule aRule, ref int RecordCount) { try { aRule.CKSQL = ParaTrans.Format(aRule.CKSQL); switch (RuleType) { case SQLRuleType.Check: SqlParameter[] px = { }; RecordCount = SqlHelper.ExecuteScalar <int>(aRule.DB_Mod.DBConnString, aRule.CKSQL, px); break; case SQLRuleType.Maintain: RecordCount = SqlHelper.ExecuteNonQuery(aRule.DB_Mod.DBConnString, aRule.CKSQL); break; default: RecordCount = -1; break; } return(true); } catch (Exception ex) { RecordCount = -1; return(false); throw ex; } }
protected virtual void RuleChecked(Checker sender, ICheckRule checkedRule, int errorCount) { m_ErrorCount += errorCount; this.m_ExcutedRuleCount++; if (this.InvokeRequired) { ThreadStart errCountChanged = delegate { lblErrorCount.Text = m_ErrorCount.ToString(); this.lblExcutedRuleCount.Text = this.m_ExcutedRuleCount.ToString(); progressBarControl1.Position = m_ExcutedRuleCount; progressBarControl1.Update(); }; this.Invoke(errCountChanged); } else { lblErrorCount.Text = m_ErrorCount.ToString(); this.lblExcutedRuleCount.Text = this.m_ExcutedRuleCount.ToString(); progressBarControl1.Position = m_ExcutedRuleCount; progressBarControl1.Update(); Application.DoEvents(); } }
private void SendCheckingEvent(ICheckRule checkingRule) { if (this.CheckingRuleChanged != null) { this.CheckingRuleChanged.Invoke(this, checkingRule); } }
private static ICheckRule CreateInstance(string strPath, string className) { if (!System.IO.File.Exists(strPath)) { return(null); } Assembly assembly = null; if (m_DictAssembly.ContainsKey(strPath)) { assembly = m_DictAssembly[strPath]; } else { assembly = Assembly.LoadFile(strPath); m_DictAssembly.Add(strPath, assembly); } try { object objRule = assembly.CreateInstance(className); //Activator.CreateInstance(Type.GetType(className)); ICheckRule checkRule = objRule as ICheckRule; return(checkRule); } catch { return(null); } }
void CheckingRuleChanged(Checker sender, ICheckRule dealingRule) { if (dealingRule == null) { return; } SendCheckingMessage(string.Format("正在检查“{0}”规则…", dealingRule.Name)); }
/// <summary> /// 檢查執行後結果 會依照模式不同而有不同的處理方式 /// </summary> /// <param name="ResultCount">檢查後筆數</param> /// <param name="aRule">a rule.</param> /// <remarks>主要給後續在實作內容</remarks> protected override void OnCheckResult(int ResultCount, ICheckRule aRule) { if (ResultCount != 0) //當筆數大於0時表示檢查結果需要輸出報表 { aRule.LSSQL = ParaTrans.Format(aRule.LSSQL); SqlParameter[] px = { }; DataTable dt4 = SqlHelper.ExecuteDataTable(aRule.DB_Mod.DBConnString, aRule.LSSQL, px); DoSendMail(aRule, GenerateHTMLReport.GenerateBody(dt4, aRule).ToString()); } ; }
/// <summary> /// Does the send mail. /// </summary> /// <param name="aRule">a rule.</param> /// <param name="aBody">a body.</param> /// <returns><c>true</c> 表示成功, <c>false</c> 反然之</returns> protected bool DoSendMail(ICheckRule aRule, string aBody) { // 從資料庫找出所有 SRNO中要通知的人員 using (var conn = new SqlConnection(this._connectionstring)) { List <SS_MUR> Murs = ((List <SS_MUR>)conn.Query <SS_MUR>(SS_MUR_SS_MUSR, new { SRNO = aRule.SRNO, ACT = 'Y' })); ThreadStart starter = () => mailProc(aRule, Murs, aBody); Thread Td = new Thread(starter); Td.Start(); } return(true); }
/// <summary> /// 呼叫發送信件 /// </summary> /// <param name="aRule">a rule.</param> /// <param name="Murs">The murs.</param> /// <param name="aBody">a body.</param> // protected void mailProc( string aSRNO, string AMUSR, string ANAME, string AEMAIL, string aTitle,string aBody) protected void mailProc(ICheckRule aRule, List <SS_MUR> Murs, string aBody) { MC mc1 = new MC(MailConfig) { SRNO = aRule.SRNO, NTYPE = "MA", MTYPE = MTYPE, ToUsers = Murs, SRNOTITL = aRule.TITL, MailBody = aBody }; mc1.Execute(); }
protected virtual void VerifyingRuleChanged(Checker sender, ICheckRule dealingRule) { if (dealingRule == null) { return; } if (this.InvokeRequired) { this.Invoke(new SetTextHandler(SetOperateText), new object[] { "正在验证“" + dealingRule.InstanceName + "”规则…" }); } else { SetOperateText("正在验证“" + dealingRule.InstanceName + "”规则…"); Application.DoEvents(); } }
protected virtual void PretreatingRuleChanged(Checker sender, ICheckRule dealingRule) { if (dealingRule == null) { return; } if (this.InvokeRequired) { this.Invoke(new SetTextHandler(SetOperateText), new object[] { "正在执行预处理…" }); } else { SetOperateText("正在执行预处理…"); Application.DoEvents(); } }
private void Init() { this.m_ErrorCount = 0; this.m_SucceedCount = 0; // 验证 if (this.m_BaseWorkspace == null) { SendMessage(enumMessageType.Exception, "检查驱动的Base库没有设置,无法继续检查"); return; } if (this.m_QueryWorkspace == null || this.m_QueryConnection == null) { SendMessage(enumMessageType.Exception, "检查驱动的Query库没有设置,无法继续检查"); return; } // 结果库 try { string strResultDBFile = this.m_ResultPath + "\\" + COMMONCONST.DB_Name_Result; System.IO.File.Copy(System.Windows.Forms.Application.StartupPath + "\\template\\report\\result_AutoTmpl.mdb", strResultDBFile, true); this.m_ResultConnection = Hy.Common.Utility.Data.AdoDbHelper.GetDbConnection(strResultDBFile); } catch (Exception exp) { SendMessage(enumMessageType.Exception, string.Format("创建结果库出错,信息:{0}", exp.Message)); return; } // 创建规则实例,赋值,分类 if (RuleInfos == null || RuleInfos.Count == 0) { return; } int count = RuleInfos.Count; m_NormalRuleList = new List <ICheckRule>(); m_TopoRuleList = new List <ICheckRule>(); m_DictRuleAndInfo = new Dictionary <ICheckRule, SchemaRule>(); for (int i = 0; i < count; i++) { if (this.RuleInfos[i] == null || this.RuleInfos[i].ruleDllInfo == null) { continue; } RuleInfo ruleInfo = new RuleInfo();// this.RuleInfos[i].ruleDllInfo; ruleInfo.ID = this.RuleInfos[i].arrayRuleParas[0].strInstID; ruleInfo.Name = this.RuleInfos[i].arrayRuleParas[0].strName; ruleInfo.Paramters = this.RuleInfos[i].arrayRuleParas[0].pParas; ruleInfo.RuleClassInfo = this.RuleInfos[i].ruleDllInfo; ruleInfo.Description = this.RuleInfos[i].strRemark; //if (ruleClassInfo == null) // continue; if (ruleInfo.RuleClassInfo == null) { SendMessage(enumMessageType.OperationalLog, string.Format("规则“{0}”无类信息,跳过检查", ruleInfo.Name)); continue; } ICheckRule checkRule = RuleFactory.CreateRuleInstance(ruleInfo.RuleClassInfo.DllName, ruleInfo.RuleClassInfo.ClassName); if (checkRule == null) { SendMessage(enumMessageType.OperationalLog, string.Format("规则“{0}”反射未成功,跳过检查", ruleInfo.Name)); continue; } try { // 参数设置 checkRule.BaseWorkspace = this.m_BaseWorkspace; checkRule.InstanceName = ruleInfo.Name; checkRule.InstanceID = ruleInfo.ID; checkRule.DefectLevel = DefectHelper.GetRuleDefectLevel(ruleInfo.ID); checkRule.MessageHandler = this.m_Messager; checkRule.QueryConnection = this.m_QueryConnection; checkRule.QueryWorkspace = this.m_QueryWorkspace; checkRule.TopoWorkspace = this.m_TopoWorkspace; checkRule.ResultConnection = this.m_ResultConnection; checkRule.SchemaID = this.m_SchemaID; checkRule.SetParamters(ruleInfo.Paramters); if (checkRule.ErrorType == enumErrorType.Topology) { if (m_Topology == null) { try { // 先创建Topo库(空库)和结果库 if (System.IO.Directory.Exists(this.m_TopoDBPath + "\\" + COMMONCONST.DB_Name_Topo)) { System.IO.Directory.Delete(this.m_TopoDBPath + "\\" + COMMONCONST.DB_Name_Topo, true); } Hy.Common.Utility.Esri.AEAccessFactory.CreateFGDB(this.m_TopoDBPath, COMMONCONST.DB_Name_Topo, ref this.m_TopoWorkspace); if (this.m_TopoWorkspace == null) { SendMessage(enumMessageType.Exception, "创建拓扑库失败"); } // 根据Base库找第一个Geodataset的空间参考,用来创建拓扑库 ISpatialReference topoSptatialRef = null; IEnumDataset enDataset = this.m_BaseWorkspace.get_Datasets(esriDatasetType.esriDTAny); IDataset ds = enDataset.Next(); while (ds != null) { if (ds is IGeoDataset) { topoSptatialRef = (ds as IGeoDataset).SpatialReference; break; } ds = enDataset.Next(); } IFeatureDataset fDataset = (this.m_TopoWorkspace as IFeatureWorkspace).CreateFeatureDataset(COMMONCONST.Dataset_Name, topoSptatialRef); if (fDataset == null) { SendMessage(enumMessageType.Exception, "创建拓扑库Dataset失败"); } ITopologyContainer topoContainer = fDataset as ITopologyContainer; //m_Topology = topoContainer.get_TopologyByName(COMMONCONST.Topology_Name); // 若已有Topology,则不再创建 //if (m_Topology == null) m_Topology = topoContainer.CreateTopology(COMMONCONST.Topology_Name, this.m_TopoTolerance, COMMONCONST.TopoError_MaxCount, "esriConfigurationKeywordTopology"); } catch (Exception exp) { SendMessage(enumMessageType.Exception, "创建Topology出错,信息:" + exp.ToString()); } } (checkRule as ITopologicalRule).Topology = m_Topology; m_TopoRuleList.Add(checkRule); } else { m_NormalRuleList.Add(checkRule); } //m_RuleList.Add(checkRule); m_DictRuleAndInfo.Add(checkRule, this.RuleInfos[i]); } catch (Exception ex) { SendMessage(enumMessageType.Exception, "初始化规则失败,信息:" + ex.ToString()); continue; } } }
void RuleChecked(Checker sender, ICheckRule checkedRule, int errorCount) { //SendCheckingMessage(string.Format("规则“{0}”: }
/// <summary> /// 檢查執行後結果 會依照模式不同而有不同的處理方式 /// </summary> /// <param name="ResultCount">The result count.</param> /// <param name="aRule">a rule.</param> /// <remarks>主要給後續在實作內容</remarks> protected virtual void OnCheckResult(int ResultCount, ICheckRule aRule) { }
void VerifyingRuleChanged(Checker sender, ICheckRule dealingRule) { if (dealingRule == null) return; SendCheckingMessage(string.Format("正在验证“{0}”规则…", dealingRule.Name)); }
protected virtual void VerifyingRuleChanged(Checker sender, ICheckRule dealingRule) { if (dealingRule == null) return; if (this.InvokeRequired) { this.Invoke(new SetTextHandler(SetOperateText), new object[] { "������֤��" + dealingRule.InstanceName + "������" }); } else { SetOperateText("������֤��" + dealingRule.InstanceName + "������"); Application.DoEvents(); } }
private void SendVerifyingEvent(ICheckRule verifyingRule) { if (this.VerifyingRuleChanged != null) this.VerifyingRuleChanged.Invoke(this,verifyingRule); }
/// <summary> /// 產生Html報表 /// </summary> /// <param name="aDT">呈現資料內容</param> /// <param name="aRule">檢查規則</param> /// <returns>傳回產生後的字串(StringBuilder)</returns> public static StringBuilder GenerateBody(DataTable aDT, ICheckRule aRule) { DataTable dt = aDT; StringBuilder strB = new StringBuilder(); //create html & table strB.AppendLine("<html><head>"); strB.AppendLine("<style type=\"text/css\">"); strB.AppendLine("@charset \"utf-8\";"); strB.AppendLine("body {background-color: #CCFFFF;}"); strB.AppendLine("body, td, th {color: #333333;}"); strB.AppendLine("h1, h2 {color: #000033;}"); strB.AppendLine("h3, h4, h5, h6 {color: #006699;}"); strB.AppendLine("a {color: #003366;}"); strB.AppendLine(".csharpcode, .csharpcode pre"); strB.AppendLine("{ font-size: small;"); strB.AppendLine(" color: black;"); strB.AppendLine(" font-family: Consolas, \"Courier New\", Courier, Monospace;"); strB.AppendLine(" background-color: #ffffff;}"); strB.AppendLine(".csharpcode pre { margin: 0em; }"); strB.AppendLine(".csharpcode .rem { color: #008000; }"); strB.AppendLine(".csharpcode .kwrd { color: #0000ff; }"); strB.AppendLine(".csharpcode .str { color: #006080; }"); strB.AppendLine(".csharpcode .op { color: #0000c0; }"); strB.AppendLine(".csharpcode .preproc { color: #cc6633; }"); strB.AppendLine(".csharpcode .asp { background-color: #ffff00; }"); strB.AppendLine(".csharpcode .html { color: #800000; }"); strB.AppendLine(".csharpcode .attr { color: #ff0000; }"); strB.AppendLine(".csharpcode .alt "); strB.AppendLine("{ background-color: #f4f4f4;"); strB.AppendLine(" width: 100%;"); strB.AppendLine(" margin: 0em;}"); strB.AppendLine(".csharpcode .lnum { color: #606060; }"); strB.AppendLine("</style>"); strB.AppendLine("<body><head>"); strB.AppendFormat("<h1><strong>{0} 查核報告表</strong></h1>", DateTime.Now.ToString("yyyy/MM/dd")); strB.AppendLine("<h2>問題:</h2><p>"); strB.AppendFormat("<strong>{0}</strong>", aRule.TITL); strB.AppendLine("<P>"); strB.AppendLine("<h2>問題說明:</h2><p>"); strB.AppendLine(TextToHtml(aRule.REMARK)); strB.AppendLine("<P>"); strB.AppendFormat("資料庫:{0}", aRule.DBID); strB.AppendLine("<h2>錯誤資料列表:</h2>"); strB.AppendLine("<center>"); strB.Append("<table border='2px' cellpadding='5' cellspacing='0' "); strB.Append("style='border: solid 1px Silver; font-size: x-small;'>"); strB.AppendLine("<tr align='left' valign='top'>"); //cteate table header foreach (DataColumn dc in dt.Columns) { strB.AppendFormat("<td valign='middle'><strong>{0}</strong></td>", dc.ColumnName); } strB.AppendLine("</tr>"); //create table body foreach (DataRow dr in dt.Rows) { strB.AppendLine("<tr align='left' valign='top'>"); foreach (DataColumn dc in dt.Columns) { string cellValue = dr[dc] != null ? dr[dc].ToString() : ""; strB.AppendFormat("<td align='center' valign='middle'>{0}</td>", cellValue); } strB.AppendLine("</tr>"); } strB.AppendLine("</table></center>"); //table footer strB.AppendLine("<P>"); strB.AppendLine("<h2>查詢SQL :</h2>"); strB.AppendLine("<P>"); TsqlFormat sf = new TsqlFormat(); strB.AppendLine(sf.FormatCode(aRule.LSSQL)); // end of html file strB.AppendLine("</body></html>"); // end line return(strB); }
private void SendRuleCheckedEvent(ICheckRule checkedRule, int errCount) { if (this.RuleChecked != null) this.RuleChecked.Invoke(this,checkedRule, errCount); }
private void SendPretreatingEvent(ICheckRule pretreatingRule) { if (this.PretreatingRuleChanged != null) this.PretreatingRuleChanged.Invoke(this,pretreatingRule); }
private void SendCheckingEvent(ICheckRule checkingRule) { if (this.CheckingRuleChanged != null) this.CheckingRuleChanged.Invoke(this,checkingRule); }
public void AddRule(ICheckRule <T> rule) { rules.Add(rule); }