Esempio n. 1
0
        // Used by Win Service - Upload Result
        //public Customer GetCustomerbyFilterforanEvent(string firstName, string lastName, DateTime? dob, long eventid)
        //{
        //    var customers = _customerRepository.GetCustomerByFilters(firstName, lastName, 0, 0, string.Empty, string.Empty, null, string.Empty);

        //    var selectedCustomers = customers.FindAll(customer => customer.DateOfBirth.HasValue && (dob == null || (dob != null && customer.DateOfBirth.Value.Date == dob.Value.Date)));

        //    Customer customerForEvent = null;
        //    if (!selectedCustomers.IsNullOrEmpty())
        //    {
        //        selectedCustomers.ForEach(customer =>
        //        {
        //            var isCustomerRegistered = _eventCustomerService.IsCustomerRegisteredfortheGivenEvent(customer.CustomerId, eventid);
        //            if (isCustomerRegistered) customerForEvent = customer;
        //        });
        //    }

        //    return customerForEvent;
        //}

        public void MarkProspectCustomerConverted(long eventCustomerId)
        {
            var prospectCustomer = GetProspectCustomer(eventCustomerId);

            if (prospectCustomer == null)
            {
                return;
            }
            prospectCustomer.IsConverted     = true;
            prospectCustomer.Status          = (long)ProspectCustomerConversionStatus.Converted;
            prospectCustomer.ConvertedOnDate = DateTime.Now;

            _uniqueItemProspectCustomerRepository.Save(prospectCustomer);
        }
        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);
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        private OrderDetail GetRefunTypeOrderLineItem(decimal amount, string reasonForRefund, long orderId, long customerId, long processedbyOrgRoleUserId)
        {
            var dataRecorder = new DataRecorderMetaData(processedbyOrgRoleUserId, DateTime.Now, null);
            var refund       = new Refund()
            {
                DataRecorderMetaData = dataRecorder,
                Notes        = reasonForRefund,
                RefundReason = RefundReason.ProcessedRefundRequest,
                Price        = amount
            };

            refund = _refundRepository.Save(refund);
            OrderItem orderItem = _orderItemRepository.SaveOrderItem(refund.Id, OrderItemType.RefundItem);

            var orderDetail = new OrderDetail()
            {
                DataRecorderMetaData      = dataRecorder,
                Description               = reasonForRefund,
                DetailType                = OrderItemType.RefundItem,
                ForOrganizationRoleUserId = customerId,
                OrderId         = orderId,
                OrderItemId     = orderItem.Id,
                OrderItemStatus =
                    (new OrderItemStatusFactory()).CreateOrderItemStatus(
                        OrderItemType.RefundItem, RefundItemStatus.Applied.StatusCode),
                Price    = amount,
                Quantity = 1
            };

            return(orderDetail);
        }
        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);
            }
        }
Esempio n. 6
0
    public ProspectCustomer SaveProspectCustomer(ProspectCustomer prospectCustomer)
    {
        long prospectCustomerId = prospectCustomer.Id;

        if (prospectCustomer.Id > 0 && prospectCustomer.CreatedOn == DateTime.MinValue)
        {
            prospectCustomer.CreatedOn = DateTime.Now;
        }
        prospectCustomer = _uniqueItemRepository.Save(prospectCustomer);

        // If this is a new prospect customer, track this conversion.)
        if (prospectCustomerId == 0)
        {
            long clickId = 0;

            HttpCookie clickIdCookie = Context.Request.Cookies["advertiserClick"];
            if (clickIdCookie != null)
            {
                long.TryParse(clickIdCookie.Value, out clickId);
            }

            // if there's a click ID, save which click caused the conversion to a prospective customer, and their prospect ID
            if (clickId > 0)
            {
                IClickConversionRepository clickConversionRepository = new ClickConversionRepository();
                clickConversionRepository.SaveProspectConversion(clickId, prospectCustomer.Id);
            }
        }
        return(prospectCustomer);
    }
Esempio n. 7
0
        private void SavePackage(PackageEditModel model)
        {
            Package packageinDb = null;
            IEnumerable <PackageTest> packageTestsinDb = null;

            var package = Mapper.Map <PackageEditModel, Package>(model);

            if (model.ForOrderDisplayFile != null)
            {
                model.ForOrderDisplayFile     = _fileRepository.Save(model.ForOrderDisplayFile);
                package.ForOrderDisplayFileId = model.ForOrderDisplayFile.Id;
            }
            if (package.Id > 0)
            {
                packageinDb                  = _packageRepository.GetById(package.Id);
                packageTestsinDb             = _packageTestRepository.GetbyPackageId(package.Id);
                package.DataRecorderMetaData = packageinDb.DataRecorderMetaData;
                package.DataRecorderMetaData.DateModified         = DateTime.Now;
                package.DataRecorderMetaData.DataRecorderModifier = new OrganizationRoleUser(_sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId);
            }
            else
            {
                package.DataRecorderMetaData = new DataRecorderMetaData(_sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId, DateTime.Now, null);
            }

            using (var scope = new TransactionScope())
            {
                package = ((IUniqueItemRepository <Package>)_packageRepository).Save(package);
                _packageRepository.SaveRolesforGivenPackageAvailability(package.Id, model.SelectedRoles);

                if (model.SelectedTests != null && model.SelectedTests.Count() > 0)
                {
                    var packageTests =
                        Mapper.Map <IEnumerable <PackageTestEditModel>, IEnumerable <PackageTest> >(model.SelectedTests);

                    foreach (var test in packageTests)
                    {
                        PackageTest packageTestInDb = null;
                        if (packageTestsinDb != null && packageTestsinDb.Count() > 0)
                        {
                            packageTestInDb = packageTestsinDb.Where(pt => pt.TestId == test.TestId).SingleOrDefault();
                        }

                        test.PackageId = package.Id;
                        if (packageTestInDb != null)
                        {
                            test.DateModified = DateTime.Now;
                            test.DateCreated  = packageTestInDb.DateCreated;
                        }
                        else
                        {
                            test.DateCreated = DateTime.Now;
                        }
                    }
                    packageTests = _packageTestRepository.Save(packageTests);
                }

                scope.Complete();
            }
        }
Esempio n. 8
0
        private void UploadLoincFiles(IEnumerable <string> sourceFiles, string uploadMediaLocation, long typeId)
        {
            foreach (var sourceFile in sourceFiles)
            {
                try
                {
                    using (var scope = new TransactionScope())
                    {
                        var fileName        = Path.GetFileName(sourceFile);
                        var destinationFile = uploadMediaLocation + fileName;
                        System.IO.File.Move(sourceFile, destinationFile);

                        var fileInfo = new FileInfo(destinationFile);

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

                        _outboundUploadRepository.Save(new OutboundUpload
                        {
                            FileId     = file.Id,
                            TypeId     = typeId,
                            StatusId   = (long)OutboundUploadStatus.Pending,
                            UploadTime = DateTime.Now
                        });

                        scope.Complete();
                    }
                }
                catch (Exception exception)
                {
                    _logger.Info("some exception occured while Moving File type : " + ((OutboundUploadType)typeId).GetDescription() + " and file name : " + sourceFile);
                    _logger.Info("message " + exception.Message);
                    _logger.Info("stack Trace " + exception.StackTrace);
                }
            }
        }
Esempio n. 9
0
        public ProspectCustomerEditModel SaveProspectCustomer(ProspectCustomerEditModel model)
        {
            //since guid is unavailable for this screen , OnlineRequestStatus is set to valid directly.
            var onlineRequestValidationModel = new OnlineRequestValidationModel()
            {
                RequestStatus = OnlineRequestStatus.Valid
            };

            model.RequestValidationModel = onlineRequestValidationModel;

            if (onlineRequestValidationModel.RequestStatus != OnlineRequestStatus.Valid)
            {
                return(model);
            }
            var prospectCustomer = Mapper.Map <ProspectCustomerEditModel, ProspectCustomer>(model);

            prospectCustomer.CreatedOn = DateTime.Now;
            _prospectCustomerRepository.Save(prospectCustomer);

            return(model);
        }
Esempio n. 10
0
 private void UpdateProspectCustomer(TempCart tempCart, Customer customer)
 {
     if (tempCart.ProspectCustomerId.HasValue)
     {
         var prospectCustomer = _prospectCustomerRepository.GetById(tempCart.ProspectCustomerId.Value);
         prospectCustomer.CustomerId                 = customer.CustomerId;
         prospectCustomer.Tag                        = ProspectCustomerTag.OnlineSignup;
         prospectCustomer.IsConverted                = true;
         prospectCustomer.Status                     = (long)ProspectCustomerConversionStatus.Converted;
         prospectCustomer.ConvertedOnDate            = DateTime.Now;
         prospectCustomer.Address.StreetAddressLine1 = customer.Address.StreetAddressLine1;
         prospectCustomer.Address.StreetAddressLine2 = customer.Address.StreetAddressLine2;
         prospectCustomer.Address.City               = customer.Address.City;
         prospectCustomer.Address.State              = _stateRepository.GetState(customer.Address.StateId).Name;
         prospectCustomer.Address.ZipCode.Zip        = customer.Address.ZipCode.Zip;
         prospectCustomer.TagUpdateDate              = DateTime.Now;
         _prospectCustomerRepository.Save(prospectCustomer);
     }
     else
     {
         var prospectCustomer = ((IProspectCustomerRepository)_prospectCustomerRepository).GetProspectCustomerByCustomerId(customer.CustomerId);
         if (prospectCustomer != null)
         {
             prospectCustomer.CustomerId                 = customer.CustomerId;
             prospectCustomer.Tag                        = ProspectCustomerTag.OnlineSignup;
             prospectCustomer.IsConverted                = true;
             prospectCustomer.Status                     = (long)ProspectCustomerConversionStatus.Converted;
             prospectCustomer.ConvertedOnDate            = DateTime.Now;
             prospectCustomer.Address.StreetAddressLine1 = customer.Address.StreetAddressLine1;
             prospectCustomer.Address.StreetAddressLine2 = customer.Address.StreetAddressLine2;
             prospectCustomer.Address.City               = customer.Address.City;
             prospectCustomer.Address.State              = _stateRepository.GetState(customer.Address.StateId).Name;
             prospectCustomer.Address.ZipCode.Zip        = customer.Address.ZipCode.Zip;
             prospectCustomer.TagUpdateDate              = DateTime.Now;
             _prospectCustomerRepository.Save(prospectCustomer);
         }
     }
 }
Esempio n. 11
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));
        }
Esempio n. 12
0
        private UserLoginLog SaveLoginInfo(long userid, string sessionId, string deviceKey)
        {
            var userLoginLog = new UserLoginLog
            {
                UserId         = userid,
                LogInDateTime  = DateTime.Now,
                BrowserSession = sessionId,
                BrowserName    = " ",
                SessionIP      = ((HttpContextWrapper)Request.Properties["MS_HttpContext"]).Request.UserHostAddress,
                DeviceKey      = deviceKey,
                RefferedUrl    = Request.RequestUri
            };

            return(_uniqueItemRepository.Save(userLoginLog));
        }
Esempio n. 13
0
 public Testimonial SaveTestimonial(Testimonial testimonial)
 {
     using (var transaction = new TransactionScope())
     {
         File file = null;
         if (testimonial.TestimonialVideo != null)
         {
             file = _fileRepository.Save(testimonial.TestimonialVideo);
             testimonial.TestimonialVideo.Id = file.Id;
         }
         testimonial = Save(testimonial);
         testimonial.TestimonialVideo = file;
         transaction.Complete();
         return(testimonial);
     }
 }
Esempio n. 14
0
        public UserLoginLog SaveLoginInfo(long userId, string userName, string browserSessionId, string browserName, string sessionIp, Uri refferedUrl)
        {
            var userLoginLog = new UserLoginLog
            {
                UserId         = userId,
                LogInDateTime  = DateTime.Now,
                BrowserSession = browserSessionId,
                BrowserName    = browserName,
                SessionIP      = sessionIp,
                RefferedUrl    = refferedUrl
            };

            _singleSessionHelper.CreateAndStoreSessionToken(userName, browserSessionId);

            return(_uniqueItemRepository.Save(userLoginLog));
        }
Esempio n. 15
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);
            }
        }
Esempio n. 16
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);
        }
Esempio n. 17
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);
        }
Esempio n. 18
0
        public CustomerCallNotes SaveCustomerNotes(long customerId, long eventId, string notes, long createdByOrgRoleUserId, CustomerRegistrationNotesType notesType, long?reasonId = null)
        {
            var customerRegistrationNotes = new CustomerCallNotes
            {
                CustomerId           = customerId,
                EventId              = eventId > 0 ? eventId : (long?)null,
                Notes                = notes,
                NotesType            = notesType,
                ReasonId             = reasonId,
                DataRecorderMetaData = new DataRecorderMetaData
                {
                    DateCreated         = DateTime.Now,
                    DataRecorderCreator = new OrganizationRoleUser(createdByOrgRoleUserId)
                }
            };


            customerRegistrationNotes = _customerNotesRepository.Save(customerRegistrationNotes);
            return(customerRegistrationNotes);
        }
Esempio n. 19
0
        private void SaveRegistrationNotes(long customerId, string notes, long organizationRoleUserId)
        {
            if (customerId <= 0)
            {
                return;
            }
            var customerRegistrationNotes = new CustomerCallNotes
            {
                CustomerId           = customerId,
                EventId              = null,
                Notes                = notes,
                NotesType            = CustomerRegistrationNotesType.AppointmentNote,
                DataRecorderMetaData = new DataRecorderMetaData
                {
                    DateCreated         = DateTime.Now,
                    DataRecorderCreator = new OrganizationRoleUser(organizationRoleUserId)
                }
            };

            _customerCallNotesRepository.Save(customerRegistrationNotes);
        }
Esempio n. 20
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);
        }
        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);
        }
Esempio n. 22
0
        private Core.Application.Domain.File SaveSignatureImage(string signatureBytes, long orgRoleUserId, MediaLocation signatureLocation, string fileName)
        {
            var filePath = Path.Combine(signatureLocation.PhysicalPath, fileName);

            var imageBytes = Convert.FromBase64String(signatureBytes);

            File.WriteAllBytes(filePath, imageBytes);

            var fileInfo = new FileInfo(filePath);

            var file = new Core.Application.Domain.File
            {
                Path       = fileName,
                FileSize   = fileInfo.Length,
                Type       = FileType.Image,
                UploadedBy = new OrganizationRoleUser(orgRoleUserId),
                UploadedOn = DateTime.Now
            };

            file = _fileRepository.Save(file);

            return(file);
        }
Esempio n. 23
0
        public void SavePodDefaultTeamTester()
        {
            var podDefaultTeam = _repository.Save(_podDefaultTeam);

            Assert.IsNull(podDefaultTeam);
        }
Esempio n. 24
0
        public ActionResult Upload(SuspectConditionFileUploadEditModel model, HttpPostedFileBase suspectConditionUploadFile)
        {
            if (Request.Files.Count < 1 || suspectConditionUploadFile == null)
            {
                model.FeedbackMessage = FeedbackMessageModel.CreateFailureMessage("No file has been uploaded. Please upload a csv file.");
                return(View(model));
            }

            var uploadMediaLocation = _mediaRepository.GetSuspectConditionUploadMediaFileLocation();

            model.SampleCsvMediaUrl = _mediaRepository.GetSamplesLocation().Url;

            HttpPostedFileBase file = Request.Files[0];
            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;

            file.SaveAs(fullPath);

            var csvReader     = IoC.Resolve <ICsvReader>();
            var customerTable = csvReader.ReadWithTextQualifier(fullPath);

            if (customerTable.Rows.Count == 0)
            {
                model.FeedbackMessage = FeedbackMessageModel.CreateFailureMessage("Uploaded file has no data.");
                return(View(model));
            }

            var columns            = customerTable.Columns.Cast <DataColumn>().Select(x => x.ColumnName).ToArray();
            var missingColumnNames = _suspectConditionUploadHelper.CheckForColumns(columns);

            if (!string.IsNullOrEmpty(missingColumnNames))
            {
                model.FeedbackMessage = FeedbackMessageModel.CreateFailureMessage("Missing Column Name(s) : " + missingColumnNames);
                return(View(model));
            }

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

            files = _fileRepository.Save(files);

            var suspectConditionUpload = new SuspectConditionUpload
            {
                FileId         = files.Id,
                UploadTime     = DateTime.Now,
                StatusId       = (long)SuspectConditionUploadStatus.UploadStarted,
                UploadedBy     = _session.UserSession.CurrentOrganizationRole.OrganizationRoleUserId,
                TotalCount     = customerTable.Rows.Count,
                ParseStartTime = DateTime.Now
            };

            suspectConditionUpload = _suspectConditionUploadRepository.Save(suspectConditionUpload);

            model.TotalRecords     = customerTable.Rows.Count;
            model.IsUploadSucceded = true;
            model.IsParseSucceded  = false;
            model.FileName         = fileName;

            model.FailedRecordsFile = Path.GetFileNameWithoutExtension(fileName) + "_Failed" + ".csv";

            if (suspectConditionUpload != null && suspectConditionUpload.Id > 0)
            {
                model.SuspectConditionUploadId = suspectConditionUpload.Id;
            }

            var failureRecords = uploadMediaLocation.PhysicalPath + model.FailedRecordsFile;

            _suspectConditionUploadHelper.CreateHeaderFileRecord(failureRecords, customerTable);

            return(View(model));
        }
        public void SavePersistsNewGiftCertificate()
        {
            GiftCertificate persistedGiftCertificate = _repository.Save(_giftCertificate);

            Assert.AreEqual(_giftCertificate.Amount, persistedGiftCertificate.Amount);
        }
Esempio n. 26
0
        public ActionResult Upload(CallUploadEditModel model)
        {
            var uploadMediaLocation = _mediaRepository.GetCallUploadMediaFileLocation();

            model.UploadCsvMediaUrl = uploadMediaLocation.Url;

            HttpPostedFileBase postedFile = Request.Files[0];

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

            if (System.IO.Path.GetExtension(postedFile.FileName).ToLower() != ".csv")
            {
                model.FeedbackMessage = FeedbackMessageModel.CreateFailureMessage("Please upload a csv file!");
                return(View(model));
            }

            var physicalPath = uploadMediaLocation.PhysicalPath;

            var fileContent = System.IO.Path.GetFileNameWithoutExtension(postedFile.FileName) + "_" + DateTime.Now.ToString("MMddyyyyhhmmss") + System.IO.Path.GetExtension(postedFile.FileName);

            var fullPath = physicalPath + fileContent;

            postedFile.SaveAs(fullPath);

            var customerTable = _csvReader.ReadWithTextQualifier(fullPath);

            if (customerTable.Rows.Count == 0)
            {
                model.FeedbackMessage = FeedbackMessageModel.CreateFailureMessage("Uploaded file has no data.");
                return(View(model));
            }

            var missingColumnNames = _callUploadHelper.CheckForColumns(customerTable.Rows[0]);

            if (!string.IsNullOrEmpty(missingColumnNames))
            {
                model.FeedbackMessage = FeedbackMessageModel.CreateFailureMessage("Missing Column Name(s) : " + missingColumnNames);
                return(View(model));
            }

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

            file = _fileRepository.Save(file);

            var callUpload = new CallUpload
            {
                FileId     = file.Id,
                UploadTime = DateTime.Now,
                StatusId   = (long)CallUploadStatus.Uploaded,
                UploadedBy = _session.UserSession.CurrentOrganizationRole.OrganizationRoleUserId
            };

            callUpload = _callUploadRepository.Save(callUpload);

            if (callUpload != null && callUpload.Id > 0)
            {
                model.FeedbackMessage = FeedbackMessageModel.CreateSuccessMessage("File Uploaded Successfull.");
            }

            return(View(model));
        }
Esempio n. 27
0
        private Core.Application.Domain.File UploadFile(string sourceFile)
        {
            var files = CreateFileModel(sourceFile);

            return(_fileRepository.Save(files));
        }
Esempio n. 28
0
        public ActionResult Index(HttpPostedFileBase phoneNumberFileUpload)
        {
            var  uploadDateTime = DateTime.Now;
            var  fileUploadName = @"PhoneNumberUpdate_" + uploadDateTime.ToString("yyyyMMddHHmmss") + "_" + _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId + ".csv";
            long uploadStatus   = (long)PhoneNumberUploadStatus.FileNotFound;
            var  model          = new CustomerPhoneNumberUpdateUploadViewModel();

            model.FeedbackMessage = new FeedbackMessageModel();
            HttpPostedFileBase file     = Request.Files[0];
            var tempMediaFileLocation   = _mediaRepository.GetTempMediaFileLocation();    //will store file at Temp location first
            var uploadMediaFileLocation = _mediaRepository.GetCustomerPhoneNumberUploadLocation();

            var physicalPath = tempMediaFileLocation.PhysicalPath;
            var fullpath     = physicalPath + fileUploadName;

            try
            {
                // we set uploadStatus as "FileNotFound" to indicate only UI error message , no DB logging
                if (Request.Files.Count != 1 || phoneNumberFileUpload == null)
                {
                    uploadStatus = (long)PhoneNumberUploadStatus.FileNotFound;
                    throw new Exception("No file has been uploaded. Please upload a csv file.");
                }

                var fileExtension = file.FileName.Split('.');
                if ((fileExtension.Length >= 2 && fileExtension[fileExtension.Length - 1].ToLower() != "csv") || fileExtension.Length < 2)
                {
                    uploadStatus = (long)PhoneNumberUploadStatus.FileNotFound;
                    throw new Exception("Uploaded file is not in CSV format");
                }

                try
                {
                    file.SaveAs(fullpath);
                }
                catch (Exception)
                {
                    uploadStatus = (long)PhoneNumberUploadStatus.UploadFailed;
                    throw;
                }

                var phoneNumberTable = _csvReader.ReadWithTextQualifier(fullpath);

                System.IO.File.Copy(fullpath, uploadMediaFileLocation.PhysicalPath + fileUploadName);
                //fullpath = uploadMediaFileLocation.PhysicalPath + fileUploadName;

                if (phoneNumberTable.Rows.Count == 0)
                {
                    uploadStatus = (long)PhoneNumberUploadStatus.FileNotFound;
                    throw new Exception("Uploaded file has no data");
                }

                var columns            = phoneNumberTable.Columns.Cast <DataColumn>().Select(x => x.ColumnName).ToArray();
                var missingColumnNames = _phoneNumberUpdateUploadHelper.CheckAllColumnExist(columns);
                if (!string.IsNullOrEmpty(missingColumnNames))
                {
                    uploadStatus = (long)PhoneNumberUploadStatus.FileNotFound;

                    var customString = missingColumnNames.Replace(PhoneNumberUpdateUploadLogColumn.CustomerId, "Customer Id")
                                       .Replace(PhoneNumberUpdateUploadLogColumn.FirstName, "First Name").Replace(PhoneNumberUpdateUploadLogColumn.LastName, "Last Name")
                                       .Replace(PhoneNumberUpdateUploadLogColumn.MemberId, "Member Id").Replace(PhoneNumberUpdateUploadLogColumn.PhoneNumber, "New Phone Number")
                                       .Replace(PhoneNumberUpdateUploadLogColumn.PhoneType, "Phone Type").Replace(PhoneNumberUpdateUploadLogColumn.DOB, "Dob");

                    throw new Exception("Missing Column Name(s):" + customString);
                }

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

                files = _fileRepository.Save(files);

                var customerPhoneNumberUpdateUpload = new CustomerPhoneNumberUpdateUpload
                {
                    FileId                  = files.Id,
                    StatusId                = (long)PhoneNumberUploadStatus.Uploaded,
                    SuccessUploadCount      = 0,
                    FailedUploadCount       = 0,
                    UploadTime              = uploadDateTime,
                    ParseStartTime          = null,
                    ParseEndTime            = null,
                    UploadedByOrgRoleUserId = _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId,
                    LogFileId               = null
                };
                _customerPhoneNumberUpdateUploadRepository.Save(customerPhoneNumberUpdateUpload);
            }

            catch (Exception ex)
            {
                model.FeedbackMessage.MessageType = UserInterfaceMessageType.Error;
                model.FeedbackMessage.Message     = ex.Message;
                if (uploadStatus == (long)PhoneNumberUploadStatus.UploadFailed)
                {
                    model.FeedbackMessage.Message = "Upload Failed";
                }
                return(View("Index", model));
            }
            model.FeedbackMessage.Message = "Upload Success";
            return(View("Index", model));
        }
Esempio n. 29
0
        public ActionResult Create(PodEditModel podEditModel)
        {
            try
            {
                podEditModel.Territories = _territoryRepository.GetAllTerritoriesIdNamePair(TerritoryType.Pod);
                podEditModel.Tests       = _testRepository.GetAll();
                if (ModelState.IsValid)
                {
                    var pod = Mapper.Map <PodEditModel, Pod>(podEditModel);
                    pod.DataRecorderMetaData = new DataRecorderMetaData()
                    {
                        DataRecorderCreator = Mapper.Map <OrganizationRoleUserModel, OrganizationRoleUser>(_sessionContext.UserSession.CurrentOrganizationRole),
                        DateCreated         = DateTime.Now
                    };

                    using (var scope = new TransactionScope())
                    {
                        pod = _podRepository.Save(pod);

                        var podTeam = new List <PodStaff>();
                        podEditModel.DefaultStaffAssigned.ToList().ForEach(dsa =>
                        {
                            var teamMember   = Mapper.Map <PodStaffEditModel, PodStaff>(dsa);
                            teamMember.PodId = pod.Id;
                            teamMember.DataRecorderMetaData = new DataRecorderMetaData
                            {
                                DataRecorderCreator = Mapper.Map <OrganizationRoleUserModel, OrganizationRoleUser>(_sessionContext.UserSession.CurrentOrganizationRole),
                                DateCreated         = DateTime.Now
                            };
                            podTeam.Add(teamMember);
                        });

                        if (!podEditModel.AssignedTerritories.IsNullOrEmpty())
                        {
                            ((IPodRepository)_podRepository).SavePodTerritories(podEditModel.AssignedTerritories,
                                                                                pod.Id);
                        }

                        // Need to check the DefaultPodTeam Issue.
                        podTeam = _podStaffAssignmentRepository.SaveMultiple(podTeam, pod.Id).ToList();

                        _podService.SavePodRooms(podEditModel.Rooms, pod.Id);

                        scope.Complete();
                    }

                    var newModel = new PodEditModel(_territoryRepository, _testRepository);

                    newModel.FeedbackMessage =
                        FeedbackMessageModel.CreateSuccessMessage(
                            "The POD information was saved successfully. You can add more PODs or close this page.");

                    return(View(newModel));
                }
                return(View(podEditModel));
            }
            catch (Exception exception)
            {
                podEditModel.FeedbackMessage = FeedbackMessageModel.CreateFailureMessage("System Error:" + exception);
                return(View(podEditModel));
            }
        }
Esempio n. 30
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));
            }
        }