protected int GetLastReportNumberID(string @directory) { int x = 0; string temp = ""; if (Directory.EnumerateFileSystemEntries(directory).Any()) { try { foreach (string fName in Directory.GetFiles(directory, "*")) { temp = ""; int i = fName.LastIndexOf("xR") + 2; while (fName[i] != ' ' && fName[i] != '.') { temp += fName[i]; i++; } if (Convert.ToInt32(temp) > x) { x = Convert.ToInt32(temp); } } x += 1; } catch (Exception e) { MessageLogManager.LogMessage("REPORT MANAGER - GLRNI ==> Unable to retrieve ID:\n" + e.Message + "\n" + e.InnerException + "\n" + e.Source + "\n" + e.TargetSite + "\n" + e.InnerException + "\n" + e.Source + "\n" + e.TargetSite); x = -2; } } return(x); }
public bool Save() { MessageLogManager.LogMessage("CLIN REPORT MANAGER - SR ==> Saving CLIN Report..."); if (SaveReport(report.FullFileName, report)) { MessageLogManager.LogMessage("CLIN REPORT MANAGER - SR ==> CLIN Report saved:\n" + report.FullFileName); return(true); } MessageLogManager.LogMessage("CLIN REPORT MANAGER - SR ==> CLIN Report failed to save: " + report.FullFileName); return(false); }
public bool AddLog(uint clientId, string clientName) { try { report.Clients.Add(clientId, new CLCOLog(clientId, clientName, 0, 0, TimeSpan.FromSeconds(0))); return(SaveReport(report.FullFileName, report)); } catch (Exception e) { MessageLogManager.LogMessage("CLCOCCM ==> Error adding client console log: " + e.Message + "\n" + e.InnerException + "\n" + e.Source + "\n" + e.TargetSite); return(false); } }
public static bool DeleteAllReports() { try { Directory.Delete(reportsDirectory, true); return(true); } catch (Exception e) { MessageLogManager.LogMessage("REPORT MANAGER ==> Error deleting reports:\n" + e.Message + "\n" + e.InnerException + "\n" + e.Source + "\n" + e.TargetSite + "\n" + e.InnerException + "\n" + e.Source + "\n" + e.TargetSite); return(false); } }
public bool UpdateLog(COSELog session) { try { report.Clients[session.ClientId].Sessions.Add(session); return(SaveReport(report.FullFileName, report)); } catch (Exception e) { MessageLogManager.LogMessage("CLCOCCM ==> Error updating client console log: " + e.Message + "\n" + e.InnerException + "\n" + e.Source + "\n" + e.TargetSite); return(false); } }
public static bool DeleteReport(string reportFullName) { try { FileInfo report = new FileInfo(reportFullName); report.Delete(); return(true); } catch (Exception e) { MessageLogManager.LogMessage("REPORT MANAGER ==> Error deleting report:\n" + reportFullName + "\n" + e.Message + "\n" + e.InnerException + "\n" + e.Source + "\n" + e.TargetSite + "\n" + e.InnerException + "\n" + e.Source + "\n" + e.TargetSite); return(false); } }
public bool StartSession(uint clientId, DateTime startTime) { try { report.Sessions[report.Sessions.Count - 1].ClientId = clientId; report.Sessions[report.Sessions.Count - 1].StartTime = startTime; return(SaveReport(report.FullFileName, report)); } catch (Exception e) { MessageLogManager.LogMessage("COSESM ==> Error starting session: " + e.Message + "\n" + e.InnerException + "\n" + e.Source + "\n" + e.TargetSite); return(false); } }
public string load(uint id) { MessageLogManager.LogMessage("YECO REPORT MANAGER - LR(bI) ==> Loading YECO Report..."); try { report = reports[id]; MessageLogManager.LogMessage("YECO REPORT MANAGER - LR(bI) ==> YECO Report loaded: " + report.FullFileName); return(report.FullFileName); } catch (Exception e) { MessageLogManager.LogMessage("YECO REPORT MANAGER - LR(bI) ==> YECO Report failed to load: " + id.ToString() + "\n" + e.Message + "\n" + e.InnerException + "\n" + e.Source + "\n" + e.TargetSite); return("Error"); } }
public bool Load(uint id) { MessageLogManager.LogMessage("COSE REPORT MANAGER - LR(bI) ==> Loading COSE Report..."); try { report = reports[id]; MessageLogManager.LogMessage("COSE REPORT MANAGER - LR(bI) ==> COSE Report loaded:\n" + report.FullFileName); return(true); } catch (Exception e) { MessageLogManager.LogMessage("COSE REPORT MANAGER - LR(bI) ==> COSE Report failed to load: " + id.ToString() + "\n" + e.Message + "\n" + e.InnerException + "\n" + e.Source + "\n" + e.TargetSite); return(false); } }
public bool EndLog(DateTime endTime, TimeSpan totalTime, double totalConsumption) { try { report.Sessions[report.Sessions.Count - 1].Logs[report.Sessions[report.Sessions.Count - 1].Logs.Count - 1].EndTime = endTime; report.Sessions[report.Sessions.Count - 1].Logs[report.Sessions[report.Sessions.Count - 1].Logs.Count - 1].TotalTime = totalTime; report.Sessions[report.Sessions.Count - 1].Logs[report.Sessions[report.Sessions.Count - 1].Logs.Count - 1].TotalConsumption = totalConsumption; return(SaveReport(report.FullFileName, report)); } catch (Exception e) { MessageLogManager.LogMessage("COSESM ==> Error ending log: " + e.Message + "\n" + e.InnerException + "\n" + e.Source + "\n" + e.TargetSite); return(false); } }
public bool Load(string @fullReportName) { MessageLogManager.LogMessage("COSE REPORT MANAGER - LR(bN) ==> Loading COSE Report..."); if ((report = (COSEReport)LoadReport(fullReportName)) != null && SaveReport(report.FullFileName, report)) { if (!reports.ContainsKey(report.Id)) { reports.Add(report.Id, report); } MessageLogManager.LogMessage("COSE REPORT MANAGER - LR(bN) ==> COSE Report loaded:\n" + report.FullFileName); return(true); } MessageLogManager.LogMessage("COSE REPORT MANAGER - LR(bN) ==> COSE Report failed to load: " + fullReportName); return(false); }
public bool LoadOnly(string reportName) { MessageLogManager.LogMessage("YECO REPORT MANAGER - LRO ==> Loading YECO Report..."); if (((report = (YECOReport)LoadReport(reportName)) != null) && SaveReport(reportName, report)) { if (!reports.ContainsKey(report.Id)) { reports.Add(report.Id, report); } MessageLogManager.LogMessage("YECO REPORT MANAGER - LRO ==> YECO Report loaded: " + report.FullFileName); return(true); } MessageLogManager.LogMessage("YECO REPORT MANAGER - LRO ==> YECO Report failed to load: " + reportName); return(false); }
public string Load(string @fullReportName, uint consoleId, string consoleName) { MessageLogManager.LogMessage("COSE REPORT MANAGER - LR+CR ==> Loading COSE Report..."); if (((report = (COSEReport)LoadReport(fullReportName)) != null || Create(consoleId, consoleName)) && SaveReport(report.FullFileName, report)) { if (!reports.ContainsKey(report.Id)) { reports.Add(report.Id, report); } MessageLogManager.LogMessage("COSE REPORT MANAGER - LR+CR ==> COSE Report loaded:\n" + report.FullFileName); return(report.FullFileName); } MessageLogManager.LogMessage("COSE REPORT MANAGER - LR+CR ==> COSE Report failed to load: " + fullReportName); return("Error"); }
public uint AddSession() { uint id = 0; try { id = (uint)report.Sessions.Count; report.Sessions.Add(new COSELog(id)); SaveReport(report.FullFileName, report); } catch (Exception e) { MessageLogManager.LogMessage("COSESM ==> Error adding session: " + e.Message + "\n" + e.InnerException + "\n" + e.Source + "\n" + e.TargetSite); } return(id); }
public bool StartLog(string eventName, uint extraConstrols, DateTime startTime) { try { report.Sessions[report.Sessions.Count - 1].Logs[report.Sessions[report.Sessions.Count - 1].Logs.Count - 1].Date = DateTime.Now; report.Sessions[report.Sessions.Count - 1].Logs[report.Sessions[report.Sessions.Count - 1].Logs.Count - 1].EventName = eventName; report.Sessions[report.Sessions.Count - 1].Logs[report.Sessions[report.Sessions.Count - 1].Logs.Count - 1].ExtraControls = extraConstrols; report.Sessions[report.Sessions.Count - 1].Logs[report.Sessions[report.Sessions.Count - 1].Logs.Count - 1].StartTime = startTime; return(SaveReport(report.FullFileName, report)); } catch (Exception e) { MessageLogManager.LogMessage("COSESM ==> Error starting log: " + e.Message + "\n" + e.InnerException + "\n" + e.Source + "\n" + e.TargetSite); return(false); } }
protected bool Create() { MessageLogManager.LogMessage("YECO REPORT MANAGER - CR ==> Creating YECO Report..."); try { uint id = (uint)GetLastReportNumberID(CODirectory); report = new YECOReport(id, CODirectory); MessageLogManager.LogMessage("YECO REPORT MANAGER - CR ==> YECO Report created: " + report.FullFileName); return(true); } catch (Exception e) { MessageLogManager.LogMessage("YECO REPORT MANAGER - CR ==> YECO Report failed to create:\n" + e.Message + "\n" + e.InnerException + "\n" + e.Source + "\n" + e.TargetSite); return(false); } }
public string Load(string reportName) { MessageLogManager.LogMessage("YECO REPORT MANAGER - LR+CR ==> Loading YECO Report..."); if (((((report = (YECOReport)LoadReport(reportName)) != null && VerifyYear(report.Date))) || Create()) && SaveReport(reportName, report)) { if (!reports.ContainsKey(report.Id)) { reports.Add(report.Id, report); } MessageLogManager.LogMessage("YECO REPORT MANAGER - LR+CR ==> YECO Report loaded: " + report.FullFileName); return(report.FullFileName); } MessageLogManager.LogMessage("YECO REPORT MANAGER - LR+CR ==> YECO Report failed to load: " + reportName); return("Error"); }
public bool DeleteAll() { MessageLogManager.LogMessage("YECO REPORT MANAGER - DA ==> Deleting YECO Reports..."); try { Directory.Delete(CODirectory, true); reports.Clear(); MessageLogManager.LogMessage("YECO REPORT MANAGER - DA ==> YECO Reports delted."); return(true); } catch (Exception e) { MessageLogManager.LogMessage("YECO REPORT MANAGER - DA ==> YECO Reports failed to delete:\n" + e.Message + "\n" + e.InnerException + "\n" + e.Source + "\n" + e.TargetSite); return(false); } }
private bool Create(uint consoleId, string consoleName) { MessageLogManager.LogMessage("COSE REPORT MANAGER - CR ==> Creating COSE Report..."); try { uint id = (uint)GetLastReportNumberID(COSEDirectory); report = new COSEReport(id, COSEDirectory, consoleId, consoleName); MessageLogManager.LogMessage("COSE REPORT MANAGER - CR ==> COSE Report created: " + report.FullFileName); return(true); } catch (Exception e) { MessageLogManager.LogMessage("COSE REPORT MANAGER - CR ==> COSE Report failed to create:\n" + e.Message + "\n" + e.InnerException + "\n" + e.Source + "\n" + e.TargetSite); return(false); } }
public uint AddLog() { uint logId; try { logId = (uint)report.Sessions[report.Sessions.Count - 1].Logs.Count; report.Sessions[report.Sessions.Count - 1].Logs.Add(new COACLog(logId)); SaveReport(report.FullFileName, report); } catch (Exception e) { MessageLogManager.LogMessage("COSESM ==> Error adding log: " + e.Message + "\n" + e.InnerException + "\n" + e.Source + "\n" + e.TargetSite); return(0); } return(logId); }
public uint AddClient(string clientName, string docId, string phoneNumber, string dateOfBirth) { uint id = 0; try { id = (uint)report.Clients.Count; report.Clients.Add(clientName, new CLINLog(id, clientName, docId, phoneNumber, dateOfBirth)); report.ClientKeys.Add(docId, clientName); SaveReport(report.FullFileName, report); } catch (Exception e) { MessageLogManager.LogMessage("CLINCM ==> Error adding client: " + e.Message + "\n" + e.InnerException + "\n" + e.Source + "\n" + e.TargetSite); } return(id); }
protected object LoadReport(string fullReportName) { try { bFormatter = new BinaryFormatter(); fStream = new FileStream(fullReportName, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite); using (Stream stream = fStream) { return(bFormatter.Deserialize(stream)); } } catch (Exception e) { MessageLogManager.LogMessage("REPORT MANAGER - LR ==> failed to load: " + fullReportName + "\n" + e.Message + "\n" + e.InnerException + "\n" + e.Source + "\n" + e.TargetSite + "\n" + e.InnerException + "\n" + e.Source + "\n" + e.TargetSite); return(null); } }
public bool SaveReport(string fullReportName, object report) { try { bFormatter = new BinaryFormatter(); fStream = new FileStream(fullReportName, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite); fStream.Seek(0, SeekOrigin.Begin); using (Stream stream = fStream) { bFormatter.Serialize(stream, report); } } catch (Exception e) { MessageLogManager.LogMessage("REPORT MANAGER - SR ==> Failed to save report: " + fullReportName + "\n" + e.Message + "\n" + e.InnerException + "\n" + e.Source + "\n" + e.TargetSite + "\n" + e.InnerException + "\n" + e.Source + "\n" + e.TargetSite); return(false); } return(true); }
protected bool LoadCurrent() { MessageLogManager.LogMessage("YECO REPORT MANAGER - LCR ==> Loading current YECO Report..."); string[] files = Directory.GetFiles(CODirectory); foreach (string file in files) { report = (YECOReport)LoadReport(file); if (report.Date.Year.ToString() == DateTime.Now.Year.ToString()) { if (!reports.ContainsKey(report.Id)) { reports.Add(report.Id, report); } MessageLogManager.LogMessage("YECO REPORT MANAGER - LCR ==> YECO Report loaded: " + report.FullFileName); return(true); } } MessageLogManager.LogMessage("YECO REPORT MANAGER - LCR ==> YECO Report failed to load."); return(false); }
public static void VerifyDirectories() { try { if (!Directory.Exists(reportsDirectory)) { Directory.CreateDirectory(reportsDirectory); } if (!Directory.Exists(CNDirectory)) { Directory.CreateDirectory(CNDirectory); } if (!Directory.Exists(CODirectory)) { Directory.CreateDirectory(CODirectory); } if (!Directory.Exists(CLDirectory)) { Directory.CreateDirectory(CLDirectory); } if (!Directory.Exists(COSEDirectory)) { Directory.CreateDirectory(COSEDirectory); } if (!Directory.Exists(CLCODirectory)) { Directory.CreateDirectory(CLCODirectory); } if (!Directory.Exists(CLINDirectory)) { Directory.CreateDirectory(CLINDirectory); } } catch (Exception e) { MessageLogManager.LogMessage("REPORT MANAGER - VD ==> Unable to verify directories:\n" + reportsDirectory + " | " + COSEDirectory + " | " + CODirectory + " |\n" + e.Message + "\n" + e.InnerException + "\n" + e.Source + "\n" + e.TargetSite + "\n" + e.InnerException + "\n" + e.Source + "\n" + e.TargetSite); } }
public bool AddSession(COSELog session) { try { if (LoadCurrent() || Create()) { if (!report.MOCOLogs.Keys.Contains(DateTime.Now.ToString("MMMM"))) { report.MOCOLogs.Add(DateTime.Now.ToString("MMMM"), new MOCOLog((uint)report.MOCOLogs.Count)); } if (!report.MOCOLogs[DateTime.Now.ToString("MMMM")].DACOLogs.Keys.Contains(DateTime.Now.Date.ToShortDateString())) { report.MOCOLogs[DateTime.Now.ToString("MMMM")].DACOLogs.Add(DateTime.Now.ToShortDateString(), new DACOLog((uint)report.MOCOLogs[DateTime.Now.ToString("MMMM")].DACOLogs.Count)); } report.MOCOLogs[DateTime.Now.ToString("MMMM")].DACOLogs[DateTime.Now.Date.ToShortDateString()].Sessions.Add(session); return(SaveReport(report.FullFileName, report)); } } catch (Exception e) { MessageLogManager.LogMessage("Failed to add session to DACO log: " + e.Message + "\n" + e.InnerException + "\n" + e.Source + "\n" + e.TargetSite); } return(false); }