private IList <T> InnerDoQuery(RestrictionBuilderBase restrictionBuilder, OrderByBuilder orderByBuilder, int max, int skip) { ArchiveExecutionContext executionContext = _archiveExecutionContextProvider.Get(); if (executionContext == null) { throw new InvalidOperationException(nameof(executionContext) + " not set, cannot be null"); } ArchiveQueryParameters context = new ArchiveQueryParameters(); context.ArchiveName = executionContext.ArchiveName; context.Entities = executionContext.Entities; context.RequestedColumns = DynamicPropertyHelper.GetAllDbColumnsPrefixed <T>(); int page = 0; if (skip > 0) { page = SetPageSizeAndGetPage(skip, max, context); } if (restrictionBuilder != null) { context.Restrictions = restrictionBuilder.GetRestrictions(); } if (orderByBuilder != null) { context.OrderBy = orderByBuilder.Get(); } return(_resultParser.Parse <T>(executionContext, _executor.GetItems(context, max, page))); }
private object DoTypeSpecificConversion(ArchiveExecutionContext executionContext, ColumnInfo column, object parsedValue) { if (parsedValue != null) { var type = parsedValue.GetType(); if (type == typeof(DateTime)) { if (!executionContext.DateTimeToUTC || column.UseRaw) { parsedValue = (DateTime)parsedValue; } else { parsedValue = _dateTimeConverter.ConvertFromTimeZone(((DateTime)parsedValue).ToUniversalTime()); } } else if (column.PropertyType == typeof(int[])) { //fix for incorrect value from SuperOffice Services if (parsedValue as string == "[A:]") { parsedValue = new int[0]; } } } return(parsedValue); }
private IList <T> ParseResult(ArchiveExecutionContext executionContext, IList <ArchiveListItem> list) { List <T> results = new List <T>(); if (list == null) { return(null); } foreach (ArchiveListItem item in list) { T t = Activator.CreateInstance <T>(); foreach (string column in item.ColumnData.Keys) { foreach (string propertyName in DynamicPropertyHelper.GetPropertyNames <T>(column)) { string value = item.ColumnData[column].DisplayValue; object parsedValue = CultureDataFormatter.ParseEncoded(value); parsedValue = DoTypeSpecificConversion(executionContext, DynamicPropertyHelper.GetColumnInfo(typeof(T), propertyName), parsedValue); ObjectPropertyAccessor.SetValue(t, propertyName, parsedValue); } } results.Add(t); } return(results); }
public ArchiveExecutionContextProvider(Action <ArchiveExecutionContext> context = null) { var executionContext = new ArchiveExecutionContext(); Settings.DefaultExecutionContext?.Invoke(executionContext); context?.Invoke(executionContext); _context = executionContext; }
private object DoTypeSpecificConversion(ArchiveExecutionContext executionContext, ColumnInfo column, object parsedValue) { if (parsedValue != null) { var type = parsedValue.GetType(); if (type == typeof(DateTime)) { if (!executionContext.DateTimeToUTC && column.UseRaw) { parsedValue = (DateTime)parsedValue; } else { parsedValue = _dateTimeConverter.ConvertFromTimeZone(((DateTime)parsedValue).ToUniversalTime()); } } } return(parsedValue); }