Exemplo n.º 1
0
        /* Product XML Format*/

        ////public string ReadXML()
        ////{
        ////    XmlDataDocument xmldoc = new XmlDataDocument();
        ////    XmlNodeList xmlnode;
        ////    int i = 0;
        ////    string str = null;
        ////    string contstr = "";
        ////    FileStream fs = new FileStream(MainFileName, FileMode.Open, FileAccess.Read);
        ////    xmldoc.Load(fs);
        ////    xmlnode = xmldoc.GetElementsByTagName("Job");
        ////    for (i = 0; i <= xmlnode.Count - 1; i++)
        ////    {
        ////        xmlnode[i].ChildNodes.Item(0).InnerText.Trim();
        ////        str = xmlnode[i].ChildNodes.Item(0).InnerText.Trim() + "  " + xmlnode[i].ChildNodes.Item(1).InnerText.Trim() + "  " + xmlnode[i].ChildNodes.Item(2).InnerText.Trim();
        ////        contstr = contstr + str;
        ////    }
        ////    return contstr;
        ////}
        public List <JobModel> ReadXMLNew()
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(MainFileNamenew);
            XmlNodeList nodeList = xmlDoc.DocumentElement.SelectNodes("/Table/Job");

            List <JobModel> iJobName = new List <JobModel> {
            };

            foreach (XmlNode node in nodeList)
            {
                try
                {
                    JobModel jobName = new JobModel();
                    jobName.JobId               = Convert.ToInt32(node.SelectSingleNode("Job_id").InnerXml);
                    jobName.JobName             = node.SelectSingleNode("Job_name").InnerXml;
                    jobName.Source_Address      = node.SelectSingleNode("Source_Address").InnerXml;
                    jobName.Source_Folder       = node.SelectSingleNode("Source_Folder").InnerXml;
                    jobName.Source_Username     = node.SelectSingleNode("Source_UserName").InnerXml;
                    jobName.Source_Password     = node.SelectSingleNode("Source_Password").InnerXml;
                    jobName.Destination_Address = node.SelectSingleNode("Destination_Address").InnerXml;

                    jobName.Deleteold  = Convert.ToBoolean(node.SelectSingleNode("Deleteold").InnerXml);
                    jobName.DeleteDays = Convert.ToInt32(node.SelectSingleNode("DeleteDays").InnerXml);

                    jobName.Destination_UserName = ""; //node.SelectSingleNode("Destination_UserName").InnerXml;
                    jobName.Destination_Password = ""; //node.SelectSingleNode("Destination_Password").InnerXml;
                    iJobName.Add(jobName);
                    //MessageBox.Show(proID + " " + proName + " " + price);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
            return(iJobName);
        }
Exemplo n.º 2
0
        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);
        }