Ejemplo n.º 1
0
        /// <summary>
        /// 通知列表中同意添加好友
        /// </summary>
        /// <param name="session">本人的session</param>
        /// <param name="noticeID">通知的ID</param>
        /// <param name="sessionFriend">好友的session</param>
        /// <param name="noticeType">标志要请求的通知类型,0全部通知,1个人通知,2系统通知,</param>
        /// <returns></returns>
        public string AddFriendByNotice(string session, string noticeID, string sessionFriend, string noticeType)
        {
            HF.Cloud.BLL.Common.Logger.Error("AddFriendByNotice方法获取到的参数session:" + session + "---sessionFriend:" + sessionFriend + "---noticeType:" + noticeType);
            NoticeEL noticeEL = new NoticeEL();

            //通过noticeID获取NoticeType=3?说明是审核的通知,修改UserUniteGroup表valid=1
            noticeEL.ID = long.Parse(noticeID);
            DataTable dtNotice = noticeEL.ExecDT(2);

            if (dtNotice != null & dtNotice.Rows.Count > 0)
            {
                //如果是加群审核通知
                if (dtNotice.Rows[0]["NoticeType"].ToString() == "3")
                {
                    long groupID = (long)dtNotice.Rows[0]["GroupID"];
                    //UserUniteGroup表中的valid改为1,则通过审核
                    UserUniteGroupEL userGroupEL = new UserUniteGroupEL();
                    userGroupEL.UserID  = long.Parse(dtNotice.Rows[0]["UserID_Friend"].ToString());
                    userGroupEL.GroupID = groupID;
                    int raG;
                    userGroupEL.ExecNonQuery(21, out raG);
                    //通知notice表中的状态NoticeState要给成1通过
                    NoticeEL notice_EL = new NoticeEL();
                    notice_EL.ID          = long.Parse(noticeID);
                    notice_EL.NoticeState = 1;
                    notice_EL.IsLook      = 1;
                    int raNoti;
                    notice_EL.ExecNonQuery(33, out raNoti);
                    HF.Cloud.BLL.Common.Logger.Error("AddFriendByNotice方法更改UserUniteGroupEL的Valid受影响的行数:" + raG + "更改通知表结果:" + raNoti);
                    //审核后给用户发通知(系统通知)
                    GroupEL groupEL = new GroupEL();
                    groupEL.ID = groupID;
                    DataTable dt_group = groupEL.ExecDT(3);
                    if (dt_group != null && dt_group.Rows.Count > 0)
                    {
                        string          groupName      = dt_group.Rows[0]["GroupName"].ToString();
                        Notice_SystemEL noticeSystemEL = new Notice_SystemEL();
                        noticeSystemEL.UserID        = long.Parse(dtNotice.Rows[0]["UserID_Friend"].ToString());
                        noticeSystemEL.NoticeTitle   = "审核通知!";
                        noticeSystemEL.NoticeContent = "您加入群\"" + groupName + "\"的申请已通过!";
                        noticeSystemEL.AddressUrl    = "groupid=" + groupID;
                        noticeSystemEL.NoticeType    = 2;
                        noticeSystemEL.IsLook        = 0;
                        noticeSystemEL.CreateTime    = DateTime.Now.ToString();
                        noticeSystemEL.Valid         = 1;
                        int raNS;
                        noticeSystemEL.ExecNonQuery(1, out raNS);
                    }
                }
                else
                {
                    //添加好友
                    FriendsBLL friendsBLL      = new FriendsBLL();
                    string     addFriendResult = friendsBLL.AddFriend(session, sessionFriend);
                    //修改通知表中记录的状态改为好友
                    noticeEL.ID          = long.Parse(noticeID);
                    noticeEL.NoticeState = 1;
                    int ra;
                    noticeEL.ExecNonQuery(31, out ra);
                    HF.Cloud.BLL.Common.Logger.Error("AddFriendByNotice方法更改NoticeState受影响的行数:" + ra);
                }
            }

            //返回通知列表
            string resultStr = GetNotice(session, noticeType);

            return(resultStr);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取用户综合信息
        /// </summary>
        /// <param name="session">本人session</param>
        /// <param name="sessionFriend">需要获取信息的用户session</param>
        /// <returns></returns>
        public string GetUserInfoBySessionAndSessionFriend(string session, string sessionFriend)
        {
            HF.Cloud.BLL.Common.Logger.Error("GetUserInfoBySessionAndSessionFriend获取用户信息方法获取到参数session:" + session + "-----sessionFriend:" + sessionFriend);
            JavaScriptSerializer        js  = new JavaScriptSerializer();
            Dictionary <string, object> dic = new Dictionary <string, object>();

            //通过sessionFriend获取用户
            SB_UserEL userel = new SB_UserEL();

            userel.Session_True = sessionFriend;
            userel.ExecuteEL(41);

            HF.Cloud.BLL.Common.Logger.Error("GetUserInfoBySessionAndSessionFriend获取用户信息结果(大于0说明成功):" + userel.ID);
            if (userel.ID > 0)
            {
                dic.Add("UserName", userel.UserName);
                dic.Add("UserTel", userel.UserTel);
                dic.Add("Duty", userel.Duty);
                dic.Add("UserEmail", userel.UserEmail);
                dic.Add("Detail", userel.Detail);
                dic.Add("ImgUrl", userel.ImgUrl);
                dic.Add("Session", userel.Session_True);
                #region  人气值
                //组合人气值,人气值=好友查看的次数(好友第一次查看有效,一次以上的不记录)+所有群组群友人数和
                int popularityInt = 0; //人气值
                                       //用户查看人气值
                PopularityBLL popularityBLL = new PopularityBLL();
                //通过Session换取UserID
                UserBLL userBLL       = new UserBLL();
                long    userID        = userBLL.GetUserIDBySession(session);
                long    userID_Friend = userBLL.GetUserIDBySession(sessionFriend);
                HF.Cloud.BLL.Common.Logger.Error("GetUserInfoBySessionAndSessionFriend方法获取到的用户ID  userID:" + userID + "---userID_Friend:" + userID_Friend);
                int friendLookInt = popularityBLL.GetPopularityNumber(userID);
                HF.Cloud.BLL.Common.Logger.Error("GetUserInfoBySessionAndSessionFriend方法用户查看人气值为:" + friendLookInt);
                popularityInt += friendLookInt;
                //群组群友人数和
                GroupBLL groupBLL    = new GroupBLL();
                int      groupNumber = groupBLL.GetGroupPopularityNumber(userID);
                HF.Cloud.BLL.Common.Logger.Error("GetUserInfoBySessionAndSessionFriend方法群组人气值为:" + groupNumber);
                popularityInt += groupNumber;
                dic.Add("Popularity", popularityInt);//人气
                #endregion
                string companyName = "";
                //通过公司ID查询公司名称
                CompanysEL compEL = new CompanysEL();
                compEL.ID = userel.CompanyID;
                compEL.ExecuteEL(2);
                HF.Cloud.BLL.Common.Logger.Error("GetUserInfoBySessionAndSessionFriend获取公司信息结果(公司名称为):" + compEL.CompanyName);
                if (!string.IsNullOrEmpty(compEL.CompanyName))
                {
                    companyName = compEL.CompanyName;
                }
                dic.Add("CompanyName", companyName);
                dic.Add("CompanyIcon", compEL.CompanyIcon);
                dic.Add("CompanyID", compEL.ID);
                ///公司简介
                string companyIntroduceStr = compEL.Introduce;
                string introduceStr        = companyIntroduceStr.Length < 50 ? companyIntroduceStr : companyIntroduceStr.Substring(0, 50).ToString() + "...";
                dic.Add("CompanyIntroduce", introduceStr);
                //查看是否有查看sessionFriend用户的记录,有就不用管,没有的话就在SB_Popularity添加一个记录
                bool isLook = popularityBLL.IsLooked(userID, userID_Friend);
                HF.Cloud.BLL.Common.Logger.Error("GetUserInfoBySessionAndSessionFriend方法,此用户是否被查看过:" + isLook);
                if (!isLook) //如果没有记录就添加一个
                {
                    long insertPopularity = popularityBLL.InsertPopularity(userID, userID_Friend);
                    HF.Cloud.BLL.Common.Logger.Error("GetUserInfoBySessionAndSessionFriend人气值增加结果:" + insertPopularity);
                }
            }
            //获取公司关键字
            CompanysBLL companyBLL = new CompanysBLL();
            string      tags       = companyBLL.GetCompanyTag_String(userel.CompanyID.ToString());
            dic.Add("Tags", tags);
            HF.Cloud.BLL.Common.Logger.Error("GetUserInfoBySessionAndSessionFriend获取公司关键字:" + tags);
            //获取点赞个数
            ThumbsBLL thumbsBLL = new ThumbsBLL();
            string    thumbs    = thumbsBLL.GetThumbs(sessionFriend);
            HF.Cloud.BLL.Common.Logger.Error("GetUserInfoBySessionAndSessionFriend获取点赞个数:" + thumbs);
            dic.Add("Thumb", thumbs.ToString());//点赞个数
            //这里要注意,第一个参数是好友的sesison,第二个参数是自己的session
            string isHadThumb = thumbsBLL.IsHadThumb(sessionFriend, session);
            dic.Add("IsHadThumb", isHadThumb);//是否被点赞
            //获取保存数
            FriendsBLL friendsBLL = new FriendsBLL();
            int        saves      = friendsBLL.GetSaveNumber(sessionFriend);
            HF.Cloud.BLL.Common.Logger.Error("GetUserInfoBySessionAndSessionFriend获取保存个数:" + saves);
            dic.Add("Save", saves.ToString());//保存个数

            //如果session==sessionFriend,说明是自己看自己
            if (session == sessionFriend)
            {
                dic.Add("Who", "0");
            }
            else
            {
                //查看sessionFriend是否是session的好友
                bool isFriend = friendsBLL.IsFriend(session, sessionFriend);
                if (isFriend)
                {
                    //说明是好友
                    dic.Add("Who", "1");
                }
                else
                {
                    //说明不是好友
                    dic.Add("Who", "2");
                }
            }
            //小程序的token
            WX_TokenBLL tokenBLL = new WX_TokenBLL();
            string      token    = tokenBLL.GetToken();
            dic.Add("Token", token);

            string strJson = js.Serialize(dic);
            HF.Cloud.BLL.Common.Logger.Error("GetUserInfoBySessionAndSessionFriend返回的数据为:" + strJson);
            return(strJson);
        }