/// <summary>
        /// 发送组消息
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="organizeId">组织机构主键</param>
        /// <param name="roleId">角色主键</param>
        /// <param name="contents">内容</param>
        /// <returns></returns>
        public string SendGroupMessage(UserInfo userInfo, string organizeId, string roleId, string contents)
        {
            int returnValue = 0;
            var parameter   = ParameterUtil.CreateWithLog(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider =>
            {
                var messageEntity = new CiMessageEntity
                {
                    Id           = BusinessLogic.NewGuid(),
                    CategoryCode = MessageCategory.Send.ToString(),
                    MSGContent   = contents,
                    IsNew        = (int)MessageStateCode.New,
                    ReadCount    = 0,
                    DeleteMark   = 0,
                    Enabled      = 1
                };
                if (!string.IsNullOrEmpty(organizeId))
                {
                    messageEntity.FunctionCode = MessageFunction.OrganizeMessage.ToString();
                    messageEntity.ObjectId     = organizeId;
                }
                if (!string.IsNullOrEmpty(roleId))
                {
                    messageEntity.FunctionCode = MessageFunction.RoleMessage.ToString();
                    messageEntity.ObjectId     = roleId;
                }

                var messageManager = new CiMessageManager(dbProvider, userInfo);
                returnValue        = messageManager.BatchSend(string.Empty, organizeId, roleId, messageEntity, false);
            });
            return(returnValue.ToString());
        }
        /// <summary>
        /// 设置实体
        /// </summary>
        /// <param name="cIMESSAGEEntity">实体</param>
        private void SetEntity(SQLBuilder sqlBuilder, CiMessageEntity cIMESSAGEEntity)
        {
            sqlBuilder.SetValue(CiMessageTable.FieldParentId, cIMESSAGEEntity.ParentId);
            sqlBuilder.SetValue(CiMessageTable.FieldFunctionCode, cIMESSAGEEntity.FunctionCode);
            sqlBuilder.SetValue(CiMessageTable.FieldCategoryCode, cIMESSAGEEntity.CategoryCode);
            sqlBuilder.SetValue(CiMessageTable.FieldObjectId, cIMESSAGEEntity.ObjectId);
            sqlBuilder.SetValue(CiMessageTable.FieldTitle, cIMESSAGEEntity.Title);
            sqlBuilder.SetValue(CiMessageTable.FieldMSGContent, cIMESSAGEEntity.MSGContent);
            sqlBuilder.SetValue(CiMessageTable.FieldReceiverId, cIMESSAGEEntity.ReceiverId);
            sqlBuilder.SetValue(CiMessageTable.FieldReceiverRealName, cIMESSAGEEntity.ReceiverRealName);
            sqlBuilder.SetValue(CiMessageTable.FieldIsNew, cIMESSAGEEntity.IsNew);
            sqlBuilder.SetValue(CiMessageTable.FieldReadCount, cIMESSAGEEntity.ReadCount);
            if (DBProvider.CurrentDbType == CurrentDbType.Oracle)
            {
                sqlBuilder.SetValue(CiMessageTable.FieldReadDate, cIMESSAGEEntity.ReadDate != null ? BusinessLogic.GetOracleDateFormat(System.DateTime.Parse(cIMESSAGEEntity.ReadDate.ToString()), "yyyy-mm-dd hh24:mi:ss") : cIMESSAGEEntity.ReadDate);
            }
            else
            {
                sqlBuilder.SetValue(CiMessageTable.FieldReadDate, cIMESSAGEEntity.ReadDate);
            }

            sqlBuilder.SetValue(CiMessageTable.FieldTargetURL, cIMESSAGEEntity.TargetURL);
            sqlBuilder.SetValue(CiMessageTable.FieldIPAddress, cIMESSAGEEntity.IPAddress);
            sqlBuilder.SetValue(CiMessageTable.FieldDeleteMark, cIMESSAGEEntity.DeleteMark);
            sqlBuilder.SetValue(CiMessageTable.FieldEnabled, cIMESSAGEEntity.Enabled);
            sqlBuilder.SetValue(CiMessageTable.FieldDescription, cIMESSAGEEntity.Description);
            sqlBuilder.SetValue(CiMessageTable.FieldSortCode, cIMESSAGEEntity.SortCode);
        }
        /// <summary>
        /// 广播消息
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="message">消息内容</param>
        /// <returns>主键</returns>
        public int Broadcast(UserInfo userInfo, string message)
        {
            int returnValue = 0;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, "广播消息");

            ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider =>
            {
                string[] receiverIds = null;
                var userManager      = new PiUserManager(dbProvider, userInfo);
                receiverIds          = userManager.GetIds(new KeyValuePair <string, object>(PiUserTable.FieldEnabled, 1), new KeyValuePair <string, object>(PiUserTable.FieldDeleteMark, 0));
                var messageManager   = new CiMessageManager(dbProvider, userInfo);
                var messageEntity    = new CiMessageEntity
                {
                    Id           = BusinessLogic.NewGuid(),
                    FunctionCode = MessageFunction.Remind.ToString(),
                    MSGContent   = message,
                    IsNew        = 1,
                    ReadCount    = 0,
                    Enabled      = 1,
                    DeleteMark   = 0
                };
                returnValue = messageManager.BatchSend(receiverIds, string.Empty, string.Empty, messageEntity, false);
            });
            return(returnValue);
        }
Esempio n. 4
0
        /// <summary>
        /// 阅读短信后设置状态值和阅读次数
        /// </summary>
        /// <param name="messageEntity">实体</param>
        /// <param name="id">短信主键</param>
        /// <returns>影响的条数</returns>
        private int OnRead(CiMessageEntity messageEntity, string id)
        {
            int returnValue = 0;

            // 针对“已发送”的情况
            if (messageEntity.ReceiverId == UserInfo.Id)
            {
                // 针对“删除的信息”的情况
                if (messageEntity.IsNew == (int)MessageStateCode.New)
                {
                    SQLBuilder sqlBuilder = new SQLBuilder(this.DBProvider);
                    sqlBuilder.BeginUpdate(this.CurrentTableName);
                    sqlBuilder.SetValue(CiMessageTable.FieldIsNew, ((int)MessageStateCode.Old).ToString());
                    sqlBuilder.SetDBNow(CiMessageTable.FieldReadDate);
                    sqlBuilder.SetWhere(CiMessageTable.FieldId, id);
                    sqlBuilder.EndUpdate();
                }
            }
            // 增加阅读次数
            messageEntity.ReadCount++;
            this.SetProperty(id, CiMessageTable.FieldReadCount, messageEntity.ReadCount.ToString());

            returnValue++;
            return(returnValue);
        }
        /// <summary>
        /// 发送系统提示消息
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="receiverId">接收者主键</param>
        /// <param name="contents">内容</param>
        /// <returns>主键</returns>
        public string Remind(UserInfo userInfo, string receiverId, string contents)
        {
            string returnValue = string.Empty;
            var    parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, "发送系统提示消息");

            ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider =>
            {
                var entity = new CiMessageEntity
                {
                    Id           = BusinessLogic.NewGuid(),
                    CategoryCode = MessageCategory.Receiver.ToString(),
                    FunctionCode = MessageFunction.Remind.ToString(),
                    ReceiverId   = receiverId,
                    MSGContent   = contents,
                    IsNew        = (int)MessageStateCode.New,
                    ReadCount    = 0,
                    DeleteMark   = 0,
                    Enabled      = 1
                };
                var manager = new CiMessageManager(dbProvider, userInfo);
                returnValue = manager.Add(entity);
            });

            return(returnValue);
        }
Esempio n. 6
0
        /// <summary>
        /// 阅读短信
        /// </summary>
        /// <param name="id">短信ID</param>
        /// <returns>数据权限</returns>
        public DataTable Read(string id)
        {
            // 这里需要改进一下,运行一个高性能的sql语句就可以了,效率会高一些
            DataTable       dataTable     = this.GetDTById(id);
            CiMessageEntity messageEntity = BaseEntity.Create <CiMessageEntity>(dataTable);

            this.OnRead(messageEntity, id);
            dataTable = this.GetDTById(id);
            return(dataTable);
        }
        /// <summary>
        /// 取得实体
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主键</param>
        /// <returns>实体</returns>
        public CiMessageEntity GetEntity(UserInfo userInfo, string id)
        {
            CiMessageEntity entity    = null;
            var             parameter = ParameterUtil.CreateWithOutMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName);

            ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider =>
            {
                entity = new CiMessageManager(dbProvider, userInfo).GetEntity(id);
            });
            return(entity);
        }
Esempio n. 8
0
        /// <summary>
        /// 添加短信,可以发给多个人
        /// </summary>
        /// <param name="messageEntity">实体</param>
        /// <param name="receiverIds">接收者ID组</param>
        /// <returns>影响行数</returns>
        public int Send(CiMessageEntity messageEntity, string[] receiverIds, bool saveSend = true)
        {
            PiUserManager userManager = new PiUserManager(DBProvider, UserInfo);
            // 每发一条短信,数据库中需要记录两条记录,他们的CreateUserId都为创建者ID。
            // 接收者多人的话,不要重复设置创建人的记录了,即对发送者来说,只要记录一条记录就够了
            int returnValue = 0;

            messageEntity.CategoryCode = MessageCategory.Receiver.ToString();
            messageEntity.IsNew        = (int)MessageStateCode.New;
            messageEntity.IPAddress    = UserInfo.IPAddress;
            messageEntity.ParentId     = null;
            messageEntity.DeleteMark   = 0;
            messageEntity.Enabled      = 1;
            returnValue++;

            PiUserEntity userEntity = null;

            for (int i = 0; i < receiverIds.Length; i++)
            {
                messageEntity.ParentId     = null;
                messageEntity.Id           = Guid.NewGuid().ToString();
                messageEntity.CategoryCode = MessageCategory.Receiver.ToString();
                messageEntity.ReceiverId   = receiverIds[i];
                userEntity = userManager.GetEntity(receiverIds[i]);
                if (userEntity != null && userEntity.Id != null)
                {
                    messageEntity.ReceiverRealName = userEntity.RealName;
                }
                messageEntity.Enabled = 1;
                messageEntity.IsNew   = 1;
                if (messageEntity.ReceiverId.Equals(UserInfo.Id))
                {
                    messageEntity.IsNew = (int)MessageStateCode.Old;
                }
                // 接收信息
                string parentId = this.Add(messageEntity, false, false);
                if (saveSend)
                {
                    // 已发送信息
                    messageEntity.Id           = Guid.NewGuid().ToString();
                    messageEntity.ParentId     = parentId;
                    messageEntity.CategoryCode = MessageCategory.Send.ToString();
                    messageEntity.DeleteMark   = 0;
                    messageEntity.Enabled      = 0;
                    this.Add(messageEntity, false, false);
                }
                returnValue++;
            }
            return(returnValue);
        }
        /// <summary>
        /// 更新实体
        /// </summary>
        /// <param name="cIMESSAGEEntity">实体</param>
        public int UpdateEntity(CiMessageEntity cIMESSAGEEntity)
        {
            SQLBuilder sqlBuilder = new SQLBuilder(DBProvider);

            sqlBuilder.BeginUpdate(this.CurrentTableName);
            this.SetEntity(sqlBuilder, cIMESSAGEEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(CiMessageTable.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(CiMessageTable.FieldModifiedOn);
            sqlBuilder.SetWhere(CiMessageTable.FieldId, cIMESSAGEEntity.Id);
            return(sqlBuilder.EndUpdate());
        }
Esempio n. 10
0
 public int BatchSend(string[] receiverIds, string organizeId, string roleId, CiMessageEntity messageEntity, bool saveSend = true)
 {
     string[] organizeIds = null;
     string[] roleIds     = null;
     if (!string.IsNullOrEmpty(organizeId))
     {
         organizeIds = new string[] { organizeId };
     }
     if (!string.IsNullOrEmpty(roleId))
     {
         roleIds = new string[] { roleId };
     }
     return(BatchSend(receiverIds, organizeIds, roleIds, messageEntity, saveSend));
 }
Esempio n. 11
0
        /// <summary>
        /// 按部门群发短信
        /// </summary>
        /// <param name="messageEntity">实体</param>
        /// <param name="organizeId">部门主键</param>
        /// <returns>影响行数</returns>
        public int Send(CiMessageEntity messageEntity, string organizeId, bool saveSend = true)
        {
            int           returnValue = 0;
            int           i           = 0;
            PiUserManager userManager = new PiUserManager(DBProvider, UserInfo);
            DataTable     dataTable   = userManager.GetChildrenUsers(organizeId);

            string[] receiverIds = new string[dataTable.Rows.Count];
            foreach (DataRow dataRow in dataTable.Rows)
            {
                receiverIds[i++] = dataRow[CiMessageTable.FieldId].ToString();
            }
            returnValue = this.Send(messageEntity, receiverIds, saveSend);
            return(returnValue);
        }
Esempio n. 12
0
        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="dbProvider">数据库连接</param>
        /// <param name="userInfo">用户信息</param>
        /// <param name="userEntity">用户实体</param>
        /// <param name="statusCode">状态码</param>
        /// <param name="statusMessage">状态信息</param>
        /// <returns>主键</returns>
        public string AddUser(IDbProvider dbProvider, UserInfo userInfo, PiUserEntity userEntity, out string statusCode, out string statusMessage)
        {
            string returnValue = string.Empty;
            var    userManager = new PiUserManager(dbProvider, userInfo);

            returnValue   = userManager.Add(userEntity, out statusCode);
            statusMessage = userManager.GetStateMessage(statusCode);

            LogManager.Instance.Add(dbProvider, userInfo, this.serviceName, RDIFrameworkMessage.UserService_AddUser, MethodBase.GetCurrentMethod());

            // 自己不用给自己发提示信息,这个提示信息是为了提高工作效率的,还是需要审核通过的,否则垃圾信息太多了
            if (userEntity.Enabled == 0 && statusCode.Equals(StatusCode.OKAdd.ToString()))
            {
                // 不是系统管理员添加
                if (!userInfo.IsAdministrator)
                {
                    // 给超级管理员群组发信息
                    var      roleManager = new PiRoleManager(dbProvider, userInfo);
                    string[] roleIds     = roleManager.GetIds(PiRoleTable.FieldCode, "Administrators", PiRoleTable.FieldId);
                    string[] userIds     = userManager.GetIds(PiUserTable.FieldCode, "Administrator", PiUserTable.FieldId);
                    // 发送请求审核的信息
                    var messageEntity = new CiMessageEntity
                    {
                        Id           = BusinessLogic.NewGuid(),
                        FunctionCode = MessageFunction.WaitForAudit.ToString(),
                        ReceiverId   = DefaultRole.Administrator.ToString(),
                        MSGContent   = userInfo.RealName + "(" + userInfo.IPAddress + ")" + RDIFrameworkMessage.UserService_Application + userEntity.RealName + RDIFrameworkMessage.UserService_Check,
                        IsNew        = 1,
                        ReadCount    = 0,
                        Enabled      = 1,
                        DeleteMark   = 0
                    };

                    var messageManager = new CiMessageManager(dbProvider, userInfo);
                    messageManager.BatchSend(userIds, null, roleIds, messageEntity, false);
                }
            }
            return(returnValue);
        }
Esempio n. 13
0
        /// <summary>
        /// 检查信息状态
        /// </summary>
        /// <returns>信息状态数组</returns>
        public string[] MessageChek()
        {
            string[] returnValue = new string[6];
            // 0.新信息的个数
            int messageCount = this.GetNewCount();

            returnValue[0] = messageCount.ToString();
            if (messageCount > 0)
            {
                CiMessageEntity messageEntity = this.GetNewOne();
                DateTime        lastChekDate  = DateTime.MinValue;
                if (messageEntity.CreateOn != null)
                {
                    // 1.最后检查时间
                    lastChekDate   = Convert.ToDateTime(messageEntity.CreateOn);
                    returnValue[1] = lastChekDate.ToString(SystemInfo.DateTimeFormat);
                }
                returnValue[2] = messageEntity.CreateUserId; // 2.最新消息的发出者
                returnValue[3] = messageEntity.CreateBy;     // 3.最新消息的发出者名称
                returnValue[4] = messageEntity.Id;           // 4.最新消息的主键
                returnValue[5] = messageEntity.MSGContent;   // 5.最新信息的内容
            }
            return(returnValue);
        }
Esempio n. 14
0
        /// <summary>
        /// 批量发送消息
        /// </summary>
        /// <param name="receiverIds">接收者主键组</param>
        /// <param name="organizeIds">组织机构主键组</param>
        /// <param name="roleIds">角色主键组</param>
        /// <param name="messageEntity">实体</param>
        /// <returns>影响行数</returns>
        public int BatchSend(string[] receiverIds, string[] organizeIds, string[] roleIds, CiMessageEntity messageEntity, bool saveSend = true)
        {
            PiUserManager userManager = new PiUserManager(DBProvider, UserInfo);

            receiverIds = userManager.GetUserIds(receiverIds, organizeIds, roleIds);
            return(this.Send(messageEntity, receiverIds, saveSend));
        }
Esempio n. 15
0
 /// <summary>
 /// 添加一条短信,只能发给一个人,在数据库中加入两条记录
 /// </summary>
 /// <param name="messageEntity">添加对象</param>
 /// <returns>影响行数</returns>
 public int Send(CiMessageEntity messageEntity, bool saveSend = true)
 {
     string[] receiverIds = new string[1];
     receiverIds[0] = messageEntity.ReceiverId.ToString();
     return(this.Send(messageEntity, receiverIds, saveSend));
 }
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="cIMESSAGEEntity">实体</param>
        public string AddEntity(CiMessageEntity cIMESSAGEEntity)
        {
            string sequence = string.Empty;

            this.Identity = false;
            if (cIMESSAGEEntity.SortCode == null || cIMESSAGEEntity.SortCode == 0)
            {
                CiSequenceManager sequenceManager = new CiSequenceManager(DBProvider, this.Identity);
                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                cIMESSAGEEntity.SortCode = int.Parse(sequence);
            }

            SQLBuilder sqlBuilder = new SQLBuilder(DBProvider, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(this.CurrentTableName, CiMessageTable.FieldId);
            if (!this.Identity)
            {
                if (string.IsNullOrEmpty(cIMESSAGEEntity.Id))
                {
                    sequence           = BusinessLogic.NewGuid();
                    cIMESSAGEEntity.Id = sequence;
                }
                sqlBuilder.SetValue(CiMessageTable.FieldId, cIMESSAGEEntity.Id);
            }
            else
            {
                if (!this.ReturnId && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                {
                    if (DBProvider.CurrentDbType == CurrentDbType.Oracle)
                    {
                        sqlBuilder.SetFormula(CiMessageTable.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                    }
                    if (DBProvider.CurrentDbType == CurrentDbType.DB2)
                    {
                        sqlBuilder.SetFormula(CiMessageTable.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                    }
                }
                else
                {
                    if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                    {
                        if (string.IsNullOrEmpty(cIMESSAGEEntity.Id))
                        {
                            if (string.IsNullOrEmpty(sequence))
                            {
                                CiSequenceManager sequenceManager = new CiSequenceManager(DBProvider, this.Identity);
                                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                            }
                            cIMESSAGEEntity.Id = sequence;
                        }
                        sqlBuilder.SetValue(CiMessageTable.FieldId, cIMESSAGEEntity.Id);
                    }
                }
            }
            this.SetEntity(sqlBuilder, cIMESSAGEEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(CiMessageTable.FieldCreateUserId, UserInfo.Id);
                sqlBuilder.SetValue(CiMessageTable.FieldCreateBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(CiMessageTable.FieldCreateOn);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(CiMessageTable.FieldModifiedUserId, UserInfo.Id);
                sqlBuilder.SetValue(CiMessageTable.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(CiMessageTable.FieldModifiedOn);
            if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.SqlServer || DBProvider.CurrentDbType == CurrentDbType.Access))
            {
                sequence = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            return(sequence);
        }
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="cIMESSAGEEntity">实体</param>
 public int Update(CiMessageEntity cIMESSAGEEntity)
 {
     return(this.UpdateEntity(cIMESSAGEEntity));
 }
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="cIMESSAGEEntity">实体</param>
 /// <param name="identity">自增量方式</param>
 /// <param name="returnId">返回主键</param>
 /// <returns>主键</returns>
 public string Add(CiMessageEntity cIMESSAGEEntity, bool identity, bool returnId)
 {
     this.Identity = identity;
     this.ReturnId = returnId;
     return(this.AddEntity(cIMESSAGEEntity));
 }
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="cIMESSAGEEntity">实体</param>
 /// <returns>主键</returns>
 public string Add(CiMessageEntity cIMESSAGEEntity)
 {
     return(this.AddEntity(cIMESSAGEEntity));
 }
Esempio n. 20
0
        /// <summary>
        /// 指定处理人
        /// </summary>
        /// <param name="userId">用户Id</param>
        /// <param name="workFlowId">流程模板Id</param>
        /// <param name="workTaskId">任务模板Id</param>
        /// <param name="workFlowInstanceId">流程实例Id</param>
        /// <param name="workTaskInstanceId">任务实例Id</param>
        /// <param name="operParam">处理者参数</param>
        /// <returns>是否成功</returns>
        public bool AssignUser(string userId, string workFlowId, string workTaskId, string workFlowInstanceId, string workTaskInstanceId, OperParameter operParam)
        {
            if (string.IsNullOrEmpty(operParam.OperContent))
            {
                return(false);
            }

            switch (operParam.OperRule)
            {
            case "1":
            {
                //创建处理人实例
                var operInsEntity = new OperatorInstanceEntity()
                {
                    OperatorInsId   = BusinessLogic.NewGuid(),
                    WorkFlowId      = workFlowId,
                    WorkTaskId      = workTaskId,
                    WorkFlowInsId   = workFlowInstanceId,
                    WorkTaskInsId   = workTaskInstanceId,  //此时是新任务Id
                    UserId          = "",
                    OperRealtion    = operParam.OperRelation,
                    OperContent     = operParam.OperContent,
                    OperContentText = operParam.OperContenText,
                    OperType        = operParam.OperType//此处保留原来的处理类型
                };
                string successCode = new OperatorInstanceManager(this.DBProvider).Create(operInsEntity);

                //给处理者发送信息
                if (!string.IsNullOrEmpty(successCode) && successCode.Length > 0)
                {
                    var messageEntity = new CiMessageEntity
                    {
                        Id           = BusinessLogic.NewGuid(),
                        FunctionCode = MessageFunction.Remind.ToString(),
                        ReceiverId   = DefaultRole.Administrator.ToString(),
                        Title        = "业务流程消息",
                        MSGContent   = "你有一待办任务,请到未认领任务界面认领。",
                        IsNew        = 1,
                        ReadCount    = 0,
                        Enabled      = 1,
                        DeleteMark   = 0
                    };

                    var messageManager = new CiMessageManager(DbFactoryProvider.GetProvider(SystemInfo.RDIFrameworkDbType, SystemInfo.RDIFrameworkDbConectionString), this.UserInfo);
                    messageManager.BatchSend(operInsEntity.OperContent, null, null, messageEntity, false);
                }

                if ((userId == operParam.OperContent) && (operParam.IsJumpSelf))    //处理者是提交人,自动处理
                {
                    var wfrun = new WorkFlowRuntime();
                    wfrun.Run(userId, operInsEntity.OperatorInsId, "提交");
                }
            }
            break;

            case "2":
            {
                //创建任务实例
                var newTaskId         = BusinessLogic.NewGuid();//新任务实例Id
                var workTaskInsEntity = new WorkTaskInstanceEntity()
                {
                    WorkFlowId     = workFlowId,
                    WorkTaskId     = workTaskId,
                    WorkFlowInsId  = workFlowInstanceId,
                    WorkTaskInsId  = newTaskId,
                    PreviousTaskId = workTaskInstanceId,    //此时是当前任务Id
                    TaskInsCaption = new WorkTaskManager(this.DBProvider).GetTaskCaption(workTaskId),
                    Status         = "1",
                };
                new WorkTaskInstanceManager(this.DBProvider).Create(workTaskInsEntity);

                //创建处理人实例
                var operInsEntity = new OperatorInstanceEntity()
                {
                    OperatorInsId   = BusinessLogic.NewGuid(),
                    WorkFlowId      = workFlowId,
                    WorkTaskId      = workTaskId,
                    WorkFlowInsId   = workFlowInstanceId,
                    WorkTaskInsId   = newTaskId,
                    UserId          = "",
                    OperRealtion    = operParam.OperRelation,
                    OperContent     = operParam.OperContent,
                    OperContentText = operParam.OperContenText,
                    OperType        = 3,//此处修改为指定处理人
                };
                string successCode = new OperatorInstanceManager(this.DBProvider).Create(operInsEntity);

                //给处理者发送信息
                if (!string.IsNullOrEmpty(successCode) && successCode.Length > 0)
                {
                    var messageEntity = new CiMessageEntity
                    {
                        Id           = BusinessLogic.NewGuid(),
                        FunctionCode = MessageFunction.Remind.ToString(),
                        ReceiverId   = DefaultRole.Administrator.ToString(),
                        Title        = "业务流程消息",
                        MSGContent   = "你有一待办任务,请到未认领任务界面认领。",
                        IsNew        = 1,
                        ReadCount    = 0,
                        Enabled      = 1,
                        DeleteMark   = 0
                    };

                    var messageManager = new CiMessageManager(DbFactoryProvider.GetProvider(SystemInfo.RDIFrameworkDbType, SystemInfo.RDIFrameworkDbConectionString), this.UserInfo);
                    messageManager.BatchSend(operInsEntity.OperContent, null, null, messageEntity, false);
                }
                if ((userId == operParam.OperContent) && (operParam.IsJumpSelf))    //处理者是提交人,自动处理
                {
                    var wfrun = new WorkFlowRuntime();
                    wfrun.Run(userId, operInsEntity.OperatorInsId, "提交");
                }
            }
            break;
            }
            return(true);
        }
Esempio n. 21
0
        /// <summary>
        /// 批量发送站内信息
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="receiverIds">接受者主键数组</param>
        /// <param name="organizeIds">组织机构主键数组</param>
        /// <param name="roleIds">角色主键数组</param>
        /// <param name="messageEntity">消息内容</param>
        /// <returns>影响行数</returns>
        public int BatchSend(UserInfo userInfo, string[] receiverIds, string[] organizeIds, string[] roleIds, CiMessageEntity messageEntity)
        {
            int returnValue = 0;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.MessageService_BatchSend);

            ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider =>
            {
                var messageManager = new CiMessageManager(dbProvider, userInfo);
                returnValue        = messageManager.BatchSend(receiverIds, organizeIds, roleIds, messageEntity, true);
            });
            return(returnValue);
        }