public virtual XDocument Load(string path) { path.ThrowOnNullOrWhiteSpace(nameof(path)); try { if (!File.Exists(path)) { return(null); } var document = XDocument.Load(path); if (document == null) { return(null); } else if (FileValidation != null && !FileValidation.ValidateSuppressionFile(document)) { return(null); } return(document); } catch (Exception exception) when(FilterException(exception)) { ErrorProcessor.ProcessError(exception); } return(null); }
public virtual bool ValidateSuppressionFile(XDocument document) { document.ThrowOnNull(nameof(document)); ValidationLog validationLog = new ValidationLog(); foreach (ISuppressionFileValidator validator in AggregatedValidators) { validator.ValidateSuppressionFile(document, validationLog); } if (validationLog.ErrorsCount == 0) { return(true); } if (ErrorProcessor == null) { return(false); } string log = validationLog.GetValidationLog(); if (log.IsNullOrWhiteSpace()) { log = "Validation of suppression file failed"; } ErrorProcessor.ProcessError(new Exception(log)); return(false); }
/// <summary> /// 重写了ExecuteQuery,增加了异常处理功能 /// </summary> public new void ExecuteQuery() { try { base.ExecuteQuery(); } catch (ServerException ex) { ErrorProcessor.Process(ex, ex.ServerErrorCode); } }
/// <summary>讀取INI文件中的特定子區塊 (浮點數)</summary> /// <param name="section">項目名稱(如 [TypeName] )</param> /// <param name="key">資料群</param> /// <param name="defaultValue">預設值</param> /// <param name="size">指定讀取的Buffer數量。</param> /// <returns>回傳"="後面的浮點數</returns> public virtual float ReadFloat(string section, string key, double defaultValue, int size = 500) { float result = 0; StringBuilder stringBuilder = new StringBuilder(size); string sDefault = defaultValue + ""; GetPrivateProfileString(section, key, sDefault, stringBuilder, size, iniPath); if (float.TryParse(stringBuilder.ToString(), out result)) { OnRead(); } else { ErrorProcessor.Record(ErrorCode.ER_DATA_TRANSFER, false); } return(result); }
/// <summary>刪除目的檔案及連結路徑。</summary> public void Dispose() { try { if (File.IsExist_File(base.IniPath)) { File.Delete(base.IniPath); } } catch (Exception ex) { ErrorProcessor.Record(ex); } finally { base.IniPath = ""; } }
public void Process(IMessage message) { if (message != null) { switch (message.Type) { case MessageType.PDU: PDUProcessor.Process(message, this); break; case MessageType.PDATA_TF: PDataProcessor.Process(message, this); break; case MessageType.ERROR: ErrorProcessor.Process(message); break; } } }
public virtual bool Save(XDocument document, string path) { document.ThrowOnNull(nameof(document)); path.ThrowOnNullOrWhiteSpace(nameof(path)); try { if (FileValidation != null && !FileValidation.ValidateSuppressionFile(document)) { return(false); } document.Save(path); } catch (Exception exception) when(FilterException(exception)) { ErrorProcessor.ProcessError(exception); return(false); } return(true); }