public void Execute(int id)
        {
            FTPUtils utils   = null;
            JobItem  jobItem = new JobItem();

            jobItem.StartDate = DateTime.UtcNow;
            jobItem.JobId     = id;
            jobItem.TaskName  = Name;
            try
            {
                var ftpConfig = _searvice.GetFtpConfig(FtpConfigurationType.PipelineOrder);
                utils = new FTPUtils(ftpConfig);
                utils.DownloadFile();
                if (utils.DownloadFileName == null)
                {
                    _taskResult = new dlxTaskResult()
                    {
                        IsSuccess    = false,
                        ErrorMessage = "Pipe Line Order Download Failed as file is not exists"
                    };
                    jobItem.Status      = false;
                    jobItem.Description = _taskResult.ErrorMessage;
                    jobItem.EndDate     = DateTime.UtcNow;
                    _searvice.JobItemLog(jobItem);
                }
                else
                {
                    _taskResult = new dlxTaskResult()
                    {
                        IsSuccess = true,
                        TaskData  = new dlxTaskData()
                        {
                            FilePath = utils.DownloadFileName
                        }
                    };
                    jobItem.Status      = true;
                    jobItem.Description = "Pipe Line Order Download Successful";
                    jobItem.EndDate     = DateTime.UtcNow;
                    _searvice.JobItemLog(jobItem);
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
                _taskResult = new dlxTaskResult()
                {
                    IsSuccess    = false,
                    ErrorMessage = "Pipe Line Order Download Failed",
                    TaskData     = new dlxTaskData()
                    {
                        FilePath = utils.DownloadFileName
                    }
                };
                jobItem.Status = false;
                //jobItem.Description = _taskResult.ErrorMessage;
                jobItem.Description = string.Format("Error: {0} Inner Exception: {1} Error Message: {2}", _taskResult.ErrorMessage, ex.InnerException == null ? "" : ex.InnerException.ToString(), ex.Message);
                jobItem.EndDate     = DateTime.UtcNow;
                _searvice.JobItemLog(jobItem);
            }
        }
예제 #2
0
        private List <string> getFtpDirectoryListing(firedumpdbDataSet.backup_locationsRow location, string path)
        {
            List <string>        filesindir = new List <string>();
            FTPCredentialsConfig ftpConfig  = new FTPCredentialsConfig();

            ftpConfig.id       = location.id;
            ftpConfig.host     = location.host;
            ftpConfig.port     = (int)location.port;
            ftpConfig.username = location.username;
            ftpConfig.password = location.password;
            if (location.usesftp == 1)
            {
                ftpConfig.useSFTP = true;
                ftpConfig.SshHostKeyFingerprint = location.ssh_key_fingerprint;
            }
            if (!string.IsNullOrEmpty(location.ssh_key))
            {
                ftpConfig.usePrivateKey  = true;
                ftpConfig.privateKeyPath = location.ssh_key;
            }
            FTPUtils ftputils = new FTPUtils(ftpConfig);

            ftputils.startSession();
            List <WinSCP.RemoteFileInfo> dirList = ftputils.getDirectoryListing(path, false, false);

            ftputils.disposeSession();
            foreach (WinSCP.RemoteFileInfo info in dirList)
            {
                filesindir.Add(info.FullName);
            }
            return(filesindir);
        }
        public void Execute(int id)
        {
            FTPUtils utils   = null;
            JobItem  jobItem = new JobItem();

            jobItem.StartDate = DateTime.UtcNow;
            jobItem.JobId     = id;
            jobItem.TaskName  = Name;
            try
            {
                var taskresult = this.PreviousTaskResult.TaskData;

                var ftpConfig = _searvice.GetFtpConfig(FtpConfigurationType.Announcement);
                utils = new FTPUtils(ftpConfig);
                bool success = utils.Archive(new FileInfo(taskresult.FilePath).Name);

                if (!success)
                {
                    _taskResult = new dlxTaskResult()
                    {
                        IsSuccess    = false,
                        ErrorMessage = "Announcement Archive Failed."
                    };
                    jobItem.Status      = false;
                    jobItem.Description = _taskResult.ErrorMessage;
                    jobItem.EndDate     = DateTime.UtcNow;
                    _searvice.JobItemLog(jobItem);
                }
                else
                {
                    _taskResult = new dlxTaskResult()
                    {
                        IsSuccess = true
                                    //TaskData = new dlxTaskData() { FilePath = utils.DownloadFileName }
                    };
                    jobItem.Status      = true;
                    jobItem.Description = "Announcement Archive Successful";
                    jobItem.EndDate     = DateTime.UtcNow;
                    _searvice.JobItemLog(jobItem);
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
                _taskResult = new dlxTaskResult()
                {
                    IsSuccess    = false,
                    ErrorMessage = "Announcement Archive Failed"
                };
                jobItem.Status = false;
                //jobItem.Description = _taskResult.ErrorMessage;
                jobItem.Description = string.Format("Error: {0} Inner Exception: {1} Error Message: {2}", _taskResult.ErrorMessage, ex.InnerException == null ? "" : ex.InnerException.ToString(), ex.Message);
                jobItem.EndDate     = DateTime.UtcNow;
                _searvice.JobItemLog(jobItem);
            };
        }
        public void Execute(int id)
        {
            FTPUtils utils   = null;
            JobItem  jobItem = new JobItem();

            jobItem.StartDate = DateTime.UtcNow;
            jobItem.JobId     = id;
            jobItem.TaskName  = Name;
            try
            {
                var ftpConfig = _searvice.GetFtpConfig(FtpConfigurationType.VID);
                utils = new FTPUtils(ftpConfig);
                utils.DownloadFile();
                if (utils.DownloadFileName == null)
                {
                    _taskResult = new dlxTaskResult()
                    {
                        IsSuccess    = false,
                        ErrorMessage = "VID Download Failed file is not exist"
                    };
                    jobItem.Status      = false;
                    jobItem.Description = _taskResult.ErrorMessage;
                    jobItem.EndDate     = DateTime.UtcNow;
                    _searvice.JobItemLog(jobItem);
                }
                else
                {
                    _taskResult = new dlxTaskResult()
                    {
                        IsSuccess = true,
                        TaskData  = new dlxTaskData()
                        {
                            FilePath = utils.DownloadFileName
                        }
                    };
                    jobItem.Status      = true;
                    jobItem.Description = "VID Download Successful";
                    jobItem.EndDate     = DateTime.UtcNow;
                    _searvice.JobItemLog(jobItem);
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
                _taskResult = new dlxTaskResult()
                {
                    IsSuccess    = false,
                    ErrorMessage = "VID Download Failed"
                };
                jobItem.Status      = false;
                jobItem.Description = _taskResult.ErrorMessage;
                jobItem.EndDate     = DateTime.UtcNow;
                _searvice.JobItemLog(jobItem);
            };
        }