Exemplo n.º 1
0
        public async Task <IActionResult> PutWorkflowDetail(int id, WorkflowDetail WorkflowDetail)
        {
            if (id != WorkflowDetail.WFId)
            {
                return(BadRequest());
            }
            _context.Entry(WorkflowDetail).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!WorkflowDetailExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 2
0
            public async Task <Unit> Handle(Command request, CancellationToken cancellationToken)
            {
                var newProjectWf = new ProjectWf(request.ProjectId, request.ProjectName);

                db.ProjectWfs.Add(newProjectWf);
                await db.SaveChangesAsync(cancellationToken);

                var processInstanceId = await bpmnService.StartProcessFor(newProjectWf);

                newProjectWf.AssociateWithProcessInstance(processInstanceId);
                await db.SaveChangesAsync(cancellationToken);

                return(Unit.Value);
            }
Exemplo n.º 3
0
        public async Task <IActionResult> Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                Token token = await _context.Tokens.FirstOrDefaultAsync(u => u.TToken == model.Token);

                if (token != null)
                {
                    User user = await _context.Users.FirstOrDefaultAsync(u => u.UMail == model.Email);

                    if (user == null)
                    {
                        _context.Users.Add(new User {
                            UMail = model.Email, UPassword = MD5Hash(model.Password), UName = model.Name, RId = 2
                        });
                        _context.Tokens.Remove(token);
                        await _context.SaveChangesAsync();

                        //EmailService emailService = new EmailService();
                        //await emailService.SendEmailAsync(model.Email, "Вас вітає СЕД Факт!", "Ви зареєструвалися в системі електронного документообігу Факт.");

                        //await Authenticate(user);

                        return(RedirectToAction("Index", "Home"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Некорректные логин и(или) пароль");
                    }
                }
            }
            return(View(model));
        }
Exemplo n.º 4
0
        public async Task <Workflow> Create(WorkflowBaseData workflowBaseData)
        {
            var workflow = new Workflow()
            {
                InstanceId   = workflowBaseData.InstanceId,
                CreatedAt    = DateTime.Now,
                Status       = WorkflowStatus.Created.ToString(),
                Participants = workflowBaseData.Participants?.Select(m => new Participant()
                {
                    Name   = m,
                    Status = ParticipantStatus.Waiting.ToString()
                }).ToList()
            };

            var result = await _context.Workflows.AddAsync(workflow);

            await _context.SaveChangesAsync();

            return(result.Entity);
        }
Exemplo n.º 5
0
            public async Task <Guid> Handle(Command request, CancellationToken cancellationToken)
            {
                using var tx = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);
                var projectWf = await db.ProjectWfs.FirstAsync(i => i.Id == request.ObjectWfId, cancellationToken);

                projectWf.MarkProjectCreatedInJira();
                await db.SaveChangesAsync(cancellationToken);

                await bpmnService.SendMessageInvoicePaid(projectWf);

                tx.Complete();
                return(projectWf.Id);
            }
Exemplo n.º 6
0
            public async Task <Guid> Handle(Command request, CancellationToken cancellationToken)
            {
                using var tx = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);

                var projectWf = await db.ProjectWfs.FirstAsync(p => p.Id == request.ObjectWfId, cancellationToken);

                projectWf.Accept();

                await db.SaveChangesAsync(cancellationToken);

                tx.Complete();

                return(projectWf.Id);
            }
Exemplo n.º 7
0
            public async Task <Unit> Handle(ProjectPrepared.Command request, CancellationToken cancellationToken)
            {
                using var tx = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);

                var projectWf = await db.ProjectWfs.FirstAsync(p => p.Id == request.ObjectWfId, cancellationToken);

                projectWf.Prepare();

                await db.SaveChangesAsync(cancellationToken);

                //необходимо обязательно удалять Task из Camunda при окончании Пользовательского перехода,
                //иначе не даст перевести в следующий статус в Camunda
                await bpmnService.CompleteTask(request.TaskId, projectWf);

                tx.Complete();

                return(Unit.Value);
            }
Exemplo n.º 8
0
            public async Task <Unit> Handle(Command request, CancellationToken cancellationToken)
            {
                using var tx = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);

                var projectWf = await db.ProjectWfs.FirstOrDefaultAsync(p => p.Id == request.ObjectWfId, cancellationToken);

                var(notificationText, targetGroup) = projectWf.Status switch
                {
                    ProjectStatus.Rejected =>
                    ($"Your projectWf {projectWf.Id} be rejected", "User"),
                    _ =>
                    ("", "")
                };

                db.Notifications.Add(new Notification(notificationText, targetGroup, null));

                await db.SaveChangesAsync(cancellationToken);

                tx.Complete();

                return(Unit.Value);
            }
        public async Task <IActionResult> TokenTable(int tokenCount)
        {
            for (int i = 0; i < tokenCount; i++)
            {
                string tokens = RandomString();
                Token  token  = await _context.Tokens.FirstOrDefaultAsync(u => u.TToken == tokens);

                if (token == null)
                {
                    _context.Tokens.Add(new Token {
                        TToken = tokens
                    });
                }
                else
                {
                    i--;
                    continue;
                }
            }
            await _context.SaveChangesAsync();

            return(TokenTable());
        }