Beispiel #1
0
        /// <summary>
        /// 发送消息
        /// </summary>
        /// <param name="code">编码</param>
        /// <param name="userIdList">用户列表</param>
        /// <param name="content">消息内容</param>
        public void SendMsg(string code, List <string> userIdList, string content)
        {
            try
            {
                if (!string.IsNullOrEmpty(content) && userIdList.Count > 0)
                {
                    IMSysUserEntity entity = iMSysUserService.GetEntityByCode(code);
                    if (entity != null)
                    {
                        foreach (var userId in userIdList)
                        {
                            IMMsgEntity iMMsgEntity = new IMMsgEntity();
                            iMMsgEntity.F_SendUserId = code;
                            iMMsgEntity.F_RecvUserId = userId;
                            iMMsgEntity.F_Content    = content;
                            iMMsgService.SaveEntity(iMMsgEntity);

                            SendHubs.callMethod("sendMsg2", code, userId, content, 1);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                if (ex is ExceptionEx)
                {
                    throw;
                }
                else
                {
                    throw ExceptionEx.ThrowBusinessException(ex);
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// 保存实体数据(新增)
 /// <param name="entity">实体</param>
 /// <summary>
 /// <returns></returns>
 public void SaveEntity(IMMsgEntity entity)
 {
     try
     {
         iMMsgService.SaveEntity(entity);
     }
     catch (Exception ex)
     {
         if (ex is ExceptionEx)
         {
             throw;
         }
         else
         {
             throw ExceptionEx.ThrowBusinessException(ex);
         }
     }
 }
Beispiel #3
0
        /// <summary>
        /// 保存实体数据(新增)
        /// <param name="entity">实体数据</param>
        /// <summary>
        /// <returns></returns>
        public void SaveEntity(IMMsgEntity entity)
        {
            IMContactsEntity myContacts    = new IMContactsEntity();
            IMContactsEntity otherContacts = new IMContactsEntity();

            myContacts.F_MyUserId    = entity.F_SendUserId;
            myContacts.F_OtherUserId = entity.F_RecvUserId;
            myContacts.F_Content     = entity.F_Content;

            otherContacts.F_MyUserId    = entity.F_RecvUserId;
            otherContacts.F_OtherUserId = entity.F_SendUserId;
            otherContacts.F_Content     = entity.F_Content;

            IMContactsEntity myContactsTmp    = this.BaseRepository().FindEntity <IMContactsEntity>(t => t.F_MyUserId.Equals(myContacts.F_MyUserId) && t.F_OtherUserId.Equals(myContacts.F_OtherUserId));
            IMContactsEntity otherContactsTmp = this.BaseRepository().FindEntity <IMContactsEntity>(t => t.F_MyUserId.Equals(otherContacts.F_MyUserId) && t.F_OtherUserId.Equals(otherContacts.F_OtherUserId));
            var db = this.BaseRepository().BeginTrans();

            try
            {
                myContacts.F_IsRead = 2;
                if (myContactsTmp == null)
                {
                    myContacts.Create();
                    db.Insert(myContacts);
                }
                else
                {
                    myContacts.Modify(myContactsTmp.F_Id);
                    db.Update(myContacts);
                }

                otherContacts.F_IsRead = 1;
                if (otherContactsTmp == null)
                {
                    otherContacts.Create();
                    db.Insert(otherContacts);
                }
                else
                {
                    otherContacts.Modify(otherContactsTmp.F_Id);
                    db.Update(otherContacts);
                }

                entity.Create();
                db.Insert(entity);

                db.Commit();
            }
            catch (Exception ex)
            {
                db.Rollback();
                if (ex is ExceptionEx)
                {
                    throw;
                }
                else
                {
                    throw ExceptionEx.ThrowServiceException(ex);
                }
            }
        }