private void RaisePageLoaded(IDataSourcePage page, int fullCount, int actualPageSize)
        {
            if (_pageLoaded != null)
            {
                _currentFullCount = fullCount;
                if (_currentSchema == null)
                {
                    IDataSourceSchema currentSchema = null;
                    if (page != null)
                    {
                        currentSchema = page.Schema();
                    }

                    _currentSchema = currentSchema;
                    if (SchemaChanged != null)
                    {
                        SchemaChanged(this, new DataSourceDataProviderSchemaChangedEventArgs(_currentSchema, _currentFullCount));
                    }
                }

                if (page.PageIndex() != ODataVirtualDataSourceDataProviderWorker.SchemaRequestIndex)
                {
                    _pageLoaded(page, fullCount, actualPageSize);
                }
            }
        }
Ejemplo n.º 2
0
 internal void RefreshSchema(System.Type objectType, string methodName, System.Type schemaType, bool preferSilent)
 {
     if (((objectType != null) && !string.IsNullOrEmpty(methodName)) && (schemaType != null))
     {
         try
         {
             TypeSchema schema = new TypeSchema(schemaType);
             this._forceSchemaRetrieval = true;
             DataTable[] tables = this.LoadSchema();
             this._forceSchemaRetrieval = false;
             IDataSourceSchema schema2 = (tables == null) ? null : new DataTableArraySchema(tables);
             this.SaveSchema(objectType, methodName, ConvertSchemaToDataTables(schema), schemaType);
             DataTable[]       tableArray2 = this.LoadSchema();
             IDataSourceSchema schema3     = (tableArray2 == null) ? null : new DataTableArraySchema(tableArray2);
             if (!DataSourceDesigner.SchemasEquivalent(schema2, schema3))
             {
                 this.OnSchemaRefreshed(EventArgs.Empty);
             }
         }
         catch (Exception exception)
         {
             if (!preferSilent)
             {
                 UIServiceHelper.ShowError(base.Component.Site, exception, System.Design.SR.GetString("ObjectDataSourceDesigner_CannotGetSchema", new object[] { schemaType.FullName }));
             }
         }
     }
 }
 public ODataDataSourcePage(IEnumerable<IDictionary<string, object>> sourceData, IDataSourceSchema schema, int pageIndex)
 {
     if (sourceData == null)
     {
         _actualData = null;
     }
     else
     {
         _actualData = sourceData.ToArray();
     }
     _schema = schema;
     _pageIndex = pageIndex;
 }
Ejemplo n.º 4
0
 public ODataDataSourcePage(IEnumerable <IDictionary <string, object> > sourceData, IDataSourceSchema schema, ISectionInformation[] groupInformation, int pageIndex)
 {
     if (sourceData == null)
     {
         _actualData = null;
     }
     else
     {
         _actualData = sourceData.ToArray();
     }
     _schema           = schema;
     _groupInfromation = groupInformation;
     _pageIndex        = pageIndex;
 }
 internal SQLiteDataSourcePage(SQLiteDataSourceQueryResult sourceData, IDataSourceSchema schema, ISectionInformation[] groupInformation, int pageIndex)
 {
     if (sourceData == null)
     {
         _actualData = null;
     }
     else
     {
         _actualData = sourceData.Data;
     }
     _schema           = schema;
     _pageIndex        = pageIndex;
     _groupInformation = groupInformation;
 }
 private void PopulateSchema(IDataSourceSchema schema)
 {
     if (schema != null)
     {
         IDictionary             duplicates = new Hashtable();
         IDataSourceViewSchema[] views      = schema.GetViews();
         if (views != null)
         {
             for (int i = 0; i < views.Length; i++)
             {
                 this.PopulateSchemaRecursive(this._schemaTreeView.Nodes, views[i], 0, duplicates);
             }
         }
     }
 }
 public static bool SchemasEquivalent(IDataSourceSchema schema1, IDataSourceSchema schema2)
 {
     if ((schema1 == null) ^ (schema2 == null))
     {
         return(false);
     }
     if ((schema1 != null) || (schema2 != null))
     {
         IDataSourceViewSchema[] views        = schema1.GetViews();
         IDataSourceViewSchema[] schemaArray2 = schema2.GetViews();
         if ((views == null) ^ (schemaArray2 == null))
         {
             return(false);
         }
         if ((views == null) && (schemaArray2 == null))
         {
             return(true);
         }
         int length = views.Length;
         int num2   = schemaArray2.Length;
         if (length != num2)
         {
             return(false);
         }
         foreach (IDataSourceViewSchema schema in views)
         {
             bool   flag = false;
             string name = schema.Name;
             foreach (IDataSourceViewSchema schema3 in schemaArray2)
             {
                 if ((name == schema3.Name) && ViewSchemasEquivalent(schema, schema3))
                 {
                     flag = true;
                     break;
                 }
             }
             if (!flag)
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Ejemplo n.º 8
0
        protected override void ProcessCompletedTask(AsyncDataSourcePageTaskHolder completedTask, int currentDelay, int pageIndex, AsyncVirtualDataSourceProviderTaskDataHolder taskDataHolder)
        {
            ODataVirtualDataSourceProviderTaskDataHolder h = (ODataVirtualDataSourceProviderTaskDataHolder)taskDataHolder;
            IDataSourceSchema schema = null;
            IEnumerable <IDictionary <string, object> > result = null;

            ISectionInformation[] groupInformation = null;
            int  schemaFetchCount = -1;
            bool isAggregationSupportedByServer = false;
            bool isGrouping = false;

            try
            {
                if (pageIndex == SchemaRequestIndex)
                {
                    Task <int> task = (Task <int>)completedTask.Task;

                    schemaFetchCount = task.Result;
                }
                else
                {
                    Task <IEnumerable <IDictionary <string, object> > > task = (Task <IEnumerable <IDictionary <string, object> > >)completedTask.Task;

                    result = task.Result;
                }
            }
            catch (AggregateException e)
            {
                bool allCancels = true;
                foreach (var ex in e.Flatten().InnerExceptions)
                {
                    if (!(ex is TaskCanceledException))
                    {
                        allCancels = false;
                    }
                }
                if (!allCancels)
                {
                    RetryIndex(pageIndex, currentDelay);
                    return;
                }
                else
                {
                    RetryIndex(pageIndex, currentDelay);
                    return;
                }
            }
            catch (TaskCanceledException e)
            {
                RetryIndex(pageIndex, currentDelay);
                //TODO: other exceptions? Is there a way to skip this state for canceled stuff?
                return;
            }

            IDataSourceExecutionContext  executionContext;
            DataSourcePageLoadedCallback pageLoaded;

            lock (SyncLock)
            {
                if (schemaFetchCount >= 0)
                {
                    ActualCount = schemaFetchCount;
                }
                else
                {
                    var completedAnnotation = h.CompletedAnnotation;
                    if (completedAnnotation.Count.HasValue)
                    {
                        ActualCount = (int)completedAnnotation.Count.Value;
                    }
                }

                groupInformation = _groupInformation;
                isAggregationSupportedByServer = _isAggregationSupportedByServer;
                schema     = ActualSchema;
                isGrouping = _groupDescriptions != null && _groupDescriptions.Count > 0;
            }

            if (schema == null)
            {
                schema = ResolveSchema();
            }
            if (isGrouping && isAggregationSupportedByServer &&
                groupInformation == null)
            {
                groupInformation = ResolveGroupInformation();
            }

            lock (SyncLock)
            {
                ActualSchema      = schema;
                _groupInformation = groupInformation;
                executionContext  = ExecutionContext;
                pageLoaded        = PageLoaded;
            }

            ODataDataSourcePage page = null;

            if (result != null)
            {
                page = new ODataDataSourcePage(result, schema, groupInformation, pageIndex);
                lock (SyncLock)
                {
                    if (!IsLastPage(pageIndex) && page.Count() > 0 && !PopulatedActualPageSize)
                    {
                        PopulatedActualPageSize = true;
                        ActualPageSize          = page.Count();
                    }
                }
            }
            else
            {
                page = new ODataDataSourcePage(null, schema, groupInformation, pageIndex);
            }

            if (PageLoaded != null)
            {
                if (ExecutionContext != null)
                {
                    if (executionContext == null || pageLoaded == null)
                    {
                        Shutdown();
                        return;
                    }

                    executionContext.Execute(() =>
                    {
                        pageLoaded(page, ActualCount, ActualPageSize);
                    });
                }
                else
                {
                    if (pageLoaded == null)
                    {
                        Shutdown();
                        return;
                    }

                    pageLoaded(page, ActualCount, ActualPageSize);
                }
            }
        }
	public static bool SchemasEquivalent(IDataSourceSchema schema1, IDataSourceSchema schema2) {}
Ejemplo n.º 10
0
 public static bool SchemasEquivalent(IDataSourceSchema schema1, IDataSourceSchema schema2)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 11
0
        protected override void ProcessCompletedTask(AsyncDataSourcePageTaskHolder completedTask, int currentDelay, int pageIndex, AsyncVirtualDataSourceProviderTaskDataHolder taskDataHolder)
        {
            SQLiteVirtualDataSourceProviderTaskDataHolder h = (SQLiteVirtualDataSourceProviderTaskDataHolder)taskDataHolder;
            IDataSourceSchema           schema = null;
            SQLiteDataSourceQueryResult result = null;
            int schemaFetchCount = -1;

            try
            {
                if (pageIndex == SchemaRequestIndex)
                {
                    Task <int> task = (Task <int>)completedTask.Task;

                    schemaFetchCount = task.Result;
                }
                else
                {
                    Task <SQLiteDataSourceQueryResult> task = (Task <SQLiteDataSourceQueryResult>)completedTask.Task;

                    result = task.Result;
                }
            }
            catch (AggregateException e)
            {
                bool allCancels = true;
                foreach (var ex in e.Flatten().InnerExceptions)
                {
                    if (!(ex is TaskCanceledException))
                    {
                        allCancels = false;
                    }
                }
                if (!allCancels)
                {
                    RetryIndex(pageIndex, currentDelay);
                    return;
                }
                else
                {
                    RetryIndex(pageIndex, currentDelay);
                    return;
                }
            }
            catch (TaskCanceledException e)
            {
                RetryIndex(pageIndex, currentDelay);
                //TODO: other exceptions? Is there a way to skip this state for canceled stuff?
                return;
            }

            IDataSourceExecutionContext  executionContext;
            DataSourcePageLoadedCallback pageLoaded;

            ISectionInformation[] groupInformation = null;

            lock (SyncLock)
            {
                if (schemaFetchCount >= 0)
                {
                    ActualCount = schemaFetchCount;
                }
                else
                {
                    ActualCount = result.FullCount;
                }

                schema           = ActualSchema;
                groupInformation = _groupInformation;
            }

            if (schema == null)
            {
                schema = ResolveSchema();
            }

            lock (SyncLock)
            {
                ActualSchema     = schema;
                executionContext = ExecutionContext;
                pageLoaded       = PageLoaded;
            }

            SQLiteDataSourcePage page = null;

            if (result != null)
            {
                page = new SQLiteDataSourcePage(result, schema, groupInformation, pageIndex);
                lock (SyncLock)
                {
                    if (!IsLastPage(pageIndex) && page.Count() > 0 && !PopulatedActualPageSize)
                    {
                        PopulatedActualPageSize = true;
                        ActualPageSize          = page.Count();
                    }
                }
            }
            else
            {
                page = new SQLiteDataSourcePage(null, schema, groupInformation, pageIndex);
            }

            if (PageLoaded != null)
            {
                if (ExecutionContext != null)
                {
                    if (executionContext == null || pageLoaded == null)
                    {
                        Shutdown();
                        return;
                    }

                    executionContext.Execute(() =>
                    {
                        pageLoaded(page, ActualCount, ActualPageSize);
                    });
                }
                else
                {
                    if (pageLoaded == null)
                    {
                        Shutdown();
                        return;
                    }

                    pageLoaded(page, ActualCount, ActualPageSize);
                }
            }
        }
 public static bool SchemasEquivalent(IDataSourceSchema schema1, IDataSourceSchema schema2)
 {
 }
 public static bool SchemasEquivalent(IDataSourceSchema schema1, IDataSourceSchema schema2)
 {
     if ((schema1 == null) ^ (schema2 == null))
     {
         return false;
     }
     if ((schema1 != null) || (schema2 != null))
     {
         IDataSourceViewSchema[] views = schema1.GetViews();
         IDataSourceViewSchema[] schemaArray2 = schema2.GetViews();
         if ((views == null) ^ (schemaArray2 == null))
         {
             return false;
         }
         if ((views == null) && (schemaArray2 == null))
         {
             return true;
         }
         int length = views.Length;
         int num2 = schemaArray2.Length;
         if (length != num2)
         {
             return false;
         }
         foreach (IDataSourceViewSchema schema in views)
         {
             bool flag = false;
             string name = schema.Name;
             foreach (IDataSourceViewSchema schema3 in schemaArray2)
             {
                 if ((name == schema3.Name) && ViewSchemasEquivalent(schema, schema3))
                 {
                     flag = true;
                     break;
                 }
             }
             if (!flag)
             {
                 return false;
             }
         }
     }
     return true;
 }
 private void PopulateSchema(IDataSourceSchema schema)
 {
     if (schema != null)
     {
         IDictionary duplicates = new Hashtable();
         IDataSourceViewSchema[] views = schema.GetViews();
         if (views != null)
         {
             for (int i = 0; i < views.Length; i++)
             {
                 this.PopulateSchemaRecursive(this._schemaTreeView.Nodes, views[i], 0, duplicates);
             }
         }
     }
 }
Ejemplo n.º 15
0
		public static bool SchemasEquivalent (IDataSourceSchema schema1, IDataSourceSchema schema2)
		{
			throw new NotImplementedException ();
		}