public void StartJob(JobModel iJobModelOne)
        {
            BackupStatus = true;
            string dMailBody = "";

            string dSourceFolder = "";

            if (iJobModelOne.Source_Folder != "/")
            {
                dSourceFolder = "/" + iJobModelOne.Source_Folder;
            }
            if (iJobModelOne != null)
            {
                //Create Connection
                FTPClass iFtp = new FTPClass(@"ftp://" + iJobModelOne.Source_Address.ToString() + ":65224" + dSourceFolder, iJobModelOne.Source_Username, iJobModelOne.Source_Password);
                //Listed Directory
                /* Get Contents of a Directory with Detailed File/Directory Info */
                System.Threading.Thread.Sleep(2000);
                List <FileClass> iFileList = iFtp.directoryListDetailClass("/");
                ConsoleText(iJobModelOne.JobName + " Files Count " + iFileList.Count);
                List <FileClass> iFilterFile = new List <FileClass> {
                };

                foreach (var item in iFileList)
                {
                    DateTime dFileDate = Convert.ToDateTime(item.FileDate);
                    if (dStartDate < dFileDate && dFileDate <= dEndDate)
                    {
                        iFilterFile.Add(item);
                    }
                }
                ConsoleText(iJobModelOne.JobName + " Filtered Count " + iFilterFile.Count);
                LoadListFileClass(lstSource, iFilterFile);


                //Send Email After Backup
                if (iFilterFile.Count > 0)
                {
                    ConsoleText(iJobModelOne.JobName + " Sync Start  " + iFilterFile.Count);
                    dMailBody = StartSync(iJobModelOne, iFilterFile);
                    ConsoleText(iJobModelOne.JobName + " Sync Ended  " + iFilterFile.Count);
                    iClass.SendCustomMail(iMailClass, "Backup of " + iJobModelOne.JobName.ToString(), dMailHeader + dMailBody);
                    ConsoleText(iJobModelOne.JobName + " Email Sent  ");
                }

                if (iJobModelOne.Deleteold == true)
                {
                    //   DeleteFolder(iJobModelOne);
                }
            }
            BackupStatus = false;
        }
        public string StartSync(JobModel iJobModelOne, List <FileClass> iFileList)
        {
            List <FileClass> iComplete    = new List <FileClass> {
            };
            string  iCompleteStr          = "";
            Boolean overAllDownloadStatus = true;

            try
            {
                string dSourceFolder = "";
                if (iJobModelOne.Source_Folder != "/")
                {
                    dSourceFolder = "/" + iJobModelOne.Source_Folder;
                }
                if (iJobModelOne != null && iFileList != null)
                {
                    //Create Connection
                    FTPClass iFtp = new FTPClass(@"ftp://" + iJobModelOne.Source_Address.ToString() + ":65224" + dSourceFolder, iJobModelOne.Source_Username, iJobModelOne.Source_Password);
                    //Listed Directory
                    /* Get Contents of a Directory with Detailed File/Directory Info */
                    iFtp.ProgressBarCallback = new ProgressBarStatus(this.DisplayProgressBarValue);
                    int    FileCount = iFileList.Count();
                    int    i         = 1;
                    String dDestinationFolderName = iJobModelOne.Destination_Address + dFolderName;
                    //Check  if the Directory exist
                    if (iFileList.Count > 0)//Directory.Exists(dDestinationFolderName) == false)
                    {
                        ConsoleText(iJobModelOne.JobName + " Folder Created Start : " + dDestinationFolderName);
                        Directory.CreateDirectory(dDestinationFolderName);

                        foreach (var item in iFileList)
                        {
                            //pgBarLabel.Step = 2048;

                            DisplayText(lblFileName, item.FileName.ToString() + ":" + i + "/" + FileCount);
                            ConsoleText(iJobModelOne.JobName + " File Name  : " + item.FileName.ToString());
                            string downloadstatus = iFtp.downloadwithProgress(item.FileName.ToString(), dDestinationFolderName + "/" + item.FileName.ToString());
                            if (downloadstatus != "Complete Download : " + item.FileName.ToString())
                            {
                                overAllDownloadStatus = false;
                                break;
                            }
                            iComplete.Add(item);
                            iCompleteStr = iCompleteStr + i + " : " + item.FileName.ToString() + Environment.NewLine;
                            ConsoleText(iJobModelOne.JobName + " Download Status : " + downloadstatus);

                            i = i + 1;
                            //break;
                        }
                    }
                    else
                    {
                        ConsoleText(iJobModelOne.JobName + " Sync Empty Folder ");
                        iCompleteStr = "Backup Empty";
                    }
                    if (overAllDownloadStatus == false)
                    {
                        ConsoleText(iJobModelOne.JobName + " Sync Empty Folder ");
                        iCompleteStr = "Backup Empty";
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException.ToString());
            }
            LoadListFileClass(lstDestination, iComplete);
            BackupStatus = false;
            return(iCompleteStr);
        }