Esempio n. 1
0
        private void btnConfig_Click(object sender, RibbonControlEventArgs e)
        {
            Config cfg = Config.Singleton;

            cfg.ReadConfig();

            Form         f  = new Dialogs.Config(cfg);
            DialogResult rc = f.ShowDialog();

            if (rc == DialogResult.OK)
            {
                cfg.WriteConfig();
            }
        }
Esempio n. 2
0
        private void ProcessData()
        {
            DateTime today     = DateTime.Now.Date;
            DateTime yesterday = today.AddDays(-1).Date;

            try
            {
                if (DateTime.Compare(today, _cfg.LastSent) <= 0)
                {
                    if (_cfg.ShowPopups)
                    {
                        MessageBox.Show(String.Format(
                                            "Today is {0:d}\r\n" +
                                            "Last time data was sent: {1:d}\r\n\r\n" +
                                            "Not sending yesterdays {2:d} data as it was already sent!",
                                            DateTime.Now,
                                            _cfg.LastSent,
                                            yesterday.Date),
                                        Config.PROD_SHORT_NAME,
                                        MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }

                    return;
                }

                // count mails
                long totalSentMails = 0;
                long sentMails      = CountSentEmails(
                    yesterday, out totalSentMails, _folderExcludeRegex);
                //MessageBox.Show(String.Format("Sent:\r\n{0}", w), "Message counts",
                //    MessageBoxButtons.OK, MessageBoxIcon.Information);

                long totalReceivedMails = 0;
                long receivedMails      = CountReceivedEmails(
                    yesterday, out totalReceivedMails, _folderExcludeRegex);
                //MessageBox.Show(String.Format("Received:\r\n{0}", w), "Message counts",
                //    MessageBoxButtons.OK, MessageBoxIcon.Information);

                if (_cfg.ShowPopups)
                {
                    MessageBox.Show(String.Format(
                                        "Today is {0:d}\r\n" +
                                        "Last time data was sent: {1:d}\r\n\r\n" +
                                        "Sending yesterdays {2:d}\r\n" +
                                        "\tsent {3} ( from total {4} ) and \r\n" +
                                        "\treceived {5} ( from total {6} ) e-mails\r\n" +
                                        "\tfor user {7} to http://www.crowdstatus.net/",
                                        DateTime.Now,
                                        _cfg.LastSent,
                                        yesterday.Date,
                                        sentMails, totalSentMails,
                                        receivedMails, totalReceivedMails,
                                        _currentUsersEmailAddress),
                                    Config.PROD_SHORT_NAME,
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                try
                {
                    // write registry
                    _cfg.LastSent           = today;
                    _cfg.LastDate           = yesterday;
                    _cfg.LastSentEmails     = sentMails;
                    _cfg.LastReceivedEmails = receivedMails;
                    _cfg.WriteConfig();
                }
                catch { }

                // send data to service
                if (_cfg.TrackReceivedEmails)
                {
                    SendToCrowdStatus(today, _currentUsersEmailAddress,
                                      _cfg.TrackReceivedEmailsToken, receivedMails).Wait();
                }

                if (_cfg.TrackSentEmails)
                {
                    SendToCrowdStatus(today, _currentUsersEmailAddress,
                                      _cfg.TrackSentEmailsToken, sentMails).Wait();
                }
            }
            catch (System.Exception ex)
            {
                if (_cfg.ShowErrors)
                {
                    MessageBox.Show("Error occurred while processing data for http://www.crowdstatus.net\r\n\r\n" +
                                    ex.ToString(),
                                    Config.PROD_SHORT_NAME + " error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }