public int ResendArchiveFiles(AppSettings appSettings, OutboundFileResendViewModel outboundFileResendViewModel) { int failedFileCount = 0; DatasetFileDetailsDataAccess dsDal = new DatasetFileDetailsDataAccess(_connectionString); var dsDetails = dsDal.GetDetailsByDataSetId(outboundFileResendViewModel.datasetId); dsDal = new DatasetFileDetailsDataAccess(_connectionString); string privateKey = dsDal.GetPrivateKey(); InterfaceMasterDataAccess interfaceMasterDal = new InterfaceMasterDataAccess(_connectionString); var interfaceMS = interfaceMasterDal.GetInterfaceDataById(outboundFileResendViewModel.interfaceId); InterfaceSftpDetailsDataAccess _interfaceSftpDetailsDAL = new InterfaceSftpDetailsDataAccess(_connectionString); var interfaceSftpDetails = _interfaceSftpDetailsDAL.GetDetailsByInterfaceId(outboundFileResendViewModel.interfaceId); failedFileCount = Utilities.CopyArchiveFiles(appSettings, interfaceSftpDetails.HostName, interfaceSftpDetails.Port, interfaceSftpDetails.UserName, interfaceSftpDetails.Password, privateKey, dsDetails.FolderLocation, outboundFileResendViewModel, interfaceMS.InterfaceType); return(failedFileCount); }
public List <OutboundFileResendGridModel> GetArchivedFiles(AppSettings appSettings, int datasetId, int interfaceId) { List <string> archiveFiles = new List <string>(); List <OutboundFileResendGridModel> outboundFileResendGrids = new List <OutboundFileResendGridModel>(); OutboundFileResendGridModel outboundFileResendGridModel = new OutboundFileResendGridModel(); DatasetFileDetailsDataAccess dsDal = new DatasetFileDetailsDataAccess(_connectionString); var dsDetails = dsDal.GetDetailsByDataSetId(datasetId); InterfaceSftpDetailsDataAccess _interfaceSftpDetailsDAL = new InterfaceSftpDetailsDataAccess(_connectionString); var interfaceSftpDetails = _interfaceSftpDetailsDAL.GetDetailsByInterfaceId(interfaceId); if (appSettings.Archival_Location["Location"] == InterfaceTypes.SFTP) { archiveFiles = Utilities.GetArchiveFilesListForSFTP(appSettings, datasetId); } else if (appSettings.Archival_Location["Location"] == InterfaceTypes.FTP) { archiveFiles = Utilities.GetArchiveFilesListForFTP(appSettings, datasetId); } else if (appSettings.Archival_Location["Location"] == InterfaceTypes.LocalNetwork) { archiveFiles = Utilities.GetArchiveFilesListForLocalNetwork(appSettings, datasetId); archiveFiles = archiveFiles.Select(f => f = f.Substring(f.LastIndexOf("\\") + 1)).ToList(); } if (archiveFiles.Count < 1) { outboundFileResendGridModel.DatasetId = null; outboundFileResendGridModel.FileName = null; outboundFileResendGridModel.LastResendDate = null; outboundFileResendGridModel.ResendCount = null; outboundFileResendGridModel.FailureReason = "FileNotFound"; outboundFileResendGrids.Add(outboundFileResendGridModel); return(outboundFileResendGrids); } else if (archiveFiles[0] == "FolderNotFound" || archiveFiles[0] == "ConnectionProblem" || archiveFiles[0] == "FileNotFound" || archiveFiles[0] == "UnauthorizedAccess") { outboundFileResendGridModel.DatasetId = null; outboundFileResendGridModel.FileName = null; outboundFileResendGridModel.LastResendDate = null; outboundFileResendGridModel.ResendCount = null; outboundFileResendGridModel.FailureReason = archiveFiles[0]; outboundFileResendGrids.Add(outboundFileResendGridModel); return(outboundFileResendGrids); } //filtering files based on full and delta file name //if(archiveFiles.Count > 0 && (archiveFiles[0] != "FolderNotFound" || archiveFiles[0] != "FileNotFound" || archiveFiles[0] == "ConnectionProblem")) else { archiveFiles = archiveFiles.Where(a => { if (dsDetails.FullFileName != null && dsDetails.FullFileName.Trim() != "" && a.StartsWith(dsDetails.FullFileName.Substring(0, dsDetails.FullFileName.LastIndexOf('.') >= 0 ? dsDetails.FullFileName.LastIndexOf('.') : dsDetails.FullFileName.Length))) { return(true); } else if (dsDetails.DeltaFileName != null && dsDetails.DeltaFileName.Trim() != "" && a.StartsWith(dsDetails.DeltaFileName.Substring(0, dsDetails.DeltaFileName.LastIndexOf('.') >= 0 ? dsDetails.DeltaFileName.LastIndexOf('.') : dsDetails.DeltaFileName.Length))) { return(true); } else { return(false); } }).ToList(); } return(_outgestionFileResendDAL.GetArchivedDetails(archiveFiles, datasetId)); }