public PivotAnalysisViewModel(IList<JiraIssue> issues)
      {
         _issues = issues;
         DataSource = new LocalDataSourceProvider();

         LoadData();
      }
        public PivotAnalysisViewModel(IList <JiraIssue> issues)
        {
            _issues    = issues;
            DataSource = new LocalDataSourceProvider();

            LoadData();
        }
        private void InitializeProviderWithXmlaClientThatReturnsErrorOnSendRequestCompleted()
        {
            var fieldInfoProvider = new FieldDescriptionProviderBaseStub();

            fieldInfoProvider.DataToReturn = new EmptyFieldInfoData();

            var engine = new PivotEngineMock();

            engine.SetToReturnErrorResponse();

            this.provider = new LocalDataSourceProvider(engine, fieldInfoProvider);
            this.provider.GroupFactory = new DataGroupFactory();
            this.provider.DeferUpdates = true;
            this.provider.RowGroupDescriptions.Add(new PropertyGroupDescription()
            {
                PropertyName = "Product"
            });
            this.provider.ColumnGroupDescriptions.Add(new PropertyGroupDescription()
            {
                PropertyName = "Promotion"
            });
            this.provider.AggregateDescriptions.Add(new PropertyAggregateDescription()
            {
                PropertyName = "Quantity"
            });
            this.provider.StatusChanged += OnProviderStatusChanged;
        }
Exemplo n.º 4
0
        private void SetupPivot()
        {
            this.provider = new LocalDataSourceProvider()
            {
                ItemsSource = this.orders
            };

            this.provider.RowGroupDescriptions.Add(new PropertyGroupDescription()
            {
                PropertyName = "Product", GroupComparer = new GroupNameComparer()
            });

            this.provider.ColumnGroupDescriptions.Add(new DateTimeGroupDescription()
            {
                PropertyName = "Date", Step = DateTimeStep.Month
            });
            this.provider.ColumnGroupDescriptions.Add(new PropertyGroupDescription()
            {
                PropertyName = "Promotion", GroupComparer = new GroupNameComparer()
            });

            this.provider.AggregateDescriptions.Add(new PropertyAggregateDescription()
            {
                PropertyName = "Quantity", CustomName = "Avg. Quantity", AggregateFunction = AggregateFunctions.Average
            });

            this.radPivotGrid1.DataProvider = this.provider;
            this.radChartView1.DataSource   = this.radPivotGrid1;

            PivotGroupNode firstNode = this.radPivotGrid1.PivotGridElement.ColumnRootGroup.Children[0];

            this.radPivotGrid1.PivotGridElement.SelectColumn(firstNode);
        }
        private void InitializeProviderThatCannotRetrieveFieldInfosOnRefresh()
        {
            var fieldInfoProvider = new FieldDescriptionProviderBaseStub();

            fieldInfoProvider.ErrorToReturn = new Exception("Dummy exception");

            var engine = new PivotEngineMock();

            this.provider = new LocalDataSourceProvider(engine, fieldInfoProvider);
            this.provider.GroupFactory = new DataGroupFactory();
            this.provider.DeferUpdates = true;
            this.provider.RowGroupDescriptions.Add(new PropertyGroupDescription()
            {
                PropertyName = "Product"
            });
            this.provider.ColumnGroupDescriptions.Add(new PropertyGroupDescription()
            {
                PropertyName = "Promotion"
            });
            this.provider.AggregateDescriptions.Add(new PropertyAggregateDescription()
            {
                PropertyName = "Quantity"
            });
            this.provider.StatusChanged += OnProviderStatusChanged;
        }
        public void LocalDataSourceProvider_ThrowException_In_Finalize()
        {
            try
            {
                LocalDataSourceProvider provider = new LocalDataSourceProvider()
                {
                    ItemsSource = Enumerable.Range(0, 10).Select(t => new Tuple <int, int>(t, t)).ToList()
                };

                var description = new PropertyGroupDescription()
                {
                    PropertyName = "Item1"
                };
                ((IGroupDescription)description).GroupComparer = new BrokenComparer();
                provider.RowGroupDescriptions.Add(description);

                provider.Refresh();
                provider.BlockUntilRefreshCompletes();

                Assert.AreEqual(DataProviderStatus.Faulted, provider.Status);
            }
            catch (Exception e)
            {
                Assert.Fail(e.ToString());
            }
        }
        private void InitializeProviderThatIsGettingFieldInfosOnRefresh()
        {
            var fieldInfoProvider = new FieldDescriptionProviderBaseStub();

            fieldInfoProvider.ActionOnGetDescriptionsDataAsync = (s) => { /* do not return */ };

            var engine = new PivotEngineMock();

            this.provider = new LocalDataSourceProvider(engine, fieldInfoProvider);
            this.provider.GroupFactory = new DataGroupFactory();
            this.provider.DeferUpdates = true;
            this.provider.RowGroupDescriptions.Add(new PropertyGroupDescription()
            {
                PropertyName = "Product"
            });
            this.provider.ColumnGroupDescriptions.Add(new PropertyGroupDescription()
            {
                PropertyName = "Promotion"
            });
            this.provider.AggregateDescriptions.Add(new PropertyAggregateDescription()
            {
                PropertyName = "Quantity"
            });
            this.provider.StatusChanged += OnProviderStatusChanged;
        }
        private void InitializeProviderThatWillRetrieveDataOnRefresh()
        {
            var fieldInfoProvider = new FieldDescriptionProviderBaseStub();

            fieldInfoProvider.DataToReturn = new EmptyFieldInfoData();

            var engine = new PivotEngineMock();

            engine.SetToReturnResponse();

            this.provider = new LocalDataSourceProvider(engine, fieldInfoProvider);
            this.provider.GroupFactory = new DataGroupFactory();
            this.provider.DeferUpdates = true;
            this.provider.RowGroupDescriptions.Add(new PropertyGroupDescription()
            {
                PropertyName = "Product"
            });
            this.provider.ColumnGroupDescriptions.Add(new PropertyGroupDescription()
            {
                PropertyName = "Promotion"
            });
            this.provider.AggregateDescriptions.Add(new PropertyAggregateDescription()
            {
                PropertyName = "Quantity"
            });
            this.provider.StatusChanged += OnProviderStatusChanged;
        }
Exemplo n.º 9
0
        public ViewModel()
        {
            var localProvider = new LocalDataSourceProvider();

            localProvider.ItemsSource = new AllOrders();
            localProvider.RowGroupDescriptions.Add(new PropertyGroupDescription {
                PropertyName = "Product"
            });
            localProvider.RowGroupDescriptions.Add(new DateTimeGroupDescription {
                PropertyName = "Date", Step = DateTimeStep.Month
            });
            localProvider.ColumnGroupDescriptions.Add(new PropertyGroupDescription {
                PropertyName = "Advertisement"
            });
            localProvider.ColumnGroupDescriptions.Add(new PropertyGroupDescription {
                PropertyName = "Promotion"
            });

            localProvider.AggregateDescriptions.Add(new PropertyAggregateDescription {
                PropertyName = "Net"
            });
            localProvider.AggregateDescriptions.Add(new PropertyAggregateDescription {
                PropertyName = "Quantity"
            });

            this.DataProvider = localProvider;
        }
Exemplo n.º 10
0
 public PivotViewModel()
 {
     PivotDataProvider = new LocalDataSourceProvider();
     var descriptionProvider = new LocalDataSourceFieldDescriptionsProvider();
     descriptionProvider.AddingContainerNode += AddingContainerNode;
     PivotDataProvider.PrepareDescriptionForField += provider_PrepareDescription;
     PivotDataProvider.FieldDescriptionsProvider = descriptionProvider;
 }
 public void TestInitialize()
 {
     this.provider = new LocalDataSourceProvider();
     this.provider.GroupFactory       = new DataGroupFactory();
     this.providerExplicit            = this.provider as IDataProvider;
     this.provider.StatusChanged     += OnProviderStatusChanged;
     this.statusChangedEventsSequence = new List <DataProviderStatusChangedEventArgs>();
     this.items = new System.Collections.ObjectModel.ObservableCollection <Item>();
 }
Exemplo n.º 12
0
        public ViewModel()
        {
            var localProvider = new LocalDataSourceProvider();
            localProvider.ItemsSource = new AllOrders();
            localProvider.RowGroupDescriptions.Add(new PropertyGroupDescription { PropertyName = "Product" });
            localProvider.RowGroupDescriptions.Add(new DateTimeGroupDescription { PropertyName = "Date", Step = DateTimeStep.Month });
            localProvider.ColumnGroupDescriptions.Add(new PropertyGroupDescription { PropertyName = "Advertisement" });
            localProvider.ColumnGroupDescriptions.Add(new PropertyGroupDescription { PropertyName = "Promotion" });

            localProvider.AggregateDescriptions.Add(new PropertyAggregateDescription { PropertyName = "Net" });
            localProvider.AggregateDescriptions.Add(new PropertyAggregateDescription { PropertyName = "Quantity" });

            this.DataProvider = localProvider;
        }
Exemplo n.º 13
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            this.pivot.GroupDescriptorElementCreating += new GroupDescriptorElementCreatingEventHandler(pivot_GroupDescriptorElementCreating);
            this.LoadData();

            this.provider = new LocalDataSourceProvider()
            {
                ItemsSource = orders
            };

            provider.RowGroupDescriptions.Add(new PropertyGroupDescription()
            {
                PropertyName = "Product", GroupComparer = new GroupNameComparer(), SortOrder = Telerik.Pivot.Core.SortOrder.Descending
            });
            provider.RowGroupDescriptions.Add(new PropertyGroupDescription()
            {
                PropertyName = "Promotion", GroupComparer = new GroupNameComparer()
            });

            provider.ColumnGroupDescriptions.Add(new PropertyGroupDescription()
            {
                PropertyName = "Advertisement", GroupComparer = new GroupNameComparer()
            });
            provider.ColumnGroupDescriptions.Add(new DateTimeGroupDescription()
            {
                PropertyName = "Date", Step = DateTimeStep.Month
            });

            provider.AggregateDescriptions.Add(new PropertyAggregateDescription()
            {
                PropertyName = "Quantity", AggregateFunction = AggregateFunctions.Sum
            });
            provider.AggregateDescriptions.Add(new PropertyAggregateDescription()
            {
                PropertyName = "Net", AggregateFunction = AggregateFunctions.Sum
            });

            provider.AggregatesPosition = PivotAxis.Rows;
            provider.AggregatesLevel    = 2;

            this.pivot.ColumnGrandTotalsPosition = TotalsPos.First;
            this.pivot.ColumnsSubTotalsPosition  = TotalsPos.First;

            this.pivot.RowGrandTotalsPosition            = TotalsPos.Last;
            this.pivot.RowsSubTotalsPosition             = TotalsPos.First;
            this.pivot.PivotGridElement.UpdateCompleted += new EventHandler(pivotGridElement_DataUpdated);
            this.pivot.PivotGridElement.DataProvider     = provider;
        }
Exemplo n.º 14
0
        internal void OnItemsSourceChanged(object newSource)
        {
            if (this.itemsSource != null)
            {
                ////TODO: Clean up items if it is required, else GC will do its work
            }

            this.areColumnsGenerated = false;
            this.dataChangeFlags    |= DataChangeFlags.Source;

            // external providers have precedence over local data provider
            IExternalItemsSource extItemSource = newSource as IExternalItemsSource;

            if (extItemSource != null)
            {
                // localDataProvider should be avoided in model logic from this moment on
                if (this.localDataProvider != null)
                {
                    this.localDataProvider.StatusChanged -= this.OnDataProviderStatusChanged;
                    this.localDataProvider = null;
                }

                if (newSource != this.externalDataProvider)
                {
                    this.externalDataProvider = extItemSource.GetExternalProvider();
                    this.UpdateProviderField(this.externalDataProvider);
                    this.externalDataProvider.Refresh(this.dataChangeFlags);
                    this.itemsSource = this.externalDataProvider.ItemsSource;
                }
            }
            else
            {
                this.itemsSource = newSource;

                if (this.localDataProvider == null)
                {
                    // create default data provider (Local (in-memory) data)
                    this.CreateDefaultDataProvider();
                }

                this.localDataProvider.ItemsSource = this.itemsSource;
            }

            this.UpdateRequestedItems(null, false);
            this.CheckDataDescriptorsCompatibility();

            // refresh the data
            this.RefreshLayout();
        }
        public void Status_WhenRefreshIsCalled_WhenItemsSourceIsNull_ShouldRemainUninitialized()
        {
            LocalDataSourceProvider provider = new LocalDataSourceProvider();

            provider.AggregateDescriptions.Add(new ListAggregateDescription()
            {
                PropertyName = "Item1"
            });

            this.provider.ItemsSource = Order.GetData();
            provider.Refresh();
            provider.BlockUntilRefreshCompletes();

            Assert.AreEqual(DataProviderStatus.Uninitialized, provider.Status);
        }
Exemplo n.º 16
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            this.LoadData();

            this.provider = new LocalDataSourceProvider()
            {
                ItemsSource = orders
            };

            provider.ColumnGroupDescriptions.Add(new PropertyGroupDescription()
            {
                PropertyName = "Product"
            });
            provider.ColumnGroupDescriptions.Add(new PropertyGroupDescription()
            {
                PropertyName = "Promotion"
            });

            provider.RowGroupDescriptions.Add(new DateTimeGroupDescription()
            {
                PropertyName = "Date", Step = DateTimeStep.Day
            });

            provider.AggregateDescriptions.Add(new PropertyAggregateDescription()
            {
                PropertyName = "Quantity", AggregateFunction = AggregateFunctions.Sum
            });
            provider.AggregateDescriptions.Add(new PropertyAggregateDescription()
            {
                PropertyName = "Net", AggregateFunction = AggregateFunctions.Sum
            });

            provider.AggregatesPosition = PivotAxis.Rows;
            provider.AggregatesLevel    = 21;

            this.radPivotGrid1.ColumnGrandTotalsPosition = TotalsPos.Last;
            this.radPivotGrid1.ColumnsSubTotalsPosition  = TotalsPos.Last;

            this.radPivotGrid1.RowGrandTotalsPosition = TotalsPos.Last;
            this.radPivotGrid1.RowsSubTotalsPosition  = TotalsPos.None;

            this.radPivotGrid1.PivotGridElement.DataProvider = provider;
        }
Exemplo n.º 17
0
        public Form1()
        {
            InitializeComponent();
            this.LoadData();

            this.provider = new LocalDataSourceProvider()
            {
                ItemsSource = orders
            };

            provider.ColumnGroupDescriptions.Add(new DateTimeGroupDescription()
            {
                PropertyName = "Date", Step = DateTimeStep.Year
            });
            provider.ColumnGroupDescriptions.Add(new PropertyGroupDescription()
            {
                PropertyName = "Promotion", GroupComparer = new GroupNameComparer()
            });

            provider.RowGroupDescriptions.Add(new PropertyGroupDescription()
            {
                PropertyName = "Product", GroupComparer = new GroupNameComparer(), SortOrder = Telerik.Pivot.Core.SortOrder.Descending
            });
            provider.RowGroupDescriptions.Add(new PropertyGroupDescription()
            {
                PropertyName = "Advertisement", GroupComparer = new GroupNameComparer()
            });

            provider.AggregateDescriptions.Add(new PropertyAggregateDescription()
            {
                PropertyName = "Quantity", AggregateFunction = AggregateFunctions.Sum
            });
            provider.AggregateDescriptions.Add(new PropertyAggregateDescription()
            {
                PropertyName = "Net", AggregateFunction = AggregateFunctions.Sum
            });

            provider.AggregatesPosition = PivotAxis.Columns;
            provider.AggregatesLevel    = 2;

            this.radPivotGrid1.PivotGridElement.DataProvider = provider;
        }
        public void LocalDataSourceProvider_FilterDescriptions()
        {
            LocalDataSourceProvider provider = new LocalDataSourceProvider();

            using (provider.DeferRefresh())
            {
                provider.ItemsSource  = Enumerable.Range(0, 10).Select(t => new Tuple <int, int>(t, t)).ToList();
                provider.GroupFactory = new DataGroupFactory();

                provider.AggregateDescriptions.Add(new ListAggregateDescription()
                {
                    PropertyName = "Item1"
                });

                provider.FilterDescriptions.Add(new PropertyFilterDescription()
                {
                    PropertyName = "Item1", Condition = new DelegateCondition((i) => Convert.ToInt32(i) % 3 != 0)
                });
                provider.FilterDescriptions.Add(new PropertyFilterDescription()
                {
                    PropertyName = "Item1", Condition = new DelegateCondition((i) => Convert.ToInt32(i) % 5 != 0)
                });
                provider.FilterDescriptions.Add(new PropertyFilterDescription()
                {
                    PropertyName = "Item1", Condition = new DelegateCondition((i) => Convert.ToInt32(i) % 7 != 0)
                });
                // will pass: 1, 2, 4, 8
            }

            provider.BlockUntilRefreshCompletes();

            var         r      = ((IDataProvider)provider).Results;
            IList <int> values = r.GetAggregateResult(0, r.Root).GetValue() as IList <int>;

            Assert.AreEqual(4, values.Count);
            Assert.IsTrue(values.Contains(1));
            Assert.IsTrue(values.Contains(2));
            Assert.IsTrue(values.Contains(4));
            Assert.IsTrue(values.Contains(8));
        }
        public void LocalDataSourceProvider_Clones_Descriptions()
        {
            var engineMock = new PivotEngineMock();
            LocalDataSourceProvider provider = new LocalDataSourceProvider(engineMock);

            using (provider.DeferRefresh())
            {
                provider.AggregateDescriptions.Add(new ListAggregateDescription()
                {
                    PropertyName = "Item1"
                });

                provider.FilterDescriptions.Add(new PropertyFilterDescription()
                {
                    PropertyName = "Item1", Condition = new DelegateCondition((i) => Convert.ToInt32(i) % 3 != 0)
                });
                provider.SortDescriptions.Add(new PropertySortDescription()
                {
                    PropertyName = "Item1", SortOrder = SortOrder.Descending
                });
                provider.GroupDescriptions.Add(new PropertyGroupDescription()
                {
                    PropertyName = "Item2", SortOrder = SortOrder.Descending
                });
                provider.ItemsSource = Enumerable.Range(0, 10).Select(t => new Tuple <int, int>(t, t)).ToList();
            }

            engineMock.ActionOnRebuildCube = (state) =>
            {
                Assert.AreNotSame(provider.AggregateDescriptions[0], state.AggregateDescriptions[0]);
                Assert.AreNotSame(provider.FilterDescriptions[0], state.FilterDescriptions[0]);
                Assert.AreNotSame(provider.GroupDescriptions[0], state.RowGroupDescriptions[0]);

                SortFieldComparer fieldComparer = state.ValueProvider.GetSortComparer() as SortFieldComparer;
                SortFieldComparer.InternalTestHook testHelper = new SortFieldComparer.InternalTestHook(fieldComparer);
                Assert.AreNotSame(provider.SortDescriptions[0], testHelper.SortDescriptions[0]);
            };
        }
        public void LocalDataSourceProvider_SortDescriptions_NoGrouping_Ascending()
        {
            var data = Enumerable.Range(0, 10000).Select((i) => new DataItem {
                ID = i, Name = "Name" + i % 500, Surname = "Surname" + (5000 - i) % 1000
            }).ToList();

            LocalDataSourceProvider provider = new LocalDataSourceProvider();

            using (provider.DeferRefresh())
            {
                provider.GroupFactory = new DataGroupFactory();
                provider.SortDescriptions.Add(new PropertySortDescription()
                {
                    PropertyName = "Name", SortOrder = SortOrder.Descending
                });
                provider.SortDescriptions.Add(new PropertySortDescription()
                {
                    PropertyName = "ID", SortOrder = SortOrder.Descending
                });
                provider.ItemsSource = data;
            }
            provider.BlockUntilRefreshCompletes();

            DataItemComparer comparer = new DataItemComparer(new DataItemNameComparer()
            {
                Descending = true
            }, new DataItemIDComparer()
            {
                Descending = true
            });

            data.Sort(comparer);

            for (int i = 0; i < data.Count; i++)
            {
                Assert.AreSame(data[i], provider.Results.Root.RowGroup.Items[i]);
            }
        }
 public Example()
 {
     InitializeComponent();
     this.randomOrders = this.Resources["RandomOrders"] as RandomOrdersGenerator;
     this.dataProvider = this.Resources["DataProvider"] as LocalDataSourceProvider;
 }
 public SynchronousLocalDataSourceFieldDescriptionsProvider(LocalDataSourceProvider provider)
     : base()
 {
 }
Exemplo n.º 23
0
 private void CreateDefaultDataProvider()
 {
     this.localDataProvider = new LocalDataSourceProvider();
     this.UpdateProviderField(this.localDataProvider as IDataProvider);
 }
Exemplo n.º 24
0
 public void TestInitialize()
 {
     this.dataProvider = new LocalDataSourceProvider();
     this.provider     = new InheritedLocalDataSourceFieldDescriptionsProvider(this.dataProvider);
 }
Exemplo n.º 25
0
 public InheritedLocalDataSourceFieldDescriptionsProvider(LocalDataSourceProvider provider) : base()
 {
     this.localProvider = provider;
 }
Exemplo n.º 26
0
 public PivotGridViewModel()
 {
     DispatcherHelper.CheckBeginInvokeOnUI(() =>
                                           DataSource = new LocalDataSourceProvider());
 }