예제 #1
0
        public IActionResult Purchase([FromQuery] int workflowid)
        {
            _logger.LogInformation("purchase for workflow {1}", workflowid);
            var workflow = _context.WorkFlows
                           .Where(u => u.Id == workflowid)
                           .Include(u => u.Chemicals)
                           .Single();

            workflow.State = util.StateRoute[workflow.State].Next[1];
            foreach (var chemical in workflow.Chemicals)
            {
                chemical.State = ChemicalState.Lab;
            }
            StatusChangeMessage msg = new StatusChangeMessage
            {
                IsRead      = false,
                RelatedId   = workflowid,
                RelatedType = RelatedTypeEnum.WorkFlow,
                UserId      = workflow.UserId
            };

            _context.WorkFlowStatusChangeMessages.Add(msg);
            _context.SaveChanges();
            return(Ok());
        }
예제 #2
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());
        }
예제 #3
0
        private void OnExchangeStatusChange(StatusChangeMessage <EProviderStatus> x)
        {
            Application.Current.Dispatcher?.BeginInvoke(DispatcherPriority.Background, new Action(() =>
            {
                ExchangeStatus = x.Content;

                if (ExchangeStatus == EProviderStatus.LoginError)
                {
                    ExchangeLoginView loginView = new ExchangeLoginView();
                    loginView.ShowDialog();
                }
            }));
        }
예제 #4
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());
        }
예제 #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());
        }