Exemplo n.º 1
0
        // PUT api/RemindRegister/5
        public IHttpActionResult PutRemindRegister(Guid id, RemindRegister remindregister)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }



            db.Entry(remindregister).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RemindRegisterExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult ProcessClosureWOCheckList(ClosureWOCheckList entity)
        {
            int procInstID = entity.ProcInstID.Value;

            string actionLower = entity.Action.ToLower();



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

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

            if (actionLower.Equals(ProjectAction.Return, StringComparison.CurrentCultureIgnoreCase))
            {
                TaskWork.Finish(e => e.RefID == entity.ProjectId &&
                                e.TypeCode == FlowCode.Closure_WOCheckList &&
                                e.Status == TaskWorkStatus.UnFinish &&
                                e.K2SN != entity.SN);
            }

            if (actionLower == "resubmit")
            {
                List <ProcessDataField> _listDataFields = new List <ProcessDataField>();

                _listDataFields.Add(new ProcessDataField("dest_PMSupervisor", entity.PMSupervisorAccount));                                                                                    // 工程PM直属上级
                _listDataFields.Add(new ProcessDataField("dest_MCCLApprovers", string.Join(";", entity.MCCLApproverAccount, entity.MCCLITApproverAccount, entity.MCCLMCCLEqApproverAccount))); // MCCL Approvers
                K2FxContext.Current.ApprovalProcess(entity.SN, account, _action.ToString(), comments, _listDataFields);

                entity.Save();
                _db.Entry(entity).State = EntityState.Modified;
                _db.SaveChanges();
            }
            else
            {
                K2FxContext.Current.ApprovalProcess(entity.SN, account, _action.ToString(), comments);
            }



            if (actionLower == "submit")
            {
            }
            else if (actionLower == "resubmit")
            {
                ProjectInfo.FinishNode(entity.ProjectId, FlowCode.Closure_WOCheckList,
                                       NodeCode.Closure_WOCheckList_ClosingCost);
            }

            //ProjectInfo.UpdateProjectStatus(entity.ProjectId, FlowCode.Closure_WOCheckList, entity.GetProjectStatus(entity.Action));
            SaveCommers(entity, _action.ToString(), ProjectCommentStatus.Submit);

            return(Ok(entity.Status));
        }
Exemplo n.º 3
0
        public IHttpActionResult PostRemind(Remind remind)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (remind.Id == new Guid())
            {
                remind.Id         = Guid.NewGuid();
                remind.CreateTime = DateTime.Now;
                db.Remind.Add(remind);
            }
            else
            {
                db.Remind.Attach(remind);
                db.Entry(remind).State = EntityState.Modified;
            }

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (RemindExists(remind.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = remind.Id }, remind));
        }
Exemplo n.º 4
0
        public IHttpActionResult Save(Dictionary dic)
        {
            if (dic.Id > 0)
            {
                dic.LastUpdateTime = DateTime.Now;
                _db.Dictionary.Attach(dic);
                _db.Entry(dic).State = EntityState.Modified;
            }
            else
            {
                var list = _db.Dictionary.Where(c => c.Code == dic.Code).ToList();
                if (list.Count > 0)
                {
                    throw new Exception("编码不能重复!");
                }


                dic.CreateTime = DateTime.Now;
                //dic.CreateUserAccount = RequestContext.
                _db.Dictionary.Add(dic);
            }
            _db.SaveChanges();
            return(Ok(dic));
        }
Exemplo n.º 5
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());
        }
Exemplo n.º 6
0
        public IHttpActionResult Send(PostClosureMemoModel model)
        {
            var actor = ProjectUsers.GetProjectUser(model.Entity.ProjectId, ProjectUserRoleCode.AssetActor);

            using (TransactionScope tranScope = new TransactionScope())
            {
                Save(model.Entity);
                ClosureTool closureTool        = ClosureTool.FirstOrDefault(ct => ct.ProjectId == model.Entity.ProjectId);
                string      compensationAwards = "";
                string      compensation       = "暂无数据";
                if (closureTool != null && closureTool.Compensation.HasValue)
                {
                    compensationAwards = closureTool.Compensation.Value > 0 ? "Yes" : "No";
                    compensation       = closureTool.Compensation.Value.ToString("N");
                }
                Dictionary <string, string> pdfData = new Dictionary <string, string>();
                pdfData.Add("WorkflowName", "Closure");
                pdfData.Add("ProjectID", model.Entity.ProjectId);
                pdfData.Add("RegionNameENUS", model.Entity.RegionNameENUS);
                pdfData.Add("RegionNameZHCN", model.Entity.RegionNameZHCN);
                pdfData.Add("MarketNameENUS", model.Entity.MarketNameENUS);
                pdfData.Add("MarketNameZHCN", model.Entity.MarketNameZHCN);
                pdfData.Add("ProvinceNameENUS", model.Entity.ProvinceNameENUS);
                pdfData.Add("ProvinceNameZHCN", model.Entity.ProvinceNameZHCN);
                pdfData.Add("CityNameENUS", model.Entity.CityNameENUS);
                pdfData.Add("CityNameZHCN", model.Entity.CityNameZHCN);
                pdfData.Add("StoreNameENUS", model.Entity.StoreNameENUS);
                pdfData.Add("StoreNameZHCN", model.Entity.StoreNameZHCN);
                pdfData.Add("StoreAddressENUS", model.Entity.StoreAddressENUS);
                pdfData.Add("StoreAddressZHCN", model.Entity.StoreAddressZHCN);
                pdfData.Add("USCode", model.Entity.USCode);
                pdfData.Add("OpenDate", model.Entity.OpenDate.Value.ToString("yyyy-MM-dd"));
                pdfData.Add("ClosureDate", model.Entity.ClosureDate.Value.ToString("yyyy-MM-dd"));
                pdfData.Add("ClosureNature", model.Entity.ClosureNature.ToString());
                if (model.Entity.BecauseOfReimaging.HasValue)
                {
                    pdfData.Add("BecauseOfReimaging", model.Entity.BecauseOfReimaging.Value ? "Yes" : "No");
                }
                else
                {
                    pdfData.Add("BecauseOfReimaging", "");
                }

                if (model.Entity.BecauseOfRemodel.HasValue)
                {
                    pdfData.Add("BecauseOfRemodel", model.Entity.BecauseOfRemodel.Value ? "Yes" : "No");
                }
                else
                {
                    pdfData.Add("BecauseOfRemodel", "");
                }

                if (model.Entity.BecauseOfDespute.HasValue)
                {
                    pdfData.Add("BecauseOfDespute", model.Entity.BecauseOfDespute.Value ? "Yes" : "No");
                }
                else
                {
                    pdfData.Add("BecauseOfDespute", "");
                }

                if (model.Entity.BecauseOfRedevelopment.HasValue)
                {
                    pdfData.Add("BecauseOfRedevelopment", model.Entity.BecauseOfRedevelopment.Value ? "Yes" : "No");
                }
                else
                {
                    pdfData.Add("BecauseOfRedevelopment", "");
                }

                if (model.Entity.BecauseOfPlanedClosure.HasValue)
                {
                    pdfData.Add("BecauseOfPlanedClosure", model.Entity.BecauseOfPlanedClosure.Value ? "Yes" : "No");
                }
                else
                {
                    pdfData.Add("BecauseOfPlanedClosure", "");
                }

                if (model.Entity.BecauseOfRebuild.HasValue)
                {
                    pdfData.Add("BecauseOfRebuild", model.Entity.BecauseOfRebuild.Value ? "Yes" : "No");
                }
                else
                {
                    pdfData.Add("BecauseOfRebuild", "");
                }

                pdfData.Add("BecauseOfOthers", model.Entity.BecauseOfOthers);

                if (model.Entity.PermanentCloseOpportunity.HasValue)
                {
                    pdfData.Add("PermanentCloseOpportunity", model.Entity.PermanentCloseOpportunity.Value ? "Yes" : "No");
                }
                else
                {
                    pdfData.Add("PermanentCloseOpportunity", "");
                }

                if (model.Entity.HasRelocationPlan.HasValue)
                {
                    pdfData.Add("HasRelocationPlan", model.Entity.HasRelocationPlan.Value ? "Yes" : "No");
                }
                else
                {
                    pdfData.Add("HasRelocationPlan", "");
                }

                pdfData.Add("PipelineName", model.Entity.PipelineName);
                pdfData.Add("CompensationAwarded", compensationAwards);
                pdfData.Add("Compensation", compensation);
                string pdfPath = HtmlConversionUtility.HtmlConvertToPDF(HtmlTempalteType.ClosureMemo, pdfData, null);
                EmailSendingResultType result;
                //邮件模板中的数据
                Dictionary <string, string> bodyValues = new Dictionary <string, string>();
                //邮件内容中的键值对
                //bodyValues.Add("ApplicantName", ClientCookie.UserNameENUS);//--提交人
                bodyValues.Add("StoreCode", model.Entity.USCode);
                bodyValues.Add("StoreName", model.Entity.StoreNameENUS);
                bodyValues.Add("Actor", actor.RoleNameENUS);            ////--呈递人
                bodyValues.Add("WorkflowName", Constants.Closure_Memo); ////--流程名称
                bodyValues.Add("ProjectName", Constants.Closure);       //项目名称
                var webRootUrl = ConfigurationManager.AppSettings["webHost"];
                var viewPage   = string.Format("{0}Closure/Main#/ClosureMemo/ClosureMemoView?projectId={1}",
                                               webRootUrl, model.Entity.ProjectId);
                bodyValues.Add("FormUrl", viewPage);

                //调用邮件服务发送邮件
                using (EmailServiceClient client = new EmailServiceClient())
                {
                    EmailMessage  message = new EmailMessage();
                    StringBuilder sbTo    = new StringBuilder();
                    Dictionary <string, string> attachments = new Dictionary <string, string>();
                    foreach (Employee emp in model.Receivers)
                    {
                        if (sbTo.Length > 0)
                        {
                            sbTo.Append(";");
                        }
                        if (!string.IsNullOrEmpty(emp.Mail))
                        {
                            sbTo.Append(emp.Mail);
                        }
                    }
                    if (sbTo.Length > 0)
                    {
                        sbTo.Append(";");
                    }
                    message.EmailBodyValues = bodyValues;
                    attachments.Add(pdfPath, model.Entity.USCode + " " + FlowCode.Closure_Memo + ".pdf");
                    message.AttachmentsDict = attachments;
                    message.To           = sbTo.ToString();
                    message.TemplateCode = EmailTemplateCode.GBMemoNotification;
                    result = client.SendNotificationEmail(message);
                }

                if (!result.Successful)
                {
                    return(BadRequest(result.ErrorMessage + " " + pdfPath));
                }

                //store关闭不在这里设置,需要判断project状态和closuredata
                //var store = StoreBasicInfo.GetStorInfo(model.Entity.USCode);
                //store.StoreStatus = "suoya301003";
                //store.statusName = "Closed";
                //store.Update();


                if (model.Entity.ClosureNature == ClosureNatureType.Permanent)
                {
                    //选项为永久关闭并且发送成功后关闭任务
                    McdAMEntities _db  = new McdAMEntities();
                    var           task = _db.TaskWork.FirstOrDefault(e => e.ReceiverAccount == ClientCookie.UserCode && e.Status == 0 && e.SourceCode == FlowCode.Closure && e.TypeCode == FlowCode.Closure_Memo && e.RefID == model.Entity.ProjectId);
                    if (task != null)
                    {
                        task.Status     = TaskWorkStatus.K2ProcessApproved;
                        task.FinishTime = DateTime.Now;
                        task.Url        = SiteInfo.GetProjectViewPageUrl(FlowCode.Closure_Memo, task.RefID);

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

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

                        ProjectInfo.FinishNode(model.Entity.ProjectId, FlowCode.Closure_Memo, NodeCode.Closure_ClosureMemo_Input);
                        ProjectInfo.FinishNode(model.Entity.ProjectId, FlowCode.Closure_Memo, NodeCode.Closure_ClosureMemo_SendMemo, ProjectStatus.Finished);

                        #region Memo完成后,设定计划任务
                        var closureConsInvtChecking = new ClosureConsInvtChecking();
                        closureConsInvtChecking.GenerateConsInvtCheckingTask(model.Entity.ProjectId);

                        if (model.Entity.ClosureDate.HasValue)
                        {
                            ScheduleLog.UpdateStoreStatusSchedule(model.Entity.USCode, model.Entity.ProjectId, model.Entity.ClosureDate.Value, ClientCookie.UserCode);
                        }
                        #endregion
                    }
                    ProjectInfo.CompleteMainIfEnable(model.Entity.ProjectId);
                }
                tranScope.Complete();
                return(Ok());
            }
        }