Example #1
0
        public async Task <ActionResult> GetMessageBoxInstanceEvents(
            [FromRoute] int instanceOwnerPartyId,
            [FromRoute] Guid instanceGuid)
        {
            string instanceId = $"{instanceOwnerPartyId}/{instanceGuid}";

            string[] eventTypes = new string[]
            {
                InstanceEventType.Created.ToString(),
                     InstanceEventType.Deleted.ToString(),
                     InstanceEventType.Saved.ToString(),
                     InstanceEventType.Submited.ToString(),
                     InstanceEventType.Undeleted.ToString()
            };

            if (string.IsNullOrEmpty(instanceId))
            {
                return(BadRequest("Unable to perform query."));
            }

            List <InstanceEvent> result = await _instanceEventRepository.ListInstanceEvents(instanceId, eventTypes, null, null);

            // filtering out Create & delete data element event
            result = result.Where(r => string.IsNullOrEmpty(r.DataId) || r.EventType.Equals(InstanceEventType.Saved)).ToList();

            return(Ok(InstanceHelper.ConvertToSBLInstanceEvent(result)));
        }
Example #2
0
        public async Task <ActionResult> GetMessageBoxInstanceEvents(
            [FromRoute] int instanceOwnerPartyId,
            [FromRoute] Guid instanceGuid)
        {
            string instanceId = $"{instanceOwnerPartyId}/{instanceGuid}";

            string[] eventTypes =
            {
                InstanceEventType.Created.ToString(),
                InstanceEventType.Deleted.ToString(),
                InstanceEventType.Saved.ToString(),
                InstanceEventType.Submited.ToString(),
                InstanceEventType.Undeleted.ToString(),
                InstanceEventType.SubstatusUpdated.ToString()
            };

            if (string.IsNullOrEmpty(instanceId))
            {
                return(BadRequest("Unable to perform query."));
            }

            List <InstanceEvent> allInstanceEvents =
                await _instanceEventRepository.ListInstanceEvents(instanceId, eventTypes, null, null);

            List <InstanceEvent> filteredInstanceEvents = InstanceEventHelper.RemoveDuplicateEvents(allInstanceEvents);

            return(Ok(InstanceHelper.ConvertToSBLInstanceEvent(filteredInstanceEvents)));
        }
Example #3
0
        public async Task <ActionResult> Get(string instanceId, string[] eventTypes, string from, string to)
        {
            if (string.IsNullOrEmpty(instanceId))
            {
                return(BadRequest("Unable to perform query."));
            }

            DateTime?fromDateTime = null, toDateTime = null;

            if (!(string.IsNullOrEmpty(from) || string.IsNullOrEmpty(to)))
            {
                try
                {
                    fromDateTime = DateTime.ParseExact(from, "s", CultureInfo.InvariantCulture);
                    toDateTime   = DateTime.ParseExact(to, "s", CultureInfo.InvariantCulture);
                }
                catch
                {
                    return(BadRequest("Unable to perform query. Invalid format for time span. Use string format of UTC."));
                }
            }

            List <InstanceEvent> result = await _repository.ListInstanceEvents(instanceId, eventTypes, fromDateTime, toDateTime);

            if (result == null || result.Count == 0)
            {
                return(NotFound($"Did not find any instance events for instanceId={instanceId} matching the given event types: {string.Join(", ", eventTypes)} and the given time frame {fromDateTime} : {toDateTime}."));
            }

            return(Ok(result));
        }
Example #4
0
        public async Task <ActionResult <ProcessHistoryList> > GetProcessHistory(
            [FromRoute] int instanceOwnerPartyId,
            [FromRoute] Guid instanceGuid)
        {
            string[]           eventTypes         = Enum.GetNames(typeof(InstanceEventType)).Where(x => x.StartsWith("process")).ToArray();
            string             instanceId         = $"{instanceOwnerPartyId}/{instanceGuid}";
            ProcessHistoryList processHistoryList = new ProcessHistoryList();

            List <InstanceEvent> processEvents = await _instanceEventRepository.ListInstanceEvents(instanceId, eventTypes, null, null);

            processHistoryList.ProcessHistory = ProcessHelper.MapInstanceEventsToProcessHistory(processEvents);

            return(Ok(processHistoryList));
        }
        public async Task <ActionResult <ProcessHistoryList> > GetProcessHistory(
            [FromRoute] int instanceOwnerPartyId,
            [FromRoute] Guid instanceGuid)
        {
            string[]           eventTypes         = Enum.GetNames(typeof(InstanceEventType)).Where(x => x.StartsWith("process")).ToArray();
            string             instanceId         = $"{instanceOwnerPartyId}/{instanceGuid}";
            ProcessHistoryList processHistoryList = new ProcessHistoryList();

            try
            {
                List <InstanceEvent> processEvents = await _instanceEventRepository.ListInstanceEvents(instanceId, eventTypes, null, null);

                processHistoryList.ProcessHistory = ProcessHelper.MapInstanceEventsToProcessHistory(processEvents);

                return(Ok(processHistoryList));
            }
            catch (Exception e)
            {
                _logger.LogError($"Unable to retriece process history for instance object {instanceId}. Due to {e}");
                return(StatusCode(500, $"Unable to retriece process history for instance object {instanceId}: {e.Message}"));
            }
        }
        public async Task <ActionResult> Get(
            [FromRoute] int instanceOwnerPartyId,
            [FromRoute] Guid instanceGuid,
            [FromQuery] string[] eventTypes,
            [FromQuery] string from,
            [FromQuery] string to)
        {
            string instanceId = $"{instanceOwnerPartyId}/{instanceGuid}";

            if (string.IsNullOrEmpty(instanceId))
            {
                return(BadRequest("Unable to perform query."));
            }

            DateTime?fromDateTime = null, toDateTime = null;

            if (!(string.IsNullOrEmpty(from) || string.IsNullOrEmpty(to)))
            {
                try
                {
                    fromDateTime = DateTimeHelper.ParseAndConvertToUniversalTime(from);
                    toDateTime   = DateTimeHelper.ParseAndConvertToUniversalTime(to);
                }
                catch
                {
                    return(BadRequest("Unable to perform query. Invalid format for time span. Use string format of UTC."));
                }
            }

            List <InstanceEvent> result = await _repository.ListInstanceEvents(instanceId, eventTypes, fromDateTime, toDateTime);

            if (result == null || result.Count == 0)
            {
                return(NotFound($"Did not find any instance events for instanceId={instanceId} matching the given event types: {string.Join(", ", eventTypes)} and the given time frame {fromDateTime} : {toDateTime}."));
            }

            return(Ok(result));
        }
Example #7
0
        public async Task <ActionResult <InstanceEventList> > Get(
            [FromRoute] int instanceOwnerPartyId,
            [FromRoute] Guid instanceGuid,
            [FromQuery] string[] eventTypes,
            [FromQuery] string from,
            [FromQuery] string to)
        {
            string instanceId = $"{instanceOwnerPartyId}/{instanceGuid}";

            if (string.IsNullOrEmpty(instanceId))
            {
                return(BadRequest("Unable to perform query."));
            }

            DateTime?fromDateTime = null, toDateTime = null;

            if (!(string.IsNullOrEmpty(from) || string.IsNullOrEmpty(to)))
            {
                try
                {
                    fromDateTime = DateTimeHelper.ParseAndConvertToUniversalTime(from);
                    toDateTime   = DateTimeHelper.ParseAndConvertToUniversalTime(to);
                }
                catch
                {
                    return(BadRequest("Unable to perform query. Invalid format for time span. Use string format of UTC."));
                }
            }

            List <InstanceEvent> instanceEvents = await _repository.ListInstanceEvents(instanceId, eventTypes, fromDateTime, toDateTime);

            InstanceEventList instanceEventList = new InstanceEventList {
                InstanceEvents = instanceEvents
            };

            return(Ok(instanceEventList));
        }