protected void BuyButton_Click(object sender, EventArgs e)
 {
     if (Contact != null)
     {
         try
         {
             IDataComConfiguration configuration  = DataComHelper.GetConfiguration(SiteIdentifierParameter);
             NetworkCredential     userCredential = configuration.GetUserCredential();
             if (userCredential != null)
             {
                 DataComClient    client     = DataComHelper.CreateClient(configuration);
                 IContactProvider provider   = new UserContactProvider(client, userCredential);
                 Contact          contact    = provider.GetContact(Contact.ContactId, true);
                 JsonSerializer   serializer = new JsonSerializer();
                 ContactHiddenField.Value = serializer.Serialize(contact);
             }
             else
             {
                 ErrorSummary.Report(GetString("datacom.nousercredential"));
                 BuyButton.Enabled = false;
             }
         }
         catch (Exception exception)
         {
             HandleException(exception);
         }
     }
 }
Esempio n. 2
0
 protected void CompanyGrid_OnAction(string actionName, object actionArgument)
 {
     if (actionName == "select")
     {
         long companyId = ValidationHelper.GetLong(actionArgument, 0);
         if (companyId > 0)
         {
             try
             {
                 IDataComConfiguration configuration = DataComHelper.GetConfiguration(SiteIdentifierParameter);
                 DataComClient         client        = DataComHelper.CreateClient(configuration);
                 ICompanyProvider      provider      = DataComHelper.CreateCompanyProvider(client, configuration);
                 Company company = provider.GetCompany(companyId);
                 if (company != null)
                 {
                     CurrentCompany = company;
                 }
             }
             catch (Exception exception)
             {
                 HandleException(exception);
             }
         }
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         RestoreParameters();
         InitializeContactPreview(Contact);
         if (!RequestHelper.IsPostBack())
         {
             IDataComConfiguration configuration  = DataComHelper.GetConfiguration(SiteIdentifierParameter);
             NetworkCredential     userCredential = configuration.GetUserCredential();
             if (userCredential != null)
             {
                 DataComClient client   = DataComHelper.CreateClient(configuration);
                 User          response = client.GetUser(userCredential);
                 InitializeAccountPoints(response.Points);
                 InitializePurchasePointsLink(response.PurchasePointsUrl);
             }
             else
             {
                 ErrorSummary.Report(GetString("datacom.nousercredential"));
                 BuyButton.Enabled = false;
             }
         }
     }
     catch (Exception exception)
     {
         HandleException(exception);
     }
 }
Esempio n. 4
0
    /// <summary>
    /// Creates a list of localized attribute name/display value pairs for the specified Data.com company, and returns it.
    /// </summary>
    /// <returns>A list of localized attribute name/display value pairs for the specified Data.com company.</returns>
    private List <RepeaterDataItem> CreateDataSource()
    {
        IDataComConfiguration     configuration = DataComHelper.GetConfiguration();
        IEntityAttributeFormatter formatter     = DataComHelper.GetEntityAttributeFormatter();
        List <RepeaterDataItem>   items         = new List <RepeaterDataItem>();
        EntityInfo entityInfo = DataComHelper.GetCompanyEntityInfo(configuration);
        IEntityAttributeMapperFactory entityAttributeFactory = DataComHelper.GetCompanyAttributeMapperFactory();

        foreach (EntityAttributeInfo entityAttributeInfo in entityInfo.Items)
        {
            string entityAttributeValue = String.Empty;
            EntityAttributeMapperBase entityAttribute = entityAttributeFactory.CreateEntityAttributeMapper(entityAttributeInfo.Name, entityInfo);
            if (entityAttribute != null)
            {
                entityAttributeValue = entityAttribute.GetEntityAttributeDisplayValue(Company, formatter);
            }
            RepeaterDataItem item = new RepeaterDataItem
            {
                AttributeName  = ResHelper.LocalizeString(entityAttributeInfo.DisplayName),
                AttributeValue = entityAttributeValue
            };
            items.Add(item);
        }

        return(items);
    }
    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);
            }
        }
    }
Esempio n. 6
0
    /// <summary>
    /// Initializes the form with the required dependencies and the specified CMS account.
    /// </summary>
    protected void InitializeDataComForm()
    {
        IDataComConfiguration configuration = DataComHelper.GetConfiguration(AccountSiteID);
        AccountInfo           accountInfo   = EditedObject as AccountInfo;

        CompanyForm.FormInformation = DataComHelper.GetAccountFormInfo();
        CompanyForm.EntityInfo      = DataComHelper.GetCompanyEntityInfo(configuration);
        CompanyForm.EntityMapping   = configuration.GetCompanyMapping();
        CompanyForm.EntityAttributeMapperFactory = DataComHelper.GetCompanyAttributeMapperFactory();
        CompanyForm.Entity = Company;
        CompanyForm.EntityAttributeFormatter = DataComHelper.GetEntityAttributeFormatter();
        CompanyForm.Restore(accountInfo);
    }
Esempio n. 7
0
    protected DataSet ContactGrid_OnDataReload(string completeWhere, string currentOrder, int currentTopN, string columns, int currentOffset, int currentPageSize, ref int totalRecords)
    {
        try
        {
            IDataComConfiguration configuration = DataComHelper.GetConfiguration(SiteIdentifierParameter);
            DataComClient         client        = DataComHelper.CreateClient(configuration);
            IContactProvider      provider      = DataComHelper.CreateContactProvider(client, configuration);
            ContactSearchResults  response      = provider.SearchContacts(CurrentContactFilter, currentOffset / currentPageSize, currentPageSize);
            DataTable             table         = new DataTable("Contacts");
            table.Columns.Add("ContactId", typeof(long));
            table.Columns.Add("FirstName", typeof(string));
            table.Columns.Add("LastName", typeof(string));
            table.Columns.Add("CompanyName", typeof(string));
            foreach (Contact contact in response.Contacts)
            {
                DataRow row = table.NewRow();
                row["ContactId"]   = contact.ContactId;
                row["FirstName"]   = contact.FirstName;
                row["LastName"]    = contact.LastName;
                row["CompanyName"] = contact.CompanyName;
                table.Rows.Add(row);
                if (contact.ContactId == CurrentContactId)
                {
                    CurrentContact = contact;
                }
            }
            DataSet dataSet = new DataSet();
            dataSet.Tables.Add(table);
            int maxHitCount = currentPageSize * MAX_PAGE_COUNT;
            int hitCount    = (int)response.TotalHits;
            if (hitCount > maxHitCount)
            {
                hitCount = maxHitCount;
                ShowWarning(GetString("datacom.toomanycontacts"), null, null);
            }
            totalRecords = hitCount;
            return(dataSet);
        }
        catch (Exception exception)
        {
            HandleException(exception);
        }
        totalRecords = 0;

        return(null);
    }
Esempio n. 8
0
    /// <summary>
    /// Initializes the form with the required dependencies and the specified CMS contact.
    /// </summary>
    protected void InitializeDataComForm()
    {
        IDataComConfiguration configuration = DataComHelper.GetConfiguration();
        ContactInfo           contactInfo   = EditedObject as ContactInfo;

        ContactForm.ParametersIdentifier         = BuyParametersIdentifier;
        ContactForm.FormInformation              = DataComHelper.GetContactFormInfo();
        ContactForm.EntityInfo                   = DataComHelper.GetContactEntityInfo();
        ContactForm.EntityMapping                = configuration.GetContactMapping();
        ContactForm.EntityAttributeMapperFactory = DataComHelper.GetContactAttributeMapperFactory();
        ContactForm.Entity = Contact;
        ContactForm.EntityAttributeFormatter = DataComHelper.GetEntityAttributeFormatter();
        ContactForm.BuyContactEnabled        = (credentialProvider.GetCredential() != null);
        ContactForm.DefaultFieldLayout       = FieldLayoutEnum.ThreeColumns;
        ContactForm.DefaultFormLayout        = FormLayoutEnum.SingleTable;
        ContactForm.Restore(contactInfo);
    }
Esempio n. 9
0
 protected override void OnPreRender(EventArgs e)
 {
     if (Mapping != null)
     {
         try
         {
             IDataComConfiguration configuration = DataComHelper.GetConfiguration();
             FormInfo   formInfo     = DataComHelper.GetAccountFormInfo();
             EntityInfo entityInfo   = DataComHelper.GetCompanyEntityInfo(configuration);
             Panel      mappingPanel = CreateMappingPanel(formInfo, entityInfo, Mapping);
             Controls.Add(mappingPanel);
         }
         catch (Exception exception)
         {
             HandleException(exception);
         }
     }
     base.OnPreRender(e);
 }
Esempio n. 10
0
 protected override void OnPreRender(EventArgs e)
 {
     if (Mapping != null)
     {
         try
         {
             IDataComConfiguration configuration = DataComHelper.GetConfiguration(CMSContext.CurrentSiteID);
             FormInfo   formInfo   = DataComHelper.GetAccountFormInfo();
             EntityInfo entityInfo = DataComHelper.GetCompanyEntityInfo(configuration);
             HtmlTable  table      = CreateTable(formInfo, entityInfo, Mapping);
             Controls.Add(table);
         }
         catch (Exception exception)
         {
             HandleException(exception);
         }
     }
     base.OnPreRender(e);
 }
    /// <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;
    }
Esempio n. 12
0
 /// <summary>
 /// Creates current request context, and returns it.
 /// </summary>
 /// <returns>Current request context.</returns>
 private RequestContext CreateContext()
 {
     if (mEntityName == "Contact")
     {
         return(new RequestContext
         {
             FormInfo = DataComHelper.GetContactFormInfo(),
             EntityInfo = DataComHelper.GetContactEntityInfo(),
             InitializeMappingControl = (x => ContactMappingControl.Mapping = x)
         });
     }
     if (mEntityName == "Company")
     {
         IDataComConfiguration configuration = DataComHelper.GetConfiguration();
         return(new RequestContext
         {
             FormInfo = DataComHelper.GetAccountFormInfo(),
             EntityInfo = DataComHelper.GetCompanyEntityInfo(configuration),
             InitializeMappingControl = (x => CompanyMappingControl.Mapping = x)
         });
     }
     throw new Exception(String.Format("[DataComEditMappingPage.CreateContext]: Invalid mapping type ({0}).", mEntityName));
 }
    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);
            }
        }
    }
Esempio n. 14
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);
        }
    }