Ejemplo n.º 1
0
        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)));
        }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        public ArchiveExecutionContextProvider(Action <ArchiveExecutionContext> context = null)
        {
            var executionContext = new ArchiveExecutionContext();

            Settings.DefaultExecutionContext?.Invoke(executionContext);
            context?.Invoke(executionContext);
            _context = executionContext;
        }
Ejemplo n.º 5
0
 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);
 }