Esempio n. 1
0
        public void SerializeandSave(string fileName, SftpCridential records)
        {
            if (records == null)
            {
                return;
            }

            var serializer = new XmlSerializer(records.GetType());

            if (Path.GetDirectoryName(fileName) == null || !Directory.Exists(Path.GetDirectoryName(fileName)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(fileName));
            }

            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }

            var stream = new StreamWriter(fileName);

            serializer.Serialize(stream, records);

            stream.Close();
            stream.Dispose();
        }
Esempio n. 2
0
        private void PostFileOnClientSftp(SftpCridential sftpSettings, CorporateAccount account, string fileName, DateTime fromDate)
        {
            if (sftpSettings != null)
            {
                _logger.Info(string.Format("Sending Result Export File on {0} sftp", account.Tag));

                if (_ntspAccountIds != null && _ntspAccountIds.Contains(account.Id))
                {
                    var destinationPathOnSftp = string.Format(_destinationSftpFolderPdfPath, account.FolderName);

                    destinationPathOnSftp = destinationPathOnSftp + "/" + "results";

                    ExportFileOnClintSftp(fileName, destinationPathOnSftp, sftpSettings);
                }
                else if (_bcbsMnAccountId == account.Id)
                {
                    ExportFileOnClintSftp(fileName, _bcbsSftpFolderPath, sftpSettings);
                }
                else if (_settings.HcpNvAccountId == account.Id)
                {
                    var destinationPathOnSftp = (!string.IsNullOrEmpty(_settings.HcpNvSftpResultReportDownloadPath) ? _settings.HcpNvSftpResultReportDownloadPath + "/" : string.Empty) + "results";

                    ExportFileOnClintSftp(fileName, destinationPathOnSftp, sftpSettings);
                }
                else if (_settings.BcbsAlAccountId == account.Id)
                {
                    ExportFileOnClintSftp(fileName, _settings.BcbsAlSftpDownloadPath + "Reports", sftpSettings);
                }

                _logger.Info(string.Format("Sent Result Export File on {0} sftp", account.Tag));
            }
        }
        private void ExportResultInSftp(string fileName, string sourcePath, SftpCridential sftpCridential)
        {
            _logger.Info("Destination Path:  " + sftpCridential.SftpPath + "\\" + fileName);
            _logger.Info("Source Path: " + sourcePath);

            var processFtp = new ProcessFtp(_logger, sftpCridential.HostName, sftpCridential.UserName, sftpCridential.Password);

            processFtp.UploadSingleFile(sourcePath, sftpCridential.SftpPath, fileName);

            _logger.Info("Sending data to sftp succeded ");
        }
Esempio n. 4
0
 private bool ExportFileOnClientSftp(string sourcePath, string destination, SftpCridential cridential)
 {
     return(UploadSingleFile(sourcePath, destination, cridential.HostName, cridential.UserName, cridential.Password));
 }
Esempio n. 5
0
 private void ExportFileOnClintSftp(string sourcePath, string destination, SftpCridential cridential)
 {
     PostFile(sourcePath, destination, cridential.HostName, cridential.UserName, cridential.Password);
 }