Esempio n. 1
0
		/// <summary>
		/// main method of the thread, generates reports
		/// </summary>
		private void generate_dataemail_processingqueue()
		{

            //Added by Phani on 16-04-2009 for RFG 1.9.2 release CaliberRM #PR126953 
            string myPathToTempDir = "";

			while (emailreports.Count != 0)
			{
				report_values emailreport = null;
                //Added Impersonation for RFG 1.9.2 release CaliberRM #PR141900
                Impersonator impersonate = null;
				try	
				{
                    
					emailreport = (report_values)emailreports.Dequeue();
					//Dequeued a waiting report
                    
                    //Added by Phani on 16-04-2009 for RFG 1.9.2 release CaliberRM #PR126953 
                    myPathToTempDir = emailreport.pathtotempdir;
					
                    //log dequeue in DB
					Hashtable h_params = new Hashtable();
					h_params.Add("entry_id", emailreport.queue_entry_id);
					h_params.Add("status", 2); //2 = dequeued
                    //for master report
                    //if (emailreport.IsMasterReport)
                    //{
                    //    int reportId = 0;
                    //    if (int.TryParse(emailreport.queue_entry_id, out reportId))
                    //    {
                    //        QueueFacade.SetMasterReportStatus(reportId, QueueStatus.Dequeued);
                    //    }
                    //}
                    //else
                    //{
                        DB.execProc("update_queued_report", h_params);
                    //}

                    //Added Impersonation for RFG 1.9.2 release CaliberRM #PR141900  
                    string username = utility.getParameter("cluster_usr_usernam");
                    string password = utility.getParameter("cluster_usr_password");
                    string domain = utility.getParameter("cluster_usr_domaim");

                    impersonate = new Impersonator(username, domain , password);
                    impersonate.Impersonate();
                    //for master report
                    if (!emailreport.IsMasterReport)
                        generate_dataemail_processingfile(emailreport);
                    else
                        generate_dataemail_processingfileMaster(emailreport);

                    impersonate.Undo();
				}
				catch (Exception ex)
				{
                    if (impersonate != null)
                    {
                        impersonate.Undo();
                    }
					if (emailreport != null)
					{
                        if (!emailreport.IsMasterReport && 
                            (ex is SmtpFailedRecipientException || ex is SmtpFailedRecipientsException))
                        {
                            try { processFailedEmails(ex, emailreport); } catch { }
                        }
                        else
                        {
                            send_error_email(emailreport, ex);
                        }

						if(emailreport.IsMasterReport)
                        {
                            int queueId = 0;
                            if (int.TryParse(emailreport.queue_entry_id, out queueId))
                            {
                            FailedMasterReportDto msg = new FailedMasterReportDto(emailreport.Master.Dto.MasterRptId,
                                emailreport.permss_user, emailreport.from, emailreport.until, queueId,
                                DateTime.Now.Date, ex.Message);
                            QueueFacade.SetFailureMessage(msg);
                            }
                        }
                        else
                        {
                            Hashtable h_params = new Hashtable();
						    h_params.Add("questionnaire_FK", emailreport.questionnaire_id);
						    h_params.Add("user_FK", emailreport.permss_user);
						    h_params.Add("from", emailreport.from);
						    h_params.Add("until", emailreport.until);
						    h_params.Add("entry_id", emailreport.queue_entry_id);
						    h_params.Add("error_reason", ex.Message);
                            h_params.Add("schedule_id", emailreport.schedule_id);

						    DB.execProc("insert_failed_report", h_params);
                        }
					}
				}
				Thread.Sleep(500);
			}

            //Added by Phani on 16-04-2009 for RFG 1.9.2 release CaliberRM #PR126953 
            if (dateString != DateTime.Today.ToShortDateString() && !String.IsNullOrEmpty(myPathToTempDir))
            {
                new tasks.DailyTasksRoutine().delete_old_temp_files(myPathToTempDir);
                dateString = DateTime.Today.ToShortDateString();
            }

		}
Esempio n. 2
0
        /// <summary>
        /// This method copies the created Siebel File into the shared folder in the cluster
        /// </summary>
        /// <returns></returns>
        private static bool copy_to_cluster()
        {
            bool success = false;
            string path_to_hpsb = utility.getParameter("path_to_hpsb");

            Impersonator impersonator = null;

            string username = utility.getParameter("cluster_usr_usernam");
            string password = utility.getParameter("cluster_usr_password");
            string domain = utility.getParameter("cluster_usr_domaim");

            impersonator = new Impersonator(username, domain, password);

            impersonator.Impersonate();

            if (File.Exists(path_to_hpsb + filename))
            {
                File.Delete(path_to_hpsb + filename);
            }

            File.Copy(path_to_tempdir + filename, path_to_hpsb + filename);

            impersonator.Undo();

            success = true;

            return success;
        }
Esempio n. 3
0
        private void generate_statisticsemail_processingqueue()
        {
            string myPathToTempDir = "";

            while (emailstatistics.Count != 0)
            {
                statistics_values values = null;
                Impersonator impersonate = null;
                try
                {

                    values = (statistics_values)emailstatistics.Dequeue();
                    myPathToTempDir = values.pathtotempdir;
                    
                    Hashtable h_params = new Hashtable();
                    h_params.Add("entry_id", values.queue_entry_id);
                    h_params.Add("status", 2); //2 = dequeued
                    
                    DB.execProc("update_queued_statistics", h_params);
                    
                    string username = utility.getParameter("cluster_usr_usernam");
                    string password = utility.getParameter("cluster_usr_password");
                    string domain = utility.getParameter("cluster_usr_domaim");

                    impersonate = new Impersonator(username, domain, password);
                    impersonate.Impersonate();
                    generate_statisticsemail_processingqueue(values);                    
                    impersonate.Undo();
                }
                catch (Exception ex)
                {
                    if (impersonate != null)
                    {
                        impersonate.Undo();
                    }
                    if (values != null)
                    {
                        send_error_email(values, ex);
                       
                        Hashtable h_params = new Hashtable();
                        h_params.Add("user_FK", values.permss_user);
                        h_params.Add("from", values.from);
                        h_params.Add("until", values.until);
                        h_params.Add("ordering", values.ordering);
                        h_params.Add("row_number", values.row_number);
                        h_params.Add("entry_id", values.queue_entry_id);
                        h_params.Add("error_reason", ex.Message);
                        
                        DB.execProc("insert_failed_statistics", h_params);
                    }
                }
                Thread.Sleep(500);
            }

            //Added by Phani on 16-04-2009 for RFG 1.9.2 release CaliberRM #PR126953 
            if (dateString != DateTime.Today.ToShortDateString() && !String.IsNullOrEmpty(myPathToTempDir))
            {
                new tasks.DailyTasksRoutine().delete_old_temp_files(myPathToTempDir);
                dateString = DateTime.Today.ToShortDateString();
            }
        }
Esempio n. 4
0
		protected void upload_btn_Click(object sender, System.EventArgs e)
		{
			bool siebel_bool = true;

//			if (siebel_file.Checked)
//			{
//				if (siebel_campaign.Text.ToString() == "")
//				{
//					siebel_bool = false;
//					siebel_error.Visible = true;
//				}
//			}

			if (campaignDropDown.SelectedIndex != 0 && file_path.Value != "" && siebel_bool)
			{		 
				//string file_format;

				if (edm.Checked == true)
				{
					file_format = "edm";
				}
				else
				{
					file_format = "dm";
				}

				//string file_source;

				if (siebel75.Checked == true)
				{
					file_source = "siebel75";
				}
				else
				{
					file_source = "siebel63";
				}

				//string save_as_path;
				string save_as_filename;
				string formatDateTimeString = "yyyy_MM_dd_hhmm";
				//.NET 1.1: string pathtotempdir = Server.MapPath(ConfigurationSettings.AppSettings["relativePathToTempdir"]);
                string pathtotempdir = Server.MapPath(utility.getParameter("path_to_temp"));
								
				save_as_filename = campaignDropDown.SelectedValue.ToString() + "__";
				save_as_filename += DateTime.Now.ToString(formatDateTimeString) + "_";
				save_as_filename += Path.GetFileNameWithoutExtension(file_path.PostedFile.FileName.ToString());
				save_as_filename += ".dat";
				
				save_as_path = Path.Combine(pathtotempdir, save_as_filename);

                string username = utility.getParameter("cluster_usr_usernam");
                string password = utility.getParameter("cluster_usr_password");
                string domain = utility.getParameter("cluster_usr_domaim");

                Impersonator impersonate = null;
                impersonate = new Impersonator(username, domain, password);
                impersonate.Impersonate();

				foreach(string file in Directory.GetFiles(pathtotempdir, campaignDropDown.SelectedValue.ToString() + "__*"))
				{
                    try
                    {
                        File.Delete(file);
                    }
                    catch
                    { 
                    }
				}
                
				try 
				{
					file_path.PostedFile.SaveAs(save_as_path);
					//Session["campaign"] = campaignDropDown.SelectedValue.ToString();
                    campaign = campaignDropDown.SelectedValue.ToString();
                    //Session["saved_file_path"] = save_as_path;
					//Session["format"] = file_format;
					//Session["source"] = file_source;
					//Session["siebel_campaign_code"] = siebel_campaign.Text.ToString();
					//Response.Redirect("process_file.aspx");
                    process_file();
				} 
				catch (Exception ex)
				{
                    error_text.Text = "Error by accessing directory - Code 001" + utility.newline;
					error_text.Text += ex.ToString();
					error_table.Visible = true;
				}

                impersonate.Undo();
			}
			else
			{
				if (campaignDropDown.SelectedIndex == 0)
				{
					validate_table_campaign.Visible = true;
				}
				
				if (file_path.Value == "")
				{
					validate_table_file.Visible = true;
				}
			}
		}