Пример #1
0
        protected void cmdSubmit_Click(object sender, EventArgs e)
        {
            //parse through the checked items in the list and approve them.
            try
            {
                foreach (GridViewRow gvr in dgItems.Rows)
                {
                    try
                    {
                        HyperLink hlId = (HyperLink)gvr.FindControl("hlId");
                        CheckBox  cb   = (CheckBox)gvr.FindControl("chkSelect");
                        if (hlId != null && cb != null && cb.Checked)
                        {
                            //approve
                            Article a = (Article)Item.GetItem(Convert.ToInt32(hlId.Text), PortalId, ItemType.Article.GetId(), false);


                            CommunityCreditService cs = new CommunityCreditService(Settings["AffiliateCode"].ToString(), Settings["AffiliateKey"].ToString());

                            CommunityCredit.Components.Earner                  ec  = new CommunityCredit.Components.Earner(UserInfo.FirstName, UserInfo.LastName, UserInfo.Email);
                            CommunityCredit.Components.PointCategory           pc  = null;
                            CommunityCredit.Components.PointCategoryCollection pcc = cs.GetPointCategories();

                            foreach (PointCategory pcat in pcc)
                            {
                                //regular blog post
                                if (pcat.ID.ToString() == cboCCCategories.SelectedValue)
                                {
                                    pc = pcat;
                                    break;
                                }
                            }

                            //build up the Publish urls and submit
                            //TODO: localize this text
                            CommunityCredit.Components.Task tc = new CommunityCredit.Components.Task("Blog post: " + a.Name,
                                                                                                     Utility.GetItemLinkUrl(a.ItemId.ToString(), PortalId), pc);
                            if (tc != null)
                            {
                                cs.AddCommunityCredit(ec, tc, Convert.ToDateTime(a.StartDate));
                            }
                        }
                    }
                    catch (Exception exc)
                    {
                        Exceptions.ProcessModuleLoadException(this, exc);
                    }
                }
                //success
                //TODO: we need to display a friendly submission message here.
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Пример #2
0
        protected void lbSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                CommunityCreditService                             cs  = new CommunityCreditService(Settings["AffiliateCode"].ToString(), Settings["AffiliateKey"].ToString());
                CommunityCredit.Components.Earner                  ec  = new CommunityCredit.Components.Earner(UserInfo.FirstName, UserInfo.LastName, UserInfo.Email);
                CommunityCredit.Components.PointCategory           pc  = null;
                CommunityCredit.Components.PointCategoryCollection pcc = cs.GetPointCategories();

                foreach (PointCategory pcat in pcc)
                {
                    if (pcat.ID.ToString() == ddlSubCategory.SelectedValue)
                    {
                        pc = pcat;
                        break;
                    }
                }
                //TODO: localize this text
                CommunityCredit.Components.Task tc = new CommunityCredit.Components.Task(txtDescription.Text.Trim(),
                                                                                         txtUrl.Text.Trim(), pc);
                if (tc != null)
                {
                    cs.AddCommunityCredit(ec, tc, Convert.ToDateTime(txtDateEarned.Text.Trim()));
                }

                //add submission confirmation text
                lblError.Text    = Localization.GetString("SubmissionConfirmed", LocalResourceFile);
                lblError.Visible = true;
                //txtDateEarned.Text = string.Empty;
                txtUrl.Text = string.Empty;
                //txtDescription.Text = string.Empty;
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }