public void GetErrorReportFileNameMethod(string erid, string processedDateAndTimeStamp)
        {
            //find the main group folder name
            GetGroupName gName = new GetGroupName();

            gName.GetGroupNameMethod(erid);
            string groupName = GetGroupName.GroupName;

            string errorDirectory = @"C:\Users\14025\Documents\File Consultants\Groups\" + groupName + @"\Import\Errors";

            List <string> groupFolderLocation = new List <string>();
            List <string> fileNameOnly        = new List <string>();
            List <string> tempFolderLocation  = new List <string>();



            foreach (string file in Directory.GetFiles(errorDirectory, "*" + processedDateAndTimeStamp + "*", SearchOption.AllDirectories))
            {
                groupFolderLocation.Add(file);

                string fNameOnly = Path.GetFileName(file);

                fileNameOnly.Add(fNameOnly);

                string destinationFile = @"C:\Users\14025\Documents\File Consultants\Brandon\Temp\" + fNameOnly;

                tempFolderLocation.Add(destinationFile);
            }



            //foreach (string dir in Directory.GetDirectories(errorDirectory))
            //{
            //    foreach ( string f in Directory.GetFiles(dir))
            //    {
            //        if (f.Contains(processedDateAndTimeStamp))
            //        {

            //            groupFolderLocation.Add(f);

            //            string fNameOnly = Path.GetFileName(f);

            //            fileNameOnly.Add(fNameOnly);

            //            string destinationFile = @"C:\Users\14025\Documents\File Consultants\Brandon\Temp\" + fNameOnly;

            //            tempFolderLocation.Add(destinationFile);
            //        }
            //    }

            //}


            ErrorReportGroupFolderLocations = groupFolderLocation;

            ErrorReportFileNamesOnly = fileNameOnly;

            ErrorReportTempFolderLocations = tempFolderLocation;
        }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string erid1 = textBox1.Text;

            GetStringBetweenString getString    = new GetStringBetweenString();
            GetGroupName           getGroupName = new GetGroupName();

            getGroupName.GetGroupNameMethod(erid1);
            string groupName = GetGroupName.GroupName;

            //search the archive folder for the erid
            string zippedCSVfiles = @"C:\Users\14025\Documents\File Consultants\Brandon\Archive\Backup_CSV\";

            string archivedFilesPath = @"C:\Users\14025\Documents\File Consultants\Brandon\Archive";

            string[] archivedFiles   = Directory.GetFiles(archivedFilesPath);
            string[] achivedCSVFiles = Directory.GetFiles(zippedCSVfiles);

            if (CSV_isChecked == true)
            {
                foreach (string zippedFilePath in achivedCSVFiles)
                {
                    if (zippedFilePath.Contains(erid1))
                    {
                        ZippedFilePath = zippedFilePath;

                        string zippedFileName = Path.GetFileName(zippedFilePath);
                        //MessageBox.Show(zippedFileName);
                        ZippedFileName           = zippedFileName;
                        FileNameWithoutExtension = getString.GetStringBetweenStringMethod(zippedFileName, "", ".");
                    }
                    else
                    {
                        //MessageBox.Show("The employer: "+groupName+" is not an archived implementation.","Employer is not Archived.",MessageBoxButtons.OK,MessageBoxIcon.Warning);
                    }
                }


                string pathOfFileToExtract1 = ZippedFilePath;
                //string groupNameWithoutSpaces = groupName.Replace(" ", "");
                string groupNameWithUnderscore1 = groupName.Replace(" - ", "_");
                string destinationFolderName1   = @"C:\Users\14025\Documents\File Consultants\Brandon\" + groupNameWithUnderscore1;



                DialogResult result1 = MessageBox.Show("Are you sure you want to resurrect this Implementation from the depths of Hades?\r\r" + groupName, "Resurrect this Implementation?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                if (result1 == DialogResult.Yes)
                {
                    //move contents of folder to new employer folder in Brandon Folder

                    if (!Directory.Exists(groupName))
                    {
                        Directory.CreateDirectory(destinationFolderName1);


                        try
                        {
                            System.IO.Compression.ZipFile.ExtractToDirectory(pathOfFileToExtract1, destinationFolderName1);
                        }
                        catch (System.IO.IOException ex)
                        {
                            //MessageBox.Show("Method: ZipFileMethod()\r\r" + ex, "Could not unzip/archive employer directory", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        catch (System.ArgumentException ex)
                        {
                            // MessageBox.Show("Method: ZipFileMethod()\r\r" + ex, "Could not zip/archive employer directory", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        catch (System.NotSupportedException ex)
                        {
                            // MessageBox.Show("Method: ZipFileMethod()\r\r" + ex, "Could not zip/archive employer directory", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                    }

                    //MessageBox.Show(destinationFolderName);
                    //get and read the rtf file
                    string[] unArchivedFiles   = Directory.GetFiles(destinationFolderName1);
                    string   sourceFileName    = @"C:\Users\14025\Documents\File Consultants\Brandon\" + groupNameWithUnderscore1 + @"\" + groupNameWithUnderscore1 + @"_Notes.rtf";
                    string   sourceFileNameTXT = @"C:\Users\14025\Documents\File Consultants\Brandon\" + groupNameWithUnderscore1 + @"\" + groupNameWithUnderscore1 + @"_Notes.txt";

                    RtfFileToTextFile = sourceFileNameTXT;
                    string notesFileName = @"C:\Users\14025\Documents\File Consultants\Brandon\Notes\" + groupNameWithUnderscore1 + @"_Notes.rtf";


                    foreach (string unArchivedFile in unArchivedFiles)
                    {
                        if (unArchivedFile.Contains(".rtf"))
                        {
                            //create a copy in .txt format, inside the unarchived folder
                            if (!File.Exists(sourceFileNameTXT))
                            {
                                try
                                {
                                    File.Copy(sourceFileName, sourceFileNameTXT);
                                }
                                catch (IOException ex)
                                {
                                    MessageBox.Show("File could not be copied because of the following error: \r\r" + ex, "File Could Not Be Copied.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                            else
                            {
                                MessageBox.Show("File already exists in the Notes folder", "File Could Not Be Moved.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }


                            //MessageBox.Show(unArchivedFile);

                            //move rtf file to the Notes folder

                            if (!File.Exists(notesFileName))
                            {
                                try
                                {
                                    File.Move(sourceFileName, notesFileName);
                                }
                                catch (IOException ex)
                                {
                                    MessageBox.Show("File could not be moved because of the following error: \r\r" + ex, "File Could Not Be Moved.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                            else
                            {
                                MessageBox.Show("File already exists in the Notes folder", "File Could Not Be Moved.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }


                    //get Implemenation Details from the text file



                    if (File.Exists(sourceFileNameTXT))
                    {
                        string allTextFileData = File.ReadAllText(sourceFileNameTXT);

                        if (allTextFileData.Contains("Details:"))
                        {
                            //MessageBox.Show(allTextFileData);

                            string isolateImpData = getString.GetStringBetweenStringMethod(allTextFileData, "Details:", "}");

                            MessageBox.Show(isolateImpData);



                            string impData = isolateImpData.Substring(12);
                            MessageBox.Show(impData);

                            //parse and store impData into a string array

                            string[] impDataArray = impData.Split(',');
                            ImpDataArray = impDataArray;
                        }
                    }
                    else
                    {
                        MessageBox.Show("File does not exist in folder", "Cannot Open File", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }



                    //add information back to Excel database

                    string ername    = ImpDataArray[0];
                    string erid2     = ImpDataArray[1];
                    string region    = ImpDataArray[2];
                    string segment   = ImpDataArray[3];
                    string effDate   = ImpDataArray[4];
                    string curProd   = ImpDataArray[5];
                    string addProd   = ImpDataArray[6];
                    string newImp    = ImpDataArray[7];
                    string AM_IM     = ImpDataArray[8];
                    string impDdline = ImpDataArray[9];
                    string sftpFlag  = ImpDataArray[10];

                    string inConName  = ImpDataArray[11];
                    string inConPhone = ImpDataArray[12];
                    string inConEmail = ImpDataArray[13];
                    string inConType  = ImpDataArray[14];

                    string exConName  = ImpDataArray[15];
                    string exConPhone = ImpDataArray[16];
                    string exConEmail = ImpDataArray[17];
                    string exConType  = ImpDataArray[18];
                    string fileType   = ImpDataArray[19];

                    string chkbx1  = ImpDataArray[20];
                    string chkbx2  = ImpDataArray[21];
                    string chkbx3  = ImpDataArray[22];
                    string chkbx4  = ImpDataArray[23];
                    string chkbx5  = ImpDataArray[24];
                    string chkbx6  = ImpDataArray[25];
                    string chkbx7  = ImpDataArray[26];
                    string chkbx8  = ImpDataArray[27];
                    string chkbx9  = ImpDataArray[28];
                    string chkbx10 = ImpDataArray[29];

                    string inConName2  = ImpDataArray[30];
                    string inConPhone2 = ImpDataArray[31];
                    string inConEmail2 = ImpDataArray[32];
                    string inConType2  = ImpDataArray[33];

                    string inConName3  = ImpDataArray[34];
                    string inConPhone3 = ImpDataArray[35];
                    string inConEmail3 = ImpDataArray[36];
                    string inConType3  = ImpDataArray[37];

                    string inConName4  = ImpDataArray[38];
                    string inConPhone4 = ImpDataArray[39];
                    string inConEmail4 = ImpDataArray[40];
                    string inConType4  = ImpDataArray[41];

                    string exConName2  = ImpDataArray[42];
                    string exConPhone2 = ImpDataArray[43];
                    string exConEmail2 = ImpDataArray[44];
                    string exConType2  = ImpDataArray[45];

                    string exConName3  = ImpDataArray[46];
                    string exConPhone3 = ImpDataArray[47];
                    string exConEmail3 = ImpDataArray[48];
                    string exConType3  = ImpDataArray[49];

                    string exConName4  = ImpDataArray[50];
                    string exConPhone4 = ImpDataArray[51];
                    string exConEmail4 = ImpDataArray[52];
                    string exConType4  = ImpDataArray[53];



                    ExcelDataBasePush db = new ExcelDataBasePush();
                    db.ExcelDataBasePushMethod(ername, erid2, region, segment,
                                               effDate, curProd, addProd, newImp,
                                               AM_IM, impDdline, sftpFlag,
                                               inConName, inConPhone, inConEmail, inConType,
                                               exConName, exConPhone, exConEmail, exConType, fileType,
                                               inConName2, inConPhone2, inConEmail2, inConType2,
                                               inConName3, inConPhone3, inConEmail3, inConType3,
                                               inConName4, inConPhone4, inConEmail4, inConType4,
                                               exConName2, exConPhone2, exConEmail2, exConType2,
                                               exConName3, exConPhone3, exConEmail3, exConType3,
                                               exConName4, exConPhone4, exConEmail4, exConType4,
                                               chkbx1, chkbx2, chkbx3, chkbx4, chkbx5, chkbx6,
                                               chkbx7, chkbx8, chkbx9, chkbx10);
                }
                else if (result1 == DialogResult.No)
                {
                }

                if (File.Exists(RtfFileToTextFile))
                {
                    File.Delete(RtfFileToTextFile);
                }
                else
                {
                    MessageBox.Show("Cannot delete .txt file. File does not exist in folder", "Cannot Delete File", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                //delete completed .zip file
                if (File.Exists(ZippedFilePath))
                {
                    File.Delete(ZippedFilePath);
                }
                else
                {
                    MessageBox.Show("Cannot delete .zip file. File does not exist in Archive folder", "Cannot Delete File", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                // refresh Implementation List
                Form_OpenImplementationList form1 = new Form_OpenImplementationList();
                form1.Show();
            }
            else
            {
                foreach (string zippedFilePath in archivedFiles)
                {
                    if (zippedFilePath.Contains(erid1))
                    {
                        ZippedFilePath = zippedFilePath;

                        string zippedFileName = Path.GetFileName(zippedFilePath);
                        //MessageBox.Show(zippedFileName);
                        ZippedFileName           = zippedFileName;
                        FileNameWithoutExtension = getString.GetStringBetweenStringMethod(zippedFileName, "", ".");
                    }
                    else
                    {
                        //MessageBox.Show("The employer: "+groupName+" is not an archived implementation.","Employer is not Archived.",MessageBoxButtons.OK,MessageBoxIcon.Warning);
                    }
                }


                string pathOfFileToExtract = ZippedFilePath;
                //string groupNameWithoutSpaces = groupName.Replace(" ", "");
                string groupNameWithUnderscore = groupName.Replace(" - ", "_");
                string destinationFolderName   = @"C:\Users\14025\Documents\File Consultants\Brandon\" + groupNameWithUnderscore;



                DialogResult result = MessageBox.Show("Are you sure you want to resurrect this Implementation from the depths of Hades?\r\r" + groupName, "Resurrect this Implementation?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                if (result == DialogResult.Yes)
                {
                    //move contents of folder to new employer folder in Brandon Folder

                    if (!Directory.Exists(groupName))
                    {
                        Directory.CreateDirectory(destinationFolderName);


                        try
                        {
                            System.IO.Compression.ZipFile.ExtractToDirectory(pathOfFileToExtract, destinationFolderName);
                        }
                        catch (System.IO.IOException ex)
                        {
                            //MessageBox.Show("Method: ZipFileMethod()\r\r" + ex, "Could not unzip/archive employer directory", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        catch (System.ArgumentException ex)
                        {
                            // MessageBox.Show("Method: ZipFileMethod()\r\r" + ex, "Could not zip/archive employer directory", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        catch (System.NotSupportedException ex)
                        {
                            // MessageBox.Show("Method: ZipFileMethod()\r\r" + ex, "Could not zip/archive employer directory", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                    }

                    //MessageBox.Show(destinationFolderName);
                    //get and read the rtf file
                    string[] unArchivedFiles   = Directory.GetFiles(destinationFolderName);
                    string   sourceFileName    = @"C:\Users\14025\Documents\File Consultants\Brandon\" + groupNameWithUnderscore + @"\" + groupNameWithUnderscore + @"_Notes.rtf";
                    string   sourceFileNameTXT = @"C:\Users\14025\Documents\File Consultants\Brandon\" + groupNameWithUnderscore + @"\" + groupNameWithUnderscore + @"_Notes.txt";

                    RtfFileToTextFile = sourceFileNameTXT;
                    string notesFileName = @"C:\Users\14025\Documents\File Consultants\Brandon\Notes\" + groupNameWithUnderscore + @"_Notes.rtf";


                    foreach (string unArchivedFile in unArchivedFiles)
                    {
                        if (unArchivedFile.Contains(".rtf"))
                        {
                            //create a copy in .txt format, inside the unarchived folder
                            if (!File.Exists(sourceFileNameTXT))
                            {
                                try
                                {
                                    File.Copy(sourceFileName, sourceFileNameTXT);
                                }
                                catch (IOException ex)
                                {
                                    MessageBox.Show("File could not be copied because of the following error: \r\r" + ex, "File Could Not Be Copied.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                            else
                            {
                                MessageBox.Show("File already exists in the Notes folder", "File Could Not Be Moved.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }


                            //MessageBox.Show(unArchivedFile);

                            //move rtf file to the Notes folder

                            if (!File.Exists(notesFileName))
                            {
                                try
                                {
                                    File.Move(sourceFileName, notesFileName);
                                }
                                catch (IOException ex)
                                {
                                    MessageBox.Show("File could not be moved because of the following error: \r\r" + ex, "File Could Not Be Moved.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                            else
                            {
                                MessageBox.Show("File already exists in the Notes folder", "File Could Not Be Moved.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }


                    //get Implemenation Details from the text file



                    if (File.Exists(sourceFileNameTXT))
                    {
                        string allTextFileData = File.ReadAllText(sourceFileNameTXT);

                        if (allTextFileData.Contains("Details:"))
                        {
                            //MessageBox.Show(allTextFileData);

                            string isolateImpData = getString.GetStringBetweenStringMethod(allTextFileData, "Details:", "}");

                            MessageBox.Show(isolateImpData);



                            string impData = isolateImpData.Substring(12);
                            MessageBox.Show(impData);

                            //parse and store impData into a string array

                            string[] impDataArray = impData.Split('|');
                            ImpDataArray = impDataArray;
                        }
                    }
                    else
                    {
                        MessageBox.Show("File does not exist in folder", "Cannot Open File", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }



                    //add information back to Excel database

                    string ername    = ImpDataArray[0];
                    string erid2     = ImpDataArray[1];
                    string region    = ImpDataArray[2];
                    string segment   = ImpDataArray[3];
                    string effDate   = ImpDataArray[4];
                    string curProd   = ImpDataArray[5];
                    string addProd   = ImpDataArray[6];
                    string newImp    = ImpDataArray[7];
                    string AM_IM     = ImpDataArray[8];
                    string impDdline = ImpDataArray[9];
                    string sftpFlag  = ImpDataArray[10];

                    string inConName  = ImpDataArray[11];
                    string inConPhone = ImpDataArray[12];
                    string inConEmail = ImpDataArray[13];
                    string inConType  = ImpDataArray[14];

                    string exConName  = ImpDataArray[15];
                    string exConPhone = ImpDataArray[16];
                    string exConEmail = ImpDataArray[17];
                    string exConType  = ImpDataArray[18];
                    string fileType   = ImpDataArray[19];

                    string chkbx1  = ImpDataArray[20];
                    string chkbx2  = ImpDataArray[21];
                    string chkbx3  = ImpDataArray[22];
                    string chkbx4  = ImpDataArray[23];
                    string chkbx5  = ImpDataArray[24];
                    string chkbx6  = ImpDataArray[25];
                    string chkbx7  = ImpDataArray[26];
                    string chkbx8  = ImpDataArray[27];
                    string chkbx9  = ImpDataArray[28];
                    string chkbx10 = ImpDataArray[29];

                    string inConName2  = ImpDataArray[30];
                    string inConPhone2 = ImpDataArray[31];
                    string inConEmail2 = ImpDataArray[32];
                    string inConType2  = ImpDataArray[33];

                    string inConName3  = ImpDataArray[34];
                    string inConPhone3 = ImpDataArray[35];
                    string inConEmail3 = ImpDataArray[36];
                    string inConType3  = ImpDataArray[37];

                    string inConName4  = ImpDataArray[38];
                    string inConPhone4 = ImpDataArray[39];
                    string inConEmail4 = ImpDataArray[40];
                    string inConType4  = ImpDataArray[41];

                    string exConName2  = ImpDataArray[42];
                    string exConPhone2 = ImpDataArray[43];
                    string exConEmail2 = ImpDataArray[44];
                    string exConType2  = ImpDataArray[45];

                    string exConName3  = ImpDataArray[46];
                    string exConPhone3 = ImpDataArray[47];
                    string exConEmail3 = ImpDataArray[48];
                    string exConType3  = ImpDataArray[49];

                    string exConName4  = ImpDataArray[50];
                    string exConPhone4 = ImpDataArray[51];
                    string exConEmail4 = ImpDataArray[52];
                    string exConType4  = ImpDataArray[53];



                    ExcelDataBasePush db = new ExcelDataBasePush();
                    db.ExcelDataBasePushMethod(ername, erid2, region, segment,
                                               effDate, curProd, addProd, newImp,
                                               AM_IM, impDdline, sftpFlag,
                                               inConName, inConPhone, inConEmail, inConType,
                                               exConName, exConPhone, exConEmail, exConType, fileType,
                                               inConName2, inConPhone2, inConEmail2, inConType2,
                                               inConName3, inConPhone3, inConEmail3, inConType3,
                                               inConName4, inConPhone4, inConEmail4, inConType4,
                                               exConName2, exConPhone2, exConEmail2, exConType2,
                                               exConName3, exConPhone3, exConEmail3, exConType3,
                                               exConName4, exConPhone4, exConEmail4, exConType4,
                                               chkbx1, chkbx2, chkbx3, chkbx4, chkbx5, chkbx6,
                                               chkbx7, chkbx8, chkbx9, chkbx10);
                }
                else if (result == DialogResult.No)
                {
                }

                if (File.Exists(RtfFileToTextFile))
                {
                    File.Delete(RtfFileToTextFile);
                }
                else
                {
                    MessageBox.Show("Cannot delete .txt file. File does not exist in folder", "Cannot Delete File", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                //delete completed .zip file
                if (File.Exists(ZippedFilePath))
                {
                    File.Delete(ZippedFilePath);
                }
                else
                {
                    MessageBox.Show("Cannot delete .zip file. File does not exist in Archive folder", "Cannot Delete File", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                // refresh Implementation List
                Form_OpenImplementationList form = new Form_OpenImplementationList();
                form.Show();
            }
        }
        private void listView1_DragDrop(object sender, DragEventArgs e)
        {
            string[] droppedFiles = (string[])e.Data.GetData(DataFormats.FileDrop, false);

            try
            {
                foreach (string droppedFile in droppedFiles)//iterate through all files dropped into the form
                {
                    if (droppedFile.Contains(".doc") || droppedFile.Contains(".docx") || droppedFile.Contains("Nonstandard") || droppedFile.Contains("NonstandardFileProcessRequest"))
                    {
                        NonstandardFormPathAndName = droppedFile;
                        //MessageBox.Show(nonstandardCurrentFilePath);
                        try
                        {
                            string nonstandardFileNameOnly = Path.GetFileName(NonstandardFormPathAndName);
                            NonstandardFormFileNameOnly = nonstandardFileNameOnly;
                            listView1.Items.Add(nonstandardFileNameOnly);

                            string sourceFileandPath = NonstandardFormPathAndName;

                            string destinationFileandPath = TempFolderPath + nonstandardFileNameOnly;

                            if (!File.Exists(destinationFileandPath))
                            {
                                File.Copy(NonstandardFormPathAndName, destinationFileandPath);
                            }
                            else
                            {
                                MessageBox.Show("File Already Exists");
                            }
                        }
                        catch (UnauthorizedAccessException ex)
                        {
                        }

                        //pull data from table
                        GetNonstandardFileData getData = new GetNonstandardFileData();
                        getData.GetNonstandardFileDataMethod(droppedFile);

                        string[] ERIDs = GetNonstandardFileData.EmployerID;

                        foreach (string erid in ERIDs)
                        {
                            //MessageBox.Show("ERID going inside Method: "+erid);

                            GetGroupName getGroupName = new GetGroupName();
                            getGroupName.GetGroupNameMethod(erid);
                            string groupName = GetGroupName.GroupName;
                            GroupName = groupName;


                            //MessageBox.Show("groupName coming outside of method: "+groupName);



                            //MessageBox.Show(GroupName);

                            //MessageBox.Show(GroupsFolderPath + GroupName);


                            if (Directory.Exists(GroupsFolderPath + GroupName + @"\DOCS"))
                            {
                                //MessageBox.Show("DOCS");
                                Process.Start(GroupsFolderPath + GroupName + @"\DOCS");
                                //Process.Start(@"https://etltrac.payflex.com/etl/");

                                //Thread.Sleep(6500);

                                //MOUSE_LeftClick leftClick = new MOUSE_LeftClick();
                                //leftClick.MOUSE_LeftClickMethod(3500, 145);

                                //SendKeys.Send(erid);
                                //SendKeys.Send("{ENTER}");
                            }
                            else if (Directory.Exists(GroupsFolderPath + GroupName + @"\Docs"))
                            {
                                //MessageBox.Show("Docs");

                                Process.Start(GroupsFolderPath + GroupName + @"\Docs");
                                //Process.Start(@"https://etltrac.payflex.com/etl/");

                                //Thread.Sleep(6500);

                                //MOUSE_LeftClick leftClick = new MOUSE_LeftClick();
                                //leftClick.MOUSE_LeftClickMethod(3500, 145);

                                //SendKeys.Send(erid);
                                //SendKeys.Send("{ENTER}");
                            }
                            else if (Directory.Exists(GroupsFolderPath + GroupName + @"\docs"))
                            {
                                //MessageBox.Show("docs");

                                //Process.Start(GroupsFolderPath + GroupName + @"\docs");
                                //Process.Start(@"https://etltrac.payflex.com/etl/");

                                //Thread.Sleep(3500);

                                //MOUSE_LeftClick leftClick = new MOUSE_LeftClick();
                                //leftClick.MOUSE_LeftClickMethod(3500, 145);

                                //SendKeys.Send(erid);
                                //SendKeys.Send("{ENTER}");
                            }
                        }



                        //MessageBox.Show(groupName);

                        //open docs folder
                    }
                    else if (droppedFile.Contains(".txt") || droppedFile.Contains(".pgp"))
                    {
                        NonstandardFilePathAndName = droppedFile;

                        string fileNameOnly    = Path.GetFileName(NonstandardFilePathAndName);
                        string sourceFile      = NonstandardFilePathAndName;
                        string destinationFile = TempFolderPath + fileNameOnly;
                        listView1.Items.Add(fileNameOnly);

                        if (!File.Exists(fileNameOnly))
                        {
                            try
                            {
                                File.Copy(sourceFile, destinationFile);


                                //rename destination file

                                string destinationFileNameOnly = Path.GetFileName(destinationFile);
                                string todaysDate = DateTime.Today.ToString("yyyyMMdd");

                                string     newFileNameWithDate = todaysDate + "_" + destinationFileNameOnly;
                                string     newNSFormFilePathAndNameWithDate = TempFolderPath + newFileNameWithDate + ".docx";
                                RenameFile rename = new RenameFile();
                                rename.RenameFileMethod(destinationFile, newFileNameWithDate);

                                //make an extra copy of the nonstandard form file
                                if (!File.Exists(newNSFormFilePathAndNameWithDate))
                                {
                                    File.Copy(NonstandardFormPathAndName, newNSFormFilePathAndNameWithDate);
                                }
                            }
                            catch (UnauthorizedAccessException ex)
                            {
                            }
                        }
                    }
                    if (droppedFile.Contains(".msg"))
                    {
                        //MessageBox.Show("Email File " + droppedFile);
                    }

                    this.BringToFront();
                }
            }
            catch (ArgumentNullException ex)
            {
            }
        }
        private void listView1_DragDrop(object sender, DragEventArgs e)
        {
            string[] droppedFiles = (string[])e.Data.GetData(DataFormats.FileDrop, false);
            try
            {
                foreach (string droppedFile in droppedFiles)//iterate through all files dropped into the form
                {
                    if (droppedFile.Contains(".dat"))
                    {
                        Process.Start(@"C:\Users\14025\Documents\File Consultants\Groups\Payment Adjustment\Import\");
                        PaymentAdjustmentFilePathAndName = droppedFile;
                        GetStringBetweenString getString = new GetStringBetweenString();



                        //MessageBox.Show(nonstandardCurrentFilePath);
                        try
                        {
                            PaymentAdjustmentFileNameOnly = Path.GetFileName(PaymentAdjustmentFilePathAndName);

                            listView1.Items.Add(PaymentAdjustmentFileNameOnly);



                            //copy to Temp folder

                            string sourceFileandPath = PaymentAdjustmentFilePathAndName;

                            string destinationFileandPath = TempFolderPath + PaymentAdjustmentFileNameOnly;

                            if (!File.Exists(destinationFileandPath))
                            {
                                File.Copy(PaymentAdjustmentFilePathAndName, destinationFileandPath);
                            }


                            //copy to Payment Adjustment folder

                            //destinationFileandPath = PaymentAdjustmentFolder + PaymentAdjustmentFileNameOnly;

                            //if (!File.Exists(destinationFileandPath))
                            //{
                            //    File.Copy(PaymentAdjustmentFilePathAndName, destinationFileandPath);

                            //}

                            //open DOCS folder and Temp folder

                            ERID = getString.GetStringBetweenStringMethod(PaymentAdjustmentFileNameOnly, "", "_");

                            GetGroupName getGroupName = new GetGroupName();
                            getGroupName.GetGroupNameMethod(ERID);
                            GroupName = GetGroupName.GroupName;


                            Process.Start(GroupsFolderPath + GroupName + @"\DOCS");
                            Process.Start(TempFolderPath);

                            //save filename in clipboard for copy/paste into script
                            Clipboard.SetText(PaymentAdjustmentFileNameOnly);
                        }
                        catch (UnauthorizedAccessException ex)
                        {
                        }
                    }
                    else if (droppedFile.Contains(".msg"))
                    {
                        EmailFilePathAndName = droppedFile;

                        EmailFileNameOnly = Path.GetFileName(EmailFilePathAndName);

                        listView1.Items.Add(EmailFileNameOnly);

                        //copy to temp folder with timestamp and pmtadj filename
                        string sourceFile      = EmailFilePathAndName;
                        string destinationFile = TempFolderPath + EmailFileNameOnly;

                        if (!File.Exists(destinationFile))
                        {
                            try
                            {
                                File.Copy(sourceFile, destinationFile);


                                //rename destination file

                                string destinationFileNameOnly = Path.GetFileName(destinationFile);
                                string todaysDate = DateTime.Today.ToString("yyyyMMdd");

                                string newFileNameWithDate = todaysDate + "_" + PaymentAdjustmentFileNameOnly;



                                RenameFile rename = new RenameFile();
                                rename.RenameFileMethod(destinationFile, newFileNameWithDate);

                                //make an extra copy of the Email file
                                //if (!File.Exists(newEmailFilePathAndNameWithDate))
                                //{
                                //    File.Copy(PaymentAdjustmentFilePathAndName, newEmailFilePathAndNameWithDate);

                                //}
                            }
                            catch (UnauthorizedAccessException ex)
                            {
                            }
                        }
                    }


                    this.BringToFront();
                }
            }
            catch (ArgumentNullException ex)
            {
            }
        }
        public void GetInputPSVFileNamesMethod(string erid, string processedDateAndTimeStamp)
        {
            //find the main group folder name
            GetGroupName gName = new GetGroupName();

            gName.GetGroupNameMethod(erid);
            string groupName = GetGroupName.GroupName;



            string exportDirectory = @"C:\Users\14025\Documents\File Consultants\Groups\" + groupName + @"\Export";



            List <string> groupFolderLocation = new List <string>();
            List <string> inputfileNameOnly   = new List <string>();
            List <string> outputfileNameOnly  = new List <string>();
            List <string> tempFolderLocation  = new List <string>();



            foreach (string file in Directory.GetFiles(exportDirectory, "*" + processedDateAndTimeStamp + "*", SearchOption.AllDirectories))
            {
                if (file.Contains(processedDateAndTimeStamp))
                {
                    groupFolderLocation.Add(file);

                    string fNameOnly = Path.GetFileName(file);



                    int count = fNameOnly.Count(x => x == '_');//counting the number of underscores

                    int indexOfFirstDash       = fNameOnly.IndexOf('-');
                    int indexOfFirstUnderscore = fNameOnly.IndexOf('_');


                    if (count >= 5 || indexOfFirstDash == 14)
                    {
                        outputfileNameOnly.Add(fNameOnly);
                        //MessageBox.Show("This file contains 4 undescores and is an input file. " + fNameOnly);
                    }
                    else if (count < 5 || indexOfFirstDash > 20)
                    {
                        inputfileNameOnly.Add(fNameOnly);
                        //MessageBox.Show("This file contains 4 undescores and is an input file. " + fNameOnly);
                    }

                    //else if (fNameOnly.Contains("-") && !fNameOnly.Contains("TEST"))
                    //{
                    //    outputfileNameOnly.Add(fNameOnly);
                    //    //MessageBox.Show("This file contains - and is an output file. "+fNameOnly);

                    //}
                    //else if (fNameOnly.Contains("-") && !fNameOnly.Contains("TEST"))
                    //{
                    //    outputfileNameOnly.Add(fNameOnly);
                    //    //MessageBox.Show("This file contains - and is an output file. "+fNameOnly);

                    //}



                    //MessageBox.Show("This file contains 5 underscores and is an output file. " + fNameOnly);



                    string destinationFile = @"C:\Users\14025\Documents\File Consultants\Brandon\Temp\" + fNameOnly;

                    tempFolderLocation.Add(destinationFile);
                }


                PSVFolderLocations = groupFolderLocation;

                InputPSVFileNamesOnly = inputfileNameOnly;

                OutputPSVFileNamesOnly = outputfileNameOnly;

                InputPSVTempFolderLocations = tempFolderLocation;
            }
        }