Example #1
0
        public void button1_Click(object sender, EventArgs e)
        {
            string Password  = "******";
            string skey      = @"\\6.1.1.144\Company\Development\BBS Definition Files\secring.skr";
            string pkey      = @"\\6.1.1.144\Company\Development\BBS Definition Files\pubring.skr";
            string TypeCheck = null;


            JobNumber = textBox1.Text;
            MailDate  = textBox2.Text;

            System.Windows.Forms.Application.DoEvents();



            if (textBox2.Text.Length == 0)
            {
                MessageBox.Show("Please Enter the Mailing Date"); // check if a mailing date has been entered
                this.Close();
                System.Windows.Forms.Application.Exit();
                Environment.Exit(0);
            }

            if (textBox2.Text.Length == 0)
            {
                MessageBox.Show("Please Enter the Job Number"); // check if a job number has been entered
                this.Close();
                System.Windows.Forms.Application.Exit();
                Environment.Exit(0);
            }

            // check if we are doing an autonet or onecall



            listBox1.Items.Add("Selecting File ....");             // keep user updated

            OpenFileDialog openFileDialog2 = new OpenFileDialog(); // open file dialog to select encrypted file

            openFileDialog2.Filter = "pgp files (*.pgp)|*.pgp|All files (*.*)|*.*";
            openFileDialog2.ShowDialog();

            EncryptedFiles = openFileDialog2.FileName; // get file path for PGP
            dir            = Path.GetDirectoryName(EncryptedFiles);

            tc = TypChk(TypeCheck, EncryptedFiles);    // check what type of file we are working with

            bool csv = EncryptedFiles.Contains("csv"); // check if working with csv and if we need to convert it to xls

            listBox1.Items.Add("Decrypting File ....");
            DecryptFiles(EncryptedFiles, Password, skey, JobNumber, csv); // Decrypt files
            listBox1.Items.Add("*DONE*");


            listBox1.Items.Add("Prepearing Mailing Job ....");
            BBS.BBSNow(EncryptedFiles, MailDate, JobNumber, csv, tc); // run BBS Job
            listBox1.Items.Add("*DONE*");

            listBox1.Items.Add("Creating Output File ....");
            CSV.CreateData(JobNumber, EncryptedFiles, tc); // add booklet barcode and job number to export file
            CSV.ReplaceTxt(EncryptedFiles, JobNumber, tc); //replace £
            listBox1.Items.Add("*DONE*");

            listBox1.Items.Add("Creating PDF File ....");
            Composer(dir); // prepare file for composer and place on server

            listBox1.Items.Add("Moving Files ....");
            Email.MoveFiles();  // Move Files from composer
            listBox1.Items.Add("*DONE*");

            EncryptFiles(); // Encrypt Files for email
            listBox1.Items.Add("Encrypt Files ....");
            listBox1.Items.Add("*DONE*");

            Email.SendEmail(); // Create and send email
            listBox1.Items.Add("Send Email ....");
            listBox1.Items.Add("*DONE*");
        }
Example #2
0
        private static readonly string InstallFlder = "C:\\SORTANDSAVE\\SYSTEM\\";             // set sort and save system folder


        public static void BBSNow(String en, String md, String jn, bool csv, string TypeCheck)
        {
            DateTime Newmd = DateTime.Parse(md);                                  // Mail Date
            string   ex;

            string dir = Path.GetDirectoryName(en);                              //Get directory we are working in

            Directory.CreateDirectory(dir + "\\" + "BBS\\");                     // create a folder for BBS Files



            // check if we are extracting a csv or xls

            if (csv == true)
            {
                // open excel import csv and save as xls
                CSV.ConvertCSV(jn, dir);
            }
            else
            {
                CSV.TocCsvthenXLS(jn, dir);
                //CSV.ConvertCSV(jn, dir);

                // Tidy up xls


                ex = ".xls";
            }


            BBSAPI.ResetMailingOptions();
            BBSAPI.SetInstallationFolder(InstallFlder);
            BBSAPI.SetOutputBase(dir + "\\" + "BBS\\");
            BBSAPI.SetWeight(30);
            BBSAPI.SetDescription(jn);
            BBSAPI.SetReference(jn);
            BBSAPI.SetCollectionDate(Newmd.ToString("yyyyMMdd"));
            BBSAPI.SetHandoverDate(Newmd.AddDays(1).ToString("yyyymmdd"));
            BBSAPI.SetInput(1, dir + "\\" + jn + ".xls");
            //BBSAPI.SetTable(1, "One Call Fulfillment Template -$");



            int    result = BBSAPI.RunMailingJob(UrisGroup.fn);
            string dataSr;
            string FlePth = dir + "\\" + jn + ".xls";

            // MessageBox.Show(result.ToString());

            //load and write to job file for mailing email

            if (UrisGroup.tc == "OneCall")
            {
                dataSr = @"""OneCall"",""OneCall""," + FlePth + @",""31/12/2199"",""'One Call Fulfillment Template -$'""";
                File.Copy(@"G:\Development\BBS Definition Files\URISOA.JOB", dir + "\\BBS\\URIS.JOB");
            }
            else
            {
                dataSr = @"""AutoNet"",""AutoNet""," + FlePth + @",""31/12/2199"",""'AG Tab$'""";  // 'AG Tab$'
                File.Copy(@"G:\Development\BBS Definition Files\URISOA.JOB", dir + "\\BBS\\URIS.JOB");
            }



            var MyIni = new IniFile(dir + "\\BBS\\URIS.JOB");

            MyIni.Write("Weight", "30", "InitialInfo");
            MyIni.Write("OutputBase", dir + "\\" + "BBS", "InitialInfo");
            MyIni.Write("Description", jn + " URIS", "InitialInfo");
            MyIni.Write("JobReference", jn + " URIS", "InitialInfo");
            MyIni.Write("CollectionDate", Newmd.ToString("dd/MM/yyyy"), "InitialInfo");
            MyIni.Write("HandoverDate", Newmd.AddDays(1).ToString("dd/MM/yyyy"), "InitialInfo");
            MyIni.Write("", dataSr, "Data Sources");



            string text = File.ReadAllText(dir + "\\BBS\\URIS.JOB");

            text = text.Replace(((char)34).ToString() + "=", ((char)34).ToString());
            text = text.Replace("=" + ((char)34).ToString(), ((char)34).ToString());
            File.WriteAllText(dir + "\\BBS\\URIS.JOB", text);

            // clean up files

            File.Delete(dir + "\\" + jn + ".IMD");
            File.Delete(dir + "\\" + jn + ".EXD");

            //File.Delete(dir + "\\BBS\\URIS.JOB");
            //File.Copy(UrisGroup.fn, dir + "\\BBS\\URIS.JOB");
        }