Ejemplo n.º 1
0
        public OAMQMessages BuildMessage(TodoWork todo)
        {
            OAMQMessages message = new OAMQMessages();

            message.Sender     = SystemNameByOA;
            message.Sendertime = WebHelper.DateTimeNow;
            if (todo.ProcessCode == string.Empty)
            {
                message.Flowtype = string.Empty;
            }
            else
            {
                message.Flowtype = WorkflowEngine.WorkflowService.ProcessNameList[todo.ProcessID];
            }
            message.FlowID            = todo.ProcessInstanceID.ToString();
            message.Title             = todo.InstanceName;
            message.Nodename          = todo.NodeName + ObjectHelper.EnumDescription((CommonConsts.NodeType)todo.NodeType);
            message.PtpUrl            = string.Format(FormUrl, todo.BizProcessID);
            message.Userid            = TodoWorkAdapter.Instance.GetLoginNameByUid(todo.UserID);
            message.CreatorName       = TodoWorkAdapter.Instance.GetLoginNameByUid(todo.CreateProcessUserID);
            message.CreateTime        = todo.CreateProcessTime;
            message.ModifierName      = TodoWorkAdapter.Instance.GetLoginNameByUid(todo.CreateProcessUserID);
            message.ModifyTime        = WebHelper.DateTimeNow;
            message.Operatetime       = todo.CreatedTime;
            message.Flowmess          = 1; //待办
            message.Viewtype          = 0; //未读
            message.Status            = 0;
            message.ErrorCount        = 0;
            message.MessageCreateTime = WebHelper.DateTimeNow;
            message.TodoType          = todo.TodoType;
            message.TodoID            = todo.ID;
            message.BizID             = todo.BizProcessID;
            return(message);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 关闭通知类待办
        /// </summary>
        /// <param name="bizProcessID"></param>
        /// <param name="userID"></param>
        /// <param name="todoWorkID"></param>
        /// <param name="projectID"></param>
        public void CloseNotificationTodo(int bizProcessID, int userID, int todoWorkID, int projectID)
        {
            TodoWork todo = TodoWorkAdapter.Instance.Load(todoWorkID);

            if (todo == null)
            {
                throw new Exception("没有找到指定的待办。");
            }
            else if (todo.BizProcessID != bizProcessID || todo.ProjectID != projectID || todo.UserID != userID)
            {
                throw new Exception("用户无权限或该待办不存在。");
            }
            else if (todo.TodoType != (int)CommonConsts.TodoType.Notification)
            {
                throw new Exception("无法处理未知的待办类型。");
            }
            else
            {
                try
                {
                    OAMQMessages msg = OAService.OAServiceInstance.BuildMessage(todo);
                    using (TransactionScope trans = TransactionScopeFactory.Create())
                    {
                        //删除通知待办,暂不生成已办日志
                        TodoWorkAdapter.Instance.Delete(todo.ID);
                        OAService.OAServiceInstance.CloseOATodo(msg);
                        trans.Complete();
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 关闭工作流待办
 /// </summary>
 /// <param name="todo"></param>
 public void CloseWorkflowTodo(TodoWork todo)
 {
     try
     {
         OAMQMessages msg = OAService.OAServiceInstance.BuildMessage(todo);
         using (TransactionScope trans = TransactionScopeFactory.Create())
         {
             //删除通知待办
             TodoWorkAdapter.Instance.Delete(todo.ID);
             bool sendMessage     = true;
             bool needDoneMessage = true;
             if (OAMessageExceptionList.ContainsKey(todo.ProcessCode.ToLower().Trim()))
             {
                 needDoneMessage = false;
                 if (OAMessageExceptionList[todo.ProcessCode.ToLower().Trim()].ToString() == todo.NodeType.ToString())
                 {
                     sendMessage = false;;
                 }
             }
             if (sendMessage)
             {
                 OAService.OAServiceInstance.CloseOATodo(msg, needDoneMessage);
             }
             trans.Complete();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 创建OA待办
        /// </summary>
        /// <param name="todo"></param>
        public void CreateOATodo(OAMQMessages message)
        {
            if (NeedSendOAMessage == true)
            {
                message.Sendertime = message.Sendertime.AddSeconds(1);
                if (message.TodoType == (int)CommonConsts.TodoType.Notification)
                {
                    message.PtpUrl = string.Format(AlarmUrl, message.TodoID);
                }

                message.ID = OAMQMessagesAdapter.Instance.Insert(message);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 创建通知类的待办
        /// </summary>
        /// <param name="bizProcessID">业务相关ID</param>
        /// <param name="todoTitle">待办标题</param>
        /// <param name="receiveUserID">接收用户ID</param>
        /// <param name="receiveUserName">接收用户姓名</param>
        /// <param name="receiveUserCode">接收用户代码</param>
        /// <param name="receivecUserID">接收用户cUserID</param>
        /// <param name="createUserID">创建者ID</param>
        /// <param name="createUserName">创建者姓名</param>
        /// <param name="createUserCode">创建者代码</param>
        /// <param name="createcUserID">创建者cUserID</param>
        public void CreateNotificationTodo(int bizProcessID, string todoTitle,
                                           int receiveUserID, string receiveUserName, string receiveUserCode, int receivecUserID,
                                           int createUserID, string createUserName, string createUserCode, int createcUserID, int projectID)
        {
            TodoWork todo = new TodoWork();

            todo.NodeType     = 0;
            todo.BizProcessID = bizProcessID;
            todo.InstanceName = todoTitle;
            //todo.NodeInstanceID = 0;
            todo.NodeInstanceID = 0;
            todo.NodeName       = "";
            //todo.ProcessID = 0;
            //todo.ProcessInstanceID = 0;
            //todo.PreviousNodeInstanceID = 0;
            todo.ProcessID              = 0;
            todo.ProcessInstanceID      = 0;
            todo.PreviousNodeInstanceID = 0;
            todo.ProcessCode            = "";
            todo.Status   = (int)CommonConsts.TodoStatus.Unread;
            todo.TodoType = (int)CommonConsts.TodoType.Notification;
            todo.cUserID  = receivecUserID;
            todo.UserCode = receiveUserCode;
            todo.UserID   = receiveUserID;
            todo.UserName = receiveUserName;

            todo.CreatedTime = WebHelper.DateTimeNow;
            todo.ModifyTime  = WebHelper.DateTimeNow;

            todo.CreateProcessTime = WebHelper.DateTimeNow;

            todo.CreateProcessUserName = createUserName;
            todo.ProjectID             = projectID;
            try
            {
                OAMQMessages msg = OAService.OAServiceInstance.BuildMessage(todo);
                using (TransactionScope trans = new TransactionScope())
                {
                    TodoWorkAdapter.Instance.Insert(todo);
                    OAService.OAServiceInstance.CreateOATodo(msg);
                    trans.Complete();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 删除OA已办
 /// </summary>
 /// <param name="todo"></param>
 public void RemoveOADone(OAMQMessages message)
 {
     if (NeedSendOAMessage == true)
     {
         message.Flowmess = 9;//删除已办,oa系统中将看不到
         if (message.FlowID.IndexOf("_") <= 0)
         {
             message.FlowID = message.FlowID + "_" + message.BizID.ToString();
         }
         if (message.TodoType == (int)CommonConsts.TodoType.Notification)
         {
             message.PtpUrl = string.Format(AlarmUrl, message.TodoID);
         }
         OAMQMessagesAdapter.Instance.Insert(message);
     }
 }
Ejemplo n.º 7
0
        /// <summary>
        /// 标记OA中的待办为已读
        /// </summary>
        /// <param name="todo"></param>
        public void UpdateOATodoReaded(TodoWork todo)
        {
            if (NeedSendOAMessage == true)
            {
                OAMQMessages message = OAMQMessagesAdapter.Instance.LoadByProcessInstanceID(todo.ProcessInstanceID);

                if (message == null)
                {
                    message = BuildMessage(todo);
                    //message.ID = Guid.NewGuid().ToString();
                    message.Sendertime        = WebHelper.DateTimeNow;
                    message.Viewtype          = -2; //已读
                    message.Status            = 0;
                    message.ErrorCount        = 0;
                    message.MessageCreateTime = WebHelper.DateTimeNow;
                    OAMQMessagesAdapter.Instance.Insert(message);
                }
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// 删除OA待办,创建已办
 /// </summary>
 /// <param name="todo"></param>
 public void CloseOATodo(OAMQMessages message, bool needDoneMessage = true)
 {
     if (NeedSendOAMessage == true)
     {
         message.Flowmess = 9;//删除待办,oa系统中将看不到
         if (message.TodoType == (int)CommonConsts.TodoType.Notification)
         {
             message.PtpUrl = string.Format(AlarmUrl, message.TodoID);
         }
         OAMQMessagesAdapter.Instance.Insert(message);
         //如果是流程类型的待办,需要在OA中创建一个已办,并且需要已办历史
         if (message.TodoType == (int)CommonConsts.TodoType.TODO && needDoneMessage)
         {
             OAMQMessages doneMmessage = message;
             //doneMmessage.ID = Guid.NewGuid().ToString();
             doneMmessage.FlowID   = message.FlowID + "_" + message.BizID.ToString();
             doneMmessage.Flowmess = 2;   //已办
             OAMQMessagesAdapter.Instance.Insert(doneMmessage);
         }
     }
 }
Ejemplo n.º 9
0
 public void UpdateOAMQMessage(OAMQMessages message)
 {
     OAMQMessagesAdapter.Instance.Update(message);
 }