public void PrinterManager_DeleteDataFiles_AutoRecreate_Test()
        {
            System.IO.File.Delete(DirectoryController.DataDirectoryLocation + "printer.db");

            var manager = new PrinterManager();
            
            var printer = new Printer();
            manager.LoadPrinterList();

            // Datei sollte wieder existieren
            Assert.IsTrue(System.IO.File.Exists(DirectoryController.DataDirectoryLocation + "printer.db"));
        }
        public void PrinterSaveAndLoad_Test()
        {
            var manager = new PrinterManager();
            manager.PrinterDatabase.Initialize();
            manager.PrinterDatabase.CreatePrinter("localhost");
            Assert.AreEqual(manager.LoadPrinterList().Count, 1);



            Config.Load();
            Config.Notifications.SendTo = "*****@*****.**";
            Config.Save();
        }
Esempio n. 3
0
        /// <summary>
        /// Reports the printer status at a specific time
        /// </summary>
        private void Reporting()
        {
            Config.Load();

            if (Config.Reporting.SimpleMailReport || Config.Reporting.ExcelMailReport)
            {
                Logger.Log("Reporting started", LogType.Service);
                PrinterManager manager = new PrinterManager();

                while (true)
                {
                    Config.Load();

                    Logger.Log("Mail report invoked", LogType.Service);

                    DateTime now = DateTime.Now;

                    if (now <= Config.Reporting.TimeToStart)
                    {
                        Logger.Log("Reporting sleeping for " + (Config.Reporting.TimeToStart - now) , LogType.Service);
                        Thread.Sleep(Config.Reporting.TimeToStart - now);
                    }
                    else
                    {
                        Logger.Log("Reporting sleeping for " + (Config.Reporting.TimeToStart.AddHours(24) - now), LogType.Service);
                        Thread.Sleep(Config.Reporting.TimeToStart.AddHours(24) - now);
                    }

                    manager.LoadPrinterList();

                    // no need to write the checked printers back to the database
                    // no database update is performed after
                    manager.ParallelPollPrinterList();

                    MailReportFormatter mailReportFormatter;

                    ReportMessage message = null;

                    if (Config.Reporting.SimpleMailReport)
                    {
                        mailReportFormatter = new TextMailReportFormatter();
                        mailReportFormatter.AddPrinterList(manager.PrinterList);

                        message = mailReportFormatter.GenerateReportMessage();
                        try
                        {
                            Mailer.SendMailOverSmtp(Config.Reporting.SendReportTo, "Prinfo.NET Reporting", message.Message);
                        }
                        catch (Exception ex)
                        {
                            Logger.Log(GlobalizationHelper.LibraryResource.GetString("smtp_error") + ex.Message, LogType.Error);
                        }
                    }
                    if (Config.Reporting.ExcelMailReport)
                    {
                        mailReportFormatter = new ExcelMailReportFormatter();
                        mailReportFormatter.AddPrinterList(manager.PrinterList);

                        message = mailReportFormatter.GenerateReportMessage();

                        try
                        {
                            Mailer.SendMailOverSmtp(Config.Reporting.SendReportTo, "Prinfo.NET Reporting", message.Message, message.Attachment);
                        }
                        catch (Exception ex)
                        {
                            Logger.Log(GlobalizationHelper.LibraryResource.GetString("smtp_error") + ex.Message, LogType.Error);
                        }
                    }
                   
                
                }
            }
        }
Esempio n. 4
0
        private void ShowInfoBox()
        {
            PrinterManager mangi = new PrinterManager();
            mangi.LoadPrinterList();

            int supplyCount = 0;

            foreach (var printer in mangi)
            {
                supplyCount += printer.Supplies.Count;
            }

            MessageBox.Show("Status des Prinfo.NET Dienstes: " + ServiceState() + ".Derzeit sind " + mangi.PrinterList.Count + " Drucker in der Datenbank. Diese besitzen insgesamt " + supplyCount + " Verbrauchsteile. Prinfo.NET Bibliotheksversion: " + Config.Version.Description, "Prinfo.NET Info", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
        
        }