private bool GetPropertyValue(BugCheckEntry qcEntry, ref object value) { if (qcEntry == null || GlobalMethods.Misc.IsEmptyString(qcEntry.EntryName)) { return(false); } string[] arrEntryName = qcEntry.EntryName.Split('.'); if (arrEntryName == null) { return(false); } object desObject = this.QCEngine; for (int index = 0; index < arrEntryName.Length; index++) { string szPropertyName = arrEntryName[index]; if (desObject == null || GlobalMethods.Misc.IsEmptyString(szPropertyName)) { continue; } PropertyInfo propertyInfo = this.GetPropertyInfo(desObject.GetType(), szPropertyName); if (propertyInfo == null) { continue; } desObject = this.GetPropertyValue(desObject, propertyInfo); } value = desObject; return(true); }
private bool CompareBoolEntry(BugCheckEntry qcEntry) { bool bNormalValue = false; if (!bool.TryParse(qcEntry.EntryValue, out bNormalValue)) { return(false); } bool bRealValue = false; if (!this.GetPropertyValue(qcEntry, ref bRealValue)) { return(false); } if (qcEntry.Operator == SystemData.Operator.EQUAL) { return(bRealValue == bNormalValue); } else if (qcEntry.Operator == SystemData.Operator.NOEQUAL) { return(bRealValue != bNormalValue); } return(false); }
private bool GetPropertyValue(BugCheckEntry qcEntry, ref DateTime value) { object obj = null; if (!this.GetPropertyValue(qcEntry, ref obj) || obj == null) { return(false); } return(DateTime.TryParse(obj.ToString(), out value)); }
public override void ComputeEntryOccurCount() { base.ComputeEntryOccurCount(); //恢复各Entry项为默认值 this.ResumeEntry(); if (this.QCEngine == null || this.QCEngine.DocText == null) { return; } //遍历文档,检索并设置Entry发生次数 int nDocTotalLength = this.QCEngine.DocText.Length; for (int nCharIndex = 0; nCharIndex < nDocTotalLength; nCharIndex++) { int nSkipLength = 0; for (int nWordLen = this.m_nEntryMinLen; nWordLen <= this.m_nEntryMaxLen; nWordLen++) { if (nCharIndex > nDocTotalLength - nWordLen) { break; } string szWord = this.QCEngine.DocText.Substring(nCharIndex, nWordLen); object obj = this.m_htDocumentEntry[szWord]; if (obj == null) { continue; } nSkipLength = szWord.Length - 1; List <BugCheckEntry> lstEntrys = obj as List <BugCheckEntry>; if (lstEntrys == null) { continue; } for (int index = 0; index < lstEntrys.Count; index++) { BugCheckEntry qcEntry = lstEntrys[index]; if (qcEntry.Operator == SystemData.Operator.NOCONTAINS) { qcEntry.OccurCount = 0; } else if (qcEntry.Operator == SystemData.Operator.CONTAINS) { qcEntry.OccurCount++; } } } nCharIndex += nSkipLength; } }
private bool GetPropertyValue(BugCheckEntry qcEntry, ref string value) { object obj = null; if (!this.GetPropertyValue(qcEntry, ref obj) || obj == null) { return(false); } value = obj.ToString(); return(true); }
private bool CompareStringEntry(BugCheckEntry qcEntry) { string szNormalValue = qcEntry.EntryValue; if (GlobalMethods.Misc.IsEmptyString(szNormalValue)) { return(false); } string szRealValue = string.Empty; if (!this.GetPropertyValue(qcEntry, ref szRealValue)) { return(false); } if (qcEntry.Operator == SystemData.Operator.EQUAL) { return(string.Compare(szRealValue, szNormalValue) == 0); } else if (qcEntry.Operator == SystemData.Operator.MORE) { return(string.Compare(szRealValue, szNormalValue) > 0); } else if (qcEntry.Operator == SystemData.Operator.LESS) { return(string.Compare(szRealValue, szNormalValue) < 0); } else if (qcEntry.Operator == SystemData.Operator.NOLESS) { return(string.Compare(szRealValue, szNormalValue) >= 0); } else if (qcEntry.Operator == SystemData.Operator.NOMORE) { return(string.Compare(szRealValue, szNormalValue) <= 0); } else if (qcEntry.Operator == SystemData.Operator.NOEQUAL) { return(string.Compare(szRealValue, szNormalValue) != 0); } else if (qcEntry.Operator == SystemData.Operator.CONTAINS) { return(szRealValue.IndexOf(szNormalValue) >= 0); } else if (qcEntry.Operator == SystemData.Operator.NOCONTAINS) { return(szRealValue.IndexOf(szNormalValue) < 0); } return(false); }
public static void AddEntry(BugCheckEngine qcEngine, MedQCEntry medQCEntry) { if (qcEngine == null || medQCEntry == null) { return; } BugCheckEntry qcEntry = new BugCheckEntry(); qcEntry.EntryID = medQCEntry.EntryID; qcEntry.EntryName = medQCEntry.EntryName; qcEntry.EntryType = medQCEntry.EntryType; qcEntry.EntryDesc = medQCEntry.EntryDesc; qcEntry.Operator = medQCEntry.Operator; qcEntry.EntryValue = medQCEntry.EntryValue; qcEntry.ValueType = medQCEntry.ValueType; qcEntry.OccurCount = 0; string szEntryType = qcEntry.EntryType.ToUpper(); if (szEntryType == SystemData.QCRule.ENTRY_TYPE_DOCUMENT) { if (m_htEntryHandlerTable == null) { m_htEntryHandlerTable = new Hashtable(); } DocumentEntryHanlder documentEntryHandler = m_htEntryHandlerTable[szEntryType] as DocumentEntryHanlder; if (documentEntryHandler == null) { documentEntryHandler = new DocumentEntryHanlder(qcEngine); m_htEntryHandlerTable.Add(szEntryType, documentEntryHandler); } documentEntryHandler.AddEntry(qcEntry); } else if (szEntryType == SystemData.QCRule.ENTRY_TYPE_REFLECTION) { if (m_htEntryHandlerTable == null) { m_htEntryHandlerTable = new Hashtable(); } ReflectionEntryHandler reflectionEntryHandler = m_htEntryHandlerTable[szEntryType] as ReflectionEntryHandler; if (reflectionEntryHandler == null) { reflectionEntryHandler = new ReflectionEntryHandler(qcEngine); m_htEntryHandlerTable.Add(szEntryType, reflectionEntryHandler); } reflectionEntryHandler.AddEntry(qcEntry); } }
public virtual void AddEntry(BugCheckEntry qcEntry) { if (qcEntry == null) { return; } if (this.m_htEntryTable == null) { this.m_htEntryTable = new Hashtable(); } if (this.m_htEntryTable.Contains(qcEntry.EntryID)) { return; } this.m_htEntryTable.Add(qcEntry.EntryID, qcEntry); }
private bool CompareIntEntry(BugCheckEntry qcEntry) { int nNormalValue = 0; if (!int.TryParse(qcEntry.EntryValue, out nNormalValue)) { return(false); } int nRealValue = 0; if (!this.GetPropertyValue(qcEntry, ref nRealValue)) { return(false); } if (qcEntry.Operator == SystemData.Operator.EQUAL) { return(nRealValue == nNormalValue); } else if (qcEntry.Operator == SystemData.Operator.MORE) { return(nRealValue > nNormalValue); } else if (qcEntry.Operator == SystemData.Operator.LESS) { return(nRealValue < nNormalValue); } else if (qcEntry.Operator == SystemData.Operator.NOLESS) { return(nRealValue >= nNormalValue); } else if (qcEntry.Operator == SystemData.Operator.NOMORE) { return(nRealValue <= nNormalValue); } else if (qcEntry.Operator == SystemData.Operator.NOEQUAL) { return(nRealValue != nNormalValue); } return(false); }
private bool CompareDatetimeEntry(BugCheckEntry qcEntry) { DateTime dtNormalValue = DateTime.Now; if (!DateTime.TryParse(qcEntry.EntryValue, out dtNormalValue)) { return(false); } DateTime dtRealValue = DateTime.Now; if (!this.GetPropertyValue(qcEntry, ref dtRealValue)) { return(false); } if (qcEntry.Operator == SystemData.Operator.EQUAL) { return(DateTime.Compare(dtRealValue, dtNormalValue) == 0); } else if (qcEntry.Operator == SystemData.Operator.MORE) { return(DateTime.Compare(dtRealValue, dtNormalValue) > 0); } else if (qcEntry.Operator == SystemData.Operator.LESS) { return(DateTime.Compare(dtRealValue, dtNormalValue) < 0); } else if (qcEntry.Operator == SystemData.Operator.NOLESS) { return(DateTime.Compare(dtRealValue, dtNormalValue) >= 0); } else if (qcEntry.Operator == SystemData.Operator.NOMORE) { return(DateTime.Compare(dtRealValue, dtNormalValue) <= 0); } else if (qcEntry.Operator == SystemData.Operator.NOEQUAL) { return(DateTime.Compare(dtRealValue, dtNormalValue) != 0); } return(false); }
public override void AddEntry(BugCheckEntry qcEntry) { base.AddEntry(qcEntry); if (qcEntry == null || qcEntry.EntryValue == null) { return; } if (qcEntry.EntryValue.Trim() == string.Empty) { return; } List <BugCheckEntry> lstEntrys = null; //把关键字添加到Hashtable中,以便在遍历文档时可由关键字快速获取Entry string szEntryValue = qcEntry.EntryValue.Trim(); object obj = this.m_htDocumentEntry[szEntryValue]; if (obj != null) { lstEntrys = obj as List <BugCheckEntry>; if (lstEntrys != null) { lstEntrys.Add(qcEntry); } return; } if (szEntryValue.Length < this.m_nEntryMinLen) { this.m_nEntryMinLen = szEntryValue.Length; } if (szEntryValue.Length > this.m_nEntryMaxLen) { this.m_nEntryMaxLen = szEntryValue.Length; } //这里做成一个Entry列表,是因为有些Entry的关键字是相相同的 lstEntrys = new List <BugCheckEntry>(); lstEntrys.Add(qcEntry); this.m_htDocumentEntry.Add(szEntryValue, lstEntrys); }
public static BugCheckEntry GetEntry(string szEntryID) { if (m_htEntryHandlerTable == null) { return(null); } foreach (object obj in m_htEntryHandlerTable.Values) { BugCheckEntryHandlerBase entryHandlerBase = obj as BugCheckEntryHandlerBase; if (entryHandlerBase == null) { continue; } BugCheckEntry qcEntry = entryHandlerBase.GetEntry(szEntryID); if (qcEntry != null) { return(qcEntry); } } return(null); }
public override void ComputeEntryOccurCount() { base.ComputeEntryOccurCount(); if (this.EntryTable == null) { return; } foreach (object obj in this.EntryTable.Values) { BugCheckEntry qcEntry = obj as BugCheckEntry; if (qcEntry == null) { return; } qcEntry.OccurCount = 0; bool bResult = false; if (qcEntry.ValueType == SystemData.QCRule.ENTRY_VALUE_TYPE_INT) { bResult = this.CompareIntEntry(qcEntry); } else if (qcEntry.ValueType == SystemData.QCRule.ENTRY_VALUE_TYPE_BOOL) { bResult = this.CompareBoolEntry(qcEntry); } else if (qcEntry.ValueType == SystemData.QCRule.ENTRY_VALUE_TYPE_DATE) { bResult = this.CompareDatetimeEntry(qcEntry); } else if (qcEntry.ValueType == SystemData.QCRule.ENTRY_VALUE_TYPE_TEXT) { bResult = this.CompareStringEntry(qcEntry); } if (bResult) { qcEntry.OccurCount++; } } }
/// <summary> /// 恢复各Entry项为默认值 /// </summary> private void ResumeEntry() { if (this.EntryTable == null) { return; } foreach (object obj in this.EntryTable.Values) { BugCheckEntry qcEntry = obj as BugCheckEntry; if (qcEntry == null) { continue; } if (qcEntry.Operator == SystemData.Operator.NOCONTAINS) { qcEntry.OccurCount = 1; } else { qcEntry.OccurCount = 0; } } }
public override void AddEntry(BugCheckEntry entryInfo) { base.AddEntry(entryInfo); }
public static void AddRule(MedQCRule medQCRule) { if (m_htRuleTable == null) { m_htRuleTable = new Hashtable(); } string szRuleID = medQCRule.RuleID.Trim(); BugCheckRule qcRule = m_htRuleTable[szRuleID] as BugCheckRule; if (qcRule == null) { qcRule = new BugCheckRule(); qcRule.RuleID = szRuleID; m_htRuleTable.Add(szRuleID, qcRule); } qcRule.Operator = medQCRule.Operator; qcRule.BugKey = string.Empty; qcRule.BugLevel = (BugLevel)medQCRule.BugLevel; qcRule.BugDesc = medQCRule.BugDesc; qcRule.Response = medQCRule.Response; if (!GlobalMethods.Misc.IsEmptyString(medQCRule.RuleID1)) { string szSubRule1ID = medQCRule.RuleID1.Trim(); BugCheckRule qcSubRule1 = m_htRuleTable[szSubRule1ID] as BugCheckRule; if (qcSubRule1 == null) { qcSubRule1 = new BugCheckRule(); qcSubRule1.RuleID = szSubRule1ID; m_htRuleTable.Add(szSubRule1ID, qcSubRule1); } qcRule.SubRule1 = qcSubRule1; } if (!GlobalMethods.Misc.IsEmptyString(medQCRule.RuleID2)) { string szSubRule2ID = medQCRule.RuleID2.Trim(); BugCheckRule qcSubRule2 = m_htRuleTable[szSubRule2ID] as BugCheckRule; if (qcSubRule2 == null) { qcSubRule2 = new BugCheckRule(); qcSubRule2.RuleID = szSubRule2ID; m_htRuleTable.Add(szSubRule2ID, qcSubRule2); } qcRule.SubRule2 = qcSubRule2; } if (!GlobalMethods.Misc.IsEmptyString(medQCRule.EntryID)) { string szEntryID = medQCRule.EntryID.Trim(); BugCheckEntry qcEntry = BugCheckEntryManager.GetEntry(szEntryID); if (qcEntry == null) { return; } qcRule.RuleEntry = qcEntry; } if (!GlobalMethods.Misc.IsEmptyString(medQCRule.RefRuleID)) { string szResultRuleID = medQCRule.RefRuleID.Trim(); BugCheckRule qcResultRule = m_htRuleTable[szResultRuleID] as BugCheckRule; if (qcResultRule == null) { qcResultRule = new BugCheckRule(); qcResultRule.RuleID = szResultRuleID; m_htRuleTable.Add(szResultRuleID, qcResultRule); } qcRule.RefRule = qcResultRule; } }