Exemple #1
0
 protected void BuyButton_Click(object sender, EventArgs e)
 {
     if (Contact != null)
     {
         try
         {
             ICredentialProvider credentialProvider = new UserCredentialProvider(MembershipContext.AuthenticatedUser);
             NetworkCredential   userCredential     = credentialProvider.GetCredential();
             if (userCredential != null)
             {
                 DataComClient    client     = DataComHelper.CreateClient();
                 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);
         }
     }
 }
Exemple #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         RestoreParameters();
         InitializeContactPreview(Contact);
         if (!RequestHelper.IsPostBack())
         {
             ICredentialProvider credentialProvider = new UserCredentialProvider(MembershipContext.AuthenticatedUser);
             NetworkCredential   userCredential     = credentialProvider.GetCredential();
             if (userCredential != null)
             {
                 DataComClient client   = DataComHelper.CreateClient();
                 User          response = client.GetUser(userCredential);
                 InitializeAccountPoints(response.Points);
                 InitializePurchasePointsLink(DATACOM_LOGIN_PAGE);
             }
             else
             {
                 ErrorSummary.Report(GetString("datacom.nousercredential"));
                 BuyButton.Enabled = false;
             }
         }
     }
     catch (Exception exception)
     {
         HandleException(exception);
     }
 }
 protected void BuyButton_Click(object sender, EventArgs e)
 {
     if (Contact != null)
     {
         try
         {
             ICredentialProvider credentialProvider = new UserCredentialProvider(MembershipContext.AuthenticatedUser);
             NetworkCredential userCredential = credentialProvider.GetCredential();
             if (userCredential != null)
             {
                 DataComClient client = DataComHelper.CreateClient();
                 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);
         }
     }
 }
    protected DataSet ContactGrid_OnDataReload(string completeWhere, string currentOrder, int currentTopN, string columns, int currentOffset, int currentPageSize, ref int totalRecords)
    {
        try
        {
            ICredentialProvider credentialProvider = new UserCredentialProvider(MembershipContext.AuthenticatedUser);

            DataComClient        client   = DataComHelper.CreateClient();
            IContactProvider     provider = DataComHelper.CreateContactProvider(client, credentialProvider.GetCredential());
            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);
    }
    protected DataSet ContactGrid_OnDataReload(string completeWhere, string currentOrder, int currentTopN, string columns, int currentOffset, int currentPageSize, ref int totalRecords)
    {
        try
        {
            ICredentialProvider credentialProvider = new UserCredentialProvider(MembershipContext.AuthenticatedUser);

            DataComClient client = DataComHelper.CreateClient();
            IContactProvider provider = DataComHelper.CreateContactProvider(client, credentialProvider.GetCredential());
            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;
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         RestoreParameters();
         InitializeContactPreview(Contact);
         if (!RequestHelper.IsPostBack())
         {
             ICredentialProvider credentialProvider = new UserCredentialProvider(MembershipContext.AuthenticatedUser);
             NetworkCredential userCredential = credentialProvider.GetCredential();
             if (userCredential != null)
             {
                 DataComClient client = DataComHelper.CreateClient();
                 User response = client.GetUser(userCredential);
                 InitializeAccountPoints(response.Points);
                 InitializePurchasePointsLink(DATACOM_LOGIN_PAGE);
             }
             else
             {
                 ErrorSummary.Report(GetString("datacom.nousercredential"));
                 BuyButton.Enabled = false;
             }
         }
     }
     catch (Exception exception)
     {
         HandleException(exception);
     }
 }