private void CreateDistinationDirectory(string directoryPath)
 {
     if (!DirectoryOperationsHelper.IsDirectoryExist(directoryPath))
     {
         DirectoryOperationsHelper.CreateDirectory(directoryPath);
     }
 }
        private void SerializeandSave(string fileName, AccountEventZipSetting setting)
        {
            if (setting == null)
            {
                return;
            }

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

            if (Path.GetDirectoryName(fileName) == null || !DirectoryOperationsHelper.IsDirectoryExist(Path.GetDirectoryName(fileName)))
            {
                DirectoryOperationsHelper.CreateDirectory(Path.GetDirectoryName(fileName));
            }

            if (DirectoryOperationsHelper.IsFileExist(fileName))
            {
                DirectoryOperationsHelper.Delete(fileName);
            }

            var stream = new StreamWriter(fileName);

            serializer.Serialize(stream, setting);

            stream.Close();
            stream.Dispose();
        }
示例#3
0
        private void PatientWithGapTag(DateTime exportToTime, DateTime exportFromTime, CorporateAccount corporateAccount, DateTime?eventDateFromConsider, DateTime?eventDateToConsider)
        {
            try
            {
                var destinationFolderPdfPath = string.Format(_destinationFolderResultPdfPath, corporateAccount.FolderName);
                destinationFolderPdfPath = destinationFolderPdfPath + "\\Q-ResultPdf";

                PostResultPdfOnSftp(exportToTime, exportFromTime, corporateAccount, destinationFolderPdfPath, true, _bcbsMiGapPatinetTags);

                if (DirectoryOperationsHelper.IsDirectoryExist(destinationFolderPdfPath) && DirectoryOperationsHelper.GetFiles(destinationFolderPdfPath).Any())
                {
                    var destinationSftp = string.Format(_destinationFolderResultReportPath, corporateAccount.FolderName);

                    if (!DirectoryOperationsHelper.IsDirectoryExist(destinationSftp))
                    {
                        DirectoryOperationsHelper.CreateDirectory(destinationSftp);
                    }

                    var destinationfile = destinationSftp + @"\Q_MOBILE_ResultPdf_" + DateTime.Today.ToString("yyyyMMdd") + ".zip";

                    _zipHelper.CreateZipFiles(destinationFolderPdfPath, destinationfile, true);
                }
            }
            catch (Exception exception)
            {
                _logger.Error(string.Format("some error occurred for the \n Message {0} \n Stack Trace {1}", exception.Message, exception.StackTrace));
            }
        }
        public void CopyOverAwvEkgGraph(long eventId, long customerId, string saveFilePath, AwvEkgTestResult testResult)
        {
            if (testResult == null || testResult.ResultImage == null)
            {
                return;
            }
            var destinationDirectory = Path.GetDirectoryName(saveFilePath);

            var supportDestDirectoryPath = destinationDirectory + @"\" + StringforMediaDirectory;

            if (!DirectoryOperationsHelper.IsDirectoryExist(supportDestDirectoryPath))
            {
                DirectoryOperationsHelper.CreateDirectory(supportDestDirectoryPath);
            }

            string input = _mediaRepository.GetResultMediaFileLocation(customerId, eventId).PhysicalPath +
                           testResult.ResultImage.File.Path;

            using (Image img = Image.FromFile(input))
            {
                //rotate the picture by 90 degrees and re-save the picture as a Jpeg
                img.RotateFlip(RotateFlipType.Rotate270FlipNone);
                img.Save(supportDestDirectoryPath + "\\" + testResult.ResultImage.File.Path, System.Drawing.Imaging.ImageFormat.Jpeg);
            }
        }
        public void CopyOverMedia(long eventId, long customerId, string saveFilePath, IEnumerable <ResultMedia> resultMedia)
        {
            if (resultMedia == null || resultMedia.Count() < 1)
            {
                return;
            }
            var destinationDirectory = Path.GetDirectoryName(saveFilePath);

            var supportDestDirectoryPath = destinationDirectory + @"\" + StringforMediaDirectory;

            if (!DirectoryOperationsHelper.IsDirectoryExist(supportDestDirectoryPath))
            {
                DirectoryOperationsHelper.CreateDirectory(supportDestDirectoryPath);
            }

            var mediaPath = _mediaRepository.GetResultMediaFileLocation(customerId, eventId).PhysicalPath;

            foreach (var media in resultMedia)
            {
                if (media.File.Type == FileType.Image)
                {
                    DirectoryOperationsHelper.DeleteFileIfExist(supportDestDirectoryPath + "\\" + media.File.Path);
                    System.IO.File.Copy(mediaPath + media.File.Path, supportDestDirectoryPath + "\\" + media.File.Path);
                }
            }
        }
        private void GenerateLabsInboundReport(LabsInboundFilter filter)
        {
            var dataGen = new ExportableDataGenerator <LabsInboundViewModel, LabsInboundFilter>(_labsInboundReportService.GetLabsInboundReportList, _logger);
            var model   = dataGen.GetData(filter);

            var account = _corporateAccountRepository.GetById(filter.AccountId);

            if (model != null && !model.Collection.IsEmpty())
            {
                var folder = string.Format(_settings.FloridaBlueInboundReportPath, account.FolderName, DateTime.Now.ToString("yyyy-MM-dd"));

                if (!Directory.Exists(folder))
                {
                    DirectoryOperationsHelper.CreateDirectory(folder);
                }

                _logger.Info("Directory Path :" + folder);

                var fileName = _pipeDelimitedReportHelper.GetReportName(ReportType.LabsInbound);

                if (model.Collection != null && model.Collection.Any())
                {
                    var filePath = folder + "\\" + fileName + ".txt";
                    if (File.Exists(filePath))
                    {
                        _logger.Info("file Deleteing"); File.Delete(filePath);
                    }

                    _pipeDelimitedReportHelper.Write(model.Collection, folder, fileName + ".txt");

                    _logger.Info("File Generated at :" + folder + " file Name: " + fileName);

                    if (_sendReportToSftp)
                    {
                        try
                        {
                            _logger.Info("Sending file to SFTP.");

                            var destinationPath = _destinationSftpPath + "\\" + account.FolderName + "\\Download\\Reports";
                            SendFilesToSftp(Path.Combine(folder, fileName), destinationPath, fileName);

                            _logger.Info("File sent to SFTP.");
                        }
                        catch (Exception ex)
                        {
                            _logger.Info("Error sending file to SFTP.");
                            _logger.Error("Message : " + ex.Message);
                            _logger.Error("Stack Trace : " + ex.StackTrace);
                        }
                    }
                }
            }
            else
            {
                _logger.Info("No record found for " + account.Tag);
            }
        }
        private string GetCsvFileName(CorporateAccount account, string fileName)
        {
            var folderLocation = string.Format(_wellmedMemberStatusDestinationPath, account.FolderName, DateTime.Today.Year);

            if (!DirectoryOperationsHelper.IsDirectoryExist(folderLocation))
            {
                DirectoryOperationsHelper.CreateDirectory(folderLocation);
            }

            var destinationFileName = Path.Combine(folderLocation, fileName);

            if (DirectoryOperationsHelper.IsFileExist(destinationFileName))
            {
                DirectoryOperationsHelper.Delete(destinationFileName);
            }

            return(destinationFileName);
        }
示例#8
0
        public void PollMailRoundCustomersReport()
        {
            try
            {
                _logger.Info("Entering Matrix Report Polling Agent");

                var healthPlans = _corporateAccountRepository.GetAllHealthPlan();
                var callQueues  = _callQueueRepository.GetAll(false, true);

                if (callQueues.IsNullOrEmpty())
                {
                    _logger.Info("No call queue found.");
                    return;
                }
                var mailRoundCallQueue       = callQueues.FirstOrDefault(x => x.Category == HealthPlanCallQueueCategory.MailRound);
                var fillEventCallQueue       = callQueues.FirstOrDefault(x => x.Category == HealthPlanCallQueueCategory.FillEventsHealthPlan);
                var languageBarrierCallQueue = callQueues.FirstOrDefault(x => x.Category == HealthPlanCallQueueCategory.LanguageBarrier);

                foreach (var healthPlan in healthPlans)
                {
                    try
                    {
                        _logger.Info(string.Format("Generating Matrix Report for accountId {0} and account tag {1}. ", healthPlan.Id, healthPlan.Tag));

                        var destinationPath = _settings.MailRoundCustomersReportDestinantionPath;

                        var filePath = Path.Combine(destinationPath, string.Format(@"MatrixReport_{0}_{1}.csv", healthPlan.Tag, DateTime.Now.ToString("MMddyyyy")));

                        DirectoryOperationsHelper.CreateDirectory(destinationPath);

                        var customers = new List <MailRoundCustomersReportViewModel>();

                        _logger.Info("Fetching customers for fill event call queue");
                        var fillEventCustomers = GetCustomersForMatrixReport(healthPlan.Id, fillEventCallQueue);
                        if (!fillEventCustomers.IsNullOrEmpty())
                        {
                            customers.AddRange(fillEventCustomers);
                        }
                        else
                        {
                            _logger.Info("No customers found for fill event call queue");
                        }


                        _logger.Info("Fetching customers for mail round call queue");
                        var mailRoundCustomers = GetCustomersForMatrixReport(healthPlan.Id, mailRoundCallQueue);
                        if (!mailRoundCustomers.IsNullOrEmpty())
                        {
                            if (!customers.IsNullOrEmpty())
                            {
                                var existingCustomerIds = customers.Select(c => c.CustomerID);
                                mailRoundCustomers = mailRoundCustomers.Where(x => !existingCustomerIds.Contains(x.CustomerID)).ToList();
                            }
                            customers.AddRange(mailRoundCustomers);
                        }
                        else
                        {
                            _logger.Info("No customers found for mail round call queue");
                        }


                        _logger.Info("Fetching customers for language barrier call queue");
                        var languageBarrierCustomers = GetCustomersForMatrixReport(healthPlan.Id, languageBarrierCallQueue);
                        if (!languageBarrierCustomers.IsNullOrEmpty())
                        {
                            if (!customers.IsNullOrEmpty())
                            {
                                var existingCustomerIds = customers.Select(c => c.CustomerID);
                                languageBarrierCustomers = languageBarrierCustomers.Where(x => !existingCustomerIds.Contains(x.CustomerID)).ToList();
                            }
                            customers.AddRange(languageBarrierCustomers);
                        }
                        else
                        {
                            _logger.Info("No customers found for language barrier call queue");
                        }


                        if (customers.Any())
                        {
                            var exporter = ExportableDataGeneratorProcessManager <ViewModelBase, ModelFilterBase> .GetCsvExporter <MailRoundCustomersReportViewModel>();

                            DirectoryOperationsHelper.DeleteFileIfExist(filePath);

                            _baseExportableReportHelper.GenerateCsv(filePath, exporter, customers);
                            _logger.Error(string.Format("Successfully Matrix Report Generated for AccountId {0} and Account Tag {1}.", healthPlan.Id, healthPlan.Tag));
                        }
                        else
                        {
                            _logger.Error(string.Format("No records found for AccountId {0} and Account Tag {1}. \n\n", healthPlan.Id, healthPlan.Tag));
                        }
                    }
                    catch (Exception ex)
                    {
                        _logger.Error(string.Format("Error occured while generating Matrix Report for AccountId {0} and Account Tag {1} : \n Error {2} \n Trace: {3} ", healthPlan.Id, healthPlan.Tag, ex.Message, ex.StackTrace));
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Error(string.Format("Error occured while generating Matrix Report : \n Error {0} \n Trace: {1} ", ex.Message, ex.StackTrace));
            }
        }
示例#9
0
        public void PollForReportGeneration()
        {
            if (!_daysOfWeek.Contains(DateTime.Today.DayOfWeek))
            {
                _logger.Info(string.Format("Today is {0}. Job is set to run on {1} .", DateTime.Today.DayOfWeek, string.Join(", ", _daysOfWeek)));
                return;
            }

            if (_accountIds.IsNullOrEmpty())
            {
                _logger.Info("No accounts found for Gift Certificate Report.");
                return;
            }
            var corporateAccounts = _corporateAccountRepository.GetByIds(_accountIds);

            var toDate   = DateTime.Today;
            var fromDate = new DateTime(toDate.Year, 1, 1);

            foreach (var corporateAccount in corporateAccounts)
            {
                try
                {
                    var customSettingFilePath = string.Format(_customSettingFile, corporateAccount.Tag);
                    var customSettings        = _customSettingManager.Deserialize(customSettingFilePath);

                    var exportFromTime = customSettings.LastTransactionDate ?? _cutOffDate;

                    var filter = new HealthPlanGiftCertificateReportFilter
                    {
                        Tag      = corporateAccount.Tag,
                        FromDate = exportFromTime.Date,
                        ToDate   = toDate
                    };

                    fromDate = filter.FromDate.HasValue ? filter.FromDate.Value : fromDate;

                    _logger.Info(string.Format("Generating for account with ID : {0} and tag : {1} from {2} to {3}", corporateAccount.Id, corporateAccount.Tag, fromDate.ToShortDateString(), toDate.ToShortDateString()));

                    var       pageNumber = 1;
                    const int pageSize   = 100;

                    var list = new List <HealthPlanGiftCertificateReportViewModel>();

                    while (true)
                    {
                        int totalRecords;
                        var model = _eventCustomerReportingService.GetForHealthPlanGiftCertificateReport(pageNumber, pageSize, filter, out totalRecords);
                        if (model == null || model.Collection == null || !model.Collection.Any())
                        {
                            break;
                        }

                        list.AddRange(model.Collection);
                        _logger.Info(String.Format("PageNumber:{0} Totalrecords: {1}  Current Length: {2}\n\n", pageNumber, totalRecords, list.Count));

                        pageNumber++;

                        if (list.Count >= totalRecords)
                        {
                            break;
                        }
                    }

                    if (!list.Any())
                    {
                        _logger.Info(string.Format("No records found for account with ID : {0} and tag : {1}", corporateAccount.Id, corporateAccount.Tag, fromDate.ToShortDateString(), toDate.ToShortDateString()));
                        continue;
                    }

                    var internalLocation = string.Format(_giftCertificateReportInternalLocation, corporateAccount.FolderName);

                    if (!DirectoryOperationsHelper.IsDirectoryExist(internalLocation))
                    {
                        DirectoryOperationsHelper.CreateDirectory(internalLocation);
                    }

                    var fileName = @"\" + string.Format("CCI_offline_HealthFair_{0}.csv", DateTime.Today.ToString("yyyy_MM_dd"));//CCI_offline_HealthFair_YYYY_MM_DD

                    var internalFilePath = internalLocation + fileName;

                    WriteCsv(list, internalFilePath);

                    if (DirectoryOperationsHelper.IsFileExist(internalFilePath))
                    {
                        var folder = Path.Combine(string.Format(_giftCertificateReportDownloadPath, corporateAccount.FolderName), DateTime.Today.Year.ToString());

                        if (!DirectoryOperationsHelper.IsDirectoryExist(folder))
                        {
                            DirectoryOperationsHelper.CreateDirectory(folder);
                        }

                        var filePath = folder + fileName;

                        DirectoryOperationsHelper.Copy(internalFilePath, filePath);
                    }

                    _logger.Info(string.Format("Completed Gift Certificate Report for account with ID : {0} and tag : {1} from {2} to {3}", corporateAccount.Id, corporateAccount.Tag, fromDate.ToShortDateString(), toDate.ToShortDateString()));

                    customSettings.LastTransactionDate = toDate;
                    _customSettingManager.SerializeandSave(customSettingFilePath, customSettings);
                }
                catch (Exception ex)
                {
                    _logger.Info(string.Format("Error occured for account with ID : {0} and tag : {1} \nMessage : {2} \nStack Trace : {3}", corporateAccount.Id, corporateAccount.Tag, ex.Message, ex.StackTrace));
                }
            }
        }
示例#10
0
        private FileModel RetrieveFileFromRequest()
        {
            string fileNameWithoutExtension = Guid.NewGuid().ToString();
            var    location = _mediaRepository.GetTempMediaFileLocation().PhysicalPath;//_mediaLocation + @"/temp";

            if (location.IndexOfAny(Path.GetInvalidPathChars()) != -1)
            {
                throw new InvalidFileNameException();
            }

            var fileModel = new FileModel
            {
                FolderPath         = location,
                IsTemporaryLocated = true
            };

            if (!Directory.Exists(location))
            {
                DirectoryOperationsHelper.CreateDirectory(location);
            }

            var req = ControllerContext.HttpContext.Request.InputStream;

            req.Seek(0, SeekOrigin.Begin);

            if (Request.Files.Count > 0)
            {
                var file = Request.Files[0];

                fileModel.Caption  = Path.GetFileNameWithoutExtension(file.FileName);
                fileModel.FileName = fileNameWithoutExtension + Path.GetExtension(file.FileName);

                fileModel.MimeType = Request.ContentType;
                fileModel.FileSize = file.ContentLength;

                file.SaveAs(location + fileModel.FileName);
            }
            else if (Request.ContentLength > 0)
            {
                var fileName = Request.Headers["X-File-Name"];
                fileModel.Caption  = Server.UrlDecode(Path.GetFileNameWithoutExtension(fileName));
                fileModel.FileName = fileNameWithoutExtension + Path.GetExtension(fileName);
                fileModel.MimeType = Request.ContentType;
                fileModel.FileSize = Request.ContentLength;
                var fileContents = new byte[Request.ContentLength];

                Request.InputStream.Seek(0, SeekOrigin.Begin);
                Request.InputStream.Read(fileContents, 0, Request.ContentLength);

                using (var fileStream = new FileStream(location + fileModel.FileName, FileMode.Create, FileAccess.Write))
                {
                    fileStream.Write(fileContents, 0, fileContents.Length);
                }
            }

            fileModel.Url          = _mediaRepository.GetTempMediaFileLocation().Url;
            fileModel.UploadedBy   = _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId;
            fileModel.PhisicalPath = location;

            return(fileModel);
        }
        public void Create(IEnumerable <EventCustomersEntity> eventCustomerEntities, IEnumerable <OrderedPair <long, long> > orgRoleUserIdUserIdPairs,
                           IEnumerable <UserEntity> userEntities, IEnumerable <Address> addresses, IEnumerable <CustomerProfileEntity> customerProfileEntities, IEnumerable <EventsEntity> eventsEntities,
                           IEnumerable <CustomerHealthInfoEntity> customerHealthInfoEntities, IEnumerable <OrderedPair <long, string> > careCoordinatorIdNamePair,
                           IEnumerable <CustomerPrimaryCarePhysicianEntity> primaryCarePhysicianEntities, IEnumerable <Address> pcpAddresses, IEnumerable <EventAppointmentEntity> eventAppointmentEntities,
                           string destinationDirectory)
        {
            long totalRecords = eventCustomerEntities.Count();
            long counter      = 1;

            _logger.Info("Total Records : " + totalRecords);

            var fileName = destinationDirectory + string.Format(@"\HRA-QA_{0}.csv", DateTime.Now.Date.ToString("yyyyMMdd"));

            if (!DirectoryOperationsHelper.IsDirectoryExist(destinationDirectory))
            {
                DirectoryOperationsHelper.CreateDirectory(destinationDirectory);
            }

            WriteCsvHeader(fileName);

            foreach (var eventCustomerEntity in eventCustomerEntities)
            {
                try
                {
                    _logger.Info(string.Format("Creating Model for event {0} and customer {1}", eventCustomerEntity.EventId, eventCustomerEntity.CustomerId));

                    var userId = orgRoleUserIdUserIdPairs.Where(oru => oru.FirstValue == eventCustomerEntity.CustomerId).Select(oru => oru.SecondValue).Single();

                    var user = userEntities.Where(u => u.UserId == userId).Select(u => u).Single();

                    var address = addresses.Where(a => a.Id == user.HomeAddressId).Select(a => a).Single();

                    var customer = customerProfileEntities.Where(cp => cp.CustomerId == eventCustomerEntity.CustomerId).Select(cp => cp).Single();

                    var eventData = eventsEntities.Where(e => e.EventId == eventCustomerEntity.EventId).Select(e => e).Single();

                    var primaryCarePhysician = primaryCarePhysicianEntities.Where(pcp => pcp.CustomerId == eventCustomerEntity.CustomerId).Select(pcp => pcp).FirstOrDefault();

                    var eventAppointment = eventAppointmentEntities.Where(ea => ea.AppointmentId == eventCustomerEntity.AppointmentId).Select(ea => ea).Single();

                    var hafAnswers = customerHealthInfoEntities.Where(chi => chi.EventCustomerId == eventCustomerEntity.EventCustomerId).Select(chi => chi).ToArray();

                    var answers = new List <OrderedPair <long, string> >();

                    foreach (var question in HouseCallHafResultExportHelper.Questions)
                    {
                        var hafAnswer = hafAnswers.Where(ha => ha.CustomerHealthQuestionId == question.FirstValue).Select(ha => ha).FirstOrDefault();

                        if (hafAnswer != null && question.FirstValue != 1233 && question.FirstValue != 1244)
                        {
                            if (receivedDateUnkownQuestionIds.Contains(question.FirstValue) || checkboxQuestionIds.Contains(question.FirstValue))
                            {
                                if (!string.IsNullOrEmpty(hafAnswer.HealthQuestionAnswer))
                                {
                                    answers.Add(new OrderedPair <long, string>(question.FirstValue, "Yes"));
                                }
                                else
                                {
                                    answers.Add(new OrderedPair <long, string>(question.FirstValue, ""));
                                }
                            }
                            else if (hafAnswer.HealthQuestionAnswer == "RefusedDeclined")
                            {
                                answers.Add(new OrderedPair <long, string>(question.FirstValue, "Refused/Declined"));
                            }
                            else if (hafAnswer.HealthQuestionAnswer == "Retired disabled")
                            {
                                answers.Add(new OrderedPair <long, string>(question.FirstValue, "Retired/disabled"));
                            }
                            else if (hafAnswer.HealthQuestionAnswer == "Is it chronic pain")
                            {
                                answers.Add(new OrderedPair <long, string>(question.FirstValue, "It is chronic pain"));
                            }
                            else if (hafAnswer.HealthQuestionAnswer == "Is it acute pain")
                            {
                                answers.Add(new OrderedPair <long, string>(question.FirstValue, "It is acute pain"));
                            }
                            else
                            {
                                answers.Add(new OrderedPair <long, string>(question.FirstValue, hafAnswer.HealthQuestionAnswer));
                            }
                        }
                        else
                        {
                            if (question.FirstValue == 1177)
                            {
                                var healthQuestionAnswers = hafAnswers.Where(ha => assistiveDevicesUsedQuestionIds.Contains(ha.CustomerHealthQuestionId)).OrderBy(ha => ha.CustomerHealthQuestionId).Select(ha => ha.HealthQuestionAnswer);
                                answers.Add(new OrderedPair <long, string>(question.FirstValue, string.Join(",", healthQuestionAnswers)));
                            }
                            else if (question.FirstValue == 1248)
                            {
                                var healthQuestionAnswers = hafAnswers.Where(ha => assistanceServicesUsedQuestionIds.Contains(ha.CustomerHealthQuestionId)).OrderBy(ha => ha.CustomerHealthQuestionId).Select(ha => ha.HealthQuestionAnswer);
                                answers.Add(new OrderedPair <long, string>(question.FirstValue, string.Join(",", healthQuestionAnswers)));
                            }
                            else if (question.FirstValue == 1233)
                            {
                                var healthQuestionAnswers = hafAnswers.Where(ha => itemsNeededByFamilyMembersQuestionIds.Contains(ha.CustomerHealthQuestionId)).OrderBy(ha => ha.CustomerHealthQuestionId).Select(ha => ha.HealthQuestionAnswer);
                                answers.Add(new OrderedPair <long, string>(question.FirstValue, string.Join(",", healthQuestionAnswers)));
                            }
                            else if (question.FirstValue == 1244)
                            {
                                var healthQuestionAnswers = hafAnswers.Where(ha => lackOfTransportationQuestionIds.Contains(ha.CustomerHealthQuestionId)).OrderBy(ha => ha.CustomerHealthQuestionId).Select(ha => ha.HealthQuestionAnswer);
                                answers.Add(new OrderedPair <long, string>(question.FirstValue, string.Join(",", healthQuestionAnswers)));
                            }
                            else
                            {
                                answers.Add(new OrderedPair <long, string>(question.FirstValue, ""));
                            }
                        }
                    }

                    var model = new HouseCallHafResultExportModel
                    {
                        CustomerId = customer.CustomerId,
                        MemberId   = string.IsNullOrEmpty(customer.InsuranceId) ? "" : customer.InsuranceId,
                        FirstName  = user.FirstName,
                        LastName   = user.LastName,
                        Dob        = user.Dob,
                        Gender     = customer.Gender,
                        Phone      = user.PhoneHome,
                        Address1   = address.StreetAddressLine1,
                        City       = address.City,
                        State      = address.State,
                        Zip        = address.ZipCode.Zip,

                        EventId = eventData.EventId,
                        HealthAssesmentAnswer = answers,
                        RegistrationDate      = eventCustomerEntity.DateCreated,
                    };

                    if (model.EventId > 0)
                    {
                        var theEvent = _eventRepository.GetById(model.EventId);
                        if (theEvent.HostId > 0)
                        {
                            var host = _hostRepository.GetHostForEvent(theEvent.Id);
                            model.EventLocation = host.OrganizationName;
                            model.EventAddress  = host.Address.ToShortAddressString();
                        }
                    }

                    if (primaryCarePhysician != null)
                    {
                        model.PCPName = new Name(primaryCarePhysician.FirstName, primaryCarePhysician.MiddleName, primaryCarePhysician.LastName).FullName;

                        var pcpAddress = pcpAddresses != null?pcpAddresses.Where(x => x.Id == primaryCarePhysician.Pcpaddress).FirstOrDefault() : null;

                        if (pcpAddress != null)
                        {
                            model.PCPAddress = pcpAddress.StreetAddressLine1;
                            model.PCPCity    = pcpAddress.City;
                            model.PCPState   = pcpAddress.State;
                            model.PCPZip     = pcpAddress.ZipCode.Zip;
                        }
                    }

                    if (eventAppointment != null)
                    {
                        model.AppointmentDate = eventAppointment.StartTime;
                        model.AppointmentTime = eventAppointment.StartTime;
                    }

                    WriteCsv(model, fileName);
                    _logger.Info(counter + " completed out of " + totalRecords);

                    counter++;
                }
                catch (Exception ex)
                {
                    _logger.Error(string.Format("\n\nFor Event {0} and Customer {1} \n Error:{2}", eventCustomerEntity.EventId, eventCustomerEntity.CustomerId, ex.Message));
                }
            }
        }
示例#12
0
        private void GenerateCrosswalkInboundReport(CrosswalkInboundFilter filter)
        {
            var account = _corporateAccountRepository.GetById(filter.AccountId);

            filter.Tag = account.Tag;

            if (account.IsHealthPlan)
            {
                filter.StopSendingPdftoHealthPlanDate = _settings.StopSendingPdftoHealthPlanDate;
            }

            var model = _crosswalkInboundReportService.GetCrosswalkInboundReportList(filter, _logger);

            if (model != null)
            {
                var folder = string.Format(_settings.FloridaBlueInboundReportPath, account.FolderName, DateTime.Now.ToString("yyyy-MM-dd"));
                if (!Directory.Exists(folder))
                {
                    DirectoryOperationsHelper.CreateDirectory(folder);
                }
                var fileName    = _pipeDelimitedReportHelper.GetReportName(ReportType.CrosswalkInbound) + ".txt";
                var zipFileName = _pipeDelimitedReportHelper.GetReportName(ReportType.CrosswalkZip);

                if (model.Collection != null && model.Collection.Any())
                {
                    _logger.Info("generating File");
                    var tempMediaLocation = _mediaRepository.GetTempMediaFileLocation().PhysicalPath + zipFileName + "\\";
                    if (!Directory.Exists(tempMediaLocation))
                    {
                        DirectoryOperationsHelper.CreateDirectory(tempMediaLocation);
                    }

                    var resultPostedToPlanFileName = Path.Combine(_resultPostedToPlanPath, string.Format("ResultPostedto_{0}.xml", account.Tag));
                    var resultPosted = _resultPdfPostedSerializer.Deserialize(resultPostedToPlanFileName);
                    resultPosted = resultPosted == null || resultPosted.Customer.IsNullOrEmpty() ? new ResultPdfPostedXml {
                        Customer = new List <CustomerInfo>()
                    } : resultPosted;

                    foreach (var crosswalkViewModel in model.Collection)
                    {
                        var hafResultPdfLocation = _mediaRepository.GetPremiumVersionResultPdfLocation(crosswalkViewModel.EventId, crosswalkViewModel.CustomerId);
                        var hafResultPdfFileName = _mediaRepository.GetPdfFileNameForHealthPlanResultReport();
                        var pcpResultPdfFileName = _mediaRepository.GetPdfFileNameForPcpResultReport();

                        _logger.Info(" Event Id: " + crosswalkViewModel.EventId + " Customer Id: " + crosswalkViewModel.CustomerId);

                        if (DirectoryOperationsHelper.IsFileExist(tempMediaLocation + crosswalkViewModel.FileName))
                        {
                            var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(tempMediaLocation + crosswalkViewModel.FileName);
                            var files = DirectoryOperationsHelper.GetFiles(tempMediaLocation, fileNameWithoutExtension + "*.pdf");
                            crosswalkViewModel.FileName = fileNameWithoutExtension + "_" + files.Count() + ".pdf";
                        }

                        if (File.Exists(hafResultPdfLocation.PhysicalPath + hafResultPdfFileName))
                        {
                            var destinationFileName = GetFileName(resultPosted.Customer, crosswalkViewModel.EventId, crosswalkViewModel.CustomerId, Path.GetFileNameWithoutExtension(crosswalkViewModel.FileName), (long)ResultFormatType.PDF);
                            crosswalkViewModel.FileName = destinationFileName + ".pdf";

                            _logger.Info("Copying File.. filePath from : " + hafResultPdfLocation.PhysicalPath + hafResultPdfFileName);
                            _logger.Info("Copying File.. filePath To : " + tempMediaLocation + crosswalkViewModel.FileName);

                            DirectoryOperationsHelper.Copy(hafResultPdfLocation.PhysicalPath + hafResultPdfFileName, tempMediaLocation + crosswalkViewModel.FileName);

                            resultPosted.Customer.Add(GetCustomerInfo(crosswalkViewModel));
                        }
                        else if (File.Exists(hafResultPdfLocation.PhysicalPath + pcpResultPdfFileName))
                        {
                            var destinationFileName = GetFileName(resultPosted.Customer, crosswalkViewModel.EventId, crosswalkViewModel.CustomerId, Path.GetFileNameWithoutExtension(crosswalkViewModel.FileName), (long)ResultFormatType.PDF);
                            crosswalkViewModel.FileName = destinationFileName + ".pdf";

                            _logger.Info("Copying File.. filePath from : " + hafResultPdfLocation.PhysicalPath + pcpResultPdfFileName);
                            _logger.Info("Copying File.. filePath To : " + tempMediaLocation + crosswalkViewModel.FileName);

                            DirectoryOperationsHelper.Copy(hafResultPdfLocation.PhysicalPath + pcpResultPdfFileName, tempMediaLocation + crosswalkViewModel.FileName);

                            resultPosted.Customer.Add(GetCustomerInfo(crosswalkViewModel));
                        }
                        else
                        {
                            _logger.Info("file not found");
                        }
                    }

                    _resultPdfPostedSerializer.SerializeandSave(resultPostedToPlanFileName, resultPosted);

                    _pipeDelimitedReportHelper.Write(model.Collection, folder, fileName);
                    DirectoryOperationsHelper.Copy(folder + "\\" + fileName, tempMediaLocation + fileName);

                    _logger.Info("generating Zip ");
                    _zipHelper.CreateZipFiles(tempMediaLocation, folder + "\\" + zipFileName + ".zip");

                    if (_sendReportToSftp)
                    {
                        try
                        {
                            _logger.Info("Sending zip to SFTP.");

                            var destinationPath = _destinationSftpPath + "\\" + account.FolderName + "\\Download\\Reports";
                            SendFilesToSftp(Path.Combine(folder, zipFileName + ".zip"), destinationPath, zipFileName + ".zip");

                            _logger.Info("Zip sent to SFTP.");
                        }
                        catch (Exception ex)
                        {
                            _logger.Info("Error sending zip to SFTP.");
                            _logger.Error("Message : " + ex.Message);
                            _logger.Error("Stack Trace : " + ex.StackTrace);
                        }
                    }

                    _logger.Info("Deleting temp folder: " + tempMediaLocation);
                    DirectoryOperationsHelper.DeleteDirectory(tempMediaLocation, true);

                    _logger.Info("Deleting text file: " + folder + "\\" + fileName);
                    DirectoryOperationsHelper.Delete(folder + "\\" + fileName);
                }
                else
                {
                    _logger.Info("No Data found for account Id: " + filter.AccountId);
                }
            }
            else
            {
                _logger.Info("No record found for " + account.Tag);
            }
        }
示例#13
0
        private void GenerateCrosswalkLabInboundReport(CrosswalkLabInboundFilter filter)
        {
            var account = _corporateAccountRepository.GetById(filter.AccountId);

            filter.Tag = account.Tag;

            var model = _crosswalkInboundReportService.GetCrosswalkLabInboundReportList(filter);

            if (model != null)
            {
                var folder = string.Format(_settings.FloridaBlueInboundReportPath, account.FolderName, DateTime.Now.ToString("yyyy-MM-dd"));
                if (!Directory.Exists(folder))
                {
                    DirectoryOperationsHelper.CreateDirectory(folder);
                }
                var fileName    = _pipeDelimitedReportHelper.GetReportName(ReportType.CrosswalkLabInbound) + ".txt";
                var zipFileName = _pipeDelimitedReportHelper.GetReportName(ReportType.CrosswalkLabZip);

                if (model.Collection != null && model.Collection.Any())
                {
                    _logger.Info("generating File");
                    _pipeDelimitedReportHelper.Write(model.Collection, folder, fileName);

                    var tempMediaLocation = _mediaRepository.GetTempMediaFileLocation().PhysicalPath + zipFileName + "\\";

                    if (!Directory.Exists(tempMediaLocation))
                    {
                        DirectoryOperationsHelper.CreateDirectory(tempMediaLocation);
                    }

                    foreach (var crosswalkViewModel in model.Collection)
                    {
                        var resultMediaLocation = _mediaRepository.GetResultMediaFileLocation(crosswalkViewModel.CustomerId, crosswalkViewModel.EventId);

                        _logger.Info(" Event Id: " + crosswalkViewModel.EventId + " Customer Id: " + crosswalkViewModel.CustomerId);
                        _logger.Info("file Path: " + resultMediaLocation.PhysicalPath + crosswalkViewModel.TestPdf);

                        if (!string.IsNullOrEmpty(crosswalkViewModel.TestPdf) && File.Exists(resultMediaLocation.PhysicalPath + crosswalkViewModel.TestPdf))
                        {
                            _logger.Info("Copying File.. filePath from : " + resultMediaLocation.PhysicalPath + crosswalkViewModel.TestPdf);
                            _logger.Info("Copying File.. filePath To : " + tempMediaLocation + crosswalkViewModel.FileName);
                            File.Copy(resultMediaLocation.PhysicalPath + crosswalkViewModel.TestPdf, tempMediaLocation + crosswalkViewModel.FileName);
                        }
                        else
                        {
                            _logger.Info("file not found");
                            _logger.Info("filePath : " + resultMediaLocation.PhysicalPath + "\\" + crosswalkViewModel.TestPdf);
                        }
                    }

                    File.Copy(folder + "\\" + fileName, tempMediaLocation + fileName);

                    _logger.Info("generating Zip ");
                    _zipHelper.CreateZipFiles(tempMediaLocation, folder + "\\" + zipFileName + ".zip");

                    _logger.Info("Deleting text file: " + folder + "\\" + fileName);
                    File.Delete(folder + "\\" + fileName);

                    if (_sendReportToSftp)
                    {
                        try
                        {
                            _logger.Info("Sending zip to SFTP.");

                            var destinationPath = _destinationSftpPath + "\\" + account.FolderName + "\\Download\\Reports";
                            SendFilesToSftp(Path.Combine(folder, zipFileName + ".zip"), destinationPath, zipFileName + ".zip");

                            _logger.Info("Zip sent to SFTP.");
                        }
                        catch (Exception ex)
                        {
                            _logger.Info("Error sending zip to SFTP.");
                            _logger.Error("Message : " + ex.Message);
                            _logger.Error("Stack Trace : " + ex.StackTrace);
                        }
                    }
                }
                else
                {
                    _logger.Info("No record found for " + account.Tag);
                }
            }
            else
            {
                _logger.Info("No record found for " + account.Tag);
            }
        }