public ReportingCancellationTokenSource(string description = null)
     : base()
 {
     logger = LogService.GetLogger();
     status = StatusService.GetInstance();
     processDescription = description ?? string.Empty;
 }
Ejemplo n.º 2
0
 public static StatusService GetInstance()
 {
     if (instance == null)
     {
         instance = new StatusService();
     }
     return instance;
 }
Ejemplo n.º 3
0
 public static StatusService GetInstance()
 {
     if (instance == null)
     {
         instance = new StatusService();
     }
     return(instance);
 }
Ejemplo n.º 4
0
        public StorageService()
        {
            MsgDispatcher = MessageDispatcher.GetInstance();
            logger = LogService.GetLogger();

            DBService = DataBaseService.GetInstance();
            Status = StatusService.GetInstance();

            logger.Debug("Storage service initiated");
            logger.Debug("Starting history update");
            Task.Factory.StartNew(async () => await UpdateHistory());
            purchaseHistory = new ListSafe<Purchase>();
        }
Ejemplo n.º 5
0
        private void InitializeServices()
        {
            StoreService = StorageService.GetInstance();
            Status = StatusService.GetInstance();
            UpdateService = UpdateService.GetInstance();
            Settings = SettingsService.GetInstance();

            logger = new Logger(this.GetType().ToString());
            logger.SendEmail = Settings.GetSetting(SettingsService.SEND_EMAIL_AUTO_KEY).SettingBoolValue;

            MsgDispatcher = MessageDispatcher.GetInstance();

            Settings.SettingsChanged += Settings_SettingsChanged;
        }
Ejemplo n.º 6
0
        public MainWindow()
        {
            InitializeComponent();

            DataContext = this;

            MsgDispatcher = MessageDispatcher.GetInstance();

            MsgDispatcher.AddHandler(MessageHandler);

            statusService = StatusService.GetInstance();
            updateService = UpdateService.GetInstance();
            logger = LogService.GetLogger();

            Status = statusService.GetStatus();
        }
Ejemplo n.º 7
0
        public static void SendLogFile()
        {
            Task.Factory.StartNew(() =>
            {
                var status = StatusService.GetInstance();
                var logger = new Logger("EmailSender");

                var logPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "HomeCalc", "HomeCalc.View.log");
                if (!File.Exists(logPath))
                {
                    status.Post("Помилка! Інформація для відправлення не знайдена.");
                    return;
                }

                SmtpClient client            = new SmtpClient();
                client.Port                  = 587;
                client.Host                  = "smtp.gmail.com";
                client.EnableSsl             = true;
                client.Timeout               = 10000;
                client.DeliveryMethod        = SmtpDeliveryMethod.Network;
                client.UseDefaultCredentials = false;
                client.Credentials           = new NetworkCredential("*****@*****.**", "qnagsgimnrihnwrr");

                MailMessage mm  = new MailMessage("*****@*****.**", "*****@*****.**", "HomeCalc log report", "Something going wrong...");
                mm.BodyEncoding = UTF8Encoding.UTF8;
                mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;

                ContentType contentType = new ContentType();
                contentType.MediaType   = MediaTypeNames.Text.Plain;
                contentType.Name        = "HomeCalc.View.log";

                mm.Attachments.Add(new Attachment(logPath, contentType));

                try
                {
                    client.Send(mm);
                    status.Post("Інформацію відправлено!");
                }
                catch (SmtpException ex)
                {
                    logger.Error(ex.Message);
                    logger.Error(ex.StatusCode.ToString());
                    status.Post("Помилка при з'єднанні з сервером електронної пошти.");
                }
            });
        }