public List <OutboundFileResendGridModel> GetArchivedDetails(List <string> archivedFiles, int datasetId)
        {
            List <OutboundFileResendGridModel> grid = new List <OutboundFileResendGridModel>();

            using (_dbContext = string.IsNullOrEmpty(_connectionString) ? _dbContext : new ZionContext(_connectionString))
            {
                archivedFiles.ForEach(f =>
                {
                    OutboundFileResendGridModel g = new OutboundFileResendGridModel();
                    g.DatasetId     = datasetId;
                    g.FileName      = f;
                    var auditDetail = _dbContext.OutboundFileResendAudit.Where(o => o.DatasetId == datasetId &&
                                                                               o.FileName == f).OrderByDescending(outboundDetails => outboundDetails.CreatedDate).FirstOrDefault();
                    if (auditDetail != null)
                    {
                        g.LastResendDate = auditDetail.CreatedDate;
                    }
                    if (auditDetail == null)
                    {
                        g.LastResendDate = null;
                    }
                    g.ResendCount = _dbContext.OutboundFileResendAudit.Where(outboundDetails => outboundDetails.DatasetId == datasetId && g.FileName == outboundDetails.FileName).ToList().Count();
                    grid.Add(g);
                });
            }
            grid = grid.Where(g => g.DatasetId == datasetId).ToList();
            return(grid);
        }
Ejemplo n.º 2
0
        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));
        }