public void AppendErrorMsg(string line, LogGrid gridValue) { if (InvokeRequired) { // We're not in the UI thread, so we need to call BeginInvoke BeginInvoke(new LogGridParameterDelegate(AppendErrorMsg), new object[] { line, gridValue }); return; } this.LogGridList.Add(gridValue); this.ErrorLog.Add(line); this.AppendNormalMsg(line); }
/// <summary> /// Append a new Log /// </summary> /// <param name="msgType">message type</param> /// <param name="msg">message string</param> /// <param name="resultType">result type</param> public void AppendLog(LogMsgType msgType, string msg, LogResultType resultType) { string outputStr = ""; string msgTypeStr = ""; string resultTypeStr = ""; switch (msgType) { case LogMsgType.Error: msgTypeStr = "Error"; break; case LogMsgType.Info: msgTypeStr = "Info"; break; case LogMsgType.Warning: msgTypeStr = "Warning"; break; default: throw new NotImplementedException(); } switch (resultType) { case LogResultType.AlreadyExist: resultTypeStr = "Already Exist"; break; case LogResultType.GenerateSuccess: resultTypeStr = "Generate Success"; break; case LogResultType.Mismatch: resultTypeStr = "Checksum Mismatch"; break; case LogResultType.NotFound: resultTypeStr = "Record Not Found"; break; case LogResultType.Passed: resultTypeStr = "Passed"; break; default: throw new NotImplementedException(); } outputStr = msgTypeStr + " | " + msg + " | " + resultTypeStr; if (msgType == LogMsgType.Error) { LogGrid gridValue = new LogGrid(msgTypeStr, msg, resultTypeStr); this.ParentForm.AppendErrorMsg(outputStr, gridValue); } else { this.ParentForm.AppendNormalMsg(outputStr); } }