Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
 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);
     }
 }
Ejemplo n.º 4
0
 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);
     }
 }
Ejemplo n.º 5
0
 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);
     }
 }
Ejemplo n.º 6
0
 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);
     }
 }
Ejemplo n.º 7
0
 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);
     }
 }
Ejemplo n.º 8
0
 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");
     }
 }
Ejemplo n.º 9
0
 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);
     }
 }
Ejemplo n.º 10
0
 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);
     }
 }
Ejemplo n.º 11
0
 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);
 }
Ejemplo n.º 12
0
 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);
 }
Ejemplo n.º 13
0
 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");
 }
Ejemplo n.º 14
0
        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);
        }
Ejemplo n.º 15
0
 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);
     }
 }
Ejemplo n.º 16
0
 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);
     }
 }
Ejemplo n.º 17
0
 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");
 }
Ejemplo n.º 18
0
 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);
     }
 }
Ejemplo n.º 19
0
 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);
     }
 }
Ejemplo n.º 20
0
        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);
        }
Ejemplo n.º 21
0
        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);
        }
Ejemplo n.º 22
0
 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);
     }
 }
Ejemplo n.º 23
0
 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);
 }
Ejemplo n.º 24
0
 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);
 }
Ejemplo n.º 25
0
        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);
            }
        }
Ejemplo n.º 26
0
 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);
 }