Beispiel #1
0
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="recordCount">记录数</param>
        /// <param name="pageIndex">当前页</param>
        /// <param name="pageSize">每页显示</param>
        /// <param name="whereClause">条件</param>
        /// <param name="dbParameters">参数</param>
        /// <param name="order">排序</param>
        /// <returns>数据表</returns>
        public DataTable GetDataTableByPage(BaseUserInfo userInfo, out int recordCount, int pageIndex, int pageSize, string whereClause, List <KeyValuePair <string, object> > dbParameters, string order = null)
        {
            var result = new DataTable(BaseMessageEntity.TableName);

            int myRecordCount = 0;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessMessageDb(userInfo, parameter, (dbHelper) =>
            {
                if (SecretUtil.IsSqlSafe(whereClause))
                {
                    var messageManager = new BaseMessageManager(dbHelper, userInfo);
                    result             = messageManager.GetDataTableByPage(out myRecordCount, pageIndex, pageSize, whereClause, dbHelper.MakeParameters(dbParameters), order);
                    result.TableName   = BaseMessageEntity.TableName;
                    // FileUtil.WriteMessage("userInfo1:" + userInfo.Serialize() + " " + whereClause, "D:/Web/DotNet.CommonV4.2/DotNet.WCFService/Log/" + "SqlSafe" + DateTime.Now.ToString(BaseSystemInfo.DateFormat) + ".txt");
                    // FileUtil.WriteMessage("userInfo2:" + userInfo.Serialize() + " " + whereClause, System.Web.HttpContext.Current.Server.MapPath("~/Log/") + "SqlSafe" + DateTime.Now.ToString(BaseSystemInfo.DateFormat) + ".txt");
                }
                else
                {
                    if (System.Web.HttpContext.Current != null)
                    {
                        // 记录注入日志
                        FileUtil.WriteMessage("userInfo:" + userInfo.Serialize() + " " + whereClause, System.Web.HttpContext.Current.Server.MapPath("~/Log/") + "SqlSafe" + DateTime.Now.ToString(BaseSystemInfo.DateFormat) + ".txt");
                    }
                }
            });
            recordCount = myRecordCount;

            return(result);
        }
Beispiel #2
0
        public int SendGroupMessage(BaseUserInfo userInfo, string organizeId, string roleId, string contents)
        {
            int result = 0;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessMessageDb(userInfo, parameter, (dbHelper) =>
            {
                // 发给角色里所有的
                BaseMessageEntity entity = new BaseMessageEntity();
                //messageEntity.Id = Guid.NewGuid().ToString("N");
                entity.CategoryCode = MessageCategory.Send.ToString();
                if (!string.IsNullOrEmpty(organizeId))
                {
                    entity.FunctionCode = MessageFunction.OrganizeMessage.ToString();
                    entity.ObjectId     = organizeId;
                }
                if (!string.IsNullOrEmpty(roleId))
                {
                    entity.FunctionCode = MessageFunction.RoleMessage.ToString();
                    entity.ObjectId     = roleId;
                }
                entity.Contents          = contents;
                entity.IsNew             = (int)MessageStateCode.New;
                entity.ReadCount         = 0;
                entity.DeletionStateCode = 0;
                var manager      = new BaseMessageManager(dbHelper, userInfo);
                manager.Identity = true;
                result           = manager.BatchSend(string.Empty, organizeId, roleId, entity, false);
            });

            return(result);
        }
Beispiel #3
0
        /// <summary>
        /// 广播消息
        /// 2015-09-29 吉日嘎拉 改进发送消息功能
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="allcompany">是否发全公司</param>
        /// <param name="roleIds">角色主键</param>
        /// <param name="areaIds">区域主键</param>
        /// <param name="companyIds">公司主键</param>
        /// <param name="subCompany">发下属公司</param>
        /// <param name="departmentIds">部门主键数组</param>
        /// <param name="subDepartment">发下属部门</param>
        /// <param name="userIds">用户主键数组</param>
        /// <param name="message">消息内容</param>
        /// <param name="onlineOnly">只发送给在线用户</param>
        /// <returns>影响行数</returns>
        public int Broadcast(BaseUserInfo userInfo, bool allcompany, string[] roleIds, string[] areaIds, string[] companyIds, bool subCompany, string[] departmentIds, bool subDepartment, string[] userIds, string message, bool onlineOnly)
        {
            int result = 0;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessMessageDb(userInfo, parameter, (dbHelper) =>
            {
                var manager = new BaseMessageManager(userInfo);
                result      = manager.Broadcast(userInfo.SystemCode, allcompany, roleIds, areaIds, companyIds, subCompany, departmentIds, subDepartment, userIds, message, onlineOnly);
            });

            return(result);
        }
Beispiel #4
0
        /// <summary>
        /// 发送系统提示消息
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="userId">接收者主键</param>
        /// <param name="contents">内容</param>
        /// <returns>主键</returns>
        public string Remind(BaseUserInfo userInfo, string userId, string contents)
        {
            string result = string.Empty;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessMessageDb(userInfo, parameter, (dbHelper) =>
            {
                var manager = new BaseMessageManager(dbHelper, userInfo);
                result      = manager.Remind(userId, contents);
            });

            return(result);
        }
Beispiel #5
0
        /// <summary>
        /// 发送消息
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="receiverId">接收者主键</param>
        /// <param name="contents">内容</param>
        /// <param name="functionCode">内容</param>
        /// <returns>主键</returns>
        public string Send(BaseUserInfo userInfo, string receiverId, string contents, string functionCode)
        {
            string result = string.Empty;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessMessageDb(userInfo, parameter, (dbHelper) =>
            {
                var manager = new BaseMessageManager(dbHelper, userInfo);
                BaseMessageEntity entity = manager.Send(receiverId, contents, functionCode);
                result = entity.Id;
            });

            return(result);
        }
Beispiel #6
0
        /// <summary>
        /// 获取特定用户的新信息
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="receiverId">当前交互的用户</param>
        /// <returns>数据表</returns>
        public DataTable ReadFromReceiver(BaseUserInfo userInfo, string receiverId)
        {
            var dt = new DataTable(BaseMessageEntity.TableName);

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessMessageDb(userInfo, parameter, (dbHelper) =>
            {
                var messageManager = new BaseMessageManager(dbHelper, userInfo);
                dt           = messageManager.ReadFromReceiver(receiverId);
                dt.TableName = BaseMessageEntity.TableName;
            });

            return(dt);
        }
Beispiel #7
0
        /// <summary>
        /// 批量发送站内信息
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="receiverIds">接受者主键数组</param>
        /// <param name="ids">组织机构主键数组</param>
        /// <param name="roleIds">角色主键数组</param>
        /// <param name="messageEntity">消息内容</param>
        /// <returns>影响行数</returns>
        public int BatchSend(BaseUserInfo userInfo, string[] receiverIds, string[] organizeIds, string[] roleIds, BaseMessageEntity messageEntity)
        {
            int result = 0;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessMessageDb(userInfo, parameter, (dbHelper) =>
            {
                var manager = new BaseMessageManager(dbHelper, userInfo);
                //manager.Identity = false;
                result = manager.BatchSend(receiverIds, organizeIds, roleIds, messageEntity, true);
            });

            return(result);
        }
Beispiel #8
0
        /// <summary>
        /// 阅读消息
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主键</param>
        public int Read(BaseUserInfo userInfo, string id)
        {
            int result = 0;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessMessageDb(userInfo, parameter, (dbHelper) =>
            {
                var messageManager = new BaseMessageManager(dbHelper, userInfo);
                if (messageManager.Read(id, true) != null)
                {
                    result++;
                }
            });

            return(result);
        }
        /// <summary>
        /// 获取最近联系人
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <returns>用户列表</returns>
        public DataTable GetRecentContacts(BaseUserInfo userInfo)
        {
            DataTable result = null;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessMessageDb(userInfo, parameter, (dbHelper) =>
            {
                /*
                 * var manager = new BaseMessageRecentManager(dbHelper, userInfo);
                 * string sqlQuery = string.Empty;
                 * if (dbHelper.CurrentDbType == CurrentDbType.Oracle)
                 * {
                 *  sqlQuery = "SELECT " + BaseMessageRecentEntity.FieldTargetId + " AS " + BaseUserEntity.FieldId
                 + "," + BaseMessageRecentEntity.FieldRealName
                 + "," + BaseMessageRecentEntity.FieldCompanyName
                 + "," + BaseMessageRecentEntity.FieldDepartmentName
                 + "  FROM " + BaseMessageRecentEntity.TableName
                 + " WHERE " + BaseMessageRecentEntity.FieldUserId + "= '" + userInfo.Id + "'"
                 + " AND ROWNUM < = 50 "
                 + " ORDER BY " + BaseMessageRecentEntity.FieldModifiedOn + " DESC ";
                 + }
                 + else
                 + {
                 +  sqlQuery = "SELECT TOP 50 " + BaseMessageRecentEntity.FieldTargetId + " AS " + BaseUserEntity.FieldId
                 + "," + BaseMessageRecentEntity.FieldRealName
                 + "," + BaseMessageRecentEntity.FieldCompanyName
                 + "," + BaseMessageRecentEntity.FieldDepartmentName
                 + "  FROM " + BaseMessageRecentEntity.TableName
                 + " WHERE " + BaseMessageRecentEntity.FieldUserId + "= '" + userInfo.Id + "'"
                 + " ORDER BY " + BaseMessageRecentEntity.FieldModifiedOn + " DESC ";
                 + }
                 */

                // 2015-09-27 吉日嘎拉 最新联系人方式,从缓存服务器里读取
                result = new DataTable(BaseUserEntity.TableName);
                result.Columns.Add(BaseUserEntity.FieldId.ToUpper());
                result.Columns.Add(BaseUserEntity.FieldRealName.ToUpper());
                result.Columns.Add(BaseUserEntity.FieldCompanyName.ToUpper());
                result.Columns.Add(BaseUserEntity.FieldDepartmentName.ToUpper());
                result.Columns.Add(BaseUserEntity.FieldSortCode.ToUpper());

# if Redis
                // 2015-11-20 吉日嘎拉 为了让程序能编译通过
                using (var redisClient = PooledRedisHelper.GetMessageClient())
                {
                    List <string> list = redisClient.GetAllItemsFromSortedSetDesc(("r" + userInfo.Id));
                    for (int i = 0; i < list.Count && i < 100; i++)
                    {
                        BaseUserEntity userEntity = BaseUserManager.GetObjectByCache(list[i]);
                        if (userEntity != null)
                        {
                            DataRow dr = result.NewRow();
                            dr[BaseUserEntity.FieldId]             = userEntity.Id;
                            dr[BaseUserEntity.FieldRealName]       = userEntity.RealName;
                            dr[BaseUserEntity.FieldCompanyName]    = userEntity.CompanyName;
                            dr[BaseUserEntity.FieldDepartmentName] = userEntity.DepartmentName;
                            dr[BaseUserEntity.FieldSortCode]       = i;
                            result.Rows.Add(dr);
                        }
                    }
                }
#endif
                result.AcceptChanges();
            });