private IDocument DoConvert(QuoteSlipSchedules i, IBaseTemplate template)
        {
            var quoteSlipDoc = _document.OpenFile(Constants.CacheNames.GenerateQuoteSlip, Settings.Default.TemplateQuoteSlip);

            _presenter.ConvertToQuoteSlip(Settings.Default.TemplateQuoteSlip, quoteSlipDoc, i as QuoteSlipSchedules, template);
            return(quoteSlipDoc);
        }
Ejemplo n.º 2
0
        public void PopulateGraphics(IBaseTemplate template, string previousCoverPageTitle, string previousLogoTitle)
        {
            var names  = new string[2];
            var values = new string[2];

            //do not populate array with images if their values have not changed.
            if (!String.Equals(template.CoverPageTitle, previousCoverPageTitle, StringComparison.OrdinalIgnoreCase))
            {
                if (template.CoverPageImageUrl != null)
                {
                    names[0]  = Constants.ImageProperties.Theme;
                    values[0] = template.CoverPageImageUrl;
                }
            }

            if (!String.Equals(template.LogoTitle, previousLogoTitle, StringComparison.OrdinalIgnoreCase))
            {
                if (template.LogoImageUrl != null)
                {
                    names[1]  = Constants.ImageProperties.CompanyLogo;
                    values[1] = template.LogoImageUrl;
                }
            }

            Document.ChangeDocumentImages(names, values);
            Document.UpdateOrCreatePropertyValue(Constants.WordDocumentProperties.CoverPageTitle, template.CoverPageTitle);
            Document.UpdateOrCreatePropertyValue(Constants.WordDocumentProperties.LogoTitle, template.LogoTitle);
        }
 private static void FinaliseConvert(IDocument quoteSlipDoc, IBaseTemplate sourceTemplateData, QuoteSlipWizardPresenter quoteSlipWizardPresenter)
 {
     sourceTemplateData.DocumentTitle = "Quotation Slip";
     quoteSlipWizardPresenter.PopulateData(sourceTemplateData);
     quoteSlipDoc.MoveToStartOfDocument();
     quoteSlipDoc.CloseInformationPanel(true);
 }
Ejemplo n.º 4
0
        public virtual void PopulateDocument(IBaseTemplate template)
        {
            //populate the content controls
            BasePresenter.PopulateData(template);

            //change the graphics selected
            // if (Streams == null) return;
            BasePresenter.PopulateGraphics(template, string.Empty, string.Empty);
        }
Ejemplo n.º 5
0
 public virtual void PopulateDocument(IBaseTemplate template, string previousCoverPageTitle, string previousLogoTitle)
 {
     //populate the content controls
     BaseWizardPresenter.PopulateData(template);
     //change the graphics selected
     // if (Streams == null) return;
     BaseWizardPresenter.PopulateGraphics(template, previousCoverPageTitle, previousLogoTitle);
     BaseWizardPresenter.UpdateFields();
 }
Ejemplo n.º 6
0
        public void PopulateDocument(IBaseTemplate template, string previousCoverPageTitle, string previousLogoTitle, IDocument document)
        {
            var tmpPresenter = new BaseWizardPresenter(document, this);

            //populate the content controls
            tmpPresenter.PopulateData(template);
            //change the graphics selected
            // if (Streams == null) return;
            tmpPresenter.PopulateGraphics(template, previousCoverPageTitle, previousLogoTitle);
            tmpPresenter.UpdateFields();
            tmpPresenter.CreateOrUpdateDocumentProperty(Constants.WordDocumentProperties.DocumentGeneratedDate, DateTime.Now.ToString(CultureInfo.CurrentUICulture));
        }
Ejemplo n.º 7
0
        public IBaseTemplate GetTemplate(string name)
        {
            IBaseTemplate _t = null;

            try
            {
                if (Templates != null)
                {
                    _t = Templates.Where(t => t.Name == name).FirstOrDefault();
                }
            }
            catch (System.Exception ex)
            {
                _logger.LogError($"Unable to find '{name}' template. {ex.Message}");
                throw;
            }

            return(_t);
        }
Ejemplo n.º 8
0
        public void ConvertToQuoteSlip(string quoteSlipServerRelativeUrl, IDocument quoteSlipDoc,
                                       IQuoteSlipSchedules schedule, IBaseTemplate sourceTemplateData)
        {
            var quoteSlipWizardPresenter = new QuoteSlipWizardPresenter(quoteSlipDoc, _view);

            var question = new QuestionClass
            {
                Id    = schedule.Id,
                Title = schedule.Title,
                Url   = schedule.Url
            };
            var questions = new List <IQuestionClass> {
                question
            };

            quoteSlipWizardPresenter.InsertPolicySchedule(questions, true);
            InsertUnderwritingInformations(quoteSlipDoc, schedule);
            CopyAllContentControlValuesBetweenTemplates(quoteSlipDoc);
            CopyAllTablesBetweenTemplates(quoteSlipDoc);
            FinaliseConvert(quoteSlipDoc, sourceTemplateData, quoteSlipWizardPresenter);
        }
Ejemplo n.º 9
0
        public void PopulateData(IBaseTemplate template)
        {
            //populate field controls.
            foreach (PropertyInfo pInfo in template.GetType().GetProperties())
            {
                if (pInfo == null)
                {
                    break;
                }

                string value = String.Empty;
                if (pInfo.GetValue(template, null) != null)
                {
                    value = pInfo.GetValue(template, null).ToString();
                }

                Document.PopulateControl(pInfo.Name, value);
            }

            Document.UpdateFields();
            CloseInformationPanel();
        }
Ejemplo n.º 10
0
        public object LoadData(IBaseTemplate template)
        {
            //read content controls and set template values.
            foreach (PropertyInfo pInfo in template.GetType().GetProperties())
            {
                if (pInfo == null)
                {
                    break;
                }

                if (!String.Equals(pInfo.PropertyType.Name, "string", StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }
                string value = Document.ReadContentControlValue(pInfo.Name);
                pInfo.SetValue(template, value, null);
            }

            //read cover page and logo property values and set template values
            template.CoverPageTitle = Document.GetPropertyValue(Constants.WordDocumentProperties.CoverPageTitle);
            template.LogoTitle      = Document.GetPropertyValue(Constants.WordDocumentProperties.LogoTitle);
            return(template);
        }
Ejemplo n.º 11
0
        public virtual void PopulateDocument(IBaseTemplate template, string previousCoverPageTitle, string previousLogoTitle)
        {
            //populate the content controls
            BaseWizardPresenter.PopulateData(template);
            //change the graphics selected
            // if (Streams == null) return;
            BaseWizardPresenter.PopulateGraphics(template, previousCoverPageTitle, previousLogoTitle);
            BaseWizardPresenter.UpdateFields();
            var type = template.GetType();

            //var propertyName = Constants.WordDocumentProperties.UsedDateOfLogo;

            //if(key.Equals("Themes",StringComparison.OrdinalIgnoreCase))
            //    propertyName = Constants.WordDocumentProperties.UsedDateOfTheme;


            var date     = DateTime.Now.ToString("dd/MM/yy");
            var logoVal  = string.Format("{0};{1}", template.LogoImageUrl, date);
            var themeVal = string.Format("{0};{1}", template.CoverPageImageUrl, date);

            BaseWizardPresenter.CreateOrUpdateDocumentProperty(Constants.WordDocumentProperties.UsedDateOfLogo, logoVal);
            BaseWizardPresenter.CreateOrUpdateDocumentProperty(Constants.WordDocumentProperties.UsedDateOfTheme, themeVal);
            BaseWizardPresenter.CreateOrUpdateDocumentProperty(Constants.WordDocumentProperties.DocumentGeneratedDate, date);
        }
 public void OpenFileWithData(IBaseTemplate template)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 13
0
        public void LogUsage(IBaseTemplate template, Enums.UsageTrackingType trackingType)
        {
            try
            {
                var list      = new SharePointList(Settings.Default.SharePointContextUrl, Settings.Default.UsageReportingListName);
                var presenter = new SharePointListPresenter(list, this);

                string segment           = string.Empty;
                string wholesaleOrRetail = string.Empty;
                string title             = "Unknown";
                string userDep           = "Unable to locate";
                string userOffice        = "Unable to locate";

                string type = GetType().Name;

                switch (type)
                {
                case "InsuranceRenewalReportWizard":
                {
                    var form = ((InsuranceRenewalReportWizard)this);
                    segment           = ConvertSegementToNumberical(form.SelectedSegment);
                    wholesaleOrRetail = form.SelectedStatutory.ToString();
                    title             = Constants.TemplateNames.InsuranceRenewalReport;
                    break;
                }

                case "ClientDiscoveryWizard":
                {
                    //var form = ((ClientDiscoveryWizard) this);
                    title = Constants.TemplateNames.ClientDiscovery;
                    break;
                }

                case "PreRenewalAgendaWizard":
                {
                    //var form = ((PreRenewalAgendaWizard) this);
                    title = Constants.TemplateNames.PreRenewalAgenda;
                    break;
                }

                case "RenewalLetterWizard":
                {
                    //var form = ((RenewalLetterWizard) this);
                    title = Constants.TemplateNames.RenewalLetter;
                    break;
                }

                case "SummaryOfDiscussionWizard":
                {
                    //var form = ((SummaryOfDiscussionWizard) this);
                    title = Constants.TemplateNames.FileNote;
                    break;
                }


                case "GenericLetterWizard":
                {
                    //var form = ((GenericLetterWizard)this);
                    title = Constants.TemplateNames.GenericLetter;
                    break;
                }

                case "PreRenewalQuestionareWizard":
                {
                    title = "Fact Finder";         //todo: need to move this to constants once we can update value in ShaerPoint. (currently Pre Renewal Questionaire and cannot be changed until new wizard is released)
                    break;
                }

                case "FactFinderWizard":
                {
                    title = "Fact Finder";         //todo: need to move this to constants once we can update value in ShaerPoint. (currently Pre Renewal Questionaire and cannot be changed until new wizard is released)
                    break;
                }

                case "QuoteSlipWizard":
                {
                    title = Constants.TemplateNames.QuoteSlip;
                    break;
                }

                case "InsuranceManualWizard":
                {
                    title = Constants.TemplateNames.InsuranceManual;
                    break;
                }

                case "ShortFormProposalWizard":
                {
                    title = Constants.TemplateNames.ShortFormProposal + " - " + template.DocumentTitle;
                    break;
                }

                case "PlacementSlip":
                {
                    title = "Placement Slip";
                    break;
                }

                default:
                {
                    title = template.DocumentTitle;
                    break;
                }
                }

                Task.Factory.StartNew(() =>
                {
                    UserPrincipalEx user = FindCurrentUserInAd();
                    if (user != null)
                    {
                        userDep    = user.Branch;
                        userOffice = user.Suburb;
                    }
                    presenter.LogUsage(trackingType.ToString(), title, template.ExecutiveName, userDep, userOffice, template.ClientName, segment, wholesaleOrRetail, DateTime.Now.ToShortDateString(), DateTime.Now.TimeOfDay.ToString());
                }, CancellationToken.None).ContinueWith((task =>
                {
                    if (task.IsFaulted)
                    {
                        OnError(task.Exception);
                    }
                }));
            }
            catch (Exception ex)
            {
                OnError(ex);
            }
        }
Ejemplo n.º 14
0
        public void LogUsage(IBaseTemplate template, Helpers.Enums.UsageTrackingType trackingType)
        {
            var list      = new SharePointList(Settings.Default.SharePointContextUrl, Settings.Default.UsageReportingListName);
            var presenter = new SharePointListPresenter(list, this);

            var segment           = string.Empty;
            var wholesaleOrRetail = string.Empty;
            var title             = "Unknown";
            var userDep           = "Unable to locate";
            var userOffice        = "Unable to locate";

            var type = this.GetType().Name;

            switch (type)
            {
            case "InsuranceRenewalReportWizard":
            {
                var form = ((InsuranceRenewalReportWizard)this);
                segment           = ConvertSegementToNumberical(form._selectedSegment);
                wholesaleOrRetail = form._selectedStatutory.ToString();
                title             = Constants.TemplateNames.InsuranceRenewalReport;
                break;
            }

            case "ClientDiscoveryWizard":
            {
                var form = ((ClientDiscoveryWizard)this);
                title = Constants.TemplateNames.ClientDiscovery;
                break;
            }

            case "PreRenewalAgendaWizard":
            {
                var form = ((PreRenewalAgendaWizard)this);
                title = Constants.TemplateNames.PreRenewalAgenda;
                break;
            }

            case "RenewalLetterWizard":
            {
                var form = ((RenewalLetterWizard)this);
                title = Constants.TemplateNames.RenewalLetter;
                break;
            }

            case "SummaryOfDiscussionWizard":
            {
                var form = ((SummaryOfDiscussionWizard)this);
                title = Constants.TemplateNames.FileNote;
                break;
            }
            }
            Task.Factory.StartNew(() =>
            {
                var user = FindCurrentUserInAD();
                if (user != null)
                {
                    userDep    = user.Branch;
                    userOffice = user.Suburb;
                }
                presenter.LogUsage(trackingType.ToString(), title, template.ExecutiveName, userDep, userOffice, template.ClientName, segment, wholesaleOrRetail, DateTime.Now.ToShortDateString(), DateTime.Now.ToString("h:mm.ss tt"));
            }, CancellationToken.None);
        }
        public void ConvertToQuoteSlip(string quoteSlipServerRelativeUrl, IDocument quoteSlipDoc, IQuoteSlipSchedules schedule, IBaseTemplate sourceTemplateData)
        {
            var quoteSlipWizardPresenter = new QuoteSlipWizardPresenter(quoteSlipDoc, _view);

            var question = new QuestionClass()
            {
                Id    = schedule.Id,
                Title = schedule.Title,
                Url   = schedule.Url
            };
            var questions = new List <IQuestionClass> {
                question
            };

            quoteSlipWizardPresenter.InsertPolicySchedule(questions, true);

            var startRange = _document.GetBookmarkStartRange(Constants.WordBookmarks.FactFinderStart + schedule.LinkedQuestionId);
            var endRange   = _document.GetBookmarkEndRange(Constants.WordBookmarks.FactFinderEnd + schedule.LinkedQuestionId);

            if (startRange < 0 || endRange < 0) //todo: ???
            {
                return;
            }

            _document.CopyRange(startRange, endRange);
            quoteSlipDoc.MoveToEndOfDocument();
            quoteSlipDoc.PasteClipboard();


            quoteSlipWizardPresenter.PopulateData(sourceTemplateData);

            quoteSlipDoc.MoveToStartOfDocument();
            quoteSlipDoc.CloseInformationPanel(true);
        }