/// <summary>
        /// This method is the main method of the Comparison Case child thread. Here, we determine the type of comparison we are running, run that comparsion,
        /// print the report, and send out an e-mail, close the case, and remove ourselves from the running threads list.
        /// </summary>
        /// <param name="o"></param>
        void ComparisonWorkerThreadMain(object o)
        {
            try
            {
                // set case to "processing"
                FSTService.CreateDailyLogEntry("Case Started");
                string message = bi.UpdateCaseStatus(recordID, "P");
                if (String.IsNullOrEmpty(message))
                {
                    FSTService.CreateDailyLogEntry(message + Environment.NewLine);
                }

                if (comparisonData.Bulk)
                {   // process bulk comparison
                    FSTService.CreateDailyLogEntry("Bulk Search Started");
                    StartBulkSearch();
                    FSTService.CreateDailyLogEntry("Bulk Search Ended and sending Email");
                }
                else
                {   // process individual comparison
                    FSTService.CreateDailyLogEntry("Individual Comparison Started");
                    StarIndividualComparison();
                    FSTService.CreateDailyLogEntry("Individual Comparison Ended and sending Email");
                }

                // set status to "processed"
                message = bi.UpdateCaseStatus(recordID, "Y");
                if (String.IsNullOrEmpty(message))
                {
                    FSTService.CreateDailyLogEntry(message + Environment.NewLine);
                }
                FSTService.CreateDailyLogEntry("Case Ended");

                // remove ourselves from the running cases list
                if (comparisonData.Bulk && (comparisonData.CompareMethodID == 13 || comparisonData.CompareMethodID == 17 || comparisonData.CompareMethodID == 14))
                {
                    FSTService.removeLongRunningCase(this);
                }
                else
                {
                    FSTService.removeRunningCase(this);
                }

                SendEmail();
                FSTService.CreateDailyLogEntry("Email Sent");
            }
            catch (Exception ex)
            {
                // if we experience any error, we log it and remove ourselves from the running cases list
                FSTService.CreateDailyLogEntry(ex.Message + Environment.NewLine + ex.StackTrace);
                if (comparisonData.Bulk && (comparisonData.CompareMethodID == 13 || comparisonData.CompareMethodID == 14 || comparisonData.CompareMethodID == 17))
                {
                    FSTService.removeLongRunningCase(this);
                }
                else
                {
                    FSTService.removeRunningCase(this);
                }
            }
        }
Пример #2
0
        public FSTService()
        {
            InitializeComponent();

            this.ServiceName = ConfigurationManager.AppSettings["FST_SERVICE_NAME"];

            FSTService.Instance = this;
            // this is how we log the messages from the DB class
            bi.m_dbinstance.OnCreateDailyLogEntry += new FST.Common.Database.CreateDailyLogEntryDelegate(FSTService.CreateDailyLogEntry);
        }
        /// <summary>
        /// E-mail the comparison report to the user, then delete the comparison report. This method assumes that the comparison report is already written
        /// to the file pointed to by strReportFilePath
        /// </summary>
        private void SendEmail()
        {
            try
            {
                string strSubject = "";
                string strBody    = "";
                if (!comparisonData.Bulk)
                {
                    strSubject = "Forensic Comparison Report Started at " + comparisonData.ReportDate.ToString() + " is ready for viewing";
                    strBody    = "The Forensic Comparison Report of Hp: " + comparisonData.HpHead +
                                 " and Hd: " + comparisonData.HdHead + " is ready for viewing";
                }
                else
                {
                    strSubject = "Bulk Comparison Started at " + comparisonData.ReportDate.ToString() + " is ready for viewing";
                    strBody    = "The Bulk Comparison of Hp: " + comparisonData.HpHead +
                                 " and Hd: " + comparisonData.HdHead + " using " +
                                 comparisonData.BulkType.ToString() + " database is ready for viewing";
                }
                DataTable dtEmailId = bi.GetEmailId(comparisonData.UserName.ToString());
                using (MailMessage msg = new MailMessage())
                {
                    msg.From = new MailAddress(ConfigurationManager.AppSettings["FST_SERVICE_EMAIL_ADDRESS_FROM"], ConfigurationManager.AppSettings["FST_SERVICE_EMAIL_ADDRESS_NAME"]);
                    msg.To.Add(new MailAddress(dtEmailId.Rows[0]["Email"].ToString().Trim(), comparisonData.UserName.Trim()));

                    Attachment atchmt;

                    atchmt = new Attachment(strReportFilePath);

                    msg.Attachments.Add(atchmt);

                    msg.Subject = strSubject;
                    msg.Body    = strBody;
                    //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);
                    }
                }
                dtEmailId.Clear();
                dtEmailId.Dispose();

                File.Delete(strReportFilePath);
            }
            catch (Exception ex)
            {
                FSTService.CreateDailyLogEntry(ex.Message + Environment.NewLine + ex.StackTrace);
            }
        }
Пример #4
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);
            }
        }