Esempio n. 1
0
        //private string path_to_settings = string.Empty;

        /// <summary>
        /// Constructor
        /// </summary>
        public Install()
        {
            InitializeComponent();

            logger.Log(LogLevel.Info, LogCode("Install.cs: Form Loading."));

            #region Load CustomSettings
            #region Get "My Documents" folder
            string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            path = Path.Combine(path, "FruPak_Settings");

            // Create folder if it doesn't already exist
            if (!Directory.Exists(path))
                Directory.CreateDirectory(path);
            #endregion

            // Initialize settings
            Settings = new PhantomCustomSettings();
            Settings.SettingsPath = Path.Combine(path, "FruPak.Phantom.config"); 
            Settings.EncryptionKey = "phantomKey";

            if (!File.Exists(Settings.SettingsPath))
            {
                Settings.Save();
                logger.Log(LogLevel.Info, LogCode("Install.cs: Default settings file created"));
            }
            // Load settings - Normally in Form_Load
            Settings.Load();
            local_path = Settings.Path_Local_Path;
            remote_path = Settings.Path_Remote_Path;
            AcroWrap_path = Settings.Path_AcroWrap_Path; // Don't actually need this here'
            copyAtStartup = Settings.CopyAtStartup;
            CopyDelayInMinutes = Settings.CopyDelayInMinutes;

            // These are accessible from the Logon form, so I don't need to reopen the settings file there
            // Was getting screwed up as the Main_Menu form is actually opened before the logon form,
            // but stays hidden.
            
            //FruPak.PF.Global.Global.Phantom_Dev_Mode = Settings.Phantom_Dev_Mode;
            
            //FruPak.PF.Global.Global.Phantom_Dev_Test = Settings.Phantom_Dev_Test_Mode;
            //FruPak.PF.Global.Global.Phantom_Dev_EnableResize = Settings.Phantom_Dev_EnableResize;

            logger.Log(LogLevel.Info, LogCode("Install.cs: Settings file opened."));

            //path_to_settings = Settings.Path_To_Settings;
            
            // Save settings - Normally in Form_Closing
            //Settings.Save();

            #endregion

        }
Esempio n. 2
0
        public static string send_mail()
        {
            string str_return = "";
            try
            {
                MailMessage oMsg = new MailMessage();


                foreach (string recipient in Recipient)
                {
                    oMsg.To.Add(recipient);
                }

                if (BCC_Email_Address.Count > 0)
                {
                    foreach (string bcc in BCC_Email_Address)
                    {
                        oMsg.Bcc.Add(bcc);
                    }
                }

                oMsg.From = new MailAddress(From_Email_Address);
                oMsg.Subject = Subject;
                oMsg.Body = message;
                oMsg.IsBodyHtml = IsBodyHtml;

                if (attachment.Count > 0 )
                {
                    foreach (string str_attachment in attachment)
                    {
                        try
                        {
                            Attachment mailAttachment = new Attachment(str_attachment);
                            oMsg.Attachments.Add(mailAttachment);
                        }
                        catch (Exception ex)
                        {
                            logger.Log(LogLevel.Debug, ex.Message);
                        }
                    }
                    attachment.Clear();
                }
                SmtpClient smtp = new SmtpClient();
                
                // Am pretty sure I'm not really needing to do al the load thingy, but until I refactor it all...

                #region Load CustomSettings
                #region Get "Application.StartupPath" folder
                string path = Application.StartupPath;
                #endregion

                // Initialize settings
                Settings = new PhantomCustomSettings();
                Settings.SettingsPath = Path.Combine(path, "FruPak.Phantom.config");
                Settings.EncryptionKey = "phantomKey";

                if (!File.Exists(Settings.SettingsPath))
                {
                    Settings.Save();
                    logger.Log(LogLevel.Info, LogCodeStatic("Default Phantom Settings file created (Sendmail)"));
                }
                // Load settings - Normally in Form_Load
                Settings.Load();

                logger.Log(LogLevel.Info, LogCodeStatic("Settings file opened."));

                #endregion


                //smtp.Host = "FRUPAK-SBS.frupak.local";
                smtp.Host = Settings.Path_SMTP_Host;
                smtp.Credentials = new System.Net.NetworkCredential(Network_UserId, Network_Password);

                smtp.Send(oMsg);
            }
            catch (Exception ex)
            {
                logger.Log(LogLevel.Trace, ex.Message);
                logger.Log(LogLevel.Trace, ex.InnerException);

                MessageBox.Show("Exception: " + 
                    ex.Message.ToString() + 
                    "\r\nInner Exception: " + 
                    ex.InnerException.ToString(), "Email Problem");

                str_return = ex.Message.ToString();
            }                    

            return str_return;
        }
Esempio n. 3
0
        public BLWO_Labels(int int_wo_Id, int int_C_User_id, bool bol_w_a)
        {
            InitializeComponent();
            logger.Log(LogLevel.Info, LogCode("BLWO_Labels - InitializeComponent"));

            // All this needs to be refactored into a single static class. Will do, but for now...

            #region Load CustomSettings
            #region Get "My Documents" folder
            string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            path = Path.Combine(path, "FruPak_Settings");

            // Create folder if it doesn't already exist
            if (!Directory.Exists(path))
                Directory.CreateDirectory(path);
            #endregion

            // Initialize settings
            Settings = new PhantomCustomSettings();
            Settings.SettingsPath = Path.Combine(path, "FruPak.Phantom.config");
            Settings.EncryptionKey = "phantomKey";

            if (!File.Exists(Settings.SettingsPath))
            {
                Settings.Save();
                // This should NEVER happen
                logger.Log(LogLevel.Info, LogCode("BLWO_Labels.cs: Default settings file created"));
            }
            // Load settings - Normally in Form_Load
            Settings.Load();

            logger.Log(LogLevel.Info, LogCode("BLWO_Labels.cs: Settings file opened."));

            #endregion

            int_Current_User_Id = int_C_User_id;
            int_Work_Order_Id = int_wo_Id;

            //populate Work Order Display
            woDisplay1.Work_Order_Id = int_wo_Id;
            woDisplay1.populate();
            DataSet ds_Get_Info;
            DataRow dr_Get_Info;

            ds_Get_Info = FruPak.PF.Data.AccessLayer.CM_Fruit_Variety.Get_Info_std(Convert.ToInt32(woDisplay1.Variety_Id.ToString()));
            for (int i = 0; i < Convert.ToInt32(ds_Get_Info.Tables[0].Rows.Count.ToString()); i++)
            {
                dr_Get_Info = ds_Get_Info.Tables[0].Rows[i];
                str_Variety_desc = dr_Get_Info["Description"].ToString();
            }
            ds_Get_Info.Dispose();

            //restrict access
            bol_write_access = bol_w_a;
            btn_Add.Enabled = bol_w_a;


            //if (FruPak.PF.Global.Global.bol_Testing == true)
            //{
            //    this.Text = "FruPak Process Factory - " + this.Text + " - Test Environment";
            //}
            //else
            //{
            //    this.Text = "FruPak Process Factory";
            //}

            populate_Combobox();

            AddColumnsProgrammatically();
            populate_datagridview();

            #region Log any interesting events from the UI to the CSV log file
            foreach (Control c in this.Controls)
            {
                if (c.GetType() == typeof(Button))
                {
                    c.Click += new EventHandler(this.Control_Click);
                }
                else if (c.GetType() == typeof(TextBox))
                {
                    c.Validated += new EventHandler(this.Control_Validated);
                }
                else if (c.GetType() == typeof(ComboBox))
                {
                    ComboBox cb = (ComboBox)c;
                    cb.SelectedValueChanged += new EventHandler(this.Control_SelectedValueChanged);
                }
                else if (c.GetType() == typeof(DateTimePicker))
                {
                    DateTimePicker dtp = (DateTimePicker)c;
                    dtp.ValueChanged += new EventHandler(this.Control_ValueChanged);
                }
                else if (c.GetType() == typeof(NumericUpDown))
                {
                    NumericUpDown nud = (NumericUpDown)c;
                    nud.ValueChanged += new EventHandler(this.Control_NudValueChanged);
                }
                else if (c.GetType() == typeof(CheckBox))
                {
                    CheckBox cb = (CheckBox)c;
                    cb.CheckedChanged += new EventHandler(this.Control_CheckedChanged);
                }

                else if (c.GetType() == typeof(FruPak.PF.Utils.UserControls.Customer))
                {
                    FruPak.PF.Utils.UserControls.Customer cust = (FruPak.PF.Utils.UserControls.Customer)c;
                    cust.CustomerChanged += new EventHandler(this.CustomerControl_CustomerChanged);
                }
            }
            #endregion

        }
Esempio n. 4
0
        /// <summary>
        /// Parameterless constructor to avoid designer error - Phantom 12/12/2014
        /// refers to Tablet_WO_Labels, which inherits from this class
        /// </summary>
        public WO_Labels()
        {
            #region Load CustomSettings
            #region Get "My Documents" folder
            string path = Application.StartupPath;
            // string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            //path = Path.Combine(path, "FruPak_Settings"); // Creates a subfolder

            // Create folder if it doesn't already exist
            //if (!Directory.Exists(path))
            //    Directory.CreateDirectory(path);
            #endregion

            // Initialize settings
            Settings = new PhantomCustomSettings();
            Settings.SettingsPath = Path.Combine(path, "FruPak.Phantom.config");
            Settings.EncryptionKey = "phantomKey";

            if (!File.Exists(Settings.SettingsPath))
            {
                Settings.Save();
                logger.Log(LogLevel.Info, LogCode("Default Phantom Settings file created"));
            }
            // Load settings - Normally in Form_Load
            Settings.Load();

            logger.Log(LogLevel.Info, LogCode("Settings file opened."));

            //local_path = Settings.Path_Local_Path;
            //remote_path = Settings.Path_Remote_Path;
            //path_to_settings = Settings.Path_To_Settings;

            // Save settings - Normally in Form_Closing
            //Settings.Save();

            #endregion

            #region Log any interesting events from the UI to the CSV log file
            foreach (Control c in this.Controls)
            {
                if (c.GetType() == typeof(Button))
                {
                    c.Click += new EventHandler(this.Control_Click);
                }
                else if (c.GetType() == typeof(TextBox))
                {
                    c.Validated += new EventHandler(this.Control_Validated);
                }
                else if (c.GetType() == typeof(ComboBox))
                {
                    ComboBox cb = (ComboBox)c;
                    cb.SelectedValueChanged += new EventHandler(this.Control_SelectedValueChanged);
                }
                else if (c.GetType() == typeof(DateTimePicker))
                {
                    DateTimePicker dtp = (DateTimePicker)c;
                    dtp.ValueChanged += new EventHandler(this.Control_ValueChanged);
                }
                else if (c.GetType() == typeof(NumericUpDown))
                {
                    NumericUpDown nud = (NumericUpDown)c;
                    nud.ValueChanged += new EventHandler(this.Control_NudValueChanged);
                }
                else if (c.GetType() == typeof(CheckBox))
                {
                    CheckBox cb = (CheckBox)c;
                    cb.CheckedChanged += new EventHandler(this.Control_CheckedChanged);
                }

                else if (c.GetType() == typeof(FruPak.PF.Utils.UserControls.Customer))
                {
                    FruPak.PF.Utils.UserControls.Customer cust = (FruPak.PF.Utils.UserControls.Customer)c;
                    cust.CustomerChanged += new EventHandler(this.CustomerControl_CustomerChanged);
                }
            }
            #endregion

        }
Esempio n. 5
0
        public static int Print()
        {
            try
            {
                if (wordApplication != null)
                {
                    int return_code = 0;
                    string default_printer = "";
                    //store current default printer - "Send To OneNote 2013"

                    // Changed to use the Phantom Settings class - The default behaviour prior to this was to use
                    // the default installed printer on the system. This gives more flexibility, but probably breaks
                    // MS Guidelines BN 2/02/2015

                    // Initialize settings
                    //#region Get "Application.StartupPath" folder
                    string path = Application.StartupPath;
                    //#endregion


                    Settings = new PhantomCustomSettings();
                    Settings.SettingsPath = Path.Combine(path, "FruPak.Phantom.config");
                    Settings.EncryptionKey = "phantomKey";

                    //if (!File.Exists(Settings.SettingsPath))
                    //{
                    //    Settings.Save();
                    //    //logger.Log(LogLevel.Info, LogCode("Default Phantom Settings file created"));
                    //}
                    //// Load settings - Normally in Form_Load
                    Settings.Load();
                    default_printer = Settings.Printer_Name;

                    // Reverted to the original, as it was causing problems on-site BN 4/02/2015
                    //default_printer = wordApplication.ActivePrinter;0

                    // This code has been in place since day 1.
                    //try
                    //{
                    //    // Is this it????
                    //    //change printer
                    //    wordApplication.ActivePrinter = Printer;
                    //}
                    //catch (Exception ex)
                    //{
                    //    logger.Log(LogLevel.Debug, ex.Message + " - " + ex.StackTrace);
                    //}


                    double version = Convert.ToDouble(wordApplication.Version, CultureInfo.InvariantCulture);
                    object oBackground = false;

                    FileInfo wordFile = new FileInfo(@FilePath + "\\" + FileName + GetDefaultExtension(wordApplication));
                    object fileObject = wordFile.FullName;
                    object outputfile = @FilePath + "\\" + FileName;

                    object oMissing = System.Reflection.Missing.Value;
                    object oTrue = true;

                    logger.Log(LogLevel.Info, LogCodeStatic("FruPak.PF.PrintLayer.Word: Word version = " + version.ToString()));

                    //Word 2007
                    if (version == 12.0)
                    {
                        // Found, Noted, but for now, do not touch - 12-01-2015 BN
                        // Hang on, isn't that path illegal anyway? Network paths ALWAYS have to be double quoted(backslashed) to be valid. ??? - 12-01-2015 BN
                        // Unless they are verbatim, which means that if you start with an at (@) symbol, the rest will be treated as a literal path:
                        // @"c:\test\test.txt"; is equal to "c:\\test\\test.txt';

                        //trial for 2007 start
                        FilePath = @"\\FruPak-SBS\PublicDocs\\FruPak\Client\Printing\Saved";
                        FileName = "Dave1";
                        return_code = FruPak.PF.PrintLayer.Word.SaveAS();


                        Microsoft.Office.Interop.Word.Application wordInstance = new Microsoft.Office.Interop.Word.Application();



                        Microsoft.Office.Interop.Word.Document doc = wordInstance.Documents.Open(ref fileObject, ref oMissing, ref oTrue, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
                        doc.Activate();
                        doc.PrintOut(oBackground, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing);


                        //end
                    }
                    else
                    {
                        try
                        {
                            // old code that worked for Robin, Glenys, and Dave's machines
                            wordApplication.PrintOut(oBackground);
                        }
                        catch (Exception ex)
                        {
                            logger.Log(LogLevel.Debug, ex.Message + " - " + ex.StackTrace);
                            return_code = 9;
                        }

                    }

                    //reset Default Printer
                    wordApplication.ActivePrinter = default_printer;

                    return return_code;
                }
                else
                {
                    logger.Log(LogLevel.Debug, "Print: wordApplication is null.");
                    //MessageBox.Show("Print: wordApplication is null.", "Print", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    //return_code = 0;

                    return 0;
                }
            }
            catch (COMException cex)
            {
                {
                    logger.Log(LogLevel.Debug, cex.Message + cex.InnerException.ToString());
                    logger.Log(LogLevel.Debug, "wordApplication.ActivePrinter: " + wordApplication.ActivePrinter);
                    logger.Log(LogLevel.Debug, "default_printer: " + Settings.Printer_Name);

                    return 0;
                }

            }
        }
Esempio n. 6
0
		private DConfig()
		{
			#region Load CustomSettings
			#region Get "My Documents" folder
			string path = Application.StartupPath;
			// string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
			//path = Path.Combine(path, "FruPak_Settings"); // Creates a subfolder

			// Create folder if it doesn't already exist
			//if (!Directory.Exists(path))
			//    Directory.CreateDirectory(path);
			#endregion

			// Initialize settings
			Settings = new PhantomCustomSettings();
			Settings.SettingsPath = Path.Combine(path, "FruPak.Phantom.config");
			Settings.EncryptionKey = "phantomKey";

			if (!File.Exists(Settings.SettingsPath))
			{
				Settings.Save();
				logger.Log(LogLevel.Info, LogCode("Default Phantom Settings file created"));
			}
			// Load settings - Normally in Form_Load
			Settings.Load();

			//logger.Log(LogLevel.Info, LogCode("Settings file opened.");

			//local_path = Settings.Path_Local_Path;
			//remote_path = Settings.Path_Remote_Path;
			//path_to_settings = Settings.Path_To_Settings;

			// Save settings - Normally in Form_Closing
			//Settings.Save();

			#endregion

			if (FruPak.PF.Global.Global.bol_Testing == true)
			{
				if (Settings.Phantom_Dev_Use_FruPak_SQL == true)
				{
					#region FRUPAK-SQL Test mode
					SQLAccessLayer.ConnectionString = @"Provider=sqloledb;" +
												"Server=" + Settings.TestMode_Server + ";" +
												"Database=" + Settings.TestMode_Database + ";" +
												"User Id=" + Settings.TestMode_User_Id + ";" +
												"Password="******";";

					logger.Log(LogLevel.Info, LogCode("Dev mode connection string = " + SQLAccessLayer.ConnectionString));

					#region Original hardcoded string
					//                SQLAccessLayer.ConnectionString = @"Provider=sqloledb;
					//				                                                Server=FRUPAK-SQL;
					//				                                                Database=Process_Factory_Test;
					//				                                                User Id=jobs;
					//				                                                Password=jobs;";
					
					#endregion
					#endregion

				}
				else
				{
					#region Bruce-Laptop Test mode
					SQLAccessLayer.ConnectionString = @"Provider=sqloledb;" +
												"Server=" + Settings.Phantom_Dev_TestMode_Server + ";" +
												"Database=" + Settings.Phantom_Dev_TestMode_Database + ";" +
												"User Id=" + Settings.Phantom_Dev_TestMode_User_Id + ";" +
												"Password="******";";

					logger.Log(LogLevel.Info, LogCode("Dev mode connection string = " + SQLAccessLayer.ConnectionString));

					#region Original hardcoded string
					//                SQLAccessLayer.ConnectionString = @"Provider=sqloledb;
					//												Server=Bruce-Laptop;
					//												Database=Process_Factory_Test;
					//												User Id=jobs;
					//												Password=jobs;"; 
					#endregion


					#endregion                
				}

			}
			else
			{
				if (Settings.Phantom_Dev_Use_FruPak_SQL == true)
				{
				   #region FRUPAK-SQL Production Mode
					SQLAccessLayer.ConnectionString = @"Provider=sqloledb;" +
												"Server=" + Settings.ProductionMode_Server + ";" +
												"Database=" + Settings.ProductionMode_Database + ";" +
												"User Id=" + Settings.ProductionMode_User_Id + ";" +
												"Password="******";";

					//logger.Log(LogLevel.Info, LogCode("Production mode connection string = " + SQLAccessLayer.ConnectionString);

					#region Original hardcoded string
					//                SQLAccessLayer.ConnectionString = @"Provider=sqloledb;
					//				                                                Server=FRUPAK-SQL;
					//				                                                Database=Process_Factory;
					//				                                                User Id=jobs;
					//				                                                Password=jobs;";

					#endregion
					#endregion
				}
				else
				{
 
					#region Bruce-Laptop Production Mode
					SQLAccessLayer.ConnectionString = @"Provider=sqloledb;" +
												"Server=" + Settings.Phantom_Dev_ProductionMode_Server + ";" +
												"Database=" + Settings.Phantom_Dev_ProductionMode_Database + ";" +
												"User Id=" + Settings.Phantom_Dev_ProductionMode_User_Id + ";" +
												"Password="******";";

					//logger.Log(LogLevel.Info, LogCode("Production mode connection string = " + SQLAccessLayer.ConnectionString);

					#region Original hardcoded string
					//                SQLAccessLayer.ConnectionString = @"Provider=sqloledb;
					//												Server=Bruce-Laptop;
					//												Database=Process_Factory;
					//												User Id=jobs;
					//												Password=jobs;"; 
					#endregion

					#endregion                
				}
			}
		}
Esempio n. 7
0
        private void Install_FormClosing(object sender, FormClosingEventArgs e)
        {
            Settings.Save();
            Settings = null;
            logger.Log(LogLevel.Info, LogCode("Install.cs: Install_FormClosing: Settings file saved."));

        }