public void LogDebug(LoggingTypeModel.LogCategory logCategory, Exception exception) { if (!LoggingLevelEnabled.Decide(LoggingLevel).Debug) { return; } _logger.Write("DEBUG", logCategory, GenerateError.GetException(exception), DateTime.Now); }
public void LogInfo(LoggingTypeModel.LogCategory logCategory, Exception exception) { if (!LoggingLevelEnabled.Decide(LoggingLevel).Info) { return; } _logger.WriteToErrorLog("INFO", logCategory, GenerateError.GetException(exception), DateTime.Now); }
public void LogDebug(LoggingTypeModel.LogCategory logCategory, Exception exception) { CheckArchive(); if (!LoggingLevelEnabled.Decide(LoggingLevel).Debug) { return; } SetupLogLocation(); _loggingFile.WriteToErrorLog("DEBUG", logCategory, GenerateError.GetException(exception), DateTime.Now); }
private void Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { MsgBox.Show("產生報表時發生錯誤" + e.Error.Message); if (GenerateError != null) { GenerateError.Invoke(this, new EventArgs()); } return; } #region 儲存 Workbook book = e.Result as Workbook; string path = Path.Combine(System.Windows.Forms.Application.StartupPath, "Reports"); DirectoryInfo dir = new DirectoryInfo(path); if (!dir.Exists) { dir.Create(); } path = Path.Combine(path, Global.ReportName + ".xls"); if (File.Exists(path)) { int i = 1; while (true) { string newPath = Path.GetDirectoryName(path) + "\\" + Path.GetFileNameWithoutExtension(path) + (i++) + Path.GetExtension(path); if (!File.Exists(newPath)) { path = newPath; break; } } } try { book.Save(path, FileFormatType.Excel2003); FISCA.LogAgent.ApplicationLog.Log("成績系統.報表", "列印" + Global.ReportName, string.Format("產生{0}份" + Global.ReportName, _data.Count)); MotherForm.SetStatusBarMessage(Global.ReportName + "產生完成"); if (GenerateCompleted != null) { GenerateCompleted.Invoke(this, new EventArgs()); } if (MsgBox.Show(Global.ReportName + "產生完成,是否立刻開啟?", MessageBoxButtons.YesNo) == DialogResult.Yes) { System.Diagnostics.Process.Start(path); } } catch (Exception ex) { MsgBox.Show("儲存失敗"); } #endregion #region 大掃除 foreach (var ced in _data) { ced.Clear(); } #endregion }
public void HandleMessages() { var reader = new StreamReader(Client.TcpClient.GetStream()); while (_isRunning) { string line = null; try { line = reader.ReadLine()?.Replace("§", ""); } catch { line = null; } if (string.IsNullOrEmpty(line)) { Client.Disconnect(); return; } while (line.Contains(" ")) { line = line.Replace(" ", " "); } while (line.EndsWith(" ")) { line = line.Substring(0, line.Length - 1); } GenerateError.CheckAndGenerate(line); ChatMessage chatMessage = new ChatMessage(Client, line); CommandMessage commandMessage = new CommandMessage(Client, line); StatMessage statMessage = new StatMessage(Client, line); Client.LastActivity = (int)(DateTime.UtcNow.Subtract(Program.StartTime)).TotalSeconds; if (chatMessage.Valid()) { chatMessage.Handle(); } else if (commandMessage.Valid()) { commandMessage.Handle(); } else if (statMessage.Valid()) { statMessage.Handle(); } else { // ??? Client.Disconnect("§2What was that?"); return; } } }