示例#1
0
        public IActionResult GetDeclarationFormByWorkFlow([FromQuery] long workflowid)
        {
            var form = _context.DeclarationForms.Where(u => u.WorkFlowId == workflowid).Single();
            var ret  = new PostDeclarationFormParam()
            {
                Form      = form,
                Chemicals = _context.Chemicals.Where(c => c.WorkFlowId == form.WorkFlowId).ToList()
            };

            return(Ok(ret));
        }
示例#2
0
 public IActionResult Declear([FromBody] PostDeclarationFormParam param)
 {
     try
     {
         param.Form.SubmitTime = DateTime.Now;
         HttpWrapper.CallServiceByPost("/api/declaration/apply",
                                       JsonSerializer.Serialize(param));
         return(Ok());
     }
     catch (Exception e)
     {
         _logger.LogError(e.Message);
         return(NotFound(e.Message));
     }
 }
示例#3
0
        public IActionResult PostDeclarationForm([FromBody] PostDeclarationFormParam param)
        {
            var form = param.Form;

            form.State = FormState.InProcess;
            // first create a workflow
            var workflow = new WorkFlow
            {
                UserId      = param.Form.UserId,
                StartTime   = DateTime.Now,
                State       = "declearing",
                Chemicals   = param.Chemicals,
                Description = param.Form.Reason,
                UserName    = param.Form.UserName
            };

            _context.WorkFlows.Add(workflow);
            _context.SaveChanges();
            // create form_workflow_relationship
            form.WorkFlowId = workflow.Id;
            _context.DeclarationForms.Add(form);
            _context.SaveChanges();
            var role = GetNotifyRoleId(util.StateRoute[workflow.State].RoleName, param.Form.LabId);
            // send message to role
            var msg = new NotificationMessage
            {
                FormId   = form.Id,
                FormType = FormType.DeclarationForm,
                IsSolved = false,
                RoleId   = role
            };

            _context.NotificationMessages.Add(msg);
            _context.SaveChanges();
            return(Ok());
        }