Esempio n. 1
0
 public MsgView(Message msg)
 {
     MsgId = msg.MsgId;
      FromUserName = msg.FromUser.UserName;
      MessageText = msg.MessageText;
      CreatedOn = msg.CreatedOn.Value;
      IsRead = msg.IsRead;
      RelatedProject = (msg.Project == null)? msg.CustomerProject.CustomerName +"[" + msg.CustomerProject.CustomerNo+"]" :
          msg.Project.ProjectName +"["+ msg.Project.Account + "]";
 }
 public void SendToNextStep(int prjid, int todoby, int desnodeid, string msg, int userid)
 {
     var tosend = _rep.Single<CustomerProject>(x => x.ID == prjid);
     if (tosend == null) return;
     // 将当前节点置于完成状态
     foreach (var log in tosend.FlowLogs.Where(x => x.IsActive))
     {
         log.EndDate = DateTime.Now;
         log.TodoBy = userid;
         log.IsActive = false;
     }
     //设置新节点记录
     var node = _rep.Single<TaskNode>(x => x.TaskId == desnodeid);
     if (node.BuildIn != "2") // 如果不是结束节点
     {
         var newLog = new FlowLog
         {
             CustProjectId = tosend.ID,
             StartDate = DateTime.Now,
             //TodoBy = todoby,
             TaskNode = node,
             IsActive = true
         };
         _rep.Add(newLog);
     }
     else{
         tosend.IsFinished = true;
     }
     // Add msg
     if (!string.IsNullOrWhiteSpace(msg))
     {
         //添加短消息
         var newmsg = new Message
         {
             CreatedOn = DateTime.Now,
           //  ToUserId = node.,// hardcode convention over config  0 ====UserGroup of '用电检查'
             ToUserGroupId =  node.ProcessGroup,
             FromUserId = userid,
             MessageText = msg,
             CustProjectId = prjid,
             IsRead = false
         };
         _rep.Add(newmsg);
     }
     _rep.Save();
 }
        public void SendToNextStep(int prjid, int todoby, int desnodeid, string msg,int userid)
        {
            var tosend = _rep.Single<Project>(x => x.ProjectId == prjid);
            if (tosend == null) return;
            // 将当前节点置于完成状态
            //todo: 需要重新改写,如果是并发流程,需要确定只提交当前节点而不影响其他节点
            foreach (var log in tosend.FlowLogs.Where(x => x.IsActive))
            {
                log.EndDate = DateTime.Now;
                log.IsActive = false;
            }
            //设置新节点记录
            //todo: 应该可以根据并发选择的流程,同时发送到多个目标节点
            var node = _rep.Single<TaskNode>(x => x.TaskId == desnodeid);
            if (node.BuildIn != "2")   // 如果不是结束节点
            {
                var newLog = new FlowLog
                {
                    ProjectId = tosend.ProjectId,
                    StartDate = DateTime.Now,
                    TodoBy = todoby,
                    TaskId = desnodeid,
                    IsActive = true
                };
                _rep.Add(newLog);
            }
            else{tosend.IsFinished = true;}  // 如果是结束归档节点则将该工程置为结束

            if (!string.IsNullOrWhiteSpace(msg))
            {
                //添加短消息
                var newmsg = new Message
                {
                    CreatedOn = DateTime.Now,
                    ToUserId = todoby,
                    FromUserId = userid,
                    MessageText = msg,
                    ProjectId = prjid,
                    IsRead = false
                };
                _rep.Add(newmsg);
            }
            _rep.Save();
        }