Exemple #1
0
        public IActionResult ApproveClaim([FromBody] SolveFormParam param)
        {
            // change state
            var formlist = _context.ClaimFormChemicalMap
                           .Where(u => u.ClaimFormId == param.FormId)
                           .Include(u => u.Chemical)
                           .Include(u => u.ClaimForm)
                           .ToList();

            if (formlist.Count <= 0)
            {
                _logger.LogError("ClaimForm not found");
                throw new NullReferenceException();
            }
            if (formlist[0].ClaimForm.State != FormState.InProcess)
            {
                return(NotFound("已有其他老师处理过该申请。"));
            }
            formlist[0].ClaimForm.HandlerId   = param.UserId;
            formlist[0].ClaimForm.HandlerName = param.UserName;
            formlist[0].ClaimForm.State       = Utils.FormState.Approved;
            foreach (var item in formlist)
            {
                item.Chemical.State = ChemicalState.InUse;
            }
            // change msg status
            var oldmsg = _context.NotificationMessages.Where(m => m.FormId == param.FormId && m.FormType == FormType.ClaimForm).ToList();

            if (oldmsg.Count != 0)
            {
                foreach (var m in oldmsg)
                {
                    m.IsSolved = true;
                }
            }
            // send msg
            var msgs = _context.WorkFlowStatusChangeMessages.Where(u => u.RelatedId == param.FormId).ToList();

            if (msgs.Count > 0)
            {
                foreach (var msg in msgs)
                {
                    msg.IsRead = false;
                }
            }
            else
            {
                var msg = new StatusChangeMessage
                {
                    RelatedId   = param.FormId,
                    RelatedType = RelatedTypeEnum.ClaimForm,
                    IsRead      = false,
                    UserId      = formlist[0].ClaimForm.UserId
                };
                _context.WorkFlowStatusChangeMessages.Add(msg);
            }
            _context.SaveChanges();
            return(Ok());
        }
Exemple #2
0
        public IActionResult ApproveFinancial([FromBody] SolveFormParam param)
        {
            // change state
            var form = _context.FinancialForms.Where(u => u.Id == param.FormId).Single();

            if (form.State != FormState.InProcess)
            {
                return(NotFound("已有其他老师处理过该申请。"));
            }
            form.HandlerId   = param.UserId;
            form.HandlerName = param.UserName;
            form.State       = FormState.Approved;
            var workflow = _context.WorkFlows.Where(u => u.Id == form.WorkFlowId).Single();
            var data     = util.StateRoute[workflow.State];

            workflow.State = data.Next[1];
            data           = util.StateRoute[workflow.State];
            // change msg status
            var oldmsg = _context.NotificationMessages.Where(m => m.FormId == param.FormId && m.FormType == FormType.FinancialForm).ToList();

            if (oldmsg.Count != 0)
            {
                foreach (var m in oldmsg)
                {
                    m.IsSolved = true;
                }
            }
            // send msg
            var msgs = _context.WorkFlowStatusChangeMessages.Where(u => u.RelatedId == workflow.Id).ToList();

            if (msgs.Count > 0)
            {
                foreach (var msg in msgs)
                {
                    msg.IsRead = false;
                }
            }
            else
            {
                var msg = new StatusChangeMessage
                {
                    RelatedId   = workflow.Id,
                    RelatedType = RelatedTypeEnum.WorkFlow,
                    IsRead      = false,
                    UserId      = workflow.UserId
                };
                _context.WorkFlowStatusChangeMessages.Add(msg);
            }
            _context.SaveChanges();
            return(Ok());
        }
 public IActionResult RejectFinancial([FromBody] SolveFormParam param)
 {
     try
     {
         HttpWrapper.CallServiceByPost("/api/financial/reject",
                                       JsonSerializer.Serialize(param));
         return(Ok());
     }
     catch (Exception e)
     {
         _logger.LogError(e.Message);
         return(NotFound(e.Message));
     }
 }
Exemple #4
0
 public IActionResult ReturnChemicals([FromBody] SolveFormParam param)
 {
     try
     {
         RpcWrapper.CallServiceByPost("/api/claim/return",
                                      JsonSerializer.Serialize(param));
         return(Ok());
     }
     catch (Exception e)
     {
         _logger.LogError(e.Message);
         return(NotFound(e.Message));
     }
 }
Exemple #5
0
        public IActionResult RejectClaim([FromBody] SolveFormParam param)
        {
            var form = _context.ClaimForms.Where(u => u.Id == param.FormId).Single();

            if (form.State != FormState.InProcess)
            {
                return(NotFound("已有其他老师处理过该申请。"));
            }
            form.State       = Utils.FormState.Rejected;
            form.HandlerName = param.UserName;
            // change msg status
            var oldmsg = _context.NotificationMessages.Where(m => m.FormId == param.FormId && m.FormType == FormType.ClaimForm).ToList();

            if (oldmsg.Count != 0)
            {
                foreach (var m in oldmsg)
                {
                    m.IsSolved = true;
                }
            }
            // send msg
            var msgs = _context.WorkFlowStatusChangeMessages.Where(u => u.RelatedId == param.FormId).ToList();

            if (msgs.Count > 0)
            {
                foreach (var msg in msgs)
                {
                    msg.IsRead = false;
                }
            }
            else
            {
                var msg = new StatusChangeMessage
                {
                    RelatedId   = param.FormId,
                    RelatedType = RelatedTypeEnum.ClaimForm,
                    IsRead      = false,
                    UserId      = form.UserId
                };
                _context.WorkFlowStatusChangeMessages.Add(msg);
            }
            _context.SaveChanges();
            return(Ok());
        }
 public IActionResult RejectDeclear([FromBody] SolveFormParam param)
 {
     if (UserRoleCache.TryGetUserRole(HttpContext.Request.Headers["certification"], out UserRoleResult result))
     {
         if (!result.Roles.Exists(r => r.LabId == param.LabId))
         {
             return(Unauthorized());
         }
     }
     try
     {
         HttpWrapper.CallServiceByPost("/api/declaration/reject",
                                       JsonSerializer.Serialize(param));
         return(Ok());
     }
     catch (Exception e)
     {
         _logger.LogError(e.Message);
         return(NotFound(e.Message));
     }
 }
        public IActionResult ReturnChemicals([FromBody] SolveFormParam param)
        {
            // change state
            var formlist = _context.ClaimFormChemicalMap
                           .Where(u => u.ClaimFormId == param.FormId)
                           .Include(u => u.Chemical)
                           .Include(u => u.ClaimForm)
                           .ToList();

            if (formlist.Count <= 0)
            {
                _logger.LogError("ClaimForm not found");
                throw new NullReferenceException();
            }
            formlist[0].ClaimForm.RealReturnTime = DateTime.Now;
            foreach (var item in formlist)
            {
                item.ClaimForm.State = FormState.Returned;
                item.Chemical.State  = ChemicalState.Lab;
            }
            return(Ok());
        }