private void _checked_CheckStateChanged(object sender, TreePathEventArgs e) { var node = ((AdvancedTreeNode)e.Path.LastNode); var isChecked = node.Checked; if (isChecked) { var item = MinorItems.Find(i => i.Title == node.Text); if (item != null) { tvaPolicies.AllNodes.ToList().ForEach( (x) => { var nodeControl = tvaPolicies.GetNodeControls(x); if (nodeControl != null) { var checkbox = nodeControl.FirstOrDefault(y => (y.Control is NodeCheckBox)); //checkbox found var dCheckBox = (NodeCheckBox)checkbox.Control; if (dCheckBox != null) { dCheckBox.SetValue(x, false); } } } ); node.Checked = true; _selectedPolicy = item; } } }
//public void InsertMainFragment(string bookmark, List<string> bookmarks, RenewalLetter template) // bool chkContacted, bool chkNewClient, bool chkFunding) //{ // Document.MoveCursorToStartOfBookmark(bookmark); // bookmarks.ForEach( // (x) => Document.InsertFile(x)); // Document.UpdateOrCreatePropertyValue(Constants.WordDocumentProperties.RlChkContacted, template.IsContactSelected.ToString()); // Document.UpdateOrCreatePropertyValue(Constants.WordDocumentProperties.RlChkNewClient, template.IsNewClientSelected.ToString()); // Document.UpdateOrCreatePropertyValue(Constants.WordDocumentProperties.RlChkFunding, template.IsFundingSelected.ToString()); //} public void PopulatePolicy(IPolicyClass lPolicy) { if (lPolicy != null) { Document.PopulateControl(Constants.WordDocumentProperties.RenewalPolicy, lPolicy.Title); } }
private void _checked_CheckStateChanged(object sender, TreePathEventArgs e) { var node = ((AdvancedTreeNode)e.Path.LastNode); bool isChecked = node.Checked; if (Reload && !WizardBeingUpdated) { bool previous = !isChecked; if (ContinueWithSignificantChange(sender, previous)) { GenerateNewTemplate = true; } else { TreeNodeAdv nodeAdv = tvaPolicies.AllNodes.FirstOrDefault(x => x.ToString() == node.Text); Type type = sender.GetType(); if (type == typeof(NodeCheckBox)) { ((NodeCheckBox)sender).SetValue(nodeAdv, previous); } return; } } IPolicyClass item = MinorItems.Find(i => i.Title == node.Text); if (isChecked) { if (item != null) { //does it already exist in the selected fragemnts. //multiple policy classes are mapped to the same fragement, we only want to insert one copy of the fragement in the template //also alert the user that they have selected a policy class already mapped to a selected policy class IPolicyClass mappingAlreadySelected = _selectedQuestionnaireFragments.Find(i => i.FragmentPolicyUrl == item.FragmentPolicyUrl); if (mappingAlreadySelected == null) //no existing mapping found { _selectedQuestionnaireFragments.Add(item); } else { MessageBox.Show(String.Format("The selected policy class '{0}' is already mapped to the same questionnaire as a previously selected policy class '{1}'. \n You will only receive one questionnaire for these policy classes.", item.Title, mappingAlreadySelected.Title)); } } } else { _selectedQuestionnaireFragments.Remove(item); } }
private void ReloadPolicyClasses(bool regenProcess) { string ids = regenProcess ? _selectedQuestionnaireFragments.Aggregate(string.Empty, (current, p) => current + p.Id + ";") : _wizardPresenter.ReadDocumentProperty(Constants.WordDocumentProperties.IncludedPolicyTypes); if (String.IsNullOrEmpty(ids)) { return; } string[] l = ids.Split(';'); foreach (string id in l) { IPolicyClass found = MinorItems.FirstOrDefault(x => x.Id == id); if (found == null) { continue; } foreach (TreeNodeAdv no in tvaPolicies.AllNodes) { if (String.Equals(no.Tag.ToString(), found.Title, StringComparison.OrdinalIgnoreCase)) { if (!regenProcess) { _selectedQuestionnaireFragments.Add(found); } TreePath path = tvaPolicies.GetPath(no); var node = ((AdvancedTreeNode)path.LastNode); node.CheckState = CheckState.Checked; node.Checked = true; if (no.Parent != null) { no.Parent.ExpandAll(); } } } } }
private void ReloadFields() { WizardBeingUpdated = true; var template = new RenewalLetter(); try { string policyReference = null; if (Cache.Contains(Constants.CacheNames.RegenerateTemplate)) { MessageBox.Show(BusinessLogic.Helpers.Constants.Miscellaneous.RegenerateOnLoadMsg, String.Empty, MessageBoxButtons.OK, MessageBoxIcon.Information); template = (RenewalLetter)Cache.Get(Constants.CacheNames.RegenerateTemplate); Cache.Remove(Constants.CacheNames.RegenerateTemplate); if (template.PolicyType != null) { policyReference = template.PolicyType.Title; } chkWarning.Checked = template.IsWarningSelected; chkFSG.Checked = template.IsFSGSelected; chkPrivacy.Checked = template.IsPrivacySelected; chkRisks.Checked = template.IsRisksSelected; chkSatutory.Checked = template.IsSatutorySelected; chkContacted.Checked = template.IsContactSelected; chkNewInsurer.Checked = template.IsNewClientSelected; chkFunding.Checked = template.IsFundingSelected; Reload = false; //behaviour like a new from this point } else { template = (RenewalLetter)_presenter.LoadData(template); policyReference = _presenter.ReadPolicyReference(); UpdateMainFragmentCheckBox(Constants.WordDocumentProperties.RlChkContacted, chkContacted); UpdateMainFragmentCheckBox(Constants.WordDocumentProperties.RlChkFunding, chkFunding); UpdateMainFragmentCheckBox(Constants.WordDocumentProperties.RlChkNewClient, chkNewInsurer); var fgKeys = _presenter.ReadDocumentProperty(Constants.WordDocumentProperties.RlSubFragments); if (fgKeys != null) { var keys = fgKeys.Split(';'); foreach (string key in keys) { if (key.Equals(Constants.FragmentKeys.FinancialServicesGuide, StringComparison.InvariantCultureIgnoreCase)) { chkFSG.Checked = true; } else if (key.Equals(Constants.FragmentKeys.GeneralAdviceWarning, StringComparison.InvariantCultureIgnoreCase)) { chkWarning.Checked = true; } else if (key.Equals(Constants.FragmentKeys.PrivacyStatement, StringComparison.InvariantCultureIgnoreCase)) { chkPrivacy.Checked = true; } else if (key.Equals(Constants.FragmentKeys.StatutoryNotices, StringComparison.InvariantCultureIgnoreCase)) { chkSatutory.Checked = true; } else if (key.Equals(Constants.FragmentKeys.UninsuredRisksReviewList, StringComparison.InvariantCultureIgnoreCase)) { chkRisks.Checked = true; } } } } txtAddressee.Text = template.Addressee; txtSalutation.Text = template.Salutation; txtClientAddress.Text = template.ClientAddress; txtClientAddress2.Text = template.ClientAddressLine2; txtClientName.Text = template.ClientName; txtPDSVersion.Text = template.PDSDescVersion; txtExecutiveName.Text = template.ExecutiveName; txtExecutiveEmail.Text = template.ExecutiveEmail; txtExecutiveMobile.Text = template.ExecutiveMobile; txtExecutivePhone.Text = template.ExecutivePhone; txtExecutiveTitle.Text = template.ExecutiveTitle; txtExecutiveDepartment.Text = template.ExecutiveDepartment; txtBranchAddress1.Text = template.OAMPSBranchAddress; txtBranchAddress2.Text = template.OAMPSBranchAddressLine2; txtPostal1.Text = template.OAMPSPostalAddress; txtPostal2.Text = template.OAMPSPostalAddressLine2; txtBranchPhone.Text = template.OAMPSBranchPhone; lblLogoTitle.Text = template.LogoTitle; lblCoverPageTitle.Text = template.CoverPageTitle; txtReference.Text = template.Reference; txtFax.Text = template.Fax; datePayment.Text = template.PaymentDate; datePolicy.Text = template.DatePolicyExpiry; dateReport.Text = template.DatePrepared; foreach (var no in tvaPolicies.AllNodes) { foreach (var cno in no.Children) { if (String.Equals(cno.Tag.ToString(), policyReference, StringComparison.OrdinalIgnoreCase)) { no.Expand(); var path = tvaPolicies.GetPath(cno); var node = ((AdvancedTreeNode)path.LastNode); node.CheckState = CheckState.Checked; node.Checked = true; _selectedPolicy = MinorItems.FirstOrDefault(i => i.Title == node.Text); } } } } catch (Exception) { } WizardBeingUpdated = false; }
private void ReloadPolicyClasses(IInsuranceManual v, bool reload) { if (v.SelectedPolicyClasses == null) { v = _wizardPresenter.LoadIncludedPolicyClasses(v); } int reOrder = 0; //repopulate selected fields v.SelectedPolicyClasses.Sort((x, y) => y.Order.CompareTo(x.Order)); for (int index = v.SelectedPolicyClasses.Count - 1; index >= 0; index--) { IPolicyClass f = v.SelectedPolicyClasses[index]; IPolicyClass found = MinorItems.FirstOrDefault(x => x.Id == f.Id); if (found != null) { foreach (TreeNodeAdv no in tvaPolicies.AllNodes) { if (String.Equals(no.Tag.ToString(), found.MajorClass, StringComparison.OrdinalIgnoreCase)) { foreach (TreeNodeAdv cno in no.Children) { if (String.Equals(cno.Tag.ToString(), found.Title, StringComparison.OrdinalIgnoreCase)) { reOrder = reOrder + 1; TreePath path = tvaPolicies.GetPath(cno); var node = ((AdvancedTreeNode)path.LastNode); node.CheckState = CheckState.Checked; node.Checked = true; no.Expand(false); //if (reload) //on generate get them from cache as they're passed thru //{ // node.Current = found.CurrentInsurer; // node.Reccommended = found.RecommendedInsurer; // node.OrderPolicy = reOrder.ToString(); // node.ReccommendedId = found.RecommendedInsurerId; // node.CurrentId = found.CurrentInsurerId; //} //else //{ node.Current = f.CurrentInsurer; node.Reccommended = f.RecommendedInsurer; node.OrderPolicy = reOrder.ToString(CultureInfo.InvariantCulture); node.ReccommendedId = f.RecommendedInsurerId; node.CurrentId = f.CurrentInsurerId; //} } } //var item = // MinorItems.FirstOrDefault( // i => String.Equals(i.Title, f.Title, StringComparison.OrdinalIgnoreCase)); //if (item != null) //{ //_selectedPolicyClasses.Add(item); //} } } } } }
private void ReloadFields() { bool auto = false; WizardBeingUpdated = true; var template = new RenewalLetter(); List <IPolicyClass> policiesReference = null; _selectedPolicies = new List <IPolicyClass>(); if (Cache.Contains(Constants.CacheNames.RegenerateTemplate)) { template = (RenewalLetter)Cache.Get(Constants.CacheNames.RegenerateTemplate); Cache.Remove(Constants.CacheNames.RegenerateTemplate); if (template.Policies != null) { policiesReference = template.Policies; } chkWarning.Checked = template.IsAdviceWarningSelected; chkFSG.Checked = template.IsFsgSelected; chkPrivacy.Checked = template.IsPrivacySelected; chkRisks.Checked = template.IsRisksSelected; chkSatutory.Checked = template.IsSatutorySelected; chkGAW.Checked = template.IsGawSelected; chkContacted.Checked = template.IsContactSelected; chkNewInsurer.Checked = template.IsNewClientSelected; chkFunding.Checked = template.IsFundingSelected; if (template.IsPrePrintSelected) { chkPrePrint.Checked = template.IsPrePrintSelected; } Reload = false; //behaviour like a new from this point auto = true; } else { template = (RenewalLetter)_wizardPresenter.LoadData(template); policiesReference = _wizardPresenter.ReadPoliciesInDocument(); UpdateMainFragmentCheckBox(Constants.WordDocumentProperties.RlChkContacted, chkContacted); UpdateMainFragmentCheckBox(Constants.WordDocumentProperties.RlChkFunding, chkFunding); UpdateMainFragmentCheckBox(Constants.WordDocumentProperties.RlChkNewClient, chkNewInsurer); UpdateMainFragmentCheckBox(Constants.WordDocumentProperties.RlChkGaw, chkGAW); //var value = _presenter.ReadDocumentProperty(Constants.WordDocumentProperties.RlRdoPreprint); //bool isSelected; //if (Boolean.TryParse(value, out isSelected)) //{ // rdoPrePrintYes.Checked = isSelected; //} UpdatePrePrintedCheckBoxChecked(); string fgKeys = _wizardPresenter.ReadDocumentProperty(Constants.WordDocumentProperties.RlSubFragments); if (fgKeys != null) { string[] keys = fgKeys.Split(';'); foreach (string key in keys) { if (key.Equals(Constants.FragmentKeys.FinancialServicesGuideLetter, StringComparison.InvariantCultureIgnoreCase)) { chkFSG.Checked = true; } else if (key.Equals(Constants.FragmentKeys.GeneralAdviceWarning, StringComparison.InvariantCultureIgnoreCase)) { chkWarning.Checked = true; } else if (key.Equals(Constants.FragmentKeys.PrivacyStatement, StringComparison.InvariantCultureIgnoreCase)) { chkPrivacy.Checked = true; } else if (key.Equals(Constants.FragmentKeys.StatutoryNotices, StringComparison.InvariantCultureIgnoreCase)) { chkSatutory.Checked = true; } else if (key.Equals(Constants.FragmentKeys.UninsuredRisksReviewList, StringComparison.InvariantCultureIgnoreCase)) { chkRisks.Checked = true; } } } } var processedTitles = new List <string>(); foreach (TreeNodeAdv no in tvaPolicies.AllNodes) { foreach (TreeNodeAdv cno in no.Children) { if (policiesReference != null && policiesReference.Count > 0) { IPolicyClass p = policiesReference.Find(i => i.Title.Replace("\r\a", string.Empty).Equals(cno.Tag.ToString().Replace("\r\a", string.Empty), StringComparison.OrdinalIgnoreCase)); if (p != null) { if (!processedTitles.Contains(cno.Tag.ToString())) { if (String.Equals(cno.Tag.ToString(), p.Title.Replace("\r\a", string.Empty), StringComparison.OrdinalIgnoreCase)) { processedTitles.Add(cno.Tag.ToString()); no.Expand(); TreePath path = tvaPolicies.GetPath(cno); var node = ((AdvancedTreeNode)path.LastNode); node.CheckState = CheckState.Checked; node.Checked = true; if ((_selectedPolicies.Find(j => j.Title == node.Text) == null)) { _selectedPolicies.Add(MinorItems.FirstOrDefault(i => i.Title == node.Text)); } } } } } } } txtAddressee.Text = template.Addressee; txtSalutation.Text = template.Salutation; txtClientAddress.Text = template.ClientAddress; txtClientAddress2.Text = template.ClientAddressLine2; txtClientAddress3.Text = template.ClientAddressLine3; txtClientName.Text = template.ClientName; txtPDSVersion.Text = template.PdsDescVersion; txtExecutiveName.Text = template.ExecutiveName; txtExecutiveEmail.Text = template.ExecutiveEmail; txtExecutiveMobile.Text = template.ExecutiveMobile; txtExecutivePhone.Text = template.ExecutivePhone; txtExecutiveTitle.Text = template.ExecutiveTitle; txtExecutiveDepartment.Text = template.ExecutiveDepartment; txtBranchAddress1.Text = template.OAMPSBranchAddress; txtBranchAddress2.Text = template.OAMPSBranchAddressLine2; txtPostal1.Text = template.OAMPSPostalAddress; txtPostal2.Text = template.OAMPSPostalAddressLine2; txtBranchPhone.Text = template.OAMPSBranchPhone; lblLogoTitle.Text = template.LogoTitle; lblCoverPageTitle.Text = template.CoverPageTitle; txtReference.Text = template.Reference; txtFax.Text = template.Fax; DateTime outDate; datePolicy.Value = DateTime.TryParse(template.DatePolicyExpiry, out outDate) ? outDate : DateTime.Today; datePayment.Value = DateTime.TryParse(template.PaymentDate, out outDate) ? outDate : DateTime.Today; dateReport.Value = DateTime.TryParse(template.DatePrepared, out outDate) ? outDate : DateTime.Today; WizardBeingUpdated = false; if (auto) { base.StartTimer(); } }
public static bool ApplyPolicy(ApplyPolicyFunction applymethod) { if (ActivePolicy == null) { ActivePolicy = new List <LoadedPolicyObject>(); } FilesystemData.ReOrderPolicies(); foreach (Type type in GetTypesWithHelpAttribute(Assembly.GetExecutingAssembly())) { PolicyObjectAttr po = type.GetCustomAttribute <PolicyObjectAttr>(); IPolicyClass instance = (IPolicyClass)Activator.CreateInstance(type); try { instance.PreApplyPolicy(); } catch (Exception ee) { Debug.WriteLine(ee.ToString()); FoxEventLog.WriteEventLog("SEH Error while finalising policy - Type 0x" + po.PolicyType.ToString("X"), System.Diagnostics.EventLogEntryType.Error); } } if (FilesystemData.UpdatePolicies != null) { foreach (KeyValuePair <LoadedPolicyObject, LoadedPolicyObject> kvp in FilesystemData.UpdatePolicies) { foreach (Type type in GetTypesWithHelpAttribute(Assembly.GetExecutingAssembly())) { PolicyObjectAttr po = type.GetCustomAttribute <PolicyObjectAttr>(); if (po.PolicyType == kvp.Key.PolicyObject.Type) { IPolicyClass instance = (IPolicyClass)Activator.CreateInstance(type); try { instance.UpdatePolicy(kvp.Key, kvp.Value); } catch (Exception ee) { Debug.WriteLine(ee.ToString()); FoxEventLog.WriteEventLog("SEH Error while updating policy - (Policy ID=" + kvp.Value.PolicyObject.ID.ToString() + " Name=" + kvp.Value.PolicyObject.Name + ")", System.Diagnostics.EventLogEntryType.Error); } break; } } } } List <LoadedPolicyObject> RemovePol = new List <LoadedPolicyObject>(); foreach (LoadedPolicyObject a in ActivePolicy) { bool PolicyFound = false; foreach (LoadedPolicyObject b in FilesystemData.LoadedPolicyObjects) { if (a.PolicyObject.ID == b.PolicyObject.ID && a.PolicyObject.Type == b.PolicyObject.Type) { PolicyFound = true; break; } } if (PolicyFound == false) { RemovePol.Add(a); } } foreach (LoadedPolicyObject a in RemovePol) { foreach (Type type in GetTypesWithHelpAttribute(Assembly.GetExecutingAssembly())) { PolicyObjectAttr po = type.GetCustomAttribute <PolicyObjectAttr>(); if (po.PolicyType == a.PolicyObject.Type) { IPolicyClass instance = (IPolicyClass)Activator.CreateInstance(type); try { instance.RemovePolicy(a); } catch (Exception ee) { Debug.WriteLine(ee.ToString()); FoxEventLog.WriteEventLog("SEH Error while removing policy - (Policy ID=" + a.PolicyObject.ID.ToString() + " Name=" + a.PolicyObject.Name + ")", System.Diagnostics.EventLogEntryType.Error); } ActivePolicy.Remove(a); break; } } } RemovePol = new List <LoadedPolicyObject>(); //empty out foreach (LoadedPolicyObject a in FilesystemData.LoadedPolicyObjects) { bool PolicyFound = false; foreach (LoadedPolicyObject b in ActivePolicy) { if (a.PolicyObject.ID == b.PolicyObject.ID && a.PolicyObject.Version == b.PolicyObject.Version && a.PolicyObject.Type == b.PolicyObject.Type) { PolicyFound = true; break; } } if (PolicyFound == false) { bool CanProcessPolicy = false; bool FoundPolicyProcessor = false; foreach (Type type in GetTypesWithHelpAttribute(Assembly.GetExecutingAssembly())) { PolicyObjectAttr po = type.GetCustomAttribute <PolicyObjectAttr>(); if (po.PolicyType == a.PolicyObject.Type) { IPolicyClass instance = (IPolicyClass)Activator.CreateInstance(type); try { instance.ApplyPolicy(a); } catch (Exception ee) { Debug.WriteLine(ee.ToString()); FoxEventLog.WriteEventLog("SEH Error while applying policy - (Policy ID=" + a.PolicyObject.ID.ToString() + " Name=" + a.PolicyObject.Name + ")", System.Diagnostics.EventLogEntryType.Error); } CanProcessPolicy = true; FoundPolicyProcessor = true; break; } } if (CanProcessPolicy == true || FoundPolicyProcessor == true) { ActivePolicy.Add(a); } if (FoundPolicyProcessor == false) { FoxEventLog.WriteEventLog("Don't know how to process policy type 0x" + a.PolicyObject.Type.ToString("X") + " - (Policy ID=" + a.PolicyObject.ID.ToString() + " Name=" + a.PolicyObject.Name + ")", System.Diagnostics.EventLogEntryType.Warning); } } } foreach (LoadedPolicyObject a in ActivePolicy) { foreach (Type type in GetTypesWithHelpAttribute(Assembly.GetExecutingAssembly())) { PolicyObjectAttr po = type.GetCustomAttribute <PolicyObjectAttr>(); if (po.PolicyType == a.PolicyObject.Type) { IPolicyClass instance = (IPolicyClass)Activator.CreateInstance(type); try { instance.ApplyOrdering(a, a.PolicyObject.Order); } catch (Exception ee) { Debug.WriteLine(ee.ToString()); FoxEventLog.WriteEventLog("SEH Error while reordering polcy - Type 0x" + po.PolicyType.ToString("X"), System.Diagnostics.EventLogEntryType.Error); } } } } foreach (Type type in GetTypesWithHelpAttribute(Assembly.GetExecutingAssembly())) { PolicyObjectAttr po = type.GetCustomAttribute <PolicyObjectAttr>(); IPolicyClass instance = (IPolicyClass)Activator.CreateInstance(type); try { switch (applymethod) { case ApplyPolicyFunction.ApplySystem: instance.FinaliseApplyPolicy(); break; case ApplyPolicyFunction.ApplyUser: instance.FinaliseApplyPolicyUserPart(); break; case ApplyPolicyFunction.Uninstall: instance.FinaliseUninstallProgramm(); break; } } catch (Exception ee) { Debug.WriteLine(ee.ToString()); FoxEventLog.WriteEventLog("SEH Error while finalising policy (applymethod=" + applymethod.ToString() + ") - Type 0x" + po.PolicyType.ToString("X"), System.Diagnostics.EventLogEntryType.Error); } } FilesystemData.UpdatePolicies = null; if (applymethod == ApplyPolicyFunction.ApplySystem) { string ApplyUserSettingsApp = ProgramAgent.AppPath + "FoxSDC_ApplyUserSettings.exe"; if (File.Exists(ApplyUserSettingsApp) == false) { FoxEventLog.WriteEventLog("The file " + ApplyUserSettingsApp + " does not exist. User settings are not applied properly.", EventLogEntryType.Error); } else { #if !DEBUG if (ProgramAgent.CPP.VerifyEXESignature(ApplyUserSettingsApp) == false) { FoxEventLog.WriteEventLog("The file " + ApplyUserSettingsApp + " cannot be verified. User settings are not applied properly.", EventLogEntryType.Error); } else #endif { try { Process.Start(ApplyUserSettingsApp, ""); //NT_AUTHORITY\SYSTEM } catch { } try { ProgramAgent.CPP.StartAppAsUser(ApplyUserSettingsApp, ""); //all other logged in users } catch { } } } } return(true); }