public Task<Stream> GetTemplate(IllustrationRequest illustrationRequest)
        {
            var tcs = new TaskCompletionSource<Stream>();

            try
            {
                //var g = illustrationRequest.Gender.HasValue ? illustrationRequest.Gender.Value : Gender.Male;
                //var smoker = illustrationRequest.IsSmoker.HasValue ? illustrationRequest.IsSmoker.Value : false;
                //var age = illustrationRequest.Age.HasValue ? AgeFromBuckets(illustrationRequest.Age.Value) : 18;
                //var requested = illustrationRequest.RequestedCoverage.HasValue ? illustrationRequest.RequestedCoverage.Value : 1000000;

                //var genderString = g == Gender.Male ? "M" : "F";
                //var smokerString = smoker ? "SM" : "NS";
                //var reqString = string.Empty;
                //if (requested <= 250000) reqString = "250K";
                //else if (requested <= 500000) reqString = "500K";
                //else reqString = "1M";

                //var filename = String.Format("{0}-{1}-{2}-{3}.pdf", genderString, smokerString, age, reqString);

                var path = WebServerPathUtils.GetPathTo(Path.Combine("bin", "Documents", "formfill.pdf"));
                var f = new FileInfo(path);
                var fs = f.OpenRead();

                
                tcs.SetResult(fs);
            }
            catch (Exception e)
            {
                tcs.SetException(e);
            }
            return tcs.Task;
        }
예제 #2
0
        public PdfService(IPdfDocumentTemplateProvider templateProvider, IllustrationRequest data)
        {
            _data = data;
            _templateProvider = templateProvider;

            if (String.IsNullOrEmpty(_data.FirstName) || String.IsNullOrEmpty(_data.LastName))
            {
                GeneratedId = Guid.NewGuid().ToString();
            }
            else
            {
                GeneratedId = String.Format("{0}-{1}", _data.FirstName, _data.LastName).Trim();
            }
        }
        public async Task GenerateIllustration(Guid meetingId, PersonModel model)
        {
            var illustrationRequest = new IllustrationRequest
            {
                FirstName = model.FirstName,
                LastName = model.LastName,
                Gender = model.Gender,
                IsSmoker = model.IsSmoker,
                DateOfBirth = model.DateOfBirth,
                Age = model.Age,
                NumOfDependents = model.NumOfDependents,
                RetirementAge = model.RetirementAge,
                ExistingCoverage = model.ExistingCoverage,
                RequestedCoverage = model.CoverageAmountRequesting,
                AnnualIncome = model.AnnualIncome,
                AnnualIncomeGrowthPercentage = model.AnnualIncomeGrowthPercent,
                Addr1 = model.Addr1,
                Addr2 = model.Addr2,
                City = model.City,
                State = model.State, 
                Zip = model.Zip
            };

            await ConnectedTask;
            await Proxy.Invoke("generateAndSaveIllustration", meetingId, illustrationRequest);
        }
예제 #4
0
        public async Task GenerateAndSaveIllustration(Guid meetingId, IllustrationRequest illustrationRequest)
        {
            var pdfService = new PdfService(_templateProvider, illustrationRequest);
            var key = pdfService.GeneratedId;
            var stream = await pdfService.CreateForm1();

            var bytedata = stream.ReadToEnd();
       //     _blogStorage.StoreValue(key, new MemoryStream(bytedata));
            PDFDocController.InsertDocument(key, bytedata);
            NotifyPdfAvailable(meetingId, key);
        }