Esempio n. 1
0
 public IHttpActionResult EditMultipleProjects(PostEditProjects postEditProjects)
 {
     if (postEditProjects.EditProjects.Count > 0)
     {
         using (TransactionScope tranScope = new TransactionScope())
         {
             var projectId          = postEditProjects.ProjectId;
             var parentCode         = postEditProjects.EditProjects[0].ParentCode;
             var projects           = ProjectInfo.Search(pi => pi.ProjectId == projectId).ToList();
             var usCode             = projects[0].USCode;
             var store              = StoreBasicInfo.GetStorInfo(usCode);
             var minExecuteSequence = postEditProjects.EditProjects.Min(p => p.ExecuteSequence);
             var maxExecuteSequance = postEditProjects.EditProjects.Max(p => p.ExecuteSequence);
             foreach (TopNavigator nav in postEditProjects.EditProjects)
             {
                 var workflow = BaseWFEntity.GetWorkflowEntity(postEditProjects.ProjectId, nav.Code);
                 workflow.Edit();
             }
             string[] cancelWorkflowCodes = FlowInfo.Search(f => f.ParentCode == parentCode && f.ExecuteSequence <= maxExecuteSequance + 1).Select(f => f.Code).ToArray();
             TaskWork.Cancel(t => cancelWorkflowCodes.Contains(t.TypeCode) && t.RefID == postEditProjects.ProjectId && t.Status != TaskWorkStatus.Finished);
             postEditProjects.EditProjects.Where(n => n.ExecuteSequence == minExecuteSequence).ToList().ForEach(n =>
             {
                 var project            = projects.FirstOrDefault(pi => pi.FlowCode == n.Code);
                 var originator         = Employee.GetSimpleEmployeeByCode(project.CreateUserAccount);
                 var source             = FlowInfo.Get(n.ParentCode);
                 var taskType           = FlowInfo.Get(n.Code);
                 TaskWork task          = new TaskWork();
                 task.Id                = Guid.NewGuid();
                 task.SourceCode        = source.Code;
                 task.SourceNameENUS    = source.NameENUS;
                 task.SourceNameZHCN    = source.NameZHCN;
                 task.Status            = TaskWorkStatus.UnFinish;
                 task.StatusNameZHCN    = "任务";
                 task.StatusNameENUS    = "任务";
                 task.Title             = TaskWork.BuildTitle(postEditProjects.ProjectId, store.NameZHCN, store.NameENUS);
                 task.RefID             = postEditProjects.ProjectId;
                 task.StoreCode         = usCode;
                 task.ReceiverAccount   = originator.Code;
                 task.ReceiverNameENUS  = originator.NameENUS;
                 task.ReceiverNameZHCN  = originator.NameZHCN;
                 task.TypeCode          = taskType.Code;
                 task.TypeNameENUS      = taskType.NameENUS;
                 task.TypeNameZHCN      = taskType.NameZHCN;
                 task.Url               = TaskWork.BuildUrl(n.Code, projectId, "");
                 task.CreateTime        = DateTime.Now;
                 task.CreateUserAccount = ClientCookie.UserCode;
                 task.Sequence          = 0;
                 task.ActivityName      = "Start";
                 task.Add();
             });
             tranScope.Complete();
         }
         return(Ok());
     }
     else
     {
         return(BadRequest("you must select projects to be edited!"));
     }
 }
Esempio n. 2
0
        public bool Add(MaterTrack materTrack)
        {
            using (TransactionScope tranScope = new TransactionScope())
            {
                materTrack.Id         = Guid.NewGuid();
                materTrack.CreateTime = DateTime.Now;
                MaterTrack.Add(materTrack);
                var project = ProjectInfo.Get(materTrack.WorkflowId, materTrack.WorkflowType);
                var store   = StoreBasicInfo.FirstOrDefault(s => s.StoreCode == project.USCode);
                var Codes   = materTrack.NodeType.Split('_');
                var url     = string.Format("/{0}/Main#/{1}/Process/View?projectId={2}", Codes[0], Codes[1], materTrack.WorkflowId);
                //if (Codes[0] == "Closure") //临时改动 只针对Closure,因为Closure 用的还是老的URL
                //{
                //    url = string.Format("/{0}/Main#/{0}/{1}/Process/View?projectId={2}", Codes[0], Codes[1], materTrack.WorkflowId);
                //}
                var title = TaskWork.BuildTitle(materTrack.WorkflowId, store.NameZHCN, store.NameENUS);
                switch (materTrack.TrackType)
                {
                case MaterTrackType.Rep:
                {
                    var actor = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == materTrack.WorkflowId && pu.RoleCode == ProjectUserRoleCode.AssetActor);
                    TaskWork.SendTask(materTrack.WorkflowId, title, project.USCode, url, actor, materTrack.WorkflowType, materTrack.NodeType, "Start_MaterTrack_Rep");
                }
                break;

                case MaterTrackType.Feedback:
                {
                    var legal = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == materTrack.WorkflowId && pu.RoleCode == ProjectUserRoleCode.Legal);
                    TaskWork.Finish(t => t.RefID == materTrack.WorkflowId && t.SourceCode == materTrack.WorkflowType && t.TypeCode == materTrack.NodeType && t.ActivityName == "Start_MaterTrack_Rep" && t.Status == TaskWorkStatus.UnFinish);
                    if (TaskWork.Count(t => t.RefID == materTrack.WorkflowId && t.SourceCode == materTrack.WorkflowType && t.TypeCode == materTrack.NodeType && t.ActivityName == "Start_MaterTrack_Feedback" && t.Status == TaskWorkStatus.UnFinish) == 0)
                    {
                        TaskWork.SendTask(materTrack.WorkflowId, title, project.USCode, url, legal, materTrack.WorkflowType, materTrack.NodeType, "Start_MaterTrack_Feedback");
                    }
                }
                break;

                case MaterTrackType.Reply:
                {
                    var actor = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == materTrack.WorkflowId && pu.RoleCode == ProjectUserRoleCode.AssetActor);
                    TaskWork.Finish(t => t.RefID == materTrack.WorkflowId && t.SourceCode == materTrack.WorkflowType && t.TypeCode == materTrack.NodeType && t.ActivityName == "Start_MaterTrack_Feedback" && t.Status == TaskWorkStatus.UnFinish);
                    if (TaskWork.Count(t => t.RefID == materTrack.WorkflowId && t.SourceCode == materTrack.WorkflowType && t.TypeCode == materTrack.NodeType && t.ActivityName == "Start_MaterTrack_Rep" && t.Status == TaskWorkStatus.UnFinish) == 0)
                    {
                        TaskWork.SendTask(materTrack.WorkflowId, title, project.USCode, url, actor, materTrack.WorkflowType, materTrack.NodeType, "Start_MaterTrack_Rep");
                    }
                }
                break;
                }
                tranScope.Complete();
                return(true);
            }
        }
Esempio n. 3
0
        private void SendWorkTaskAndEmail(ClosureInfo entity)
        {
            var newGuid = new Guid();

            var taskWorkController = new TaskWorkController();
            //任务通用部分
            var taskWork = new TaskWork();

            taskWork.SourceCode     = FlowCode.Closure;
            taskWork.SourceNameZHCN = "关店流程";
            taskWork.SourceNameENUS = taskWork.SourceCode;
            taskWork.Status         = 0;
            taskWork.StatusNameZHCN = "任务";
            taskWork.StatusNameENUS = "任务";
            var title = TaskWork.BuildTitle(entity.ProjectId, entity.StoreNameZHCN, entity.StoreNameENUS);

            taskWork.Title      = title; //string.Format("{0} {1}", entity.StoreNameCN, entity.StoreNameEN);
            taskWork.RefID      = entity.ProjectId.ToString();
            taskWork.StoreCode  = entity.USCode;
            taskWork.ActionName = NodeCode.Start;


            var objectCopy     = new ObjectCopy();
            var taskWorkEntity = objectCopy.AutoCopy(taskWork);


            //创建WOChecklist任务
            taskWorkEntity.TypeCode         = FlowCode.Closure_WOCheckList;
            taskWorkEntity.TypeNameENUS     = "WOChecklist";
            taskWorkEntity.TypeNameZHCN     = "WOChecklist";
            taskWorkEntity.ReceiverAccount  = entity.PMAccount;
            taskWorkEntity.ReceiverNameENUS = entity.PMNameENUS;
            taskWorkEntity.ReceiverNameZHCN = entity.PMNameZHCN;
            taskWorkEntity.Id = newGuid;
            //taskWorkEntity.Url = SiteInfo.WebUrl + "/closure/Main#/closure/WOCheckList/" + entity.ProjectId;
            taskWorkEntity.Url          = SiteInfo.GetProjectHandlerPageUrl(FlowCode.Closure_WOCheckList, entity.ProjectId);
            taskWorkEntity.ActivityName = "Start";
            taskWorkController.Create(taskWorkEntity);

            var closureHandler = new ClosureHandler();

            var noticerList = new List <string>();

            if (entity.NoticeUserList != null && entity.NoticeUserList.Count > 0)
            {
                noticerList = entity.NoticeUserList.Select(e => e.Account).ToList();
            }
            //noticerList.Add(entity.PMAccount);
            //closureHandler.SendEmail(newGuid, noticerList.ToArray(), "WOChecklist", entity.ProjectId, ClosureWOCheckList.TableName, entity.PMNameENUS);
            //noticerList.Remove(entity.PMAccount);


            taskWorkEntity = objectCopy.AutoCopy(taskWork);

            //创建Closure Tool任务
            taskWorkEntity.TypeCode         = FlowCode.Closure_ClosureTool;
            taskWorkEntity.TypeNameENUS     = "Closure Tool(Fin)";
            taskWorkEntity.TypeNameZHCN     = "Closure Tool(Fin)";
            taskWorkEntity.ReceiverAccount  = entity.FinanceAccount;
            taskWorkEntity.ReceiverNameZHCN = entity.FinanceNameZHCN;
            taskWorkEntity.ReceiverNameENUS = entity.FinanceNameENUS;
            taskWorkEntity.Id           = newGuid;
            taskWorkEntity.Url          = SiteInfo.GetProjectHandlerPageUrl(FlowCode.Closure_ClosureTool, entity.ProjectId);
            taskWorkEntity.ActivityName = "Start";
            taskWorkController.Create(taskWorkEntity);

            //noticerList.Add(entity.FinanceAccount);
            //closureHandler.SendEmail(newGuid, noticerList.ToArray(), "Closure Tool", entity.ProjectId, ClosureTool.TableName, entity.PMNameENUS);
            //noticerList.Remove(entity.FinanceAccount);


            taskWorkEntity = objectCopy.AutoCopy(taskWork);
            //创建LegalReview(Rep)任务
            taskWorkEntity.TypeCode         = FlowCode.Closure_LegalReview;
            taskWorkEntity.TypeNameENUS     = "LegalReview(Rep)";
            taskWorkEntity.TypeNameZHCN     = "LegalReview(Rep)";
            taskWorkEntity.ReceiverAccount  = entity.AssetActorAccount;
            taskWorkEntity.ReceiverNameZHCN = entity.AssetActorNameZHCN;
            taskWorkEntity.ReceiverNameENUS = entity.AssetActorNameENUS;
            taskWorkEntity.Id = newGuid;

            taskWorkEntity.Url          = SiteInfo.GetProjectHandlerPageUrl(FlowCode.Closure_LegalReview, entity.ProjectId);
            taskWorkEntity.ActivityName = "Start";
            taskWorkController.Create(taskWorkEntity);

            //noticerList.Add(entity.AssetActorAccount);
            //closureHandler.SendEmail(newGuid, noticerList.ToArray(), "LegalReview", entity.ProjectId, ClosureLegalReview.TableName,entity.PMNameENUS);
            //noticerList.Remove(entity.AssetActorAccount);
        }