protected void Page_Load(object sender, EventArgs e) { AccountInfo account = EditedObject as AccountInfo; AuthorizeReadRequest(account); IDataComConfiguration configuration = DataComHelper.GetConfiguration(AccountSiteID); if (configuration.GetToken() == null) { ShowWarning(GetString("datacom.notoken"), null, null); } else { try { if (!String.IsNullOrEmpty(CompanyHiddenField.Value)) { JsonSerializer serializer = new JsonSerializer(); Company freshCompany = serializer.Unserialize <Company>(CompanyHiddenField.Value); if (Company == null || Company.CompanyId != freshCompany.CompanyId) { CompanyForm.MergeHint = true; } Company = freshCompany; } if (Company == null) { AccountInfo accountInfo = EditedObject as AccountInfo; CompanyIdentity identity = DataComHelper.CreateCompanyIdentity(accountInfo); DataComClient client = DataComHelper.CreateClient(configuration); ICompanyProvider provider = DataComHelper.CreateCompanyProvider(client, configuration); CompanyFinder finder = DataComHelper.CreateCompanyFinder(provider); CompanyFilter filterHint = null; Company match = finder.Find(identity, out filterHint); if (match != null) { ShowInformation(GetString("datacom.companymatch")); Company = match; CompanyForm.MergeHint = true; } else { ShowInformation(GetString("datacom.nocompanymatch")); } Filter = filterHint; } InitializeHeaderActions(); InitializeDataComForm(); } catch (Exception exception) { HandleException(exception); } } }
/// <summary> /// Adds actions to the page header. /// </summary> protected void InitializeHeaderActions() { IDataComConfiguration configuration = DataComHelper.GetConfiguration(ContactSiteID); bool searchEnabled = (configuration.GetToken() != null); string[,] actions = new string[1 + (searchEnabled ? 1 : 0), 11]; actions[0, 0] = CMS.ExtendedControls.HeaderActions.TYPE_SAVEBUTTON; actions[0, 1] = GetString("general.apply"); actions[0, 5] = GetImageUrl("CMSModules/CMS_Content/EditMenu/save.png"); actions[0, 6] = "save"; actions[0, 8] = "true"; if (searchEnabled) { actions[1, 0] = CMS.ExtendedControls.HeaderActions.TYPE_LINKBUTTON; actions[1, 1] = GetString("general.search"); actions[1, 2] = CreateSearchActionClientScript(); actions[1, 5] = GetImageUrl("CMSModules/CMS_ContactManagement/search.png"); } HeaderActions.ActionPerformed += HeaderActions_ActionPerformed; HeaderActions.Actions = actions; }
protected void Page_Load(object sender, EventArgs e) { ContactInfo contact = EditedObject as ContactInfo; AuthorizeReadRequest(contact); IDataComConfiguration configuration = DataComHelper.GetConfiguration(ContactSiteID); if (configuration.GetToken() == null) { ShowWarning(GetString("datacom.notoken"), null, null); } else { try { if (!String.IsNullOrEmpty(ContactHiddenField.Value)) { JsonSerializer serializer = new JsonSerializer(); Contact freshContact = serializer.Unserialize <Contact>(ContactHiddenField.Value); if (Contact == null) { ContactForm.MergeHint = true; } else { if (Contact.ContactId != freshContact.ContactId) { ContactForm.MergeHint = true; } else if (String.IsNullOrEmpty(Contact.Phone) && String.IsNullOrEmpty(Contact.Email) && (!String.IsNullOrEmpty(freshContact.Phone) || !String.IsNullOrEmpty(freshContact.Email))) { ContactForm.MergeHint = true; ContactForm.MergeHintAttributes = new string[] { "Phone", "Email" }; } } Contact = freshContact; } if (Contact == null) { ContactInfo contactInfo = EditedObject as ContactInfo; ContactIdentity identity = DataComHelper.CreateContactIdentity(contactInfo); DataComClient client = DataComHelper.CreateClient(configuration); IContactProvider provider = DataComHelper.CreateContactProvider(client, configuration); ContactFinder finder = DataComHelper.CreateContactFinder(provider); ContactFilter filterHint = null; Contact match = finder.Find(identity, out filterHint); if (match != null) { ShowInformation(GetString("datacom.contactmatch")); Contact = match; ContactForm.MergeHint = true; } else { ShowInformation(GetString("datacom.nocontactmatch")); } Filter = filterHint; } InitializeHeaderActions(); InitializeDataComForm(); } catch (Exception exception) { HandleException(exception); } } }