Ejemplo n.º 1
0
 public IActionResult Create(ApprovalDto dto)
 {
     dto.ApplicantNo   = CurrentUser.No;
     dto.ApplicantName = CurrentUser.Name;
     dto.DepartmentId  = CurrentUser.DepartmentId;
     return(View(dto));
 }
Ejemplo n.º 2
0
        public IActionResult Edit(int id, IFormCollection collection)
        {
            var entity = new ApprovalDto();

            TryUpdateModelAsync(entity);

            if (ModelState.IsValid)
            {
                if (entity.Id != id)
                {
                    ModelState.AddModelError(string.Empty, "id参数无效");
                }
                else if (entity.ApplicantNo != CurrentUser.No)
                {
                    ModelState.AddModelError(string.Empty, "无权编辑此记录");
                }
                else
                {
                    var result = _service.Update(id, entity);
                    if (result > 0)
                    {
                        return(RedirectToAction(nameof(Index)));
                    }

                    ModelState.AddModelError(string.Empty, "更新失败");
                }
            }

            return(View(entity));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="id"></param>
        /// <param name="dto"></param>
        /// <returns></returns>
        public int Update(int id, ApprovalDto dto)
        {
            if (dto.Id != id)
            {
                return(0);
            }

            var entity = _db.Load <Approval>(id);

            if (entity == null)
            {
                return(0);
            }

            entity.CustomerName        = dto.CustomerName;
            entity.CustomerJob         = dto.CustomerJob;
            entity.CustomerUnit        = dto.CustomerUnit;
            entity.ContactNumber       = dto.ContactNumber;
            entity.ProjectName         = dto.ProjectName;
            entity.ExpectedClosingCost = dto.ExpectedClosingCost;
            entity.ExpectedClosingDate = dto.ExpectedClosingDate;
            entity.ActualClosingProfit = dto.ExpectedClosingProfit;
            entity.AppliedAmount       = dto.AppliedAmount;
            entity.AppliedReason       = dto.AppliedReason;

            return(_db.Update(entity));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Fire2([FromBody] ApprovalDto dto)
        {
            var eventData = new ApprovalEventData {
                UserName = dto.UserName, ApprovalResult = dto.ApprovalResult
            };

            await this._host.PublishEvent(dto.EventName, ConstValues.Approval2EventKey, JsonConvert.SerializeObject(eventData));

            return(Json(new { message = "approval event published." }));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Approval([FromBody] ApprovalDto obj)
        {
            string token = Request.Headers["Authorization"];

            var userID = Extensions.GetDecodeTokenByProperty(token, "nameid").ToInt();

            var model = await _actionPlanService.Approve(obj.id, userID, obj.KPILevelCode, obj.CategoryID);

            await _hubContext.Clients.All.SendAsync("ReceiveMessage", "user", "message");


            if (model.Item1.Count > 0 && await _settingService.IsSendMail("APPROVAL"))
            {
                if (model.Item2 == true)
                {
                    Thread thread = new Thread(async() =>
                    {
                        string URL     = _configuaration.GetSection("AppSettings:URL").ToSafetyString();
                        var data       = model.Item1.DistinctBy(x => x);
                        string content = @"<p><b>*PLEASE DO NOT REPLY* this email was automatically sent from the KPI system.</b></p> 
                                        <p>The account <b>" + data.First()[0].ToTitleCase() + "</b> approved the action plan <b>'" + data.First()[3] + "'</b> </p>" +
                                         "<p>Link: <a href='" + _configuration["AppSettings:URL"] + model.Item3 + "'>Click Here</a></p>" +
                                         "<br/>" +

                                         @"<p><b>*請勿回信*這封信是KPI系統自動寄出.</b></p> 
                                        <p>帳號<b>" + data.First()[0].ToTitleCase() + "</b> 已經核准了行動方案 <b>'" + data.First()[3] + "'</b> </p>" +
                                         "<p>連結: <a href='" + _configuration["AppSettings:URL"] + model.Item3 + "'>點選這裡</a></p>"
                        ;
                        await _mailHelper.SendEmailRange(data.Select(x => x[1]).ToList(), "[KPI System-05] Approved (已核准)", content);
                    });
                    thread.Start();
                }
                else
                {
                    Thread thread = new Thread(async() =>
                    {
                        string URL     = _configuaration.GetSection("AppSettings:URL").ToSafetyString();
                        var data       = model.Item1.DistinctBy(x => x);
                        string content = @"<p><b>*PLEASE DO NOT REPLY* this email was automatically sent from the KPI system.</b></p> 
                                        <p>The account <b>" + data.First()[0].ToTitleCase() + "</b> not approve the action plan <b>'" + data.First()[3] + "'</b> </p>" +
                                         "<p>Link: <a href='" + _configuration["AppSettings:URL"] + model.Item3 + "'>Click Here</a></p>" +
                                         "<br/>" +

                                         @"<p><b>*請勿回信*這封信是KPI系統自動寄出.</b></p> 
                                        <p>帳號<b>" + data.First()[0].ToTitleCase() + "</b> 取消核准行動方案 <b>'" + data.First()[3] + "'</b> </p>" +
                                         "<p>連結: <a href='" + _configuration["AppSettings:URL"] + model.Item3 + "'>點選這裡</a></p>"
                        ;
                        await _mailHelper.SendEmailRange(data.Select(x => x[1]).ToList(), "[KPI System-05] Not Approved", content);
                    });
                    thread.Start();
                }
            }
            return(Ok(new { status = true, isSendmail = true }));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 创建
        /// </summary>
        /// <param name="dto"></param>
        /// <param name="userNo"></param>
        /// <param name="userName"></param>
        /// <param name="departmentId"></param>
        /// <returns></returns>
        public int Create(ApprovalDto dto, string userNo, string userName, int departmentId)
        {
            var entity = _mapper.Map <Approval>(dto);

            entity.ApplicantNo   = userNo;
            entity.ApplicantName = userName;
            entity.DepartmentId  = departmentId;
            entity.ApproveStep   = 0;
            entity.ApproveResult = 0;
            entity.CreateAt      = DateTime.Now;

            return(_db.Insert(entity));
        }
Ejemplo n.º 7
0
 public CompanyPost(string userId, ApprovalDto data)
 {
     this.companyPostId   = data.request.companyPostRequestId;
     this.companyId       = data.request.companyId;
     this.companyUserId   = userId;
     this.companyName     = data.companyName;
     this.postTitle       = data.request.postTitle;
     this.postSubTitle    = data.request.postSubTitle;
     this.postDescription = data.request.postDescription;
     this.videoUrl        = data.request.videoUrl;
     this.links           = data.request.links;
     this.lastUpdated     = new DateTime().ToString();
     this.approvedBy      = data.approvedBy;
     this.validTill       = data.request.validTill;
     this.isActive        = true;
 }
Ejemplo n.º 8
0
        public IActionResult Create(IFormCollection collection)
        {
            var entity = new ApprovalDto();

            TryUpdateModelAsync(entity);
            if (ModelState.IsValid)
            {
                var id = _service.Create(entity, CurrentUser.No, CurrentUser.Name, CurrentUser.DepartmentId);
                if (id > 0)
                {
                    return(RedirectToAction(nameof(Index)));
                }

                ModelState.AddModelError(string.Empty, "创建失败");
            }
            return(View(entity));
        }