예제 #1
0
        public string sendUserTalkRec(string SendUserID, string ReceiveUserID, string TalkType)
        {
            string json     = "";
            string jsonItem = "";

            switch (TalkType)
            {
            case "1":    //单聊
                IM_TalkBLL         talkBLL  = new IM_TalkBLL();
                List <IM_TalkInfo> talkList = talkBLL.GetList(new Guid(SendUserID), new Guid(ReceiveUserID), 1);
                foreach (IM_TalkInfo talkModel in talkList)
                {
                    talkBLL.UpdateForState(talkModel.ID, 2);
                    jsonItem += ",{";
                    jsonItem += "ID:'" + talkModel.ID + "'";
                    jsonItem += ",SendUserName:'******'";
                    jsonItem += ",SendUserID:'" + talkModel.SendUserID + "'";
                    jsonItem += ",Note:'" + talkModel.Note + "'";
                    jsonItem += ",Type:'" + talkModel.Type + "'";
                    jsonItem += ",CreateDate:'" + talkModel.CreateDate + "'";
                    jsonItem += "}";
                }
                json += "TalkList:[" + (jsonItem.Length == 0 ? "" : jsonItem.Substring(1)) + "]";
                break;

            case "2":    //群聊
                IM_TalkGroupBLL         talkGroupBLL     = new IM_TalkGroupBLL();
                IM_TalkGroupHintBLL     talkGroupHintBLL = new IM_TalkGroupHintBLL();
                List <IM_TalkGroupInfo> talkGroupList    = talkGroupBLL.GetList(new Guid(SendUserID), new Guid(ReceiveUserID));
                foreach (IM_TalkGroupInfo talkGroupModel in talkGroupList)
                {
                    talkGroupHintBLL.UpdateForState(talkGroupModel.ID, new Guid(ReceiveUserID), 2);
                    jsonItem += ",{";
                    jsonItem += "ID:'" + talkGroupModel.ID + "'";
                    jsonItem += ",SendUserName:'******'";
                    jsonItem += ",SendUserID:'" + talkGroupModel.SendUserID + "'";
                    jsonItem += ",Note:'" + talkGroupModel.Note + "'";
                    jsonItem += ",Type:'" + talkGroupModel.Type + "'";
                    jsonItem += ",CreateDate:'" + talkGroupModel.CreateDate + "'";
                    jsonItem += "}";
                }
                json += "TalkList:[" + (jsonItem.Length == 0 ? "" : jsonItem.Substring(1)) + "]";
                break;
            }


            json = "[{" + json + "}]";

            return(json);
        }
예제 #2
0
        public string getUserAboutNews(string UserID)
        {
            QueryBuilder queryBuilder = new QueryBuilder();
            string       json         = "";

            //添加好友提示
            queryBuilder.AddFilter("ReceiveUserID", "=", UserID);
            //queryBuilder.AddFilter("BusinessType", "=", "1");
            queryBuilder.AddFilter("State", "=", "0");
            queryBuilder.AddOrderASC("CreateDate");
            IM_NewsBLL         newsBLL  = new IM_NewsBLL();
            List <IM_NewsInfo> newsList = newsBLL.GetList(queryBuilder);
            string             jsonItem = "";

            foreach (IM_NewsInfo newsModel in newsList)
            {
                newsBLL.UpdateForState(newsModel.ID, 1);
                jsonItem += ",{";
                jsonItem += "ID:'" + newsModel.ID + "'";
                jsonItem += ",SendUserID:'" + newsModel.SendUserID + "'";
                jsonItem += ",ReceiveUserID:'" + newsModel.ReceiveUserID + "'";
                jsonItem += ",BusinessType:'" + (newsModel.BusinessType == 3 ? 2 : newsModel.BusinessType) + "'";//修改加入群
                jsonItem += ",Note:'" + newsModel.Note + "'";
                jsonItem += "}";
            }
            json = "NewsList:[" + (jsonItem.Length == 0 ? "" : jsonItem.Substring(1)) + "]";

            //单聊提示
            jsonItem = "";
            IM_TalkBLL         talkBLL  = new IM_TalkBLL();
            List <IM_TalkInfo> talkList = talkBLL.GetList(new Guid(UserID));

            foreach (IM_TalkInfo talkModel in talkList)
            {
                talkBLL.UpdateForState(talkModel.ID, 1);
                jsonItem += ",{";
                jsonItem += "ID:'" + talkModel.ID + "'";
                jsonItem += ",SendUserName:'******'";
                jsonItem += ",SendUserID:'" + talkModel.SendUserID + "'";
                jsonItem += ",Note:'" + talkModel.Note + "'";
                jsonItem += ",Type:'" + talkModel.Type + "'";
                jsonItem += ",CreateDate:'" + talkModel.CreateDate + "'";
                jsonItem += "}";
            }
            json += ",TalkList:[" + (jsonItem.Length == 0 ? "" : jsonItem.Substring(1)) + "]";

            //群聊提示
            jsonItem = "";
            IM_TalkGroupBLL         talkGroupBLL     = new IM_TalkGroupBLL();
            IM_TalkGroupHintBLL     talkGroupHintBLL = new IM_TalkGroupHintBLL();
            List <IM_TalkGroupInfo> talkGroupList    = talkGroupBLL.GetList(new Guid(UserID));

            foreach (IM_TalkGroupInfo talkGroupModel in talkGroupList)
            {
                talkGroupHintBLL.UpdateForState(talkGroupModel.ID, new Guid(UserID), 1);
                jsonItem += ",{";
                jsonItem += "ID:'" + talkGroupModel.ID + "'";
                jsonItem += ",GroupName:'" + talkGroupModel.GroupName + "'";
                jsonItem += ",GroupID:'" + talkGroupModel.GroupID + "'";
                jsonItem += ",UserName:'******'";
                jsonItem += ",Note:'" + talkGroupModel.Note + "'";
                jsonItem += ",Type:'" + talkGroupModel.Type + "'";
                jsonItem += ",CreateDate:'" + talkGroupModel.CreateDate + "'";
                jsonItem += "}";
            }
            json += ",TalkGroupList:[" + (jsonItem.Length == 0 ? "" : jsonItem.Substring(1)) + "]";

            json = "[{" + json + "}]";



            return(json);
        }