예제 #1
0
        public void Can_Update_Instance()
        {
            Guid         guid    = Guid.NewGuid();
            const string comment = "This here is an update";

            _service.InsertInstance(Scaffold.Instance(guid, 1));

            WorkflowInstancePoco instance = _service.GetByGuid(guid);

            instance.AuthorComment = comment;

            _service.UpdateInstance(instance);
            WorkflowInstancePoco updatedInstance = _service.GetByGuid(guid);

            Assert.Equal(comment, updatedInstance.AuthorComment);
        }
예제 #2
0
        public string GetNotifications(Guid instanceGuid, int emailType)
        {
            try
            {
                WorkflowInstancePoco instance = _instancesService.GetByGuid(instanceGuid);

                Notifications.Send(instance, (EmailType)emailType);

                return("done - check the mail drop folder");
            }
            catch (Exception e)
            {
                return(ViewHelpers.ApiException(e).ToString());
            }
        }
예제 #3
0
        public string GetNotifications(Guid instanceGuid, int emailType)
        {
            try
            {
                WorkflowInstancePoco instance = _instancesService.GetByGuid(instanceGuid);

                _emailer.Send(instance, (EmailType)emailType);

                return($"Notifications sent for { instance.Id }. Check the mail pickup folder.");
            }
            catch (Exception e)
            {
                return(ViewHelpers.ApiException(e).ToString());
            }
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="instanceGuid"></param>
        /// <returns></returns>
        private WorkflowInstancePoco GetInstance(Guid instanceGuid)
        {
            WorkflowInstancePoco instance = _instancesService.GetByGuid(instanceGuid);

            instance.SetScheduledDate();

            // TODO -> fix this
            List <WorkflowTaskInstancePoco> tasks = _tasksService.GetTasksWithGroupByInstanceGuid(instance.Guid);

            if (tasks.Any())
            {
                instance.TaskInstances = tasks;
            }

            return(instance);
        }
예제 #5
0
        public string GetNotifications(Guid instanceGuid, int emailType)
        {
            try
            {
                WorkflowInstancePoco instance = _instancesService.GetByGuid(instanceGuid);

                var node = _utility.GetPublishedContent(1078);

                _notifications.Send(instance, (EmailType)emailType);

                return(node.Name);
            }
            catch (Exception e)
            {
                return(ViewHelpers.ApiException(e).ToString());
            }
        }
예제 #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="instanceGuid"></param>
        /// <returns></returns>
        private WorkflowInstancePoco GetInstance(Guid instanceGuid)
        {
            WorkflowInstancePoco instance = _instancesService.GetByGuid(instanceGuid);

            instance.SetScheduledDate();

            // TODO -> fix this
            List <WorkflowTaskInstancePoco> tasks = _tasksService.GetTasksWithGroupByInstanceGuid(instance.Guid);

            if (tasks.Any())
            {
                // ordering by descending id to allow for cases with multiple rejections
                // most recent will be highest id, obviously...
                instance.TaskInstances = tasks.OrderByDescending(t => t.Id).ToList();
            }

            return(instance);
        }
예제 #7
0
        public IHttpActionResult GetTasksByInstanceGuid(Guid guid)
        {
            try
            {
                List <WorkflowTaskInstancePoco> tasks    = _tasksService.GetTasksWithGroupByInstanceGuid(guid);
                WorkflowInstancePoco            instance = _instancesService.GetByGuid(guid);

                return(Json(new
                {
                    items = tasks,
                    currentStep = tasks.Count(x => x.TaskStatus.In(TaskStatus.Approved, TaskStatus.NotRequired)) + 1, // value is for display, so zero-index isn't friendly
                    totalSteps = instance.TotalSteps
                }, ViewHelpers.CamelCase));
            }
            catch (Exception ex)
            {
                string msg = $"Error getting tasks by instance guid {guid}";
                Log.Error(msg, ex);
                return(Content(HttpStatusCode.InternalServerError, ViewHelpers.ApiException(ex, msg)));
            }
        }
예제 #8
0
        public async Task <HttpResponseMessage> GetNotifications(Guid instanceGuid, int emailType)
        {
            try
            {
                WorkflowInstancePoco instance = _instancesService.GetByGuid(instanceGuid);

                var msg = await _emailer.Send(instance, (EmailType)emailType);

                var response = new HttpResponseMessage
                {
                    Content = new StringContent(msg)
                };
                response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html");

                return(response);
            }
            catch (Exception e)
            {
                return(new HttpResponseMessage
                {
                    Content = new StringContent(ViewHelpers.ApiException(e).ToString())
                });
            }
        }