示例#1
0
        private void UpdateEligibilityUploadDetail(EligibilityUpload eligibilityUploadDomain, List <EligibilityUploadLogViewModel> failedRecordsList, string fileName)
        {
            if (failedRecordsList.Any())
            {
                try
                {
                    var location       = _mediaRepository.GetEligibilityUploadMediaFileLocation();
                    var failedFilePath = location.PhysicalPath + Path.GetFileNameWithoutExtension(fileName) + "_Failed.csv";
                    var exporter       = ExportableDataGeneratorProcessManager <ViewModelBase, ModelFilterBase> .GetCsvExporter <EligibilityUploadLogViewModel>();

                    WriteCsv(failedFilePath, exporter, failedRecordsList);
                    var failedRecords = new FileInfo(failedFilePath);
                    var file          = new File
                    {
                        Path       = failedRecords.Name,
                        FileSize   = failedRecords.Length,
                        Type       = FileType.Csv,
                        UploadedBy = new OrganizationRoleUser(1),
                        UploadedOn = DateTime.Now
                    };
                    file = _fileRepository.Save(file);
                    eligibilityUploadDomain.FailedUploadCount = failedRecordsList.Count();
                    eligibilityUploadDomain.LogFileId         = file.Id;
                }
                catch (Exception ex)
                {
                    _logger.Error("Exception Raised while creating failed records CSV\n message: " + ex.Message + " stacktrace: " + ex.StackTrace);
                }
            }
            _eligibilityUploadRepository.Save(eligibilityUploadDomain);
        }
        private void SaveFileInfoForCsvUpload(HealthPlanCallQueueCriteriaEditModel model, HealthPlanCallQueueCriteria criteria)
        {
            if (!model.UploadFileName.IsNullOrEmpty())
            {
                var file  = new FileInfo(_mediaRepository.GetTempMediaFileLocation().PhysicalPath + model.UploadFileName);
                var files = new File
                {
                    Path       = file.Name,
                    FileSize   = file.Length,
                    Type       = FileType.Csv,
                    UploadedBy = new OrganizationRoleUser(_sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId),
                    UploadedOn = file.CreationTime,
                    IsArchived = false
                };
                files = _fileRepository.Save(files);

                var healthPlanCriteriaAssignmentUpload = new HealthPlanCriteriaAssignmentUpload
                {
                    FileId     = files.Id,
                    UploadTime = file.CreationTime,
                    UploadedByOrgRoleUserId = _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId,
                    CriteriaId = criteria.Id
                };
                _healthPlanCriteriaAssignmentUploadRepository.Save(healthPlanCriteriaAssignmentUpload);
                model.UploadFileName = null;
                System.IO.File.Copy(_mediaRepository.GetTempMediaFileLocation().PhysicalPath + file.Name, _mediaRepository.GetMassAgentAssignmentUploadMediaFileLocation().PhysicalPath + file.Name);
            }
        }
        private long GenerateFailedCustomerLogFile(IEnumerable <MergeCustomerUploadLog> failedCustomerList, string fileName)
        {
            try
            {
                var location       = _mediaRepository.GetMergeCustomerUploadMediaFileLocation();
                var failedFilePath = location.PhysicalPath + Path.GetFileNameWithoutExtension(fileName) + "_FailedCustomer.csv";

                var modelData = Mapper.Map <IEnumerable <MergeCustomerUploadLog>, IEnumerable <MergeCustomerUploadLogViewModel> >(failedCustomerList);

                var exporter = ExportableDataGeneratorProcessManager <ViewModelBase, ModelFilterBase> .GetCsvExporter <MergeCustomerUploadLogViewModel>();

                WriteCsv(failedFilePath, exporter, modelData);

                var failedRecords = new FileInfo(failedFilePath);

                var file = new File
                {
                    Path       = failedRecords.Name,
                    FileSize   = failedRecords.Length,
                    Type       = FileType.Csv,
                    UploadedBy = new OrganizationRoleUser(1),
                    UploadedOn = DateTime.Now
                };

                file = _fileRepository.Save(file);
                return(file.Id);
            }
            catch (Exception ex)
            {
                _logger.Error("Error while creating failed customers log  file \n message: " + ex.Message + " stacktrace: " + ex.StackTrace);
            }

            return(0);
        }
示例#4
0
        private void UpdateMedicationUploadDetail(MedicationUpload medicationUpload, IReadOnlyCollection <MedicationUploadLog> failedRecordsList, string fileName)
        {
            if (failedRecordsList.Any())
            {
                try
                {
                    var location       = _mediaRepository.GetMedicationUploadMediaFileLocation();
                    var failedFilePath = location.PhysicalPath + Path.GetFileNameWithoutExtension(fileName) + "_Failed.csv";

                    var modelData = Mapper.Map <IEnumerable <MedicationUploadLog>, IEnumerable <MedicationUploadLogViewModel> >(failedRecordsList);

                    var exporter = ExportableDataGeneratorProcessManager <ViewModelBase, ModelFilterBase> .GetCsvExporter <MedicationUploadLogViewModel>();

                    WriteCsv(failedFilePath, exporter, modelData);

                    var failedRecords = new FileInfo(failedFilePath);

                    var file = new File
                    {
                        Path       = failedRecords.Name,
                        FileSize   = failedRecords.Length,
                        Type       = FileType.Csv,
                        UploadedBy = new OrganizationRoleUser(1),
                        UploadedOn = DateTime.Now
                    };

                    file = _fileRepository.Save(file);
                    medicationUpload.FailedUploadCount = failedRecordsList.Count();
                    medicationUpload.LogFileId         = file.Id;
                }
                catch (Exception ex)
                {
                    _logger.Error("Exception raised while creating failed customer records \n Message: " + ex.Message + "\n\tStack trace: " + ex.StackTrace);
                }
            }
            try
            {
                _medicationUploadRepository.Save(medicationUpload);
            }
            catch (Exception ex)
            {
                _logger.Error("Exception raised while saving medicationUpload \n Message: " + ex.Message + "\n\tStack trace: " + ex.StackTrace);
            }
        }
示例#5
0
        private File SaveLogFile(string logFilePath, StringBuilder csvStringBuilder)
        {
            WriteCsv(logFilePath, csvStringBuilder);

            var failedRecords = new FileInfo(logFilePath);

            var file = new File
            {
                Path       = failedRecords.Name,
                FileSize   = failedRecords.Length,
                Type       = FileType.Csv,
                UploadedBy = new OrganizationRoleUser(1),
                UploadedOn = DateTime.Now
            };

            file = _fileRepository.Save(file);

            return(file);
        }
示例#6
0
        private void SaveFile(ExportableReportsQueue exportableReportsQueue, string fileName)
        {
            var filePath = _exportableMediaLocation.PhysicalPath + fileName;
            var fileInfo = new FileInfo(filePath);

            var file = new File
            {
                Path       = fileName,
                FileSize   = fileInfo.Length,
                Type       = FileType.Compressed,
                UploadedBy = new OrganizationRoleUser(exportableReportsQueue.RequestedBy),
                UploadedOn = DateTime.Now
            };

            file = _fileRepository.Save(file);

            exportableReportsQueue.FileId = file.Id;

            UpdateExportReportEndTimeAndStaus(exportableReportsQueue, (long)ExportableReportStatus.Completed);
        }
        private void UpdateRapsUploadDetail(RapsUpload rapsUpload, List <RapsUploadLog> failedCustomerList, string fileName)
        {
            if (failedCustomerList.Any())
            {
                try
                {
                    var location       = _mediaRepository.GetRapsUploadMediaFileLocation();
                    var failedFilePath = location.PhysicalPath + Path.GetFileNameWithoutExtension(fileName) + "_FailedRaps.csv";

                    var modelData = Mapper.Map <IEnumerable <RapsUploadLog>, IEnumerable <RapsUploadLogViewModel> >(failedCustomerList);

                    var exporter = ExportableDataGeneratorProcessManager <ViewModelBase, ModelFilterBase> .GetCsvExporter <RapsUploadLogViewModel>();

                    WriteCsv(failedFilePath, exporter, modelData);

                    var failedRecords = new FileInfo(failedFilePath);

                    var file = new File
                    {
                        Path       = failedRecords.Name,
                        FileSize   = failedRecords.Length,
                        Type       = FileType.Csv,
                        UploadedBy = new OrganizationRoleUser(1),
                        UploadedOn = DateTime.Now
                    };

                    file = _fileRepository.Save(file);
                    rapsUpload.FailedUploadCount = failedCustomerList.Count();
                    rapsUpload.LogFileId         = file.Id;
                }
                catch (Exception ex)
                {
                    _logger.Error("exception Raised While Creating Failed Customer Records \n message: " + ex.Message + " stack trace: " + ex.StackTrace);
                }
            }

            _rapsUploadRepository.Save(rapsUpload);
        }
示例#8
0
        private void UpdateStaffScheduleUploadDetail(StaffEventScheduleUpload staffEventScheduleUploadDomain, List <StaffEventScheduleUploadLogViewModel> failedRecordsList, string fileName,
                                                     IEnumerable <StaffEventScheduleUploadLog> staffEventScheduleUploadLogCollection)
        {
            if (failedRecordsList.Any())
            {
                try
                {
                    var location       = _mediaRepository.GetStaffScheduleUploadMediaFileLocation();
                    var failedFilePath = location.PhysicalPath + Path.GetFileNameWithoutExtension(fileName) + "_Failed.csv";
                    var exporter       = ExportableDataGeneratorProcessManager <ViewModelBase, ModelFilterBase> .GetCsvExporter <StaffEventScheduleUploadLogViewModel>();

                    WriteCsv(failedFilePath, exporter, failedRecordsList);
                    var failedRecords = new FileInfo(failedFilePath);
                    var file          = new File
                    {
                        Path       = failedRecords.Name,
                        FileSize   = failedRecords.Length,
                        Type       = FileType.Csv,
                        UploadedBy = new OrganizationRoleUser(1),
                        UploadedOn = DateTime.Now
                    };
                    file = _fileRepository.Save(file);
                    staffEventScheduleUploadDomain.FailedUploadCount = failedRecordsList.Count();
                    staffEventScheduleUploadDomain.LogFileId         = file.Id;

                    if (!staffEventScheduleUploadLogCollection.IsNullOrEmpty())
                    {
                        staffEventScheduleUploadLogCollection.ForEach(x => x.UploadId = staffEventScheduleUploadDomain.Id);
                        _staffEventScheduleUploadLogRepository.Save(staffEventScheduleUploadLogCollection);
                    }
                }
                catch (Exception ex)
                {
                    _logger.Error("Exception Raised while creating failed records CSV\n message: " + ex.Message + " stacktrace: " + ex.StackTrace);
                }
            }
            _staffEventScheduleUploadRepository.Save(staffEventScheduleUploadDomain);
        }
示例#9
0
        public JsonResult CreateResultArchive(string fileName, long fileSize)
        {
            var file = new File
            {
                Path       = fileName,
                Type       = FileType.Compressed,
                FileSize   = fileSize,
                UploadedBy = new OrganizationRoleUser(_session.UserSession.CurrentOrganizationRole.OrganizationRoleUserId),
                UploadedOn = DateTime.Now
            };

            file = _fileRepository.Save(file);

            var rapsUpload = new RapsUpload
            {
                FileId     = file.Id,
                UploadTime = DateTime.Now,
                StatusId   = (long)RapsUploadStatus.UploadStarted,
                UploadedBy = _session.UserSession.CurrentOrganizationRole.OrganizationRoleUserId
            };

            rapsUpload = _rapsUploadRepository.Save(rapsUpload);

            //update the file name
            file.Path = _fileHelper.AddPostFixToFileName(file.Path, rapsUpload.Id.ToString());
            _fileRepository.Save(file);


            var editModel = new RapsFileUploadEditModel
            {
                File = file,
                Id   = rapsUpload.Id
            };

            return(Json(editModel, JsonRequestBehavior.AllowGet));
        }
示例#10
0
        public ActionResult ScheduleUpload(HttpPostedFileBase scheduleUploadFile)
        {
            var model = new StaffEventScheduleUploadViewModel
            {
                FeedbackMessage   = new FeedbackMessageModel(),
                SampleCsvMediaUrl = _mediaRepository.GetSamplesLocation().Url + "StaffEventScheduleUploadSample.csv"
            };

            try
            {
                if (Request.Files.Count < 1 || scheduleUploadFile == null)
                {
                    model.FeedbackMessage = FeedbackMessageModel.CreateFailureMessage("No file has been uploaded. Please upload a csv file.");
                    return(View(model));
                }

                HttpPostedFileBase file = Request.Files[0];
                var fileExtension       = file.FileName.Split('.');
                if ((fileExtension.Length >= 2 && fileExtension[fileExtension.Length - 1].ToLower() != "csv") || fileExtension.Length < 2)
                {
                    model.FeedbackMessage = FeedbackMessageModel.CreateFailureMessage("File uploaded is not a CSV");
                    return(View(model));
                }

                var uploadMediaLocation = _mediaRepository.GetStaffScheduleUploadMediaFileLocation();

                var physicalPath     = uploadMediaLocation.PhysicalPath;
                var fileUploadedName = (Path.GetFileNameWithoutExtension(file.FileName) + Path.GetExtension(file.FileName)).Replace("'", "").Replace("&", "");
                var fileName         = (Path.GetFileNameWithoutExtension(fileUploadedName) + "_" + DateTime.Now.ToString("MMddyyyyhhmmss") + Path.GetExtension(fileUploadedName)).Replace("'", "").Replace("&", "");

                var fullPath = physicalPath + fileName;

                try
                {
                    file.SaveAs(fullPath);
                }
                catch (Exception ex)
                {
                    _logger.Error(string.Format("Staff Event Schedule Upload\nException occurred while saving file on server. FileName:{0} Path: {1}", fileUploadedName, fullPath));
                    _logger.Error(string.Format("Exception message: {0}\n\tStackTrace:{1}", ex.Message, ex.StackTrace));
                    model.FeedbackMessage = FeedbackMessageModel.CreateFailureMessage("Some internal error occurred");
                    return(View(model));
                }

                var staffScheduleTable = _csvReader.ReadWithTextQualifier(fullPath);
                if (staffScheduleTable.Rows.Count == 0)
                {
                    model.FeedbackMessage = FeedbackMessageModel.CreateFailureMessage("Uploaded file has no data.");

                    return(View(model));
                }

                var columns            = staffScheduleTable.Columns.Cast <DataColumn>().Select(x => x.ColumnName).ToArray();
                var missingColumnNames = CheckAllScheduleUploadColumnExist(columns);
                if (!string.IsNullOrEmpty(missingColumnNames))
                {
                    model.FeedbackMessage = FeedbackMessageModel.CreateFailureMessage("Missing Column Name(s) : " + missingColumnNames);

                    return(View(model));
                }

                var files = new File
                {
                    Path       = fileName,
                    FileSize   = file.ContentLength,
                    Type       = FileType.Csv,
                    UploadedBy = new OrganizationRoleUser(_sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId),
                    UploadedOn = DateTime.Now
                };

                try
                {
                    files = _fileRepository.Save(files);
                }
                catch (Exception ex)
                {
                    _logger.Error(string.Format("Staff Event Schedule Upload\nException occurred while saving info in File table."));
                    _logger.Error(string.Format("Exception message: {0}\n\tStackTrace:{1}", ex.Message, ex.StackTrace));

                    model.FeedbackMessage = FeedbackMessageModel.CreateFailureMessage("Some internal error occurred");
                    return(View(model));
                }

                var staffAssignmentUpload = new StaffEventScheduleUpload
                {
                    FileId     = files.Id,
                    UploadTime = DateTime.Now,
                    UploadedByOrgRoleUserId = _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId,
                    StatusId = (long)StaffEventScheduleParseStatus.Uploaded
                };

                try
                {
                    staffAssignmentUpload = _staffEventScheduleUploadRepository.Save(staffAssignmentUpload);
                }
                catch (Exception ex)
                {
                    _logger.Error(string.Format("Staff Event Schedule Upload\nException occurred while saving info in StaffEventScheduleUpload."));
                    _logger.Error(string.Format("Exception message: {0}\n\tStackTrace:{1}", ex.Message, ex.StackTrace));

                    model.FeedbackMessage = FeedbackMessageModel.CreateFailureMessage("Some internal error occurred");
                    return(View(model));
                }

                if (staffAssignmentUpload != null && staffAssignmentUpload.Id > 0)
                {
                    ModelState.Clear();
                    return(RedirectToAction("ScheduleUpload", "Schedule", new { message = "File uploaded successfully" }));
                }

                model.FeedbackMessage = FeedbackMessageModel.CreateFailureMessage("File upload failed");
                return(View(model));
            }
            catch (Exception ex)
            {
                _logger.Error(string.Format("Staff Event Schedule Upload\nException occurred"));
                _logger.Error(string.Format("Exception message: {0}\n\tStackTrace:{1}", ex.Message, ex.StackTrace));

                model.FeedbackMessage = FeedbackMessageModel.CreateFailureMessage("Some internal error occurred");
                return(View(model));
            }
        }
示例#11
0
        public JsonResult CreateResultArchive(long eventId, string fileName, long fileSize)
        {
            if (eventId < 1)
            {
                throw new Exception("EventId should not be empty!");
            }
            try
            {
                var theEvent = _eventRepository.GetById(eventId);
                if (theEvent == null || theEvent.EventDate.Date > DateTime.Now.Date || theEvent.Status != EventStatus.Active || theEvent.PodIds.IsNullOrEmpty())
                {
                    throw new Exception("Provide a valid EventId!");
                }
            }
            catch
            {
                var model = new ResultArchiveUploadEditModel
                {
                    EventId = -1,
                    File    = null,
                    Id      = 0
                };

                return(Json(model, JsonRequestBehavior.AllowGet));
            }

            var file = new File
            {
                Path       = fileName,
                Type       = FileType.Compressed,
                FileSize   = fileSize,
                UploadedBy = new OrganizationRoleUser(_session.UserSession.CurrentOrganizationRole.OrganizationRoleUserId),
                UploadedOn = DateTime.Now
            };

            file = _fileRepository.Save(file);

            var resultArchive = new ResultArchive
            {
                FileId                  = file.Id,
                EventId                 = eventId,
                UploadStartTime         = DateTime.Now,
                Status                  = ResultArchiveUploadStatus.Uploading,
                UploadedByOrgRoleUserId =
                    _session.UserSession.CurrentOrganizationRole.OrganizationRoleUserId
            };

            resultArchive = _resultArchiveUploadRepository.Save(resultArchive);

            //update the file name
            file.Path = _fileHelper.AddPostFixToFileName(file.Path, resultArchive.Id.ToString());
            _fileRepository.Save(file);


            //return ResultArchiveUploadEditModel;
            var editModel = new ResultArchiveUploadEditModel
            {
                EventId = eventId,
                File    = file,
                Id      = resultArchive.Id
            };

            return(Json(editModel, JsonRequestBehavior.AllowGet));
        }