Ejemplo n.º 1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            int groupId = 0;

            if (context.Request.Form["groupId"] == null)
            {
                context.Response.Write("{success:false,msg:'参数错误'}");
                return;
            }
            if (!int.TryParse(context.Request.Form["groupId"], out groupId))
            {
                context.Response.Write("{success:false,msg:'参数错误'}");
                return;
            }

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

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

            CY.UME.Core.Business.Group group = CY.UME.Core.Business.Group.Load(groupId);

            if (group == null)
            {
                context.Response.Write("{success:false,msg:'您所在的群不存在或已被删除'}");
                return;
            }

            try
            {
                CY.UME.Core.Business.AccountGroup ag = new CY.UME.Core.Business.AccountGroup();
                IList<CY.UME.Core.Business.AccountGroup> agList;

                if (currentAccount.Id != group.CreatorId)
                {
                    agList = ag.GetAccountGroupByGroupIdAndAccountId(currentAccount, group);

                    CY.UME.Core.Business.AccountGroup aGroup = CY.UME.Core.Business.AccountGroup.Load(agList[0].Id);

                    aGroup.DeleteOnSave();
                    aGroup.Save();
                }
                else
                {
                    group.IsChecked = false;
                    group.Save();
                }

                context.Response.Write("{success:true}");
            }
            catch
            {
                context.Response.Write("{success:false,msg:'系统忙,请稍后再试'}");
            }
        }
Ejemplo n.º 2
0
        protected void Submit_OnClick(object sender, EventArgs e)
        {
            string[] accountIdArray = mm_HiddenMember.Value.Split(',');
            long accountId = 0;
            int groupId = 0, role = 0;

            if (!int.TryParse(mm_HiddenGroupId.Value, out groupId))
            {
                throw new Exception("参数错误");
            }

            group = CY.UME.Core.Business.Group.Load(groupId);

            if (group == null)
            {
                throw new Exception("参数错误");
            }

            if (!int.TryParse(DDLOperation.SelectedValue, out role))
            {
                throw new Exception("参数错误");
            }

            if (role != 0 && role != 1 && role != -1)
            {
                throw new Exception("参数错误");
            }

            foreach (string strAccountId in accountIdArray)
            {
                if (!long.TryParse(strAccountId, out accountId))
                {
                    continue;
                }

                CY.UME.Core.Business.Account account = CY.UME.Core.Business.Account.Load(accountId);

                if (account == null)
                {
                    continue;
                }

                CY.UME.Core.Business.AccountGroup ag = new CY.UME.Core.Business.AccountGroup();
                IList<CY.UME.Core.Business.AccountGroup> agList = ag.GetAccountGroupByGroupIdAndAccountId(account, group);

                if (agList.Count > 0)
                {
                    ag = CY.UME.Core.Business.AccountGroup.Load(agList[0].Id);
                }

                if (role == -1)
                {
                    ag.DeleteOnSave();
                }
                else
                {
                    ag.Role = role;
                }

                ag.Save();
            }

            BindData(group);
        }
Ejemplo n.º 3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            int groupId = 0;
            CY.UME.Core.Business.Account currentAccount;

            #region validate
            if (context.Request.Params["groupId"] == null )
            {
                context.Response.Write("{success:false,msg:'参数错误'}");
                return;
            }

            if (!int.TryParse(context.Request.Params["groupId"].ToString(), out groupId))
            {
                context.Response.Write("{success:false,msg:'参数错误'}");
                return;
            }

            currentAccount = CY.UME.Core.Global.GetCurrentAccount();

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

            try
            {
                CY.UME.Core.Business.Group group = CY.UME.Core.Business.Group.Load(groupId);

                if(group==null)
                {
                    context.Response.Write("{success:false,msg:'该群组不存在或已被删除'}");
                    return;
                }

                if (group.MaxMemberNum <= group.MemberNum)
                {
                    context.Response.Write("{success:false,msg:'该群组已达最大人数上限'}");
                    return;
                }

                //标识群组邀请通知已读
                IList<CY.UME.Core.Business.Notice> noticeList = CY.UME.Core.Business.Notice.GetNoticeByTypeAndInstanceId(currentAccount, false, "groupinvite", groupId.ToString(), new CY.UME.Core.PagingInfo { CurrentPage = 1, PageSize = int.MaxValue });

                foreach (CY.UME.Core.Business.Notice notice in noticeList)
                {
                    CY.UME.Core.Business.Notice noticeTemp = CY.UME.Core.Business.Notice.Load(notice.Id);

                    noticeTemp.IsReaded = true;
                    noticeTemp.Save();
                }
                if (noticeList.Count > 0)
                {
                    CY.UME.Core.Business.AccountGroup ag = new CY.UME.Core.Business.AccountGroup();
                    IList<CY.UME.Core.Business.AccountGroup> accountGroupList = ag.GetAccountGroupByGroupIdAndAccountId(currentAccount, group);

                    if (accountGroupList.Count == 0)
                    {
                        ag.AccountId = currentAccount.Id;
                        ag.DateCreated = DateTime.Now;
                        ag.GroupId = groupId;
                        ag.LastVisitDate = DateTime.Now;
                        ag.Name = currentAccount.Name;
                        ag.Role = 0;

                        ag.Save();
                    }
                }

                context.Response.Write("{success:true,GroupName:'"+group.Name+"'}");
            }
            catch
            {
                context.Response.Write("{success:false,msg:'请稍后,系统忙'}");
            }
        }
Ejemplo n.º 4
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            int groupId = 0;
            CY.UME.Core.Business.Account currentAccount;
            CY.UME.Core.Business.Group group;

            #region validate
            if(context.Request.Form["groupId"]==null)
            {
                context.Response.Write("{success:false,msg:'参数错误'}");
                return;
            }

            if (!int.TryParse(context.Request.Form["groupId"], out groupId))
            {
                context.Response.Write("{success:false,msg:'参数错误'}");
                return;
            }

            group = CY.UME.Core.Business.Group.Load(groupId);

            if(group==null)
            {
                context.Response.Write("{success:false,msg:'该群不存在或已被删除'}");
                return;
            }

            currentAccount = CY.UME.Core.Global.GetCurrentAccount();

            if(currentAccount==null)
            {
                context.Response.Write("{success:false,msg:'登录超时失败,请重新登录'}");
                return;
            }
            #endregion

            try
            {
                if (group.CheckIsGroupMember(currentAccount))
                {
                    context.Response.Write("{success:true,msg:'已是群组成员'}");
                    return;
                }

                CY.UME.Core.Business.Account groupCreator =CY.UME.Core.Business.Account.Load(group.CreatorId);

                if (group.MaxMemberNum <= group.MemberNum)
                {
                    context.Response.Write("{success:false,msg:'该群已达用户数已达上线'}");
                    return;
                }

                if (group.AddPermission == 0)//需群主验证加入
                {
                    CY.UME.Core.Business.AccountGroup ag = new CY.UME.Core.Business.AccountGroup();

                    IList<CY.UME.Core.Business.AccountGroup> agList = ag.GetAccountGroupByGroupIdAndAccountId(currentAccount, group);

                    if (agList.Count > 0)
                    {
                        ag = agList[0];

                        if (ag.Role != 2)
                        {
                            context.Response.Write("{success:true,msg:'加入成功'}");
                            return;
                        }
                        else if (ag.Role == 2)
                        {
                            context.Response.Write("{success:false,msg:'申请已发出,请等待'}");
                            return;
                        }
                    }

                    CY.UME.Core.Business.AccountGroup agTemp = new CY.UME.Core.Business.AccountGroup();

                    agTemp.AccountId = currentAccount.Id;
                    agTemp.DateCreated = DateTime.Now;
                    agTemp.GroupId = group.Id;
                    agTemp.Name = currentAccount.Name;
                    agTemp.Role = 2;

                    agTemp.Save();

                    context.Response.Write("{success:false,msg:'申请已发出,请等待'}");
                    return;
                }
                else if(group.AddPermission==1)//任何人可以加入
                {
                    CY.UME.Core.Business.AccountGroup accountGroup =new CY.UME.Core.Business.AccountGroup();

                    accountGroup.AccountId =currentAccount.Id;
                    accountGroup.DateCreated =DateTime.Now;
                    accountGroup.GroupId =group.Id;
                    accountGroup.Name =currentAccount.Name;
                    accountGroup.Role =0;

                    accountGroup.Save();

                    group.MemberNum++;
                    group.Save();

                    context.Response.Write("{success:true,msg:'加入成功'}");
                    return;
                }
                else if(group.AddPermission==2)//只能由群主邀请加入
                {
                    context.Response.Write("{success:false,msg:'该群只能由群主邀请加入'}");
                    return;
                }

            }
            catch
            {
                context.Response.Write("{success:false,msg:'服务器忙,请稍后再试'}");
                return;
            }
        }
Ejemplo n.º 5
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            #region validate
            if (context.Request.Params["groupId"] == null)
            {
                context.Response.Write("{success:false,msg:'参数错误'}");
                return;
            }
            string groupIds = context.Request.Params["groupId"];
            string id = context.Request.Params["id"];
            string[] groupIdsstr = groupIds.Split(',');
            string json = string.Empty;
            if (groupIds != null && id != null)
            {
                CY.UME.Core.Business.Account acc = CY.UME.Core.Business.Account.Load(long.Parse(id));
            #endregion

                try
                {
                    json = "{success:true,msg:' ";
                    for (int i = 0; i < groupIdsstr.Length; i++)
                    {
                        CY.UME.Core.Business.Group group = CY.UME.Core.Business.Group.Load(int.Parse(groupIdsstr[i]));
                        CY.UME.Core.Business.AccountGroup ag = new CY.UME.Core.Business.AccountGroup();
                        IList<CY.UME.Core.Business.AccountGroup> agList = ag.GetAccountGroupByGroupIdAndAccountId(acc, group);
                        if (agList != null && agList.Count != 0)
                        {
                            if (agList[0].Role == 2)
                            {
                                context.Response.Write("{success:true,msg:'你已经发送过申请,请等候'}");
                                return;
                            }
                            else
                            {
                                context.Response.Write("{success:true,msg:'你已经加入了该群组'}");
                                return;
                            }
                        }

                        if (group.MaxMemberNum <= group.MemberNum)
                        {
                            continue;
                        }

                        if (group.AddPermission == 0)//需群主验证加入
                        {
                            CY.UME.Core.Business.AccountGroup agTemp = new CY.UME.Core.Business.AccountGroup();

                            agTemp.AccountId = acc.Id;
                            agTemp.DateCreated = DateTime.Now;
                            agTemp.GroupId = group.Id;
                            agTemp.Name = acc.Name;
                            agTemp.Role = 2;

                            agTemp.Save();
                            json += "加入申请已发出 ";
                            continue;
                        }
                        else if (group.AddPermission == 1)//任何人可以加入
                        {
                            CY.UME.Core.Business.AccountGroup accountGroup = new CY.UME.Core.Business.AccountGroup();

                            accountGroup.AccountId = acc.Id;
                            accountGroup.DateCreated = DateTime.Now;
                            accountGroup.GroupId = group.Id;
                            accountGroup.Name = acc.Name;
                            accountGroup.Role = 0;

                            accountGroup.Save();

                            group.MemberNum++;
                            group.Save();
                            json += "加入成功 ";
                            continue;

                        }
                        else if (group.AddPermission == 2)//只能由群主邀请加入
                        {
                            json += "该群只能由群组邀请加入 ";
                            continue;
                        }

                    }
                    json += "'}";
                    context.Response.Write(json);
                    return;
                }
                catch
                {
                    context.Response.Write("{success:false,msg:'服务器忙,请稍后再试'}");
                    return;
                }
            }
        }