Esempio n. 1
0
        public override void Finish(TaskWorkStatus status, TaskWork task)
        {
            using (var scope = new TransactionScope())
            {
                switch (status)
                {
                case TaskWorkStatus.K2ProcessApproved:
                    ProjectInfo.FinishNode(ProjectId, FlowCode.Reimage_Summary, NodeCode.Finish, ProjectStatus.Finished);

                    var reimagePackage = ReimagePackage.Get(ProjectId);
                    reimagePackage.GeneratePackageTask(ProjectId);
                    break;
                }

                scope.Complete();
            }
        }
Esempio n. 2
0
        public override void Finish(TaskWorkStatus status, TaskWork task)
        {
            using (var scope = new TransactionScope())
            {
                switch (status)
                {
                case TaskWorkStatus.K2ProcessApproved:
                    ProjectInfo.FinishNode(ProjectId, FlowCode.Reimage_ConsInfo, NodeCode.Reimage_ConsInfo_Confirm, ProjectStatus.Finished);

                    var reimagePackage = ReimagePackage.Get(ProjectId);
                    reimagePackage.GeneratePackageTask(ProjectId);

                    var reimageInfo = ReimageInfo.FirstOrDefault(e => e.ProjectId == ProjectId);

                    if (reimageInfo != null)
                    {
                        if (!TaskWork.Any(e => e.RefID == ProjectId &&
                                          e.TypeCode == FlowCode.Reimage_Summary &&
                                          e.Status == TaskWorkStatus.UnFinish &&
                                          e.ActivityName == NodeCode.Start))
                        {
                            var    reimageSummary = ReimageSummary.GetReimageSummaryInfo(ProjectId);
                            string filePath;
                            reimageSummary.GenerateExcel(out filePath);

                            if (!ProjectInfo.Any(e => e.ProjectId == ProjectId &&
                                                 e.FlowCode == FlowCode.Reimage_Summary &&
                                                 e.Status == ProjectStatus.Finished))
                            {
                                var summaryTask = reimageInfo.GenerateTaskWork(
                                    FlowCode.Reimage_Summary,
                                    FlowCode.Reimage_Summary,
                                    FlowCode.Reimage_Summary,
                                    string.Format(@"/Reimage/Main#/Summary?projectId={0}", ProjectId));

                                summaryTask.Add();
                            }
                        }
                    }
                    break;
                }

                scope.Complete();
            }
        }
Esempio n. 3
0
        public override string Edit()
        {
            var taskUrl = string.Format("/Reimage/Main#/ConsInfo?projectId={0}", ProjectId);

            using (var scope = new TransactionScope())
            {
                var reimageInfo = ReimageInfo.FirstOrDefault(e => e.ProjectId.Equals(ProjectId));
                if (reimageInfo == null)
                {
                    throw new Exception("Could not find the Reimage Info, please check it!");
                }
                var task = reimageInfo.GenerateTaskWork(FlowCode.Reimage_ConsInfo,
                                                        "Reimage_ConsInfo",
                                                        "Reimage_ConsInfo",
                                                        taskUrl);
                task.ActivityName = NodeCode.Start;
                task.ActionName   = SetTaskActionName(ProjectId);
                TaskWork.Add(task);

                var package = ReimagePackage.GetReimagePackageInfo(ProjectId);
                if (package != null)
                {
                    package.CompleteActorPackageTask(reimageInfo.AssetActorAccount);
                }


                var attachments = Attachment.Search(e => e.RefTableID == Id.ToString() &&
                                                    e.RefTableName == WFReimageConsInfo.TableName).AsNoTracking().ToList();



                ProjectInfo.Reset(ProjectId, FlowCode.Reimage_ConsInfo);
                var wfEntity = GetWorkflowEntity(ProjectId, FlowCode.Reimage_Package);
                if (wfEntity != null)
                {
                    wfEntity.ChangePackageHoldingStatus(HoldingStatus.No);
                }



                var form = Duplicator.AutoCopy(this);
                form.Id         = Guid.Empty;
                form.ProcInstId = null;
                form.IsHistory  = false;
                form.Comments   = null;
                form.CreateTime = DateTime.Now;
                form.SaveEdit("edit");

                List <Attachment> listAttachment = new List <Attachment>();
                Mapper.CreateMap <Attachment, Attachment>();
                foreach (var attachment in attachments)
                {
                    var newAttachment = Duplicator.AutoCopy(attachment);
                    newAttachment.RefTableID = form.Id.ToString();
                    newAttachment.ID         = Guid.NewGuid();
                    listAttachment.Add(newAttachment);
                }
                Attachment.Add(listAttachment.ToArray());
                IsHistory = true;
                Update(this);
                scope.Complete();
            }

            return(taskUrl);
        }