protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            // loading counters for the different case statuses
            caseStatus = "N";
            caseCount  = bi.GetCaseCounterByStatus(caseStatus);

            // get the cases by status (we default to the new jobs page)
            SetGVJobStatus(caseStatus);
        }
    }
Пример #2
0
        /// <summary>
        /// E-mail the counts for different job statuses to a user specified in the config file.
        /// </summary>
        private void SendEmailJobsReport()
        {
            try
            {
                string strSubject = ConfigurationManager.AppSettings["FST_SERVICE_NAME"] + " - Jobs Report";

                StringBuilder sbBody = new StringBuilder();

                int waitingToProcess = bi.GetCaseCounterByStatus("N");
                int processing       = bi.GetCaseCounterByStatus("P");
                int finished         = bi.GetCaseCounterByStatus("Y");
                int deleted          = bi.GetCaseCounterByStatus("D");
                int total            = waitingToProcess + processing + finished + deleted;

                sbBody.Append("\r\nJobs Report:\r\n");
                sbBody.Append("\r\nJobs Waiting To Process: " + waitingToProcess);
                sbBody.Append("\r\nJobs Processing: " + processing);
                sbBody.Append("\r\nJobs Finished: " + finished);
                sbBody.Append("\r\nJobs Deleted: " + deleted);
                sbBody.Append("\r\nTotal: " + deleted);

                using (MailMessage msg = new MailMessage())
                {
                    msg.From = new MailAddress(ConfigurationManager.AppSettings["FST_SERVICE_EMAIL_ADDRESS_FROM"], ConfigurationManager.AppSettings["FST_SERVICE_EMAIL_ADDRESS_NAME"]);
                    string   emailTo       = ConfigurationManager.AppSettings["FST_SERVICE_EMAIL_JOBS_REPORT_TO"];
                    string[] emailToString = emailTo.Split(';');//,1, StringSplitOptions.RemoveEmptyEntries);

                    foreach (string s in emailToString)
                    {
                        msg.To.Add(new MailAddress(s, s));
                    }
                    //msg.To.Add(new MailAddress(ConfigurationManager.AppSettings["FST_SERVICE_EMAIL_JOBS_REPORT_TO"], ConfigurationManager.AppSettings["FST_SERVICE_EMAIL_JOBS_REPORT_TO"]),;

                    msg.Subject = strSubject;
                    msg.Body    = sbBody.ToString();
                    //SmtpClient client = new SmtpClient(ConfigurationManager.AppSettings["FST_SERVICE_EMAIL_SERVER"]);
                    SmtpClient client = new SmtpClient((ConfigurationManager.AppSettings["FST_SERVICE_EMAIL_SERVER"]), Convert.ToInt32(ConfigurationManager.AppSettings["FST_SERVICE_EMAIL_SERVER_PORT"]));
                    using (client)
                    {
                        client.DeliveryMethod = SmtpDeliveryMethod.Network;
                        string username = ConfigurationManager.AppSettings["FST_SERVICE_EMAIL_SERVER_USERNAME"];
                        string password = ConfigurationManager.AppSettings["FST_SERVICE_EMAIL_SERVER_PASSWORD"];
                        client.Credentials = new NetworkCredential(username, password);
                        //client.Credentials = new NetworkCredential("username","password");
                        client.Send(msg);
                    }
                }
            }
            catch (Exception ex)
            {
                FSTService.CreateDailyLogEntry(ex.Message + Environment.NewLine + ex.StackTrace);
            }
        }