Example #1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";

            CY.UME.Core.Business.Account CurrentAccount = CY.UME.Core.Global.GetCurrentAccount();

            if (CurrentAccount == null)
            {
                context.Response.Write("{success:false,msg:'用户登录超时,请重新登录'}");
                return;
            }

            string activeId = context.Request.Params["activeid"];
            string strFriendId = context.Request.Params["straccountids"];// iFriendId.Value.Trim();//待邀请的人
            string[] friendIdArray = strFriendId.Split(',');
            long friendId = 0;

            if (string.IsNullOrEmpty(activeId))
            {
                context.Response.Write("{success:false,msg:'邀请加入的活动不存在或已被删除'}");
                return;
            }

            IList<CY.UME.Core.Business.Notice> noticeList = CY.UME.Core.Business.Notice.GetNoticeByTypeAndInstanceId(CurrentAccount, null, "activeInviteFriend", activeId, new CY.UME.Core.PagingInfo { CurrentPage = 1, PageSize = int.MaxValue });

            for (int i = 0; i < friendIdArray.Length; i++)
            {
                if (!long.TryParse(friendIdArray[i].Trim(), out friendId)) continue;

                CY.UME.Core.Business.Account friend = CY.UME.Core.Business.Account.Load(friendId);

                if (friend == null) continue;

                foreach (CY.UME.Core.Business.Notice Notice in noticeList)
                {//判断是否已经邀请过了。
                    if (Notice.AuthorId == friend.Id) continue;
                }

                CY.UME.Core.Business.Notice notice = new CY.UME.Core.Business.Notice();

                notice.AccountId = friend.Id;
                notice.AuthorId = CurrentAccount.Id;
                notice.Content = "邀请您加入活动";
                notice.DateCreated = DateTime.Now;
                notice.InstanceId = activeId;
                notice.Type = "activeInviteFriend";
                notice.IsReaded = false;

                notice.Save();

                //加入活动ActivitiesInvite表
                CY.UME.Core.Business.ActivitiesInvite activeInvite = new CY.UME.Core.Business.ActivitiesInvite();
                activeInvite.ActiveitesID = CY.Utility.Common.ConvertUtility.ConvertToInt(activeId, 0);
                activeInvite.AccountID = CurrentAccount.Id;
                activeInvite.InviteID = friendId;
                activeInvite.InviteaTime = DateTime.Now;
                activeInvite.Save();
            }
            context.Response.Write("{success:true,msg:'邀请完毕页面将自动刷新。'}");
        }
Example #2
0
        /// <summary>
        /// 提交
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void InviteFriend_OnClick(object sender, EventArgs e)
        {
            string strFriendId = iFriendId.Value.Trim();//待邀请的人
            string[] friendIdArray = strFriendId.Split(',');
            long friendId = 0;

            if (ViewState["ActiveID"] == null)
            {
                ShowAlert("提示", "邀请加入的活动不存在或已被删除");
                return;
            }

            for (int i = 0; i < friendIdArray.Length; i++)
            {
                if (!long.TryParse(friendIdArray[i].Trim(), out friendId))
                {
                    continue;
                }

                CY.UME.Core.Business.Account friend = CY.UME.Core.Business.Account.Load(friendId);

                if (friend == null)
                {
                    continue;
                }

                IList<CY.UME.Core.Business.Notice> noticeList = CY.UME.Core.Business.Notice.GetNoticeByTypeAndInstanceId(CurrentAccount, null, "activeInviteFriend", ViewState["ActiveID"].ToString(), new CY.UME.Core.PagingInfo { CurrentPage = 1, PageSize = int.MaxValue });
                if (noticeList.Count > 0)
                {
                    continue;
                }

                CY.UME.Core.Business.Notice notice = new CY.UME.Core.Business.Notice();

                notice.AccountId = friend.Id;
                notice.AuthorId = CurrentAccount.Id;
                notice.Content = "邀请您加入活动";
                notice.DateCreated = DateTime.Now;
                notice.InstanceId = ViewState["ActiveID"].ToString();
                notice.Type = "activeInviteFriend";
                notice.IsReaded = false;

                notice.Save();

                //加入活动ActivitiesInvite表
                CY.UME.Core.Business.ActivitiesInvite activeInvite = new CY.UME.Core.Business.ActivitiesInvite();
                activeInvite.ActiveitesID = CY.Utility.Common.ConvertUtility.ConvertToInt(ViewState["ActiveID"].ToString(), 0);
                activeInvite.AccountID = CurrentAccount.Id;
                activeInvite.InviteID = friendId;
                activeInvite.InviteaTime = DateTime.Now;
                activeInvite.Save();
            }

            Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>cy.ume.ui.window({title: '提示', content: '邀请好友成功'});window.location.href='ActiveDetail2.aspx?aid=" +ViewState["ActiveID"].ToString() + "'</script>");
        }