Exemplo n.º 1
0
        public string GetHelpContentFromSharePoint(string heading, string sPContext, string helpListName, string templateName)
        {
            if (!String.IsNullOrEmpty(heading))
            {
                heading = heading.Replace("\r", string.Empty).Trim();
                var query = string.Format(Constants.SharePointQueries.HelpGetItemQuery, templateName, heading);

                //todo  max move the list to a settings
                var helpList  = new SharePointList(sPContext, helpListName, query);
                var presenter = new SharePointListPresenter(helpList, this);

                var fitem = presenter.GetHelpItems().FirstOrDefault();

                if (fitem != null)
                {
                    return(fitem.GetFieldValue(Constants.SharePointFields.Content));
                }
                else
                {
                    var generalHelp = string.Format(Constants.SharePointQueries.HelpGetItemQuery, templateName, Constants.SharePointFields.WizardHelp);
                    helpList.UpdateCamlQuery(generalHelp);
                    var gitem = presenter.GetHelpItems().FirstOrDefault();
                    if (gitem != null)
                    {
                        return(gitem.GetFieldValue(Constants.SharePointFields.Content));
                    }
                }
            }
            return("Unable to find the help content for this document");
        }
Exemplo n.º 2
0
        public string GetHelpContentFromSharePoint(string heading, string sPContext, string helpListName,
                                                   string templateName)
        {
            if (!string.IsNullOrEmpty(heading))
            {
                heading = heading.Replace("\r", string.Empty).Trim();
                var query     = ListQueries.HelpGetItemQuery(templateName, heading);
                var helpList  = ListFactory.Create(helpListName, query);
                var presenter = new SharePointListPresenter(helpList, this);

                var fitem = presenter.GetHelpItems().FirstOrDefault();

                if (fitem != null)
                {
                    return(fitem.GetFieldValue(Constants.SharePointFields.Content));
                }

                var generalHelp = ListQueries.HelpGetItemQuery(templateName, Constants.SharePointFields.WizardHelp);
                helpList.UpdateCamlQuery(generalHelp);
                var gitem = presenter.GetHelpItems().FirstOrDefault();
                return(gitem != null
                    ? gitem.GetFieldValue(Constants.SharePointFields.Content)
                    : "Unable to find the help content for this document");
            }
            return("Unable to find the help content for this document");
        }
Exemplo n.º 3
0
        protected virtual List <IPolicyClass> LoadMinorPolicyTypes()
        {
            var list      = new SharePointList(Settings.Default.SharePointContextUrl, Settings.Default.MinorPolicyClassesListName);
            var presenter = new SharePointListPresenter(list, this);

            return(presenter.GetMinorPolicyItems());
        }
Exemplo n.º 4
0
        protected List <IQuestionClass> LoadQuestionsFromSharePoint(string contextUrl, string listName)
        {
            var list      = ListFactory.Create(listName, true);
            var presenter = new SharePointListPresenter(list, this);

            return(presenter.GetPreRenewalQuestionaireQuestions());
        }
Exemplo n.º 5
0
        protected List <IQuestionClass> LoadQuestionsFromSharePoint(string contextUrl, string listName)
        {
            var list      = new SharePointList(contextUrl, listName, Constants.SharePointQueries.AllItemsSortBySortOrder);
            var presenter = new SharePointListPresenter(list, this);

            return(presenter.GetPreRenewalQuestionaireQuestions());
        }
        private void LoadClaimsProcedures(TaskScheduler uiScheduler)
        {
            List <ISharePointListItem> fragments = null;

            if (Cache.Contains(Constants.CacheNames.RenLtrFragments))
            {
                fragments = (List <ISharePointListItem>)Cache.Get(Constants.CacheNames.RenLtrFragments);
            }
            else
            {
                var list      = new SharePointList(Settings.Default.SharePointContextUrl, Settings.Default.LibraryClaimsProcedures, Constants.SharePointQueries.AllItemsSortByTitle);
                var presenter = new SharePointListPresenter(list, this);
                fragments = presenter.GetItems();
            }


            if (uiScheduler == null)
            {
                DataBindClaimsControl(fragments);
            }
            else
            {
                Task.Factory.StartNew(() => DataBindClaimsControl(fragments), CancellationToken.None, TaskCreationOptions.None, uiScheduler);
            }
        }
        private List <IQuoteSlipSchedules> GetQuestionsForIncludedPolicies(string includedPolicies)
        {
            var spList    = new SharePointList(Settings.Default.SharePointContextUrl, "Quote Slip Schedules", Constants.SharePointQueries.AllItemsSortByTitle); //todo: move listname to settings
            var presenter = new SharePointListPresenter(spList, this);
            var items     = presenter.GetItems();

            var qs = includedPolicies.Split(';').Select(delegate(string p)
            {
                if (String.IsNullOrEmpty(p))
                {
                    p = "-123";                                                                                                         //saftey net incase there are any blank lookup values in sharepoint, better not to display them in the popup
                }
                var g = items.FirstOrDefault(i => i.GetLookupFieldValue(Constants.SharePointFields.QuoteSlipSchedulesFfLookupId) == p); //presenter.GetQuoteSlipSchedule(p);

                return(g == null ? null : new QuoteSlipSchedules
                {
                    Title = g.Title,
                    Url = g.FileRef,
                    Id = g.GetFieldValue(Constants.SharePointFields.FieldId),
                    LinkedQuestionId = g.GetLookupFieldValue(Constants.SharePointFields.QuoteSlipSchedulesFfLookupId)
                });
            }).Cast <IQuoteSlipSchedules>().ToList();

            return(qs);
        }
Exemplo n.º 8
0
        protected List <ISharePointListItem> LoadMajorTreeNodeTypes(string contextUrl, string listName)
        {
            var list      = new SharePointList(contextUrl, listName);
            var presenter = new SharePointListPresenter(list, this);

            return(presenter.GetItems());
        }
Exemplo n.º 9
0
        private List <IQuestionClass> LoadMinorQuestionTypes()
        {
            var list      = new SharePointList(Settings.Default.SharePointContextUrl, Settings.Default.MinorQuestionClassesListName);
            var presenter = new SharePointListPresenter(list, this);

            return(presenter.GetMinorQuestionItems());
        }
Exemplo n.º 10
0
        protected IQuestionClass LoadSchedule(string contextUrl, string listName, string title)
        {
            var list      = ListFactory.Create(listName, ListQueries.GetItemByTitleQuery(title));
            var presenter = new SharePointListPresenter(list, this);
            var t         = presenter.GetPreRenewalQuestionaireQuestions();

            return((t != null && t.Count > 0) ? t[0] : null);
        }
Exemplo n.º 11
0
        protected IManualClaimsProcedure LoadClaimsProcedure(string contextUrl, string listName, string title)
        {
            var list      = new SharePointList(contextUrl, listName, String.Format(Constants.SharePointQueries.GetItemByPolicyTypeQuery, title));
            var presenter = new SharePointListPresenter(list, this);
            List <IManualClaimsProcedure> t = presenter.GetManualClaimsProcedure();

            return((t != null && t.Count > 0) ? t[0] : null);
        }
Exemplo n.º 12
0
        protected IQuestionClass LoadSchedule(string contextUrl, string listName, string title)
        {
            var list                = new SharePointList(contextUrl, listName, String.Format(Constants.SharePointQueries.GetItemByTitleQuery, title));
            var presenter           = new SharePointListPresenter(list, this);
            List <IQuestionClass> t = presenter.GetPreRenewalQuestionaireQuestions();

            return((t != null && t.Count > 0) ? t[0] : null);
        }
Exemplo n.º 13
0
        protected IManualClaimsProcedure LoadClaimsProcedure(string contextUrl, string listName, string title)
        {
            var list      = ListFactory.Create(listName, ListQueries.GetItemByPolicyTypeQuery(title));
            var presenter = new SharePointListPresenter(list, this);
            var t         = presenter.GetManualClaimsProcedure();

            return((t != null && t.Count > 0) ? t[0] : null);
        }
Exemplo n.º 14
0
        private List <IQuoteSlipSchedules> GetQuestionsForIncludedPolicies(string includedPolicies)
        {
            var spList    = ListFactory.Create("Quote Slip Schedules");
            var presenter = new SharePointListPresenter(spList, this);
            var items     = presenter.GetItems();


            var spListQuestions = ListFactory.Create(Settings.Default.PreRenewalQuestionareMappingsListName);
            //todo: move listname to settings
            var presenterQuestions = new SharePointListPresenter(spListQuestions, this);
            var itemsQuestions     = presenterQuestions.GetItems();


            var qs = includedPolicies.Split(';').Select(delegate(string p)
            {
                if (string.IsNullOrEmpty(p))
                {
                    p = "-123";
                }
                //saftey net incase there are any blank lookup values in sharepoint, better not to display them in the popup

                var g =
                    items.FirstOrDefault(
                        i =>
                        i.GetLookupFieldValueIdArray(Constants.SharePointFields.QuoteSlipSchedulesFfLookupId)
                        .Contains(p));         //presenter.GetQuoteSlipSchedule(p);
                var title = string.Empty;

                if (g != null)
                {
                    title = g.Title;

                    if (g.Title.ToLower().Contains("workers"))
                    {
                        var question =
                            itemsQuestions.FirstOrDefault(i => i.GetFieldValue(Constants.SharePointFields.FieldId) == p);
                        //presenter.GetQuoteSlipSchedule(p);

                        title = question.Title;
                    }
                }

                return(g == null
                    ? null
                    : new QuoteSlipSchedules
                {
                    Title = title,
                    Url = g.FileRef,
                    Id = g.GetFieldValue(Constants.SharePointFields.FieldId),
                    LinkedQuestionId =
                        g.GetLookupFieldValueIdArray(Constants.SharePointFields.QuoteSlipSchedulesFfLookupId)
                });
            }).Cast <IQuoteSlipSchedules>().ToList();

            return(qs);
        }
Exemplo n.º 15
0
        public void btnOpenBICalculator_Click(IRibbonControl control)
        {
            var list      = ListFactory.Create("Configuration");
            var presenter = new SharePointListPresenter(list, null);
            var item      = presenter.GetItemByTitle("BICalculator.HttpAddress");
            var address   = item.GetFieldValue("Value");

            if (string.IsNullOrEmpty(address))
            {
                return;
            }
            Process.Start(address);
        }
Exemplo n.º 16
0
        public void btnOpenBICalculator_Click(IRibbonControl control)
        {
            var list      = new SharePointList(Properties.Settings.Default.SharePointContextUrl, "Configuration", Constants.SharePointQueries.GetItemByTitleQuery); //todo: make setting for new config list
            var presenter = new SharePointListPresenter(list, null);
            var item      = presenter.GetItemByTitle("BICalculator.HttpAddress");
            var address   = item.GetFieldValue("Value");

            if (String.IsNullOrEmpty(address))
            {
                return;
            }
            Process.Start(address);
        }
Exemplo n.º 17
0
        private List <IInsurer> GetInsurers()
        {
            List <IInsurer> returnItems;

            if (Cache.Contains("InsurersData"))
            {
                returnItems = (List <IInsurer>)Cache.Get("InsurersData");
            }
            else
            {
                var list      = new SharePointList(Settings.Default.SharePointContextUrl, Settings.Default.ApprovedInsurersListName, BusinessLogic.Helpers.Constants.SharePointQueries.AllItemsSortByTitle);
                var presenter = new SharePointListPresenter(list, this);
                returnItems = presenter.GetInsurers();
                Cache.Add("InsurersData", returnItems, new CacheItemPolicy());
            }

            return(returnItems);
        }
Exemplo n.º 18
0
        //perfomacance issue here as we are doing two trips to sharepoint
        public static string GetPostalAddressFragment(this string office, bool isPart1)
        {
            if (office == null)
            {
                return(string.Empty);
            }

            var list      = ListFactory.Create("Office Addresses");
            var presenter = new SharePointListPresenter(list, null);
            var item      = presenter.GetItemByTitle(office);

            if (item == null)
            {
                return(string.Empty);
            }

            return(isPart1 ? item.GetFieldValue("PostalAddressLine1") : item.GetFieldValue("PostalAddressLine2"));
        }
Exemplo n.º 19
0
        //perfomacance issue here as we are doing two trips to sharepoint
        public static string GetPostalAddressFragment(this string office, bool isPart1)
        {
            if (office == null)
            {
                return(string.Empty);
            }

            var list      = new SharePointList(Properties.Settings.Default.SharePointContextUrl, "Office Addresses", Constants.SharePointQueries.GetItemByTitleQuery);
            var presenter = new SharePointListPresenter(list, null);
            var item      = presenter.GetItemByTitle(office);

            if (item == null)
            {
                return(string.Empty);
            }

            return(isPart1 ? item.GetFieldValue("PostalAddressLine1") : item.GetFieldValue("PostalAddressLine2"));
        }
Exemplo n.º 20
0
        private List <IInsurer> GetInsurers()
        {
            List <IInsurer> returnItems;

            if (Cache.Contains("InsurersData"))
            {
                returnItems = (List <IInsurer>)Cache.Get("InsurersData");
            }
            else
            {
                var list = new SharePointList(Settings.Default.SharePointContextUrl,
                                              Settings.Default.ApprovedInsurersListName);
                var presenter = new SharePointListPresenter(list, this);
                returnItems = presenter.GetInsurers();
                Cache.Add("InsurersData", returnItems, new CacheItemPolicy());
            }

            return(returnItems);
        }
Exemplo n.º 21
0
        protected override List <IPolicyClass> LoadMinorPolicyTypes()
        {
            List <IPolicyClass> policies = base.LoadMinorPolicyTypes();

            var spList    = new SharePointList(Settings.Default.SharePointContextUrl, Settings.Default.PreRenewalQuestionareMappingsListName);
            var presenter = new SharePointListPresenter(spList, this);

            List <IPreRenewalQuestionareMappings> mappings = presenter.GetPreRenewalQuestionareMappings();

            policies.ForEach((x) =>
            {
                IPreRenewalQuestionareMappings w = mappings.FirstOrDefault(f => f.PolicyType.Contains(x.Title));
                if (w != null)
                {
                    x.FragmentPolicyUrl = w.FragmentUrl;
                }
            });
            return(policies);
        }
Exemplo n.º 22
0
        private List <IInsurer> GetInsurers(string type)
        {
            List <IInsurer> returnItems;

            if (Cache.Contains(type))
            {
                returnItems = (List <IInsurer>)Cache.Get(type);
            }
            else
            {
                var list      = new SharePointList(Settings.Default.SharePointContextUrl, Settings.Default.ApprovedInsurersListName, Constants.SharePointQueries.AllItemsSortByTitle);
                var presenter = new SharePointListPresenter(list, this);
                returnItems = presenter.GetInsurers();

                if (!type.Equals(Constants.CacheNames.NoCache))
                {
                    Cache.Add(type, returnItems, new CacheItemPolicy());
                }
            }

            return(returnItems);
        }
Exemplo n.º 23
0
        private void GetFragements()
        {
            _availableAttachments = new Dictionary <string, DocumentFragment>();
            List <ISharePointListItem> fragments = null;

            if (Cache.Contains(Constants.CacheNames.RenLtrFragments))
            {
                fragments = (List <ISharePointListItem>)Cache.Get(Constants.CacheNames.RenLtrFragments);
            }
            else
            {
                var list      = new SharePointList(Settings.Default.SharePointContextUrl, Settings.Default.GeneralFragmentsListName, Constants.SharePointQueries.RenewalLetterFragmentsByKey);
                var presenter = new SharePointListPresenter(list, this);
                fragments = presenter.GetItems();
            }


            foreach (ISharePointListItem i in fragments)
            {
                string key      = i.GetFieldValue("Key");
                string txtTitle = i.Title + " " + i.GetFieldValue("OAMPS_x0020_Version");
                switch (key)
                {
                case Constants.FragmentKeys.FinancialServicesGuideLetter:
                {
                    chkFSG.Text = txtTitle;
                    _availableAttachments.Add(key, new DocumentFragment
                        {
                            Title = txtTitle,
                            Key   = key,
                            Url   = Settings.Default.FragmentFSGLetter
                        });

                    break;
                }


                case Constants.FragmentKeys.GeneralAdviceWarning:
                {
                    chkWarning.Text = txtTitle;
                    _availableAttachments.Add(key, new DocumentFragment
                        {
                            Title = txtTitle,
                            Key   = key,
                            Url   = Settings.Default.FragmentWarning
                        });
                    break;
                }


                case Constants.FragmentKeys.PrivacyStatement:
                {
                    chkPrivacy.Text = txtTitle;
                    _availableAttachments.Add(key, new DocumentFragment
                        {
                            Title = txtTitle,
                            Key   = key,
                            Url   = Settings.Default.FragmentPrivacy
                        });

                    break;
                }


                case Constants.FragmentKeys.StatutoryNotices:
                {
                    chkSatutory.Text = txtTitle;
                    _availableAttachments.Add(key, new DocumentFragment
                        {
                            Title = txtTitle,
                            Key   = key,
                            Url   = Settings.Default.FragmentStatutory
                        });

                    break;
                }


                case Constants.FragmentKeys.UninsuredRisksReviewList:
                {
                    chkRisks.Text = txtTitle;
                    _availableAttachments.Add(key, new DocumentFragment
                        {
                            Title = txtTitle,
                            Key   = key,
                            Url   = Settings.Default.FragmentUninsuredRisks
                        });
                    break;
                }
                }
            }
        }
Exemplo n.º 24
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);
        }
Exemplo n.º 25
0
        private void RenewalLetter_Load(object sender, EventArgs e)
        {
            txtAddressee.Focus();
            txtAddressee.Select();
            _availableAttachments = new Dictionary <string, DocumentFragment>();

            var list      = new SharePointList(Settings.Default.SharePointContextUrl, Settings.Default.GeneralFragmentsListName, Constants.SharePointQueries.RenewalLetterFragmentsByKey);
            var presenter = new SharePointListPresenter(list, this);
            var fragments = presenter.GetItems();

            foreach (ISharePointListItem i in fragments)
            {
                var    key      = i.GetFieldValue("Key");
                string txtTitle = i.Title + " " + i.GetFieldValue("OAMPS_x0020_Version");
                switch (key)
                {
                case Constants.FragmentKeys.FinancialServicesGuide:
                {
                    chkFSG.Text = txtTitle;
                    _availableAttachments.Add(key, new DocumentFragment
                        {
                            Title = txtTitle,
                            Key   = key,
                            Url   = Settings.Default.FragmentFSG
                        });

                    break;
                }


                case Constants.FragmentKeys.GeneralAdviceWarning:
                {
                    chkWarning.Text = txtTitle;
                    _availableAttachments.Add(key, new DocumentFragment
                        {
                            Title = txtTitle,
                            Key   = key,
                            Url   = Settings.Default.FragmentWarning
                        });
                    break;
                }


                case Constants.FragmentKeys.PrivacyStatement:
                {
                    chkPrivacy.Text = txtTitle;
                    _availableAttachments.Add(key, new DocumentFragment
                        {
                            Title = txtTitle,
                            Key   = key,
                            Url   = Settings.Default.FragmentPrivacy
                        });

                    break;
                }


                case Constants.FragmentKeys.StatutoryNotices:
                {
                    chkSatutory.Text = txtTitle;
                    _availableAttachments.Add(key, new DocumentFragment
                        {
                            Title = txtTitle,
                            Key   = key,
                            Url   = Settings.Default.FragmentStatutory
                        });

                    break;
                }


                case Constants.FragmentKeys.UninsuredRisksReviewList:
                {
                    chkRisks.Text = txtTitle;
                    _availableAttachments.Add(key, new DocumentFragment
                        {
                            Title = txtTitle,
                            Key   = key,
                            Url   = Settings.Default.FragmentUninsuredRisks
                        });
                    break;
                }
                }
            }

            var uiScheduler = TaskScheduler.FromCurrentSynchronizationContext();

            if (Reload)
            {
                base.LoadTreeViewClasses(null);

                ReloadFields();
            }
            else
            {
                datePayment.Value = DateTime.Today.AddDays(14);

                Task.Factory.StartNew(() => base.LoadTreeViewClasses(uiScheduler));
            }
            base.LoadGenericImageTabs(uiScheduler, tbcWizardScreens, lblCoverPageTitle.Text, lblLogoTitle.Text);
        }
Exemplo n.º 26
0
        private void GetFragements()
        {
            _availableAttachments = new Dictionary <string, DocumentFragment>();
            List <ISharePointListItem> fragments = null;

            if (Cache.Contains(Constants.CacheNames.QuoteSlipFragments))
            {
                fragments = (List <ISharePointListItem>)Cache.Get(Constants.CacheNames.QuoteSlipFragments);
            }
            else
            {
                var list      = ListFactory.Create(Settings.Default.GeneralFragmentsListName, ListQueries.FactFinderFragmentsByKey());
                var presenter = new SharePointListPresenter(list, this);
                fragments = presenter.GetItems();
            }


            foreach (var i in fragments)
            {
                var key      = i.GetFieldValue("Key");
                var txtTitle = i.Title + " " + i.GetFieldValue("OAMPS_x0020_Version");
                switch (key)
                {
                case Constants.FragmentKeys.FinancialServicesGuide:
                {
                    chkFSG.Text = txtTitle;
                    _availableAttachments.Add(key, new DocumentFragment
                        {
                            Title  = txtTitle,
                            Key    = key,
                            Url    = Settings.Default.FragmentFSG,
                            Locked = i.GetFieldValue("Locked")
                        });

                    break;
                }


                case Constants.FragmentKeys.GeneralAdviceWarning:
                {
                    _availableAttachments.Add(key, new DocumentFragment
                        {
                            Title  = txtTitle,
                            Key    = key,
                            Url    = Settings.Default.FragmentWarning,
                            Locked = i.GetFieldValue("Locked")
                        });
                    break;
                }


                case Constants.FragmentKeys.PrivacyStatement:
                {
                    _availableAttachments.Add(key, new DocumentFragment
                        {
                            Title  = txtTitle,
                            Key    = key,
                            Url    = Settings.Default.FragmentPrivacy,
                            Locked = i.GetFieldValue("Locked")
                        });

                    break;
                }


                case Constants.FragmentKeys.StatutoryNotices:
                {
                    chkSatutory.Text = txtTitle;
                    _availableAttachments.Add(key, new DocumentFragment
                        {
                            Title  = txtTitle,
                            Key    = key,
                            Url    = Settings.Default.FragmentStatutory,
                            Locked = i.GetFieldValue("Locked")
                        });

                    break;
                }


                case Constants.FragmentKeys.UninsuredRisksReviewList:
                {
                    _availableAttachments.Add(key, new DocumentFragment
                        {
                            Title  = txtTitle,
                            Key    = key,
                            Url    = Settings.Default.FragmentUninsuredRisks,
                            Locked = i.GetFieldValue("Locked")
                        });
                    break;
                }
                }
            }
        }
Exemplo n.º 27
0
        public HelpWizard()
        {
            InitializeComponent();

            //todo: max we need to move this off accessing the word document directly.
            //todo: move this to the presenter for Help.

            var find = Globals.ThisAddIn.Application.Selection.Find;

            var r = Globals.ThisAddIn.Application.Application.Selection.Move();


            //error handling needed.
// ReSharper disable UseIndexedProperty
            find.set_Style(Globals.ThisAddIn.Application.ActiveDocument.Styles[BusinessLogic.Helpers.Constants.WordStyles.Heading1]);
// ReSharper restore UseIndexedProperty
            find.Text           = String.Empty;
            find.Forward        = false;
            find.MatchWildcards = true;
            find.Execute();


            var heading = Globals.ThisAddIn.Application.Selection.Text;

            if (!String.IsNullOrEmpty(heading))
            {
                heading = heading.Replace("\r", string.Empty).Trim();
                var templateName =
                    ((DocumentProperties)(Globals.ThisAddIn.Application.ActiveDocument.BuiltInDocumentProperties))[
                        WdBuiltInProperty.wdPropertyTitle].Value.ToString(); //todo max not able to use anthing off globals.thisaddin in wizard screens.  move this to a helpPresenter.

                //todo  max move these to constants, there is a caml query constants class

                var query = "<View>" +
                            "<Query>" +
                            "<Where>" +
                            "<And>" +
                            "<Eq><FieldRef Name='Template' /><Value Type='Lookup'>" + templateName + "</Value></Eq>" +
                            "<Eq><FieldRef Name='Title' /><Value Type='Text'>" + heading + "</Value></Eq>" +
                            "</And>" +
                            "</Where>" +
                            "</Query>" +
                            "</View>";

                //todo  max move the list to a settings
                var helpList  = new SharePointList(Settings.Default.SharePointContextUrl, "Word Help Content", query);
                var presenter = new SharePointListPresenter(helpList, this);

                var fitem = presenter.GetHelpItems().FirstOrDefault();

                if (fitem != null)
                {
                    webHelpWindow.DocumentText = fitem.GetFieldValue("Content"); //todo: max move the fieldname to a constants
                }
                else
                {
                    //todo  max move these to constants, there is a caml query constants class

                    var generalHelp = "<View>" +
                                      "<Query>" +
                                      "<Where>" +
                                      "<And>" +
                                      "<Eq><FieldRef Name='Template' /><Value Type='Lookup'>" + templateName + "</Value></Eq>" +
                                      "<Eq><FieldRef Name='Title' /><Value Type='Text'>" + "Wizard Help" + "</Value></Eq>" +
                                      "</And>" +
                                      "</Where>" +
                                      "</Query>" +
                                      "</View>";
                    helpList.UpdateCamlQuery(generalHelp);
                    var gitem = presenter.GetHelpItems().FirstOrDefault();
                    webHelpWindow.DocumentText = gitem != null?gitem.GetFieldValue("Content") : "Unable to find the help content for this document";
                }
            }

            //    Globals.ThisAddIn.Application.Application.Selection.GoTo(WdGoToItem.wdGoToTable)
        }
Exemplo n.º 28
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);
            }
        }