/// <summary>
    /// Restores parameters that were passed on to this dialog.
    /// </summary>
    private void RestoreParameters()
    {
        // Validate parameters
        if (!QueryHelper.ValidateHash("hash"))
        {
            throw new Exception("[DataComSelectContactPage.RestoreParameters]: Invalid query hash.");
        }
        Hashtable parameters = WindowHelper.GetItem(QueryHelper.GetString("pid", null)) as Hashtable;

        if (parameters == null)
        {
            throw new Exception("[DataComSelectContactPage.RestoreParameters]: The dialog page parameters are missing, the session might have been lost.");
        }

        // Restore filter
        string content = parameters["Filter"] as string;

        if (String.IsNullOrEmpty(content))
        {
            FilterParameter = new ContactFilter();
        }
        else
        {
            JsonSerializer serializer = new JsonSerializer();
            FilterParameter = serializer.Unserialize <ContactFilter>(content);
        }

        // Restore site identifier
        SiteIdentifierParameter = ValidationHelper.GetInteger(parameters["SiteID"], 0);
    }
    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);
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Do not check login if it's a CallBack - search button was pressed (see CreateSearchActionClientScript method)
        if (!RequestHelper.IsCallback())
        {
            bool validCredential = false;
            try
            {
                validCredential = CheckCredential();
            }
            catch (Exception ex)
            {
                HandleException(ex);
                return;
            }

            if (!validCredential)
            {
                URLHelper.Redirect(LoginPageUrl);
            }
        }

        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;
            }
            ContactInfo contactInfo = EditedObject as ContactInfo;
            ContactIdentity identity = DataComHelper.CreateContactIdentity(contactInfo);
            Filter = identity.CreateFilter();
            // Do not search for contact if it's a CallBack - search button was pressed (see CreateSearchActionClientScript method)
            if (Contact == null && !RequestHelper.IsCallback())
            {
                DataComClient client = DataComHelper.CreateClient();
                IContactProvider provider = DataComHelper.CreateContactProvider(client, credentialProvider.GetCredential());
                ContactFinder finder = DataComHelper.CreateContactFinder(provider);
                Contact match = finder.Find(identity);
                if (match != null)
                {
                    ShowInformation(GetString("datacom.contactmatch"));
                    Contact = match;
                    ContactForm.MergeHint = true;
                }
                else
                {
                    ShowInformation(GetString("datacom.nocontactmatch"));
                }
            }
            InitializeHeaderActions();
            InitializeDataComForm();
        }
        catch (Exception exception)
        {
            HandleException(exception);
        }
    }
Example #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Do not check login if it's a CallBack - search button was pressed (see CreateSearchActionClientScript method)
        if (!RequestHelper.IsCallback())
        {
            bool validCredential = false;
            try
            {
                validCredential = CheckCredential();
            }
            catch (Exception ex)
            {
                HandleException(ex);
                return;
            }

            if (!validCredential)
            {
                URLHelper.Redirect(UrlResolver.ResolveUrl(LoginPageUrl));
            }
        }

        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;
            }
            ContactInfo     contactInfo = EditedObject as ContactInfo;
            ContactIdentity identity    = DataComHelper.CreateContactIdentity(contactInfo);
            Filter = identity.CreateFilter();
            // Do not search for contact if it's a CallBack - search button was pressed (see CreateSearchActionClientScript method)
            if (Contact == null && !RequestHelper.IsCallback())
            {
                DataComClient    client   = DataComHelper.CreateClient();
                IContactProvider provider = DataComHelper.CreateContactProvider(client, credentialProvider.GetCredential());
                ContactFinder    finder   = DataComHelper.CreateContactFinder(provider);
                Contact          match    = finder.Find(identity);
                if (match != null)
                {
                    ShowInformation(GetString("datacom.contactmatch"));
                    Contact = match;
                    ContactForm.MergeHint = true;
                }
                else
                {
                    ShowInformation(GetString("datacom.nocontactmatch"));
                }
            }
            InitializeHeaderActions();
            InitializeDataComForm();
        }
        catch (Exception exception)
        {
            HandleException(exception);
        }
    }
    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);
            }
        }
    }
    /// <summary>
    /// Restores parameters that were passed on to this dialog.
    /// </summary>
    private void RestoreParameters()
    {
        // Validate parameters
        if (!QueryHelper.ValidateHash("hash"))
        {
            throw new Exception("[DataComSelectContactPage.RestoreParameters]: Invalid query hash.");
        }
        Hashtable parameters = WindowHelper.GetItem(QueryHelper.GetString("pid", null)) as Hashtable;
        if (parameters == null)
        {
            throw new Exception("[DataComSelectContactPage.RestoreParameters]: The dialog page parameters are missing, the session might have been lost.");
        }

        // Restore filter
        string content = parameters["Filter"] as string;
        if (String.IsNullOrEmpty(content))
        {
            FilterParameter = new ContactFilter();
        }
        else
        {
            JsonSerializer serializer = new JsonSerializer();
            FilterParameter = serializer.Unserialize<ContactFilter>(content);
        }

        // Restore site identifier
        SiteIdentifierParameter = ValidationHelper.GetInteger(parameters["SiteID"], 0);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        IDataComConfiguration configuration = DataComHelper.GetConfiguration(AccountSiteID);

        // Do not check login if it's a CallBack - search button was pressed (see CreateSearchActionClientScript method)
        if (!RequestHelper.IsCallback())
        {
            bool validCredential = false;
            try
            {
                validCredential = CheckCredential();
            }
            catch (Exception ex)
            {
                HandleException(ex);
                return;
            }

            if (!validCredential)
            {
                URLHelper.Redirect(LoginPageUrl);
            }
        }

        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;
            }
            AccountInfo accountInfo = EditedObject as AccountInfo;
            CompanyIdentity identity = DataComHelper.CreateCompanyIdentity(accountInfo);
            Filter = identity.CreateFilter();
            // Do not search for company if it's a CallBack - search button was pressed (see CreateSearchActionClientScript method)
            if (Company == null && !RequestHelper.IsCallback())
            {
                DataComClient client = DataComHelper.CreateClient();
                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"));
                }
            }
            InitializeHeaderActions();
            InitializeDataComForm();
        }
        catch (Exception exception)
        {
            HandleException(exception);
        }
    }
 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);
         }
     }
 }
Example #9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        IDataComConfiguration configuration = DataComHelper.GetConfiguration(AccountSiteID);

        // Do not check login if it's a CallBack - search button was pressed (see CreateSearchActionClientScript method)
        if (!RequestHelper.IsCallback())
        {
            bool validCredential = false;
            try
            {
                validCredential = CheckCredential();
            }
            catch (Exception ex)
            {
                HandleException(ex);
                return;
            }

            if (!validCredential)
            {
                URLHelper.Redirect(LoginPageUrl);
            }
        }

        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;
            }
            AccountInfo     accountInfo = EditedObject as AccountInfo;
            CompanyIdentity identity    = DataComHelper.CreateCompanyIdentity(accountInfo);
            Filter = identity.CreateFilter();
            // Do not search for company if it's a CallBack - search button was pressed (see CreateSearchActionClientScript method)
            if (Company == null && !RequestHelper.IsCallback())
            {
                DataComClient    client     = DataComHelper.CreateClient();
                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"));
                }
            }
            InitializeHeaderActions();
            InitializeDataComForm();
        }
        catch (Exception exception)
        {
            HandleException(exception);
        }
    }
 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);
         }
     }
 }