Ejemplo n.º 1
0
        private void send_error_email_scheduleUpdates(report_values report_params, string validRecipients, List<string> failedRecipients)
        {
            #region create and send email
            string scheduledReportStatus = ReportStatus.DELETED.ToString();

            string failedAddresses = string.Empty;
            foreach (string failedAddress in failedRecipients)
            {
                failedAddresses += failedAddress + email.EmailSeparator.ToString();
            }

            //Send email to remaining valid recipients, Questionnaire creator & Questionnaire bussiness owner.
            if (!string.IsNullOrEmpty(validRecipients))
            { 
                validRecipients += email.EmailSeparator.ToString();
                scheduledReportStatus = ReportStatus.UPDATED.ToString(); 
            }

            if (report_params.questionnaire_creator_user.ToLower().
                Equals(report_params.questionnaire_business_owner.ToLower()))
            {
                validRecipients += report_params.questionnaire_creator_user;
            }
            else
            {
                validRecipients += report_params.questionnaire_creator_user + email.EmailSeparator.ToString()
                    + report_params.questionnaire_business_owner;
            }

            MailMessage msg = new MailMessage();
            msg.IsBodyHtml = true;
            msg.From = new MailAddress(email_from);

            utility.set_Mail_address(ref msg, "to", validRecipients);

            msg.Subject = String.Format("RFG Scheduled Export got {0} due to invalid recipients - Campaign {1} - qid {2} (title: {3})", scheduledReportStatus,
                report_params.campaign_name, report_params.questionnaire_id, report_params.questionnaire_title);


            #region building emails content (information about the responsefiles)
            string mail_text = @"
                                <style>
									body {font-family:""Arial"";font-weight:normal;font-size:10pt;color:black;} 
        							table {font-family:""Arial"";font-weight:normal;font-size:10pt;color:black;}
                                    p {font-family:""Arial"";font-weight:normal;color:black;margin-top: -5px}
        							b {font-family:""Arial"";font-weight:bold;color:black;margin-top: -5px}
        							H1 { font-family:""Arial"";font-weight:normal;font-size:14pt;color:black }
        							H2 { font-family:""Arial"";font-weight:normal;font-size:10pt;color:maroon }
									H3 { font-family:""Arial"";font-weight:normal;font-size:10pt;color:darkgreen }
        							pre {font-family:""Arial Console"";font-size: .9em}
                                    .head{ font-family:""Arial"";font-weight:bold;font-size:10pt;color:red }
        							.marker {font-weight: bold; color: black;text-decoration: none;}
        							.version {color: gray;}
        							.error {margin-bottom: 10px;}
        							.expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
								</style>";

            mail_text = String.Format("{0}<span><p>Hello {1},<br><br>", mail_text, validRecipients);

            if (ReportStatus.UPDATED.ToString().Equals(scheduledReportStatus))
            {
                mail_text = String.Format("{0}The following invalid email recipient(s) got removed from the below scheduled export: {1}<br><br>",
                    mail_text, failedAddresses);
            }
            else
            {
                mail_text = String.Format("{0}The below scheduled export got DELETED as no valid recipients remained after removing all invalid recipients. The invalid recipients were: {1}<br><br>",
                    mail_text, failedAddresses);
            }
            mail_text = String.Format("{0}Please follow up in case the report should get recreated / new recipients should get added.<br><br><table border=1>",
                    mail_text);

            mail_text = String.Format("{0}<tr><td width=100>Campaign - Title:</td><td><b>{1} - {2}</b> (qid = {3})&nbsp;</td></tr>", mail_text, report_params.campaign_name, report_params.questionnaire_title, report_params.questionnaire_id);
            mail_text = String.Format("{0}<tr><td>Questionnaire Creator User: </td><td><b>{1}</b></td></tr>", mail_text, report_params.questionnaire_creator_user);
            mail_text = String.Format("{0}<tr><td>Questionnaire Business Owner: </td><td><b>{1}</b></td></tr>", mail_text, report_params.questionnaire_business_owner);
                        
            if ("d".Equals(report_params.schedule_mode))
            {
                mail_text = String.Format("{0}<tr><td>Schedule Mode: </td><td><b>{1}</b></td></tr>", mail_text, "Daily");
            }
            else
            {
                mail_text = String.Format("{0}<tr><td>Schedule Mode: </td><td><b>{1}</b></td></tr>", mail_text, "Weekly");
            }            

            if (!string.IsNullOrEmpty(report_params.schedule_day))
            {
                int index = 0;
                if(Int32.TryParse(report_params.schedule_day, out index))
                    mail_text = String.Format("{0}<tr><td>Schedule Day: </td><td><b>{1}</b></td></tr>", mail_text, weekday[index]);
            }            
            
            mail_text = String.Format("{0}<tr><td>Failed Recipient(s): </td><td><b>{1}</b></td></tr>", mail_text, failedAddresses);
            mail_text = String.Format("{0}<tr><td>Schedule ID: </td><td><b>{1}</b></td></tr></table><br>", mail_text, report_params.schedule_id);
            mail_text = String.Format("{0}<br>Regards,<br>Your RFG-team</p></span>", mail_text);
            #endregion

            msg.Body = mail_text;

            SmtpClient smtp = new SmtpClient(utility.getParameter("smtp"));
            try
            {
                smtp.Send(msg);
                msg.Dispose();
            } catch { }         

            #endregion
        }
Ejemplo n.º 2
0
		private void send_error_email(report_values email_report, Exception error)
		{
            //.NET 1.1: SmtpMail.SmtpServer = utility.getParameter("smtp");
            SmtpClient smtp = new SmtpClient(utility.getParameter("smtp"));
            
            //MailMessage msg = new MailMessage(email_from, utility.getParameter("error_email_to"));
            MailMessage msg = new MailMessage();

            string email_from = utility.getParameter("email_sender");
			//email_from = email_from.Create(email_from.IndexOf("@"), ".THREAD");
            //.NET 1.1: msg.From = email_from;
            msg.From = new MailAddress(email_from);
            
            //.NET 1.1: msg.To = utility.getParameter("error_email_to");
            //MailAddressCollection to = msg.To;
            //to.Add(utility.getParameter("error_email_to"));
            utility.set_Mail_address(ref msg, "to", utility.getParameter("error_email_to"));

			string user = email_report.permss_user;

			string link_to_RFG = utility.getParameter("UrlToApplication");
			string error_on_platform = utility.getParameter("platform");
			//error_on_platform = error_on_platform.Replace("http://", "");
			//error_on_platform = error_on_platform.Replace("/ePeRFGen/", "");

            string error_msg = String.Format("File error on {0} ({1})", error_on_platform, user);
            error_msg += " - " + error.Message;
            error_msg = error_msg.Replace(System.Environment.NewLine, "").Replace('\t', ' ');
            
            msg.SubjectEncoding = Encoding.ASCII;
            msg.Subject = error_msg;
            //.NET 1.1: msg.BodyFormat = MailFormat.Html;
            msg.IsBodyHtml = true;
            msg.Priority = MailPriority.High;

			#region building emails content (information about the error)
			//##########################################

			#region build usual error screen.

			string error_text = @"
            <style>
				body {font-family:""Verdana"";font-weight:normal;font-size: .7em;color:black;} 
        		p {font-family:""Verdana"";font-weight:normal;color:black;margin-top: -5px}
        		b {font-family:""Verdana"";font-weight:bold;color:black;margin-top: -5px}
        		H1 { font-family:""Verdana"";font-weight:normal;font-size:18pt;color:red }
        		H2 { font-family:""Verdana"";font-weight:normal;font-size:14pt;color:maroon }
				H3 { font-family:""Verdana"";font-weight:normal;font-size:14pt;color:darkgreen }
        		pre {font-family:""Lucida Console"";font-size: .9em}
        		.marker {font-weight: bold; color: black;text-decoration: none;}
        		.version {color: gray;}
        		.error {margin-bottom: 10px;}
        		.expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
			</style>
			<span><H1>Server Error in '/ePeRFGen' Application.<hr width=100% size=1 color=silver></H1>";

			error_text = String.Format("{0}<h2> <i>{1}</i> </h2></span>", error_text, error.Message);
			error_text = String.Format("{0}<font face=\"Arial, Helvetica, Geneva, SunSans-Regular, sans-serif \">", error_text);
			error_text = String.Format(@"{0}<b> Description: </b>
                                        An unhandled exception occurred during the execution of the current 
                                        web request. Please review the stack trace for more information about 
                                        the error and where it originated in the code.<br><br>", error_text);


			error_text = String.Format("{0}<b> Exception Details: </b>{1}: {2}<br><br>", error_text, error.GetType().ToString(), error.Message);

			error_text = String.Format(@"{0}<b>Stack Trace:</b><br><br><table width=100% bgcolor=""#ffffcc""><tr><td><code><pre>", error_text);

			string stacktrace = error.StackTrace;

			error_text = String.Format("{0}{1}</pre></code></td></tr></table>", error_text, (stacktrace != ""? stacktrace : ""));

			error_text = String.Format(@"{0}<br><hr width=100% size=1 color=silver><b>
                                         Version Information:</b>&nbsp;Microsoft .NET Framework Version:1.1.4322.2032; 
                                         ASP.NET Version:1.1.4322.2032</font>
                                         <hr width=100% size=1 color=silver><br>", error_text);


			error_text = String.Format("{0}<i><H3>Platform: <font color=blue>{1}</font>{2}{2}{2}{2}{2}", error_text, error_on_platform, "&nbsp;");
			error_text = String.Format("{0}User: <font color=blue>{1}</font></H3></i>", error_text, user);

			#endregion

			#region build additional data

			error_text = String.Format(@"{0}{1}Inner Exception Details - START", error_text, utility.newline); 

			//check the InnerException
			while(error.InnerException != null )
			{
				error_text = String.Format(@"{0}--------------------------------", error_text);
				error_text = String.Format(@"{0}The following InnerException reported: {1}",  error_text, error.InnerException.ToString());
				error = error.InnerException;
			}

			error_text = String.Format(@"{0}{1}Inner Exception Details - END", error_text, utility.newline);

            error_text = String.Format(@"{0}<hr width=100% size=1 color=silver><b>Error Site: <FONT color=blue>{1}datamgmt/export_response.aspx</FONT></b><BR><BR>", error_text, link_to_RFG);
			
			error_text = String.Format(@"{0}<b>Requested Report: </b><BR>---------------------<BR><BR>", error_text);
			
			error_text = String.Format(@"{0}Campaign: {1}<BR>", error_text, email_report.campaign_name);
			error_text = String.Format(@"{0}Title: {1}<BR>", error_text, email_report.questionnaire_title);			
			error_text = String.Format(@"{0}From: {1}<BR>", error_text, email_report.from.ToString());			
			error_text = String.Format(@"{0}Until: {1}<BR>", error_text, email_report.until.ToString());			
			error_text = String.Format(@"{0}Questionnaire_id: {1}<BR>", error_text, email_report.questionnaire_id);

			#endregion

			//##########################################

			#endregion

			// Sending error message to administration via e-mail
			msg.Body = error_text;
			// throw new Exception(strError);
			try
			{
                //.NET 1.1: SmtpMail.Send(msg);
                smtp.Send(msg);
                msg.Dispose();
			}
			catch
			{
			}
		}
Ejemplo n.º 3
0
		/// <summary>
		/// main method of the thread, generates a single report
		/// </summary>
		/// <param name="report_params"></param>
		private void generate_dataemail_processingfile(report_values report_params)
		{
			datamgmt.process_responses processing_files = new datamgmt.process_responses(true);
			
			processing_files.permss_user = report_params.permss_user;
			processing_files.permss_admin = report_params.permss_admin;
			processing_files.questionnaire_id = report_params.questionnaire_id;
			processing_files.from = report_params.from;
			processing_files.until = report_params.until;
			processing_files.questionnaire_title = report_params.questionnaire_title;
			processing_files.pathtotempdir = report_params.pathtotempdir;

           
			StringCollection file_names = processing_files.generate();
            
			//read number of records and delete entry in file_names
			int record_counter = Int32.Parse(file_names[0]);
			file_names.RemoveAt(0);
			
			#region create zip file
			string timeformat = "yyyyMMddHHmmss";
            string zip_name = String.Format("zip_{0}_{1}.zip", report_params.questionnaire_id, DateTime.Now.ToString(timeformat));
            utility.createZIP(zip_name, report_params.pathtotempdir, file_names);

			#endregion

			#region create and send email

            MailMessage msg = new MailMessage();
					
            //.NET 1.1: msg.BodyFormat = MailFormat.Html;
			msg.IsBodyHtml = true;

            //.NET 1.1: msg.From = email_from;
            msg.From = new MailAddress(email_from);

            //.NET 1.1: msg.To = report_params.permss_user;
            //MailAddressCollection to = msg.To;
            utility.set_Mail_address(ref msg, "to", report_params.permss_user); 
            //to.Add(report_params.permss_user);

            msg.Subject = String.Format("Response-Files for campaign {0} - qid {1} (title: {2})", report_params.campaign_name, report_params.questionnaire_id, report_params.questionnaire_title);
			

			if (record_counter > 0)
			{
				//.NET 1.1: MailAttachment response_files = new MailAttachment(report_params.pathtotempdir + zip_name);
                Attachment response_files = new Attachment(report_params.pathtotempdir + zip_name);
                msg.Attachments.Add(response_files);
			}
			
			#region building emails content (information about the responsefiles)
            //††† 20120302 Biju Pattathil | RFG2.7 PR629425:dts email having wrong RFG support link (RFG Support link will change):Start†††
            string support_url = utility.getParameter("support_link"); //+ "live/index.aspx?qid=1493&flexfield1=stop_scheduled_report&flexfield14=qid-"+report_params.questionnaire_id +"-sid-"+ report_params.schedule_id +"&flexfield15="+ report_params.permss_user; 
			
			string mail_text = @"
                                <style>
									body {font-family:""Arial"";font-weight:normal;font-size:10pt;color:black;} 
        							table {font-family:""Arial"";font-weight:normal;font-size:10pt;color:black;}
                                    p {font-family:""Arial"";font-weight:normal;color:black;margin-top: -5px}
        							b {font-family:""Arial"";font-weight:bold;color:black;margin-top: -5px}
        							H1 { font-family:""Arial"";font-weight:normal;font-size:14pt;color:black }
        							H2 { font-family:""Arial"";font-weight:normal;font-size:10pt;color:maroon }
									H3 { font-family:""Arial"";font-weight:normal;font-size:10pt;color:darkgreen }
        							pre {font-family:""Arial Console"";font-size: .9em}
                                    .head{ font-family:""Arial"";font-weight:bold;font-size:10pt;color:red }
        							.marker {font-weight: bold; color: black;text-decoration: none;}
        							.version {color: gray;}
        							.error {margin-bottom: 10px;}
        							.expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
								</style>";


			if (report_params.scheduled)
			{
                //Commented by Phani for RFG 1.9.4 release 
				//mail_text = String.Format("{0}<span><b>This is a scheduled report!</b></span><br><br>", mail_text);
                mail_text = String.Format("{0}<span class=head>This is an automatically generated scheduled report - please do not reply to this email as answers won't be read!</span><br>", mail_text);
                mail_text = String.Format("{0}<span><i>If you don't need to receive this report any longer please submit your request for the report to stop on the <a href="+ support_url+"> RFG support form</a></i></span><br><br><br>", mail_text);
			}

            mail_text = String.Format("{0}<span><p>Hello {1},<br><br>", mail_text, report_params.permss_user);

			if (record_counter > 0)
			{
				mail_text  = String.Format("{0}please find attached a zip-archive containing the requested responses for<br><br><table border=1>", mail_text);
			}
			else
			{
				mail_text  = String.Format("{0}there were no records of responses you have requested for<br><br><table border=1>", mail_text);
			}
            
            mail_text = String.Format("{0}<tr><td width=100>Campaign - Title:</td><td><b>{1} - {2}</b> (qid = {3})&nbsp;</td></tr>", mail_text, report_params.campaign_name, report_params.questionnaire_title, report_params.questionnaire_id);
            mail_text  = String.Format("{0}<tr><td>from: </td><td><b>{1}</b></td></tr>", mail_text, report_params.from.ToShortDateString());
			mail_text  = String.Format("{0}<tr><td>until: </td><td><b>{1}</b></td></tr>", mail_text, report_params.until.AddDays(-1d).ToShortDateString());
			mail_text  = String.Format("{0}<tr><td>number of records<br>in response file: </td><td><b>{1}</b></td></tr></table><br>", mail_text, record_counter.ToString());           
            mail_text  = String.Format("{0}<br>Regards,<br>Your RFG-team</p></span>", mail_text);
			#endregion

			msg.Body = mail_text;

            if (report_params.is_incremental_report) // RFG 2.19 | send email if record count > 0 for incremental schedule report
            {
                if (record_counter > 0)
                {
                    //.NET 1.1: SmtpMail.Send(msg);
                    SmtpClient smtp = new SmtpClient(utility.getParameter("smtp"));
                    smtp.Send(msg);
                }
            }
            else
            {
                SmtpClient smtp = new SmtpClient(utility.getParameter("smtp"));
                smtp.Send(msg);
            }

            msg.Dispose();

            try
            {
                File.Delete(report_params.pathtotempdir + zip_name);

                //foreach (String file in file_names)
                //{
                //    File.Delete(report_params.pathtotempdir + file);
                //}
            }
            catch
            { }

			#endregion

			//log finish in DB
			Hashtable h_params = new Hashtable();
			h_params.Add("entry_id", report_params.queue_entry_id);
			h_params.Add("status", 3); //3 = finished/completed
            DB.execProc("update_queued_report", h_params);
           
		}
Ejemplo n.º 4
0
        /// <summary>
        /// main method of the thread, generates a master report
        /// </summary>
        /// <param name="report_params"></param>
        private void generate_dataemail_processingfileMaster(report_values report_params)
        {
            datamgmt.process_responses processing_files = new datamgmt.process_responses(true);

            processing_files.permss_user = report_params.permss_user;
            processing_files.permss_admin = report_params.permss_admin;
            processing_files.questionnaire_id = report_params.questionnaire_id;
            processing_files.from = report_params.from;
            processing_files.until = report_params.until;
            processing_files.questionnaire_title = report_params.questionnaire_title;
            processing_files.pathtotempdir = report_params.pathtotempdir;

             processing_files.Master = report_params.Master;
             processing_files.IsmasterReport = report_params.IsMasterReport;
            if(report_params.scheduled)
                processing_files.IsMasterFail = processing_files.Master.ValidateMaster();
          

            StringCollection file_names = new StringCollection();
            int record_counter = 0;
            string zip_name = "";
            if (!processing_files.IsMasterFail)
            {
                file_names = processing_files.generate();

                //read number of records and delete entry in file_names
                 record_counter = Int32.Parse(file_names[0]);
                file_names.RemoveAt(0);

                #region create zip file
                string timeformat = "yyyyMMddHHmmss";

                zip_name = String.Format("zip_{0}_{1}.zip", report_params.Master.Dto.MasterRptId, DateTime.Now.ToString(timeformat));


                utility.createZIP(zip_name, report_params.pathtotempdir, file_names);

                #endregion
            }

            #region create and send email

            MailMessage msg = new MailMessage();

            //.NET 1.1: msg.BodyFormat = MailFormat.Html;
            msg.IsBodyHtml = true;

            //.NET 1.1: msg.From = email_from;
            msg.From = new MailAddress(email_from);

            //.NET 1.1: msg.To = report_params.permss_user;
            //MailAddressCollection to = msg.To;
            utility.set_Mail_address(ref msg, "to", report_params.permss_user);
            //to.Add(report_params.permss_user);
            if (processing_files.IsMasterFail)
            {
                msg.Subject = String.Format("RFG - FAILURE - combined response file report for master report {0}", report_params.Master.Dto.MasterName);
            }
            else
            {
                msg.Subject = String.Format("RFG - combined response file report for master report {0}", report_params.Master.Dto.MasterName);

            }

            if (record_counter > 0)
            {
                //.NET 1.1: MailAttachment response_files = new MailAttachment(report_params.pathtotempdir + zip_name);
                Attachment response_files = new Attachment(report_params.pathtotempdir + zip_name);
                msg.Attachments.Add(response_files);
            }

            #region building emails content (information about the responsefiles)
            //††† 20120302 Biju Pattathil | RFG2.7 PR629425:dts email having wrong RFG support link (RFG Support link will change):Start†††
            string support_url = utility.getParameter("support_link"); //+ "live/index.aspx?qid=1493&flexfield1=stop_scheduled_report&flexfield14=qid-" + report_params.questionnaire_id + "-sid-" + report_params.schedule_id + "&flexfield15=" + report_params.permss_user;

            string mail_text = @"
                                <style>
									body {font-family:""Arial"";font-weight:normal;font-size:10pt;color:black;} 
        							table {font-family:""Arial"";font-weight:normal;font-size:10pt;color:black;}
                                    p {font-family:""Arial"";font-weight:normal;color:black;margin-top: -5px}
        							b {font-family:""Arial"";font-weight:bold;color:black;margin-top: -5px}
        							H1 { font-family:""Arial"";font-weight:normal;font-size:14pt;color:black }
        							H2 { font-family:""Arial"";font-weight:normal;font-size:10pt;color:maroon }
									H3 { font-family:""Arial"";font-weight:normal;font-size:10pt;color:darkgreen }
        							pre {font-family:""Arial Console"";font-size: .9em}
                                    .head{ font-family:""Arial"";font-weight:bold;font-size:10pt;color:red }
        							.marker {font-weight: bold; color: black;text-decoration: none;}
        							.version {color: gray;}
        							.error {margin-bottom: 10px;}
        							.expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
								</style>";


            if (report_params.scheduled)
            {
                //Commented by Phani for RFG 1.9.4 release 
                //mail_text = String.Format("{0}<span><b>This is a scheduled report!</b></span><br><br>", mail_text);
                mail_text = String.Format("{0}<span class=head>This is an automatically generated scheduled report - please do not reply to this email as answers won't be read!</span><br>", mail_text);
                mail_text = String.Format("{0}<span><i>If you don't need to receive this report any longer please submit your request for the report to stop on the <a href=" + support_url + "> RFG support form</a></i></span><br><br><br>", mail_text);
            }

            mail_text = String.Format("{0}<span><p>Hello {1},<br><br>", mail_text, report_params.permss_user);

            if (record_counter > 0)
            {
                mail_text = String.Format("{0}please find attached a zip-archive containing the requested responses for<br><br><table border=1>", mail_text);
            }
            else
            {
                if (!processing_files.IsMasterFail)
                {
                    mail_text = String.Format("{0}there were no records of responses you have requested for<br><br><table border=1>", mail_text);
                }
                else
                {
                    string txt = "there is a configuration error for the below master report you should receive. Due to this error a report can not be generated.<br><span class=head>Please get in touch with {1} in order to fix the configuration error.</span><br><br><table border=1>";
                    mail_text = String.Format("{0}" + txt, mail_text, report_params.Master.Dto.Creator.ToString());
                }
            }
            //if (!report_params.IsMasterReport)
            //{
            //    mail_text = String.Format("{0}<tr><td width=100>Campaign - Title:</td><td><b>{1} - {2}</b> (qid = {3})&nbsp;</td></tr>", mail_text, report_params.campaign_name, report_params.questionnaire_title, report_params.questionnaire_id);
            //}
            //else
            //{
            if(report_params.Master.Dto.MasterRptId>1)
                mail_text = String.Format("{0}<tr><td width=100>Master Report Name:</td><td><b>{1}(mid = {2})</b> &nbsp;</td></tr>", mail_text, report_params.Master.Dto.MasterName, report_params.Master.Dto.MasterRptId.ToString());
            else
                mail_text = String.Format("{0}<tr><td width=100>Master Report Name:</td><td><b>{1}{2}</b> &nbsp;</td></tr>", mail_text, report_params.Master.Dto.MasterName, "");
            //}
            mail_text = String.Format("{0}<tr><td>from: </td><td><b>{1}</b></td></tr>", mail_text, report_params.from.ToShortDateString());
            mail_text = String.Format("{0}<tr><td>until: </td><td><b>{1}</b></td></tr>", mail_text, report_params.until.AddDays(-1d).ToShortDateString());
            mail_text = String.Format("{0}<tr><td>number of records<br>in response file: </td><td><b>{1}</b></td></tr><br>", mail_text, record_counter.ToString());
                       
            //for master report
            if (report_params.IsMasterReport)
            {
                string str = "";
                report_params.Master.Dto.MasterQ.ForEach(delegate(MasterQuestionnaireDto mq)
                {
                    str = string.Format("{4}{0}-{1}({2}={3})<br>", mq.CName, mq.QName, "qid", mq.QId.ToString(), str);
                });
                mail_text = String.Format("{0}<tr><td>list of questionnaires/<br>processors contained<br>in this master report: </td><td><b>{1}</b></td></tr></table><br>", mail_text, str);

            }
            mail_text = String.Format("{0}<br>Regards,<br>Your RFG-team</p></span>", mail_text);
            #endregion

            msg.Body = mail_text;

            //.NET 1.1: SmtpMail.Send(msg);
            SmtpClient smtp = new SmtpClient(utility.getParameter("smtp"));
            smtp.Send(msg);

            msg.Dispose();

            try
            {
                File.Delete(report_params.pathtotempdir + zip_name);

                //foreach (String file in file_names)
                //{
                //    File.Delete(report_params.pathtotempdir + file);
                //}
            }
            catch
            { }

            #endregion

            //log finish in DB
            int reportId = 0;
            if (int.TryParse(report_params.queue_entry_id, out reportId))
            {
                QueueFacade.SetMasterReportStatus(reportId, QueueStatus.Completed);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
		/// queues up a new emailreport
		/// </summary>
		/// <param name="values">settings of the emailreport to be generated</param>
        public static void generate_dataemail(report_values values, bool useSeparateThread)
        {
            #region checks whether thread has to be started at first...

            if (started_thread == null)
            {
                started_thread = new mailthread(useSeparateThread);
                if (useSeparateThread)
                {
                    started_thread.Start();
                }
            }
            #endregion

            //log queue entry in database
            Hashtable h_params = new Hashtable();
            string entry_id="";
            //for amster report
            
                h_params.Add("requestor_email", values.permss_user);
                h_params.Add("from", values.from);
                h_params.Add("until", values.until);
                //if (!values.IsMasterReport)
                //{
                h_params.Add("questionnaire_FK", values.questionnaire_id);
                h_params.Add("schedule_id", values.schedule_id);
                h_params.Add("schedule_master_id", values.schedule_master_id);
                //h_params.Add("ismasterreport", values.IsMasterReport);
                //h_params.Add("heading", values.heading);
                entry_id = DB.execProc("insert_queued_report", h_params).Rows[0][0].ToString();
                //}
                //else
                //{
                //    h_params.Add("master_fk", values.schedule_id);
                //    int reportId = 0;
                //    if (int.TryParse(values.schedule_id, out reportId))
                //    {
                //        MasterReportQueueEntryDto entry = new MasterReportQueueEntryDto(values.permss_user, values.from, values.until, reportId);
                //        QueueFacade.CreateQueueEntry(entry);
                //    }
                    
                //}
           
            //queueing (adding to queue) an emailreport
            values.queue_entry_id = entry_id;
            started_thread.emailreports.Enqueue(values);

            if (!useSeparateThread)
            {
                //if no separate thread is used then directly dequeue and process report
                started_thread.generate_dataemail_processingqueue();
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// On receiving invalid email address, collect records in RFG DB for that invalid user.
        /// 1. Send an email to RFG Support team with all details.
        /// 2. Delete/Update schedule export for invalid users.
        /// </summary>
        /// <param name="ex">Exception of type SmtpFailedRecipientException or SmtpFailedRecipientsException</param>
        /// <param name="emailreport">Details for the scheduled export</param>
        private void processFailedEmails(Exception ex, report_values emailreport)
        {
            //Read exception to get the List of all failed email ids.
            List<string> failedRecipients = GetListOfFailedEmailRecipients(ex);

            //Send email to support team for each failed email ids.
            foreach (string recipient in failedRecipients)
            {
                if (!FailedEmails.Contains(recipient))
                {
                    FailedEmails.Add(recipient);
                    send_error_email_userArtifacts(getUserArtifacts(recipient), ex);
                }
            }

            //Check if all recipients for schedule export is failing. If yes delete the schedule export.
            List<string> validRecipients = checkAllRecipientsFailed(failedRecipients, emailreport.permss_user);
            
            Hashtable h_params = new Hashtable();
            h_params.Add("schedule_id", emailreport.schedule_id);
            
            string recipient_email_fk = string.Empty;
            if (validRecipients != null && validRecipients.Count != 0)
            {
                if (validRecipients.Count == 1)
                    recipient_email_fk = validRecipients[0];
                else
                {
                    foreach (string recipient in validRecipients)
                    {
                        recipient_email_fk += recipient + email.EmailSeparator.ToString();
                    }

                    if (recipient_email_fk.EndsWith(email.EmailSeparator.ToString()))
                    {
                        recipient_email_fk = 
                            recipient_email_fk.Remove(recipient_email_fk.Length - email.EmailSeparator.ToString().Length);
                    }
                }
                h_params.Add("recipient_email", recipient_email_fk);
            }

            send_error_email_scheduleUpdates(emailreport, recipient_email_fk, failedRecipients);

            DB.execProc("delete_scheduled_export", h_params);
        }
        //for master report
        //private bool ismasterrpt = false;
        //private MasterReport Master;
        //private string mid = string.Empty;

	
		protected void Page_Load(object sender, System.EventArgs e)
		{
            edit_scheduled_MasterReport editschedule_rpt = null;
            MasterReportNow MasterrptNow = null;
            page_utilities.Set_titles(this.Page, "Export response files");
			permss = check_permissions(this.Page, true);
            if (permss.UserType == UserType.CountryUserWithoutDataAccess)
            {
                Response.Redirect("index.aspx", true);
            }


            bool bMasterRpt = false;

            if (!IsPostBack)
            {
                if (Context.Handler.GetType().Name.Equals("datamgmt_edit_scheduled_masterreport_aspx"))
                {
                    if ((edit_scheduled_MasterReport)Context.Handler != null)
                    {
                        editschedule_rpt = (edit_scheduled_MasterReport)Context.Handler;
                        bMasterRpt = true;
                    }
                }

                if (Context.Handler.GetType().Name.Equals("datamgmt_masterreportnow_aspx"))
                {
                    if ((MasterReportNow)Context.Handler != null)
                    {
                        MasterrptNow = (MasterReportNow)Context.Handler;
                        bMasterRpt = true;
                    }
                }
            }
                                    

			table_emailerror.Visible = false;
			
			if (!this.IsPostBack)
			{
                pathtotempdir = Server.MapPath(utility.getParameter("path_to_temp"));
				
				//create the values with the report settings
				values = new report_values();
                values.permss_account = permss.EmailAddress;
                values.permss_user = permss.EmailAddress;
                //ismasterrpt = Convert.ToBoolean(Session["isMasterReport"]);
                //for master report
                if (!bMasterRpt)
                {
                    Initialize_pagevariables();
                    values.campaign_name = campaign_name;
                    values.questionnaire_id = questionnaire_id;
                    values.from = from;
                    values.until = until;
                    values.questionnaire_title = questionnaire_title;
                }
                else
                {
                    if (editschedule_rpt != null)
                    {
                        values.Master = editschedule_rpt.mrd;
                        values.IsMasterReport = true;
                        values.from = editschedule_rpt.mrd.Dto.From.Value;
                        values.until = editschedule_rpt.mrd.Dto.To.Value;
                        values.questionnaire_id = editschedule_rpt.QIDs;
                        //values.heading = Master.Dto.MElementHeading.ToString();
                    }
                    else
                    {
                        values.Master = MasterrptNow.mrd;
                        values.IsMasterReport = true;
                        values.from = MasterrptNow.mrd.Dto.From.Value;
                        values.until = MasterrptNow.mrd.Dto.To.Value;
                        values.questionnaire_id = MasterrptNow.QIDs;
                    }
                }
				values.pathtotempdir = pathtotempdir;
                values.schedule_id = "-1";
                values.schedule_master_id = "-1";

				values.scheduled = false;

				mailthread.generate_dataemail(values, true);
			}
		}
Ejemplo n.º 8
0
        private void queue_scheduled_masterreports(bool useSeparateThread)
        {
            DateTime today = DateTime.Today;	//Immediate Window: today=today.AddDays(-2d);
            int weekday = (int)today.DayOfWeek;

            List<MasterReport> lst = MasterReport.GetSchMasterReport(weekday, null, null, UserType.Admin);
            DateTime w_from = today.AddDays(-7d);
            DateTime d_from = today.AddDays(-1d);
            //TODO Susann change to also recognize responses received after (milliseconds) 23:59:59,000
            //DateTime until = today.AddDays(-1d);
            DateTime until = today;
            //until = until.AddHours(23).AddMinutes(59).AddSeconds(59);


            //string pathtotempdir = Server.MapPath(utility.getParameter("path_to_temp"));
            string pathtotempdir = this.myPathToTempDir;

            foreach (MasterReport mrd in lst)
            {
                //queue up

                //create the values with the report settings
                report_values values = new report_values();
                mrd.Dto.MasterQ = MasterReport.GetMasterQuestions(mrd.Dto.MasterRptId);
                if (mrd.Dto.ScheduleMode == ScheduleMode.Daily)
                {
                    mrd.Dto.From = d_from;
                    values.from = d_from;
                }
                else
                {
                    mrd.Dto.From = w_from;
                    values.from = w_from;
                }
                mrd.Dto.To = until;


                //mrd.MasterName = single_row["master_name"].ToString();
                //mrd.MasterRptId = (int)single_row["masterid"];
                //mrd.Recipient_Email = single_row["recipient_email_FK"].ToString();
                //values.permss_user = single_row["recipient_email_FK"].ToString();
                //values.permss_admin = bool.Parse(single_row["adminrole"].ToString());
                //values.campaign_name = single_row["campaign_code_FK"].ToString();
                //values.questionnaire_id = single_row["questionnaire_id"].ToString();

                //if (single_row["schedule_mode"].ToString() == "d")
                //{
                //    values.from = d_from;
                //}
                //else
                //{
                //    values.from = w_from;
                //}
                values.until = until;
                //values.questionnaire_title = single_row["qid_title"].ToString();
                values.pathtotempdir = pathtotempdir;
                //values.schedule_id = single_row["schedule_id"].ToString();
                values.Master = mrd;
                values.permss_user = mrd.Dto.RecipientEmail;
                values.IsMasterReport = true;
                values.scheduled = true;
                values.questionnaire_id = "99999";
                values.schedule_id = "-1";
                values.schedule_master_id = mrd.Dto.MasterRptId.ToString();

                mailthread.generate_dataemail(values, useSeparateThread);
            }
        }
Ejemplo n.º 9
0
        private void queue_scheduled_reports(bool useSeparateThread)
        {
            DateTime today = DateTime.Today;	//Immediate Window: today=today.AddDays(-2d);
            int weekday = (int)today.DayOfWeek;

            Hashtable h_params = new Hashtable();
            h_params.Add("day", weekday);
            DataTable scheduled_exports = DB.execProc("select_scheduled_exports", h_params);

            DateTime w_from = today.AddDays(-7d);
            DateTime d_from = today.AddDays(-1d);
            //TODO Susann change to also recognize responses received after (milliseconds) 23:59:59,000
            //DateTime until = today.AddDays(-1d);
            DateTime until = today;
            //until = until.AddHours(23).AddMinutes(59).AddSeconds(59);

            //string pathtotempdir = Server.MapPath(utility.getParameter("path_to_temp"));
            string pathtotempdir = this.myPathToTempDir;

            foreach (DataRow single_row in scheduled_exports.Rows)
            {
                //queue up

                //create the values with the report settings
                report_values values = new report_values();
                values.permss_user = single_row["recipient_email_FK"].ToString();
                //values.permss_admin = bool.Parse(single_row["adminrole"].ToString());
                values.campaign_name = single_row["campaign_code_FK"].ToString();
                values.questionnaire_id = single_row["questionnaire_id"].ToString();

                values.questionnaire_creator_user = single_row["creator_user_FK"].ToString();
                values.questionnaire_business_owner = single_row["business_owner"].ToString();
                values.schedule_mode = single_row["schedule_mode"].ToString();
                values.schedule_day = single_row["schedule_day"].ToString();
                values.is_incremental_report = Convert.ToBoolean(single_row["is_incremental_report"]);
                
                if (single_row["schedule_mode"].ToString() == "d")
                {
                    values.from = d_from;
                }
                else
                {
                    values.from = w_from;
                }
                values.until = until;
                values.questionnaire_title = single_row["qid_title"].ToString();
                values.pathtotempdir = pathtotempdir;
                values.schedule_id = single_row["schedule_id"].ToString();
                values.schedule_master_id = "-1";
                values.scheduled = true;
                
                mailthread.generate_dataemail(values, useSeparateThread);
            }
        }
Ejemplo n.º 10
0
		private void queue_scheduled_reports()
		{
            DataTable failedReports = (DataTable)ViewState["failed_reports"];

			DateTime today = Calendar1.SelectedDate;	
			int weekday = (int)today.DayOfWeek;
			
			Hashtable h_params = new Hashtable();
			h_params.Add("day", weekday);
			DataTable scheduled_exports = DB.execProc("select_scheduled_exports", h_params);
            scheduled_exports.PrimaryKey = new DataColumn[] {scheduled_exports.Columns["schedule_id"]};

			DateTime w_from = today.AddDays(-7d);
			DateTime d_from = today.AddDays(-1d);
            //TODO Susann change to also recognize responses received after (milliseconds) 23:59:59,000
            //DateTime until = today.AddDays(-1d).AddHours(23d).AddMinutes(59d).AddSeconds(59d);
            DateTime until = today;
            
            string pathtotempdir = Server.MapPath(utility.getParameter("path_to_temp"));

			foreach (DataRow failedReport in failedReports.Rows)
            {
                DataRow foundrow = scheduled_exports.Rows.Find(failedReport["schedule_FK"].ToString());

                if (foundrow != null)
                {
                    //queue up

                    //create the values with the report settings
                    report_values values = new report_values();
                    values.permss_user = foundrow["recipient_email_FK"].ToString();
                    //values.permss_admin = bool.Parse(single_row["adminrole"].ToString());
                    values.campaign_name = foundrow["campaign_code_FK"].ToString();
                    values.questionnaire_id = foundrow["questionnaire_id"].ToString();

                    if (foundrow["schedule_mode"].ToString() == "d")
                    {
                        values.from = d_from;
                    }
                    else
                    {
                        values.from = w_from;
                    }
                    values.until = until;
                    values.questionnaire_title = foundrow["qid_title"].ToString();
                    values.pathtotempdir = pathtotempdir;
                    values.schedule_id = foundrow["schedule_id"].ToString();
                    values.schedule_master_id = "-1";
                    values.scheduled = true;

                    mailthread.generate_dataemail(values, true);
                }
            }
		}
Ejemplo n.º 11
0
        private void queue_scheduled_master_reports()
        {
            DataTable failedReports = (DataTable)ViewState["failed_reports"];

            DateTime today = Calendar1.SelectedDate;
            int weekday = (int)today.DayOfWeek;

            List<MasterReport> lst = MasterReport.GetSchMasterReport(weekday, null, null, UserType.Admin);
            DateTime w_from = today.AddDays(-7d);
            DateTime d_from = today.AddDays(-1d);
            DateTime until = today;

            string pathtotempdir = Server.MapPath(utility.getParameter("path_to_temp"));
            foreach (DataRow failedReport in failedReports.Rows)
            {
                if ("-1".Equals(failedReport["schedule_master_FK"].ToString())) continue;

                MasterReport mrd = lst.Find(o => o.Dto.MasterRptId.ToString() == failedReport["schedule_master_FK"].ToString());

                if (mrd != null)
                {
                    report_values values = new report_values();
                    mrd.Dto.MasterQ = MasterReport.GetMasterQuestions(mrd.Dto.MasterRptId);
                    if (mrd.Dto.ScheduleMode == ScheduleMode.Daily)
                    {
                        mrd.Dto.From = d_from;
                        values.from = d_from;
                    }
                    else
                    {
                        mrd.Dto.From = w_from;
                        values.from = w_from;
                    }
                    mrd.Dto.To = until;
                    values.until = until;
                    values.pathtotempdir = pathtotempdir;
                    values.Master = mrd;
                    values.permss_user = mrd.Dto.RecipientEmail;
                    values.IsMasterReport = true;
                    values.scheduled = true;
                    values.questionnaire_id = "99999";
                    values.schedule_id = "-1";
                    values.schedule_master_id = mrd.Dto.MasterRptId.ToString();

                    mailthread.generate_dataemail(values, true);
                }
            }
        }