예제 #1
0
        /// <summary>
        /// Retrieves the person event asynchronous.
        /// </summary>
        /// <param name="dateTime">The date time.</param>
        /// <param name="personId">The person identifier.</param>
        /// <param name="personType">The person type.</param>
        /// <returns>The person events.</returns>
        public async Task<EventHistory> RetrievePersonHistoryAsync(string dateTime, string personId, PersonType personType)
        {
            var workstation = DIContainer.Instance.Resolve<Workstation>();

            ListResult<EventHistory> eventData = new ListResult<EventHistory>();
            var eventHistory = new EventHistory();

            var personTypeId = personType.RetrievePersonTypeId();

            var command = this.Database.GetStoredProcCommand(RetrieveGangwayHistoryByPersonIdStoredProcedure)
                .AddParameter(PersonTypeId, DbType.Int16, personTypeId)
                .AddParameter(PersonIds, DbType.String, personId)
                .AddParameter(ShipIds, DbType.String, workstation.Ship.ShipId)
                .AddParameter(SortColumn1, DbType.String, AddedDate)
                .AddParameter(SortTypeColumn1, DbType.String, DESC)
                .AddParameter(PageNumber, DbType.Int32, OfflineConstants.DefaultPageNumber)
                .AddParameter(PageSize, DbType.Int32, OfflineConstants.DefaultPageSize);

            var list = await this.ExecuteReaderAsync(command, GangwayHistoryMapper.MapGangwayHistory);

            eventHistory.AssignGangwayEvents(PersonEventHistoryMapper.MapPersonHistory(list.Items));
            eventData.Items.Add(eventHistory);
            var data = eventData != null ? eventData.Items.FirstOrDefault() : new EventHistory();
            return await Task.FromResult(data);
        }
예제 #2
0
        /// <summary>
        /// Persons the event list asynchronous.
        /// </summary>
        /// <param name="personId">The person identifier.</param>
        /// <param name="searchParameters">The search parameters.</param>
        /// <returns>
        /// Instance of Event History
        /// </returns>
        public async Task<ListResult<EventHistory>> PersonEventListAsync(string personId, PersonEventSearchParameter searchParameters)
        {
            var eventHistoryCollection = new ListResult<EventHistory>();
            var eventHistory = new EventHistory();

            ////TODO : Implement Date time value to pass to mas service to retrieve drill events.
            DateTime dateTime;
            try
            {
                DateTime.TryParseExact(searchParameters.DateTime, CustomDateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime);
            }
            catch
            {
                dateTime = DateTime.UtcNow;
            }

            //// TODO : Will remove later after 2015-11-23 Release.
            if (dateTime.Equals(DateTime.MinValue))
            {
                dateTime = DateTime.UtcNow;
            }

            var drillEvents = RetrieveDrillEvents(dateTime, personId, searchParameters.PersonType.ToString(CultureInfo.CurrentCulture));
            var gangwayEvents = this.personEventClientRepository.RetrieveEventListAsync(new PersonHistorySearchParameters { ShipId = searchParameters.ShipId, PersonIds = searchParameters.PersonId, PersonTypeId = searchParameters.PersonTypeId, MaxResults = searchParameters.MaxResults, OrderBy = searchParameters.OrderBy, PageNumber = searchParameters.PageNumber, Parts = searchParameters.Parts });

            await Task.WhenAll(drillEvents, gangwayEvents);

            eventHistory.AssignGangwayEvents(PersonEventHistoryMapper.MapListAsync(gangwayEvents.Result.Items));
            eventHistory.AssignDrillEvents(drillEvents.Result);
            eventHistoryCollection.Items.Add(eventHistory);
            eventHistoryCollection.TotalResults = gangwayEvents.Result.TotalResults;
            return eventHistoryCollection;
        }