Ejemplo n.º 1
0
        private void SaveCommers(ClosureLegalReview entity, string action, ProjectCommentStatus status)
        {
            //if (status == ProjectCommentStatus.Save)
            //{

            var list = _db.ProjectComment.Where(
                c => c.CreateUserAccount == ClientCookie.UserCode && c.RefTableId == entity.Id && c.Status == ProjectCommentStatus.Save &&
                c.RefTableName == ClosureLegalReview.TableName && c.SourceCode == FlowCode.Closure).ToList();

            if (list.Count > 0)
            {
                ProjectComment closureCommens = list[0];
                closureCommens.Content = entity.Comments == null ? "" : entity.Comments.Trim();
                closureCommens.Status  = status;
                if (entity.ProcInstID.HasValue && entity.ProcInstID.Value > 0)
                {
                    closureCommens.ProcInstID = entity.ProcInstID;
                }
                ProjectComment.Update(closureCommens);
            }
            else
            {
                AddProjectComment(entity, action, status);
            }
        }
Ejemplo n.º 2
0
 public IHttpActionResult Edit(ClosureLegalReview entity)
 {
     using (TransactionScope tranScope = new TransactionScope())
     {
         var result = entity.Edit();
         tranScope.Complete();
         return(Ok(new
         {
             TaskUrl = result
         }));
     }
 }
Ejemplo n.º 3
0
        public IHttpActionResult UploadFinAgreement(int procInstID)
        {
            HttpRequest        request      = System.Web.HttpContext.Current.Request;
            HttpFileCollection FileCollect  = request.Files;
            string             internalName = string.Empty;
            ClosureLegalReview legalReview  = new ClosureLegalReview();

            if (FileCollect.Count > 0) //如果集合的数量大于0
            {
                var woEntity = legalReview.GetByProcInstID(procInstID);

                //用key获取单个文件对象HttpPostedFile
                HttpPostedFile fileSave      = FileCollect[0];
                string         fileName      = "FinalTerminationAgreement";
                string         fileExtension = Path.GetExtension(fileSave.FileName);
                var            current       = System.Web.HttpContext.Current;

                internalName = Guid.NewGuid() + fileExtension;
                string absolutePath = current.Server.MapPath("~/") + "UploadFiles/" + internalName;

                fileSave.SaveAs(absolutePath);

                Attachment att = new Attachment();
                att.InternalName    = internalName;
                att.RefTableName    = ClosureLegalReview.TableName;
                att.RefTableID      = woEntity.Id.ToString();
                att.RelativePath    = "//";
                att.Name            = fileName;
                att.Extension       = fileExtension;
                att.Length          = FileCollect[0].ContentLength;
                att.CreateTime      = DateTime.Now;
                att.TypeCode        = "FinAgreement";
                att.CreatorNameENUS = ClientCookie.UserNameENUS;
                att.CreatorNameZHCN = ClientCookie.UserNameZHCN;
                att.CreatorID       = ClientCookie.UserCode;

                Attachment.SaveSigleFile(att);


                ProjectInfo.FinishNode(woEntity.ProjectId, FlowCode.Closure_LegalReview,
                                       NodeCode.Closure_LegalReview_UploadAgreement);
            }

            return(Ok());
        }
Ejemplo n.º 4
0
        public IHttpActionResult SaveClosureLegalReview(ClosureLegalReview entity)
        {
            var entityInfo = ClosureLegalReview.Get(entity.ProjectId);

            if (entityInfo == null)
            {
                //entity = new ClosureLegalReview();
                entity.CreateTime        = DateTime.Now;
                entity.CreateUserAccount = ClientCookie.UserCode;
                entity.Id = Guid.NewGuid();

                entity.IsHistory = false;
                _db.ClosureLegalReview.Add(entity);
                //}
            }
            else
            {
                try
                {
                    entity.Id                = entityInfo.Id;
                    entity.CreateTime        = DateTime.Now;
                    entity.CreateUserAccount = ClientCookie.UserCode;
                    entity.IsHistory         = false;
                    //entityInfo.LegalCommers = entity.LegalCommers;
                    _db.ClosureLegalReview.Attach(entity);
                    _db.Entry(entity).State = EntityState.Modified;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }


            string action = string.IsNullOrEmpty(entity.Action) ?
                            ProjectCommentAction.Submit : entity.Action;

            SaveCommers(entity, action, ProjectCommentStatus.Save);
            var result = _db.SaveChanges();

            return(Ok());
        }
Ejemplo n.º 5
0
        public IHttpActionResult Recall(ClosureLegalReview entity)
        {
            bool _recallSuccess = false;

            if (entity.ProcInstID != null)
            {
                _recallSuccess = K2FxContext.Current.GoToActivityAndRecord(entity.ProcInstID.Value, WFClosureLegalReview.Act_Originator, ClientCookie.UserCode, ProjectAction.Recall, entity.Comments);
                if (_recallSuccess)
                {
                    SaveCommers(entity, ProjectCommentAction.Recall, ProjectCommentStatus.Submit);
                }
            }
            if (!_recallSuccess)
            {
                throw new Exception("Recall失败");
            }
            ProjectInfo.Reset(entity.ProjectId, FlowCode.Closure_LegalReview, ProjectStatus.Recalled);

            return(Ok());
        }
Ejemplo n.º 6
0
        private int ModifyProject(ClosureLegalReview entity, string action)
        {
            if (action == ProjectAction.Edit)
            {
                entity.IsHistory              = true;
                entity.LastUpdateTime         = DateTime.Now;
                entity.LastUpdateUserAccount  = ClientCookie.UserCode;
                entity.LastUpdateUserNameENUS = ClientCookie.UserNameENUS;
                entity.LastUpdateUserNameZHCN = ClientCookie.UserNameZHCN;

                _db.ClosureLegalReview.Attach(entity);
                _db.Entry(entity).State = EntityState.Modified;
            }
            //  projectInfoBLL.UpdateProjectNode(entity.ProjectId, FlowCode.Closure_LegalReview,

            // NodeCode.Start);

            var result = _db.SaveChanges();

            return(result);
        }
Ejemplo n.º 7
0
        public ClosureLegalReview GetByProjectId(string projectId, string userAccount)
        {
            ClosureLegalReview entity = ClosureLegalReview.Get(projectId);

            if (entity != null)
            {
                ProjectCommentCondition condition = new ProjectCommentCondition();
                condition.SourceCode   = FlowCode.Closure;
                condition.UserAccount  = userAccount;
                condition.RefTableId   = entity.Id;
                condition.RefTableName = ClosureLegalReview.TableName;
                condition.Status       = ProjectCommentStatus.Save;

                var comments = ProjectComment.SearchList(condition);
                if (comments != null && comments.Count > 0)
                {
                    entity.Comments = comments[0].Content;
                }
            }


            return(entity);
        }
Ejemplo n.º 8
0
        private void AddProjectComment(ClosureLegalReview entity, string action,
                                       ProjectCommentStatus status)
        {
            ProjectComment closureCommens = new ProjectComment();

            closureCommens.RefTableId   = entity.Id;
            closureCommens.RefTableName = ClosureLegalReview.TableName;

            closureCommens.TitleNameENUS = ClientCookie.TitleENUS;
            closureCommens.TitleNameZHCN = ClientCookie.TitleENUS;
            closureCommens.TitleCode     = ClientCookie.TitleENUS;

            closureCommens.CreateTime        = DateTime.Now;
            closureCommens.CreateUserAccount = ClientCookie.UserCode;


            closureCommens.UserAccount        = ClientCookie.UserCode;
            closureCommens.UserNameENUS       = ClientCookie.UserNameENUS;
            closureCommens.UserNameZHCN       = ClientCookie.UserNameZHCN;
            closureCommens.CreateUserNameZHCN = ClientCookie.UserNameZHCN;
            closureCommens.Id = Guid.NewGuid();
            if (!string.IsNullOrEmpty(entity.Comments))
            {
                closureCommens.Content = entity.Comments.Trim();
            }
            closureCommens.Action = action;
            closureCommens.Status = status;
            if (entity.ProcInstID > 0)
            {
                closureCommens.ProcInstID = entity.ProcInstID;
            }
            closureCommens.SourceCode     = FlowCode.Closure;
            closureCommens.SourceNameENUS = FlowCode.Closure;
            closureCommens.SourceNameZHCN = "关店流程";
            closureCommens.Add();
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 提交Closure
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public IHttpActionResult PostClosure(ClosureInfo entity)
        {
            using (TransactionScope tranScope = new TransactionScope())
            {
                //    bll.BeginTransAction();
                //    try
                //    {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                if (entity.ClosureReasonCode != "Others")
                {
                    entity.ClosureReasonRemark = string.Empty;
                }

                if (entity.Id == new Guid())
                {
                    entity.Id = Guid.NewGuid();

                    entity.CreateDate = DateTime.Now;

                    entity.ProjectId = ProjectInfo.CreateMainProject(FlowCode.Closure, entity.USCode, NodeCode.Start, entity.CreateUserAccount);



                    ClosureInfo.Add(entity);
                }
                else
                {
                    ClosureInfo.Update(entity);
                }
                //    bll.Commit();
                //}
                //catch (Exception ex)
                //{
                //    bll.Rollback();
                //    return BadRequest(ex.Message);
                //}
                var usersList  = new List <ProjectUsers>();
                var assetActor = GetClosureUsers(ProjectUserRoleCode.AssetActor, ProjectUserRoleCode.AssetActor, ProjectUserRoleCode.AssetActor, entity.AssetActorAccount, entity.AssetActorNameENUS, entity.AssetActorNameZHCN, entity.ProjectId);
                usersList.Add(assetActor);
                var assetRep = GetClosureUsers(ProjectUserRoleCode.AssetRep, ProjectUserRoleCode.AssetRep, ProjectUserRoleCode.AssetRep, entity.AssetRepAccount, entity.AssetRepNameENUS, entity.AssetRepNameZHCN, entity.ProjectId);
                usersList.Add(assetRep);
                var finance = GetClosureUsers(ProjectUserRoleCode.Finance, ProjectUserRoleCode.Finance, ProjectUserRoleCode.Finance, entity.FinanceAccount, entity.FinanceNameENUS, entity.FinanceNameZHCN, entity.ProjectId);
                usersList.Add(finance);
                var Legal = GetClosureUsers(ProjectUserRoleCode.Legal, ProjectUserRoleCode.Legal, ProjectUserRoleCode.Legal, entity.LegalAccount, entity.LegalNameENUS, entity.LegalNameZHCN, entity.ProjectId);
                usersList.Add(Legal);
                var PM = GetClosureUsers(ProjectUserRoleCode.PM, ProjectUserRoleCode.PM, ProjectUserRoleCode.PM, entity.PMAccount, entity.PMNameZHCN, entity.PMNameENUS, entity.ProjectId);
                usersList.Add(PM);
                var assertMgr = GetClosureUsers(ProjectUserRoleCode.AssetManager, ProjectUserRoleCode.AssetManager, ProjectUserRoleCode.AssetManager, entity.AssetManagerAccount, entity.AssetManagerNameENUS,
                                                entity.AssetManagerNameZHCN, entity.ProjectId);
                usersList.Add(assertMgr);

                var cm = GetClosureUsers(ProjectUserRoleCode.CM, ProjectUserRoleCode.CM, ProjectUserRoleCode.CM, entity.CMAccount, entity.CMNameENUS,
                                         entity.CMNameZHCN, entity.ProjectId);
                usersList.Add(cm);
                if (entity.NecessaryNoticeUserList != null && entity.NecessaryNoticeUserList.Count > 0)
                {
                    usersList.AddRange(entity.NecessaryNoticeUserList.Select(
                                           user => GetClosureUsers(ProjectUserRoleCode.View, ProjectUserRoleCode.View, ProjectUserRoleCode.View, user.Code, user.NameENUS, user.NameZHCN,
                                                                   entity.ProjectId)));
                }
                if (entity.NoticeUserList != null && entity.NoticeUserList.Count > 0)
                {
                    usersList.AddRange(entity.NoticeUserList.Select(
                                           user => GetClosureUsers(ProjectUserRoleCode.View, ProjectUserRoleCode.View, ProjectUserRoleCode.View, user.Code, user.NameENUS, user.NameZHCN,
                                                                   entity.ProjectId)));
                }

                ProjectUsers.Add(usersList.ToArray());
                SendRemind(entity);
                SendWorkTaskAndEmail(entity);

                //初始化项目信息

                ProjectInfo.CreateSubProject(FlowCode.Closure_WOCheckList, entity.ProjectId, entity.USCode, NodeCode.Start, PM.UserAccount);
                ProjectInfo.CreateSubProject(FlowCode.Closure_LegalReview, entity.ProjectId, entity.USCode, NodeCode.Start, assetActor.UserAccount);
                ProjectInfo.CreateSubProject(FlowCode.Closure_ClosureTool, entity.ProjectId, entity.USCode, NodeCode.Start, finance.UserAccount);

                var store = StoreBasicInfo.GetStorInfo(entity.USCode);

                var closureTool = new ClosureTool();
                closureTool.Id                   = Guid.NewGuid();
                closureTool.ProjectId            = entity.ProjectId;
                closureTool.IsHistory            = false;
                closureTool.IsOptionOffered      = entity.IsRelocation();
                closureTool.PipelineName         = store.PipelineNameENUS;
                closureTool.RelocationPipelineID = store.PipelineID;
                closureTool.Add();

                var woCheckList = new ClosureWOCheckList
                {
                    Id                = Guid.NewGuid(),
                    ProjectId         = entity.ProjectId,
                    CreateTime        = DateTime.Now,
                    CreateUserAccount = ClientCookie.UserCode,
                    CreateUserName    = ClientCookie.UserNameENUS,
                    IsHistory         = false
                };
                woCheckList.Add();

                var legalReview = new ClosureLegalReview
                {
                    Id                = Guid.NewGuid(),
                    ProjectId         = entity.ProjectId,
                    CreateTime        = DateTime.Now,
                    CreateUserAccount = ClientCookie.UserCode,
                    CreateUserName    = ClientCookie.UserNameENUS,
                    IsHistory         = false
                };
                legalReview.Add();

                var executiveSummary = new ClosureExecutiveSummary
                {
                    Id             = Guid.NewGuid(),
                    ProjectId      = entity.ProjectId,
                    CreateTime     = DateTime.Now,
                    CreatorAccount = ClientCookie.UserCode,
                    CreatorName    = ClientCookie.UserNameENUS,
                    IsHistory      = false
                };
                executiveSummary.Add();

                //var package = new ClosurePackage
                //{
                //    Id = Guid.NewGuid(),
                //    ProjectId = entity.ProjectId,
                //    CreateTime = DateTime.Now,
                //    CreateUserAccount = ClientCookie.UserCode,
                //    IsHistory = false
                //};
                //package.Add();

                var projectContractInfo = ProjectContractInfo.GetContractWithHistory(entity.ProjectId).Current;
                projectContractInfo.Add();

                ProjectInfo.CreateSubProject(FlowCode.Closure_ExecutiveSummary, entity.ProjectId, entity.USCode, NodeCode.Start, assetActor.UserAccount);

                ProjectInfo.CreateSubProject(FlowCode.Closure_ClosurePackage, entity.ProjectId, entity.USCode, NodeCode.Start, assetActor.UserAccount);

                ProjectInfo.CreateSubProject(FlowCode.Closure_ConsInvtChecking, entity.ProjectId, entity.USCode, NodeCode.Start, entity.PMAccount);


                ProjectInfo.CreateSubProject(FlowCode.Closure_ContractInfo, entity.ProjectId, entity.USCode,
                                             NodeCode.Start, entity.CreateUserAccount);
                ProjectInfo.CreateSubProject(FlowCode.Closure_Memo, entity.ProjectId, entity.USCode,
                                             NodeCode.Start, entity.CreateUserAccount);
                ProjectNode.GenerateOnCreate(FlowCode.Closure, entity.ProjectId);
                try
                {
                    //bllActionLog.Add(new ActionLog
                    //{
                    //    Id = Guid.NewGuid(),
                    //    ProjectId = entity.ProjectId,
                    //    Action = ActionType.Submit,
                    //    CreateTime = DateTime.Now,
                    //    Operator = entity.CreateUserAccount,
                    //    OperatorENUS = entity.CreateUserNameENUS,
                    //    OperatorZHCN = entity.CreateUserNameZHCN,
                    //    Remark = "",
                    //    OperatorTitle = "创建流程"
                    //});
                    tranScope.Complete();
                    //bll.GetDb().SaveChanges();
                }
                catch (DbEntityValidationException dbEx)
                {
                    tranScope.Dispose();
                }


                return(Ok(entity));
            }
        }
Ejemplo n.º 10
0
        public IHttpActionResult PostClosureLegalReview(ClosureLegalReview entity)
        {
            var task = _db.TaskWork.First(
                e => e.ReceiverAccount == ClientCookie.UserCode && e.Status == 0 && e.SourceCode == FlowCode.Closure &&
                e.TypeCode == FlowCode.Closure_LegalReview && e.RefID == entity.ProjectId
                );

            task.Status     = TaskWorkStatus.Finished;
            task.FinishTime = DateTime.Now;
            task.Url        = SiteInfo.GetProjectViewPageUrl(FlowCode.Closure_LegalReview, task.RefID);

            //var enableExecutiveSummary = handler.EnableExecutiveSummary(entity.ProjectId.Value);

            _db.TaskWork.Attach(task);
            _db.Entry(task).State = EntityState.Modified;

            var entityInfo = ClosureLegalReview.Get(entity.ProjectId);

            //GUID通过页面JS生成需要判断否存在


            if (entityInfo == null)
            {
                //entity = new ClosureLegalReview();
                entity.CreateTime        = DateTime.Now;
                entity.CreateUserAccount = ClientCookie.UserCode;
                entity.Id        = Guid.NewGuid();
                entity.IsHistory = false;
                _db.ClosureLegalReview.Add(entity);
                //}
            }
            else
            {
                try
                {
                    //entityInfo.LegalCommers = entity.Comments;
                    _db.ClosureLegalReview.Attach(entityInfo);
                    _db.Entry(entityInfo).State = EntityState.Modified;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }

            //bllActionLog.Add(new ActionLog
            //{
            //    Id = Guid.NewGuid(),
            //    ProjectId = entity.ProjectId,
            //    Action = ActionType.Submit,
            //    CreateTime = DateTime.Now,
            //    Operator = entity.CreateUserAccount,
            //    OperatorENUS = entity.UserNameENUS,
            //    OperatorZHCN = entity.UserNameZHCN,
            //    Remark = "提交LegalReview流程",
            //    OperatorTitle = "提交LegalReview流程"
            //});


            var result = _db.SaveChanges();

            if (result > 0)
            {
                // Start K2 Process
                string _procCode = WFClosureLegalReview.ProcessCode;
                List <ProcessDataField> _listDataFields = new List <ProcessDataField>();

                _listDataFields.Add(new ProcessDataField("dest_Creator", ClientCookie.UserCode)); // 发起人

                var closureInfo = ClosureInfo.GetByProjectId(entity.ProjectId);


                //string legalAccount = userPositionHandler.GetAccounts(entity.ProjectId.Value,
                //   UserPositionHandler.LegalCounselCode );

                string legalAccount = entity.LegalAccount;

                _listDataFields.Add(new ProcessDataField("dest_Legal", legalAccount));//entity.   Legal

                _listDataFields.Add(new ProcessDataField("ProcessCode", _procCode));
                //_listDataFields.Add(new ProcessDataField("dest_Receiver", "")); 知会人

                if (_listDataFields.Exists(o => string.IsNullOrEmpty(o.DataFieldValue)))
                {
                    result = 0;
                }
                else
                {
                    //将TaskWork生成任务传给K2
                    var taskJson = TaskWork.ConvertToJson(task);
                    _listDataFields.Add(new ProcessDataField("ProjectTaskInfo", taskJson));

                    var _debugInfo = string.Format("[Ln 326] DataFields: {0}", JsonConvert.SerializeObject(_listDataFields));
                    Log4netHelper.WriteInfoLog(_debugInfo, this.GetType(), "PostClosureLegalReview");

                    int _procInstID = 0;

                    try
                    {
                        _procInstID = K2FxContext.Current.StartProcess(_procCode, ClientCookie.UserCode, _listDataFields);
                    }
                    catch (Exception ex)
                    {
                        _debugInfo = string.Format("[Ln 339] Result: {0}", ex.Message);
                        Log4netHelper.Log4netWriteErrorLog(_debugInfo, ex);
                        Log4netHelper.WriteErrorLog(_debugInfo);
                        Log4netHelper.WriteInfoLog(_debugInfo);
                        throw ex;
                    }

                    _debugInfo = string.Format("[Ln 345] Result: {0}", _procInstID);
                    Log4netHelper.WriteInfoLog(_debugInfo, this.GetType(), "PostClosureLegalReview");



                    if (_procInstID > 0)
                    {
                        if (entityInfo == null)
                        {
                            _db.ClosureLegalReview.Attach(entity);
                            _db.Entry(entity).State = EntityState.Modified;
                        }
                        else
                        {
                            entity.Id             = entityInfo.Id;
                            entityInfo.ProcInstID = _procInstID;
                            _db.ClosureLegalReview.Attach(entityInfo);
                            _db.Entry(entityInfo).State = EntityState.Modified;
                        }

                        entity.ProcInstID = _procInstID;
                        SaveCommers(entity, ProjectCommentAction.Submit, ProjectCommentStatus.Submit);
                        result = _db.SaveChanges();
                    }
                }
            }

            ProjectInfo.FinishNode(entity.ProjectId, FlowCode.Closure_LegalReview,
                                   NodeCode.Closure_LegalReview_Input);

            return(Ok(result));
        }
Ejemplo n.º 11
0
        public IHttpActionResult ProcessClosureLegalReview(ClosureLegalReview entity)
        {
            int procInstID = entity.ProcInstID.Value;


            string account = ClientCookie.UserCode;
            //评论信息
            string comments = entity.Comments;

            // To-Do K2 action
            ProcessActionResult _action = BPMHelper.ConvertToProcAction(entity.Action);


            string op = string.Empty;
            var    _listDataFields = new List <ProcessDataField>();

            switch (entity.Action)
            {
            case "Submit":

                break;

            case "Return":
                op = ProjectCommentAction.Return;
                break;

            case "ReSubmit":
                op = ProjectCommentAction.ReSubmit;
                var legalAccount = entity.LegalAccount;
                _listDataFields.Add(new ProcessDataField("dest_Legal", legalAccount));    //entity.   Legal
                break;
            }

            ClosureLegalReview.Update(entity);
            var result = false;

            if (_listDataFields.Count > 0)
            {
                result = K2FxContext.Current.ApprovalProcess(entity.SN, account, _action.ToString(), comments, _listDataFields);
            }
            else
            {
                result = K2FxContext.Current.ApprovalProcess(entity.SN, account, _action.ToString(), comments);
            }

            if (result)
            {
                switch (entity.Action)
                {
                case ProjectAction.Recall:
                    ProjectInfo.Reset(entity.ProjectId, FlowCode.Closure_LegalReview, ProjectStatus.Recalled);
                    break;

                case ProjectAction.Return:
                    ProjectInfo.Reset(entity.ProjectId, FlowCode.Closure_LegalReview);
                    break;

                case ProjectAction.Decline:
                    ProjectInfo.Reject(entity.ProjectId, FlowCode.Closure_LegalReview);
                    break;

                case ProjectAction.ReSubmit:
                    ProjectInfo.FinishNode(entity.ProjectId, FlowCode.Closure_LegalReview, NodeCode.Closure_LegalReview_Input);
                    break;

                default:
                    ProjectInfo.FinishNode(entity.ProjectId, FlowCode.Closure_LegalReview, NodeCode.Closure_LegalReview_Input);
                    break;
                }
            }
            SaveCommers(entity, _action.ToString(), ProjectCommentStatus.Submit);
            return(Ok());
        }
Ejemplo n.º 12
0
        public IHttpActionResult GetByProcInstID(int procInstID)
        {
            var entity = ClosureLegalReview.FirstOrDefault(e => e.ProcInstID == procInstID);

            return(Ok(entity));
        }
Ejemplo n.º 13
0
        public IHttpActionResult GetById(Guid id)
        {
            var entity = ClosureLegalReview.GetById(id);

            return(Ok(entity));
        }
Ejemplo n.º 14
0
        public IHttpActionResult Upload(string projectId, string refTableName, Guid?requirementId = null)
        {
            using (TransactionScope tranScope = new TransactionScope())
            {
                var refTableId = Attachment.GetRefTableId(refTableName, projectId);
                if (refTableId == Guid.Empty.ToString())
                {
                    var newId = Guid.NewGuid();
                    refTableId = newId.ToString();
                    switch (refTableName)
                    {
                    case "MajorLeaseChangePackage":
                    {
                        var entity = new MajorLeaseChangePackage();
                        entity.ProjectId         = projectId;
                        entity.Id                = newId;
                        entity.CreateTime        = DateTime.Now;
                        entity.CreateUserAccount = ClientCookie.UserCode;
                        entity.IsHistory         = false;
                        entity.Add();
                    }
                    break;

                    case "ReimageSummary":
                    {
                        var entity = new ReimageSummary();
                        entity.ProjectId         = projectId;
                        entity.Id                = newId;
                        entity.CreateTime        = DateTime.Now;
                        entity.CreateUserAccount = ClientCookie.UserCode;
                        entity.IsHistory         = false;
                        entity.Add();
                    }
                    break;

                    case "ReimageConsInfo":
                    {
                        var entity = new ReimageConsInfo();
                        entity.ProjectId         = projectId;
                        entity.Id                = newId;
                        entity.CreateTime        = DateTime.Now;
                        entity.CreateUserAccount = ClientCookie.UserCode;
                        entity.IsHistory         = false;
                        entity.Add();
                    }
                    break;

                    case "ReimagePackage":
                    {
                        var entity = new ReimagePackage();
                        entity.ProjectId         = projectId;
                        entity.Id                = newId;
                        entity.CreateTime        = DateTime.Now;
                        entity.CreateUserAccount = ClientCookie.UserCode;
                        entity.IsHistory         = false;
                        entity.Add();
                    }
                    break;

                    case "RebuildLegalReview":
                    {
                        var entity = new RebuildLegalReview();
                        entity.ProjectId         = projectId;
                        entity.Id                = newId;
                        entity.CreateTime        = DateTime.Now;
                        entity.CreateUserAccount = ClientCookie.UserCode;
                        entity.IsHistory         = false;
                        entity.Add();
                    }
                    break;

                    case "ClosureLegalReview":
                    {
                        var entity = new ClosureLegalReview();
                        entity.ProjectId         = projectId;
                        entity.Id                = newId;
                        entity.CreateTime        = DateTime.Now;
                        entity.CreateUserAccount = ClientCookie.UserCode;
                        entity.IsHistory         = false;
                        entity.Add();
                    }
                    break;

                    case "ClosureExecutiveSummary":
                    {
                        var entity = new ClosureExecutiveSummary();
                        entity.ProjectId      = projectId;
                        entity.Id             = newId;
                        entity.CreateTime     = DateTime.Now;
                        entity.CreatorAccount = ClientCookie.UserCode;
                        entity.IsHistory      = false;
                        entity.Add();
                    }
                    break;

                    case "ClosurePackage":
                    {
                        var entity = new ClosurePackage();
                        entity.ProjectId         = projectId;
                        entity.Id                = newId;
                        entity.CreateTime        = DateTime.Now;
                        entity.CreateUserAccount = ClientCookie.UserCode;
                        entity.IsHistory         = false;
                        entity.Add();
                    }
                    break;
                    }
                }
                var userRole = ProjectUsers.Get(ClientCookie.UserCode, projectId);
                var files    = HttpContext.Current.Request.Files;
                if (requirementId.HasValue)
                {
                    var attReq      = AttachmentRequirement.Get(requirementId.Value);
                    var projectInfo = ProjectInfo.Get(projectId, attReq.FlowCode);
                    var store       = StoreBasicInfo.GetStorInfo(projectInfo.USCode);
                    var attachNode  = NodeInfo.FirstOrDefault(n => n.FlowCode == attReq.FlowCode && n.Code == attReq.NodeCode);
                    if (attachNode != null)
                    {
                        ProjectInfo.FinishNode(projectId, attReq.FlowCode, attReq.NodeCode);
                    }
                    var    file          = files[0];
                    string fileName      = Path.GetFileName(file.FileName);
                    string fileExtension = Path.GetExtension(file.FileName);
                    var    current       = System.Web.HttpContext.Current;
                    string internalName  = Guid.NewGuid() + fileExtension;
                    string absolutePath  = current.Server.MapPath("~/") + "UploadFiles/" + internalName;

                    file.SaveAs(absolutePath);

                    Attachment att = Attachment.Get(refTableId, requirementId.Value);

                    if (att == null)
                    {
                        att = new Attachment();
                        att.InternalName    = internalName;
                        att.RefTableName    = refTableName;
                        att.RefTableID      = refTableId;
                        att.RelativePath    = "//";
                        att.Name            = fileName;
                        att.Extension       = fileExtension;
                        att.Length          = file.ContentLength;
                        att.CreateTime      = DateTime.Now;
                        att.CreatorNameZHCN = ClientCookie.UserNameZHCN;
                        att.CreatorNameENUS = ClientCookie.UserNameENUS;
                        att.CreatorID       = ClientCookie.UserCode;
                        att.ID            = Guid.NewGuid();
                        att.RequirementId = requirementId;
                        att.TypeCode      = "";
                        Attachment.Add(att);
                    }
                    else
                    {
                        att.InternalName    = internalName;
                        att.RefTableName    = refTableName;
                        att.RefTableID      = refTableId;
                        att.RelativePath    = "//";
                        att.Name            = fileName;
                        att.Extension       = fileExtension;
                        att.Length          = file.ContentLength;
                        att.CreateTime      = DateTime.Now;
                        att.CreatorNameZHCN = ClientCookie.UserNameZHCN;
                        att.CreatorNameENUS = ClientCookie.UserNameENUS;
                        att.CreatorID       = ClientCookie.UserCode;
                        Attachment.Update(att);
                    }
                    //TempClosure上传SignAgreement
                    //if (requirementId.Value.Equals(new Guid("1E9B17AF-357A-4DC9-8A60-17766663FB75")))
                    //{
                    //    var url = "/TempClosure/Main#/ClosureMemo?projectId=" + projectId;
                    //    var actor = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == projectId && pu.RoleCode == ProjectUserRoleCode.AssetActor);
                    //    var title = string.Concat(projectId, " ", store.NameZHCN, " ", store.NameENUS);
                    //    TaskWork.Finish(t => t.ReceiverAccount == ClientCookie.UserCode && t.RefID == projectId && t.Status == TaskWorkStatus.UnFinish && t.TypeCode == FlowCode.TempClosure_ClosurePackage);
                    //    //TaskWork.SendTask(projectId, title, projectInfo.USCode, url, actor, FlowCode.TempClosure, FlowCode.TempClosure_ClosureMemo, "Start");
                    //}
                }
                else
                {
                    List <Attachment> attachments = new List <Attachment>();
                    string            typeCode    = "";
                    if (refTableName == "RebuildLegalReview")
                    {
                        typeCode = "Contract";
                    }
                    for (int i = 0; i < files.Count; i++)
                    {
                        var    file          = files[i];
                        string fileName      = Path.GetFileName(file.FileName);
                        string fileExtension = Path.GetExtension(file.FileName);
                        var    current       = System.Web.HttpContext.Current;
                        string internalName  = Guid.NewGuid() + fileExtension;
                        string absolutePath  = current.Server.MapPath("~/") + "UploadFiles/" + internalName;

                        file.SaveAs(absolutePath);

                        Attachment att = new Attachment();
                        att.InternalName    = internalName;
                        att.RefTableName    = refTableName;
                        att.RefTableID      = refTableId;
                        att.RelativePath    = "//";
                        att.Name            = fileName;
                        att.Extension       = fileExtension;
                        att.Length          = file.ContentLength;
                        att.CreateTime      = DateTime.Now;
                        att.CreatorNameZHCN = ClientCookie.UserNameZHCN;
                        att.CreatorNameENUS = ClientCookie.UserNameENUS;
                        att.CreatorID       = ClientCookie.UserCode;
                        att.ID            = Guid.NewGuid();
                        att.RequirementId = requirementId;
                        att.TypeCode      = typeCode;
                        attachments.Add(att);
                    }
                    Attachment.Add(attachments.ToArray());
                }
                tranScope.Complete();
                return(Ok());
            }
        }
Ejemplo n.º 15
0
        public IHttpActionResult UploadContract(string projectId)
        {
            HttpRequest        request     = System.Web.HttpContext.Current.Request;
            HttpFileCollection FileCollect = request.Files;
            int    result       = 0;
            string resultStr    = string.Empty;
            string internalName = string.Empty;

            if (FileCollect.Count > 0) //如果集合的数量大于0
            {
                var entity = ClosureLegalReview.Get(projectId);

                if (entity == null)
                {
                    entity                   = new ClosureLegalReview();
                    entity.ProjectId         = projectId;
                    entity.Id                = Guid.NewGuid();
                    entity.CreateTime        = DateTime.Now;
                    entity.CreateUserAccount = ClientCookie.UserCode;

                    entity.IsHistory = false;

                    _db.ClosureLegalReview.Add(entity);
                    //}
                }


                for (int i = 0; i < FileCollect.Count; i++)
                {
                    //用key获取单个文件对象HttpPostedFile
                    HttpPostedFile fileSave = FileCollect[i];

                    string fileName = Path.GetFileName(fileSave.FileName);


                    string fileExtension = Path.GetExtension(fileSave.FileName);
                    var    current       = System.Web.HttpContext.Current;

                    internalName = Guid.NewGuid() + fileExtension;
                    string absolutePath = current.Server.MapPath("~/") + "UploadFiles/" + internalName;
                    //通过此对象获取文件名

                    fileSave.SaveAs(absolutePath);

                    Attachment att = new Attachment();
                    att.InternalName    = internalName;
                    att.RefTableName    = ClosureLegalReview.TableName;
                    att.RefTableID      = entity.Id.ToString();
                    att.RelativePath    = "//";
                    att.Name            = fileName;
                    att.Extension       = fileExtension;
                    att.Length          = FileCollect[i].ContentLength;
                    att.CreateTime      = DateTime.Now;
                    att.ID              = Guid.NewGuid();
                    att.TypeCode        = "Contract";
                    att.CreatorID       = ClientCookie.UserCode;
                    att.CreatorNameENUS = ClientCookie.UserNameENUS;
                    att.CreatorNameZHCN = ClientCookie.UserNameZHCN;
                    _db.Attachment.Add(att);
                }
                result = _db.SaveChanges();
            }
            return(Ok(result));
        }
Ejemplo n.º 16
0
        protected static BaseWFEntity GetEmptyWorkflowEntity(string flowCode)
        {
            BaseWFEntity wfEntity = null;

            switch (flowCode)
            {
            case FlowCode.MajorLease:
                wfEntity = new MajorLeaseInfo();
                wfEntity.IsMainProject = true;
                break;

            case FlowCode.MajorLease_LegalReview:
                wfEntity = new MajorLeaseLegalReview();
                break;

            case FlowCode.MajorLease_FinanceAnalysis:
                wfEntity = new MajorLeaseFinancAnalysis();
                break;

            case FlowCode.MajorLease_ConsInfo:
                wfEntity = new MajorLeaseConsInfo();
                break;

            case FlowCode.MajorLease_Package:
                wfEntity = new MajorLeaseChangePackage();
                break;

            case FlowCode.MajorLease_ConsInvtChecking:
                wfEntity = new MajorLeaseConsInvtChecking();
                break;

            case FlowCode.MajorLease_GBMemo:
                wfEntity = new MajorLeaseGBMemo();
                break;

            case FlowCode.Closure:
                wfEntity = new ClosureInfo();
                wfEntity.IsMainProject = true;
                break;

            case FlowCode.Closure_ClosurePackage:
                wfEntity = new ClosurePackage();
                break;

            case FlowCode.Closure_ClosureTool:
                wfEntity = new ClosureTool();
                break;

            case FlowCode.Closure_ConsInvtChecking:
                wfEntity = new ClosureConsInvtChecking();
                break;

            case FlowCode.Closure_LegalReview:
                wfEntity = new ClosureLegalReview();
                break;

            case FlowCode.Closure_WOCheckList:
                wfEntity = new ClosureWOCheckList();
                break;

            case FlowCode.Closure_ExecutiveSummary:
                wfEntity = new ClosureExecutiveSummary();
                break;

            case FlowCode.TempClosure:
                wfEntity = new TempClosureInfo();
                wfEntity.IsMainProject = true;
                break;

            case FlowCode.TempClosure_LegalReview:
                wfEntity = new TempClosureLegalReview();
                break;

            case FlowCode.TempClosure_ClosurePackage:
                wfEntity = new TempClosurePackage();
                break;

            case FlowCode.Rebuild:
                wfEntity = new RebuildInfo();
                wfEntity.IsMainProject = true;
                break;

            case FlowCode.Rebuild_LegalReview:
                wfEntity = new RebuildLegalReview();
                break;

            case FlowCode.Rebuild_FinanceAnalysis:
                wfEntity = new RebuildFinancAnalysis();
                break;

            case FlowCode.Rebuild_ConsInfo:
                wfEntity = new RebuildConsInfo();
                break;

            case FlowCode.Rebuild_Package:
                wfEntity = new RebuildPackage();
                break;

            case FlowCode.Rebuild_ConsInvtChecking:
                wfEntity = new RebuildConsInvtChecking();
                break;

            case FlowCode.Rebuild_GBMemo:
                wfEntity = new GBMemo();
                break;

            case FlowCode.Renewal:
                wfEntity = new RenewalInfo();
                wfEntity.IsMainProject = true;
                break;

            case FlowCode.Renewal_Letter:
                wfEntity = new RenewalLetter();
                break;

            case FlowCode.Renewal_LLNegotiation:
                wfEntity = new RenewalLLNegotiation();
                break;

            case FlowCode.Renewal_ConsInfo:
                wfEntity = new RenewalConsInfo();
                break;

            case FlowCode.Renewal_Tool:
                wfEntity = new RenewalTool();
                break;

            case FlowCode.Renewal_Analysis:
                wfEntity = new RenewalAnalysis();
                break;

            case FlowCode.Renewal_ClearanceReport:
                wfEntity = new RenewalClearanceReport();
                break;

            case FlowCode.Renewal_ConfirmLetter:
                wfEntity = new RenewalConfirmLetter();
                break;

            case FlowCode.Renewal_LegalApproval:
                wfEntity = new RenewalLegalApproval();
                break;

            case FlowCode.Renewal_Package:
                wfEntity = new RenewalPackage();
                break;

            case FlowCode.Renewal_GBMemo:
                wfEntity = new RenewalGBMemo();
                break;

            case FlowCode.Reimage:
                wfEntity = new ReimageInfo();
                wfEntity.IsMainProject = true;
                break;

            case FlowCode.Reimage_ConsInfo:
                wfEntity = new ReimageConsInfo();
                break;

            case FlowCode.Reimage_Summary:
                wfEntity = new ReimageSummary();
                break;

            case FlowCode.Reimage_Package:
                wfEntity = new ReimagePackage();
                break;

            case FlowCode.Reimage_ConsInvtChecking:
                wfEntity = new ReimageConsInvtChecking();
                break;

            case FlowCode.Reimage_GBMemo:
                wfEntity = new ReimageGBMemo();
                break;
            }
            return(wfEntity);
        }
Ejemplo n.º 17
0
        public IHttpActionResult RecallProject(PostSimpleWorkflowData postData)
        {
            ApiProxy.SetCookies(Request.RequestUri.Host, HttpContext.Current.Request.Cookies);
            var rootPath = string.Concat(HttpContext.Current.Request.Url.Scheme, @"://", HttpContext.Current.Request.Url.Authority, HttpContext.Current.Request.ApplicationPath);

            switch (postData.FlowCode)
            {
                #region Closure
            case FlowCode.Closure_WOCheckList:
            {
                var entity = ClosureWOCheckList.Get(postData.ProjectId);
                entity.Comments = postData.ProjectComment;
                var postDataBytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(entity));
                ApiProxy.Call(rootPath + "api/ClosureWOCheckList/Recall", "POST", null, postDataBytes);
            }
            break;

            case FlowCode.Closure_LegalReview:
            {
                var entity = ClosureLegalReview.Get(postData.ProjectId);
                entity.Comments = postData.ProjectComment;
                var postDataBytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(entity));
                ApiProxy.Call(rootPath + "api/LegalReview/Recall", "POST", null, postDataBytes);
            }
            break;

            case FlowCode.Closure_ClosurePackage:
            {
                var entity = ClosurePackage.Get(postData.ProjectId);
                entity.Comments = postData.ProjectComment;
                var postDataBytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(entity));
                ApiProxy.Call(rootPath + "api/ClosurePackage/Recall", "POST", null, postDataBytes);
            }
            break;

            case FlowCode.Closure_ConsInvtChecking:
            {
                var entity = ClosureConsInvtChecking.Get(postData.ProjectId);
                entity.Comments = postData.ProjectComment;
                var postDataBytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(entity));
                ApiProxy.Call(rootPath + "api/ClosureConsInvtChecking/Recall", "POST", null, postDataBytes);
            }
            break;

            case FlowCode.Closure_ClosureTool:
            {
                var entity = ClosureTool.Get(postData.ProjectId);
                entity.Comments = postData.ProjectComment;
                var postDataBytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(entity));
                ApiProxy.Call(rootPath + "api/closureTool/Recall", "POST", null, postDataBytes);
            }
            break;

                #endregion Closure
            default:
                var wfEntity = BaseWFEntity.GetWorkflowEntity(postData.ProjectId, postData.FlowCode);
                wfEntity.Recall(postData.ProjectComment);
                break;
            }
            return(Ok());
        }