예제 #1
0
        /// <summary>
        /// Pobiera kolekcje z bazy danych i pakuje je w kontenery
        /// </summary>
        private async Task GetContainers()
        {
            try
            {
                HttpWorkItemCollectionClient client = new HttpWorkItemCollectionClient();

                IEnumerable <WorkItemCollectionPublic> response = await client.GetAllWorkItemCollections(mTaskBoard.ID).ConfigureAwait(false);

                foreach (WorkItemCollectionPublic wic in response)
                {
                    wic.WorkItems = new List <WorkItemPublic>();
                    await GetWorkItems(wic).ConfigureAwait(false);
                }

                await Application.Current.Dispatcher.BeginInvoke(() =>
                {
                    foreach (WorkItemCollectionPublic wic in response)
                    {
                        ContainerCollection.Add(new CtrlWorkItemContainer(mContext, wic));
                    }
                });
            }
            catch (Exception ex)
            {
                mContext.DialogBuilder.ErrorDialog("Could not retrieve collections, due to server error.", ex);
            }
        }
예제 #2
0
        /// <summary>
        /// Metoda dodajaca nowy kontener do obserwowalnej kolekcji kontenerow
        /// </summary>
        private async Task AddContainer()
        {
            try
            {
                HttpWorkItemCollectionClient client = new HttpWorkItemCollectionClient();

                WorkItemCollectionPublic workItemCollection = new WorkItemCollectionPublic()
                {
                    Name        = "Unnamed Collection",
                    TaskBoardID = mTaskBoard.ID
                };

                WorkItemCollectionPublic response = await client.CreateWorkItemCollection(workItemCollection).ConfigureAwait(false);

                response.WorkItems = new List <WorkItemPublic>();

                await Application.Current.Dispatcher.BeginInvoke(() =>
                {
                    ContainerCollection.Add(new CtrlWorkItemContainer(mContext, response));
                });
            }
            catch (Exception ex)
            {
                mContext.DialogBuilder.ErrorDialog("Could not create a collection, due to server error.", ex);
            }
        }
예제 #3
0
        public void TestMethod1()
        {
            ContainerCollection containerCollection = new ContainerCollection();
            Container           container1          = new Container
            {
                Weight         = 30,
                IsRefrigerated = false,
                IsValuable     = false
            };

            for (int i = 0; i < 21; i++)
            {
                containerCollection.Add(container1);
            }
            //containerCollection.Add(container5);
            //containerCollection.Add(container6);

            containerCollection.OrderByWeight();
            Ship ship = new Ship();
            //Deck deck = new Deck();
            Row row = new Row(4);


            //Act
            row.AddRefrigerated(containerCollection.GetContainers());
            //ship.PlaceContainersOnShip(containerCollection.GetContainers());
            //deck.Add(containerCollection.GetContainers(), 4);

            //Assert
            //Assert.AreEqual(4, row.GetStacks().Count);
            Assert.AreEqual(1, ship);
        }
예제 #4
0
        public bool AddContainer(IContainer container, List <IStack> stacksOnXAxis)
        {
            if (Check(container, stacksOnXAxis))
            {
                ContainerCollection.Add(container);
                if (container.Valuable)
                {
                    HasValuable = true;
                }
                return(true);
            }

            return(false);
        }
예제 #5
0
 private void LoadContainerHelper(Container container)
 {
     container.UpdateMethod = APMCore.UpdateMethod.Update;
     _containers.Add(container);
 }
        public void OpenStatistics()
        {
            IFactory <IColorGenerator> colorGeneratorFactory = Factory.Default <RandomColorGenerator>();

            ContainerCollection <ContainerCollection <StatisticsViewModel> > viewModel = new ContainerCollection <ContainerCollection <StatisticsViewModel> >();
            Stack <StatisticsViewModel> appendTo = new Stack <StatisticsViewModel>();

            Container <ContainerCollection <StatisticsViewModel> > allViewModel = new Container <ContainerCollection <StatisticsViewModel> >();

            allViewModel.Title = "All";
            allViewModel.Data  = new ContainerCollection <StatisticsViewModel>()
            {
                new Container <StatisticsViewModel>()
                {
                    Title = "All",
                    Data  = new StatisticsViewModel(colorGeneratorFactory.Create())
                }
            };
            appendTo.Push(allViewModel.Data[0].Data);
            viewModel.Add(allViewModel);

            foreach (IGrouping <int, Month> year in countingService.Months().OrderByDescending(m => m.Year).GroupBy(m => m.Year))
            {
                Container <ContainerCollection <StatisticsViewModel> > yearViewModel = new Container <ContainerCollection <StatisticsViewModel> >();
                yearViewModel.Title = year.Key.ToString();
                yearViewModel.Data  = new ContainerCollection <StatisticsViewModel>();

                yearViewModel.Data.Add(new Container <StatisticsViewModel>()
                {
                    Title = "All",
                    Data  = new StatisticsViewModel(colorGeneratorFactory.Create())
                });
                appendTo.Push(yearViewModel.Data[0].Data);

                foreach (Month month in year.OrderBy(m => m.Value))
                {
                    Container <StatisticsViewModel> monthViewModel = new Container <StatisticsViewModel>();
                    monthViewModel.Title = month.ToShortString();
                    monthViewModel.Data  = new StatisticsViewModel(colorGeneratorFactory.Create());

                    appendTo.Push(monthViewModel.Data);

                    foreach (ApplicationCountModel application in countingService.Applications(month, month))
                    {
                        appendTo.ForEach(vm => vm.AddApplication(application.Path, application.Count));
                    }

                    foreach (FileCountModel file in countingService.Files(month, month))
                    {
                        appendTo.ForEach(vm => vm.AddFile(file.Path, file.Count));
                    }

                    appendTo.Pop();
                    yearViewModel.Data.Add(monthViewModel);
                }

                appendTo.Pop();
                viewModel.Add(yearViewModel);
            }

            statisticsWindow           = new StatisticsWindow();
            statisticsWindow.ViewModel = viewModel;
            statisticsWindow.Owner     = configurationWindow;
            statisticsWindow.Closed   += OnStatisticsWindowClosed;
            statisticsWindow.ShowDialog();
        }