private async Task<IEnumerable> GetUpdatesDataCore(string userID)
        {
            //Get all updates
            var updates = await ParseObject.GetQuery("Update").Include("User").FindAsync();

            var updatesModel = from c in updates select new UpdateModel(c);

            var groupedData = from u in updatesModel
                              group u by u.Date.Date into groupData
                              select new
                              {
                                  Name = groupData.Key,
                                  Items = groupData
                              };

            ObservableCollection<GroupedData<UpdateModel>> data = new ObservableCollection<GroupedData<UpdateModel>>();
            foreach (var item in groupedData)
            {
                GroupedData<UpdateModel> list = new GroupedData<UpdateModel>();
                list.Key = item.Name;
                foreach (var itemInGroup in item.Items)
                {
                    list.Add(itemInGroup);
                }
                data.Add(list);
            }

            return data;
        }
    static void Main(string[] args)
    {
        BulkDateInsert item = new BulkDateInsert()
        {
            CalendarDate = @"\/Date(1490985000000)\/", Calendarday = "Sat", isweekday = false, isweekend = true
        };
        BulkDateInsert item1 = new BulkDateInsert()
        {
            CalendarDate = @"\/Date(1491071400000)\/", Calendarday = "Sun", isweekday = false, isweekend = true
        };
        List <BulkDateInsert> list = new List <BulkDateInsert>();

        list.Add(item);
        list.Add(item1);

        IList <BulkDateInsert> objExcelCon = list;

        GroupedData gdata = new GroupedData()
        {
            Calendardata = objExcelCon
        };

        Program p = new Program();

        p.CreateDocumentForCalendarData(gdata).Wait();
    }
示例#3
0
        private static void LetKIzunaDecide(Data data, int groupValueOld, int groupAmmountOld)
        {
            int groupAmmount = EvaluateGroupOfAmmountStage2(data.Menge);
            int groupValue   = EvaluateGroupOfValueStage2(data.Wert);
            var same1        = CompareGoup(groupValue, groupAmmountOld);
            var same2        = CompareGoup(groupAmmount, groupValueOld);

            //TODO: Auslagern



            if (same1 == same2)
            {
                DecideStage3(data);
                var a = 2 + 2; //HINWEIS: Abfangen von fehlern
            }

            if (same1)
            {
                GroupedData dat = new GroupedData()
                {
                    Data = data, Group = groupValue
                };
                Acces.groupedData.Add(dat);
            }
            else if (same2)
            {
                GroupedData dat = new GroupedData()
                {
                    Data = data, Group = groupAmmount
                };
                Acces.groupedData.Add(dat);
            }
        }
示例#4
0
        private static void DecideStage2(Data data, int groupValue, int groupAmount)
        {
            var groupDictance = groupAmount - groupValue;
            int?group         = null;

            //TODO: auslagern
            if (groupDictance == 1 || groupDictance == -1)
            {
                LetKIzunaDecide(data, groupValue, groupAmount);
            }
            else
            {
                if (groupDictance > 0)
                {
                    group = groupValue;
                    GroupedData dat = new GroupedData()
                    {
                        Data = data, Group = Convert.ToInt32(group)
                    };
                    Acces.groupedData.Add(dat);
                }
                else
                {
                    //TODO: add Groupe Diffenrence bigger 1
                }
            }
        }
示例#5
0
        public IActionResult GetAllToGroupedData()
        {
            GroupedData groupedData;
            var         data   = new List <GroupedData>();
            var         groups = _mealService.GetAllGroupCode(out bool result, out string message);

            foreach (var group in groups)
            {
                groupedData      = new GroupedData();
                groupedData.text = group.GroupCode.ToUpper();

                var children = _mealService.GetByGroupCode(group.GroupCode, out result, out message);
                foreach (var child in children)
                {
                    groupedData.children.Add(new ChildItem()
                    {
                        id = child.Id.ToString(), text = child.Name
                    });
                }

                data.Add(groupedData);
            }

            return(new OkObjectResult(new GenericResult(result, message, data)));
        }
示例#6
0
        private void CreateDistanceJoints()
        {
            var sizeY = settings.StandsSettings.Segments;

            var distanceJoints = new GroupedData <GPDistanceJoint>();

            var group1 = new List <GPDistanceJoint>();
            var group2 = new List <GPDistanceJoint>();

            for (int i = 0; i < bodies.Length; i++)
            {
                if (i % sizeY == 0)
                {
                    continue;
                }

                var body1    = bodies[i - 1];
                var body2    = bodies[i];
                var distance = Vector3.Distance(body1.Position, body2.Position);//to global

                var list = i % 2 == 0 ? group1 : group2;

                var joint = new GPDistanceJoint(i - 1, i, distance, 0.5f);
                list.Add(joint);
            }

            distanceJoints.AddGroup(group1);
            distanceJoints.AddGroup(group2);

            DistanceJoints = distanceJoints;
        }
示例#7
0
        public IObservable <GroupedPhotometryDataFrame> Process(IObservable <GroupedPhotometryDataFrame> source)
        {
            return(Observable.Defer(() =>
            {
                GroupedData[] groups = null;
                return source.Do(input =>
                {
                    if (groups == null || groups.Length != input.Groups.Length)
                    {
                        groups = new GroupedData[input.Groups.Length];
                        for (int i = 0; i < groups.Length; i++)
                        {
                            groups[i].Name = input.Groups[i].Name;
                            var labels = groups[i].Labels = new string[input.Groups[i].Activity.Length];
                            var data = groups[i].Data = new IPointListEdit[input.Groups[i].Activity.Length];
                            for (int j = 0; j < data.Length; j++)
                            {
                                data[j] = new PointPairList();
                                labels[j] = GraphHelper.GetRegionLabel(ref input.Groups[i].Activity[j].Region);
                            }
                        }
                    }

                    for (int i = 0; i < groups.Length; i++)
                    {
                        for (int j = 0; j < groups[i].Data.Length; j++)
                        {
                            groups[i].Data[j].Add(input.Timestamp, input.Groups[i].Activity[j].Value);
                        }
                    }
                }).Finally(() =>
                {
                    if (groups == null)
                    {
                        return;
                    }
                    var graph = new RollingGraph();
                    InitializeGraphPane(graph);
                    graph.PaneCount = groups.Length;
                    for (int i = 0; i < groups.Length; i++)
                    {
                        var group = groups[i];
                        var pane = graph.MasterPane.PaneList[i];
                        for (int j = 0; j < group.Data.Length; j++)
                        {
                            pane.AddCurve(group.Labels[j], group.Data[j], graph.GetNextColor(), SymbolType.None);
                        }

                        pane.Legend.FontSpec.Size = ScaleSize;
                        pane.YAxis.Title.Text = group.Name;
                        pane.YAxis.Title.IsVisible = true;
                    }

                    SaveGraph(graph);
                });
            }));
        }
示例#8
0
        public PartialViewResult Partial_BonusesByDepartments_LINQ(/* decimal reportsum */)
        {
            BonusesViewParams PageParams = new BonusesViewParams(this.Request);

            //   Сумма ограничения бонусов по отделам из запроса страницы.
            decimal param_ReportBonusSum = PageParams.ReportBonusSum.ParamValue;

            //
            //   Создаем описание первого запроса к данным.
            //   Мы будем использовать этот запрос ниже, внутри второго, основного запроса.
            //
            //   Следует отметить, что LINQ не отправляет никакие запросы до тех пор, пока
            //   данные по нему не будут либо вызваны (например, в месте энумерации списка),
            //   либо полностью сформирован (если один запрос используется внутри другого).
            //
            var Query1 =
                from B in PaymentsData.Bonuses                                  //   Собираем все записи о бонусах.
                join E in PaymentsData.Employees                                //   Присоединяем данные о сотрудниках, которые
                on B.EmployeeID equals E.EmployeeID                             //      связаны с этими бонусами.
                join D in PaymentsData.Departments                              //      А также присоединяем данные об отделах, которые
                on E.DepartmentID equals D.DepartmentID                         //         связаны с присоединенными только что сотрудниками.
                group B by D.DepartmentID into GroupedData                      //      Группируем выборку по отделам.
                let TotalBonusSum = GroupedData.Sum(x => x.Value)               //      Создаем переменную и создаем для нее агрегатный запрос суммы.
                                    where TotalBonusSum >= param_ReportBonusSum //      Делаем выборку по полученному запросу.
                                    select new                                  //   Выбираем нужные данные:
            {
                DepartmentID    = GroupedData.Key,                              //     а) поле Идентификатора отдела
                TotalBonusValue = TotalBonusSum,                                //     б) и сумму бонусов по этому отделу
            };

            //   Создаем второй основной комплексный запрос на основе первого.
            //   К данным по суммам бонусам нам нужно присоединить название отдела.
            IEnumerable <Models.DepartmentTotalBonusInfo> DepartmentBonusList =
                from Q in Query1
                join D in PaymentsData.Departments
                on Q.DepartmentID equals D.DepartmentID
                select new Models.DepartmentTotalBonusInfo {
                DepartmentID    = Q.DepartmentID,
                DepartmentName  = D.Name,
                TotalBonusValue = Q.TotalBonusValue,
            };

            //   Передаем запрос. Обращение к базе данных произойдет *только* при первом обращении
            //   к списку энумерации. То есть, только внутри Вида.
            return(PartialView(DepartmentBonusList));
        }
        List <GroupedData> GetGroups()
        {
            List <GroupedData> groups = new List <GroupedData>();

            for (int i = 1; i < 100; i++)
            {
                var group = new GroupedData {
                    GroupName = $"Group {i}"
                };

                group.Add(new GroupItem {
                    DisplayText = $"Item {i}"
                });

                groups.Add(group);
            }

            return(groups);
        }
        private GroupedData <DateTime, AudioItem> CreateAudioItemGroup(IGroup <SelectableItem <AudioItem>, DateTime> group)
        {
            var audioItemGroup = new GroupedData <DateTime, SelectableItem <AudioItem> >()
            {
                Key = group.GroupKey
            };

            ReadOnlyObservableCollection <SelectableItem <AudioItem> > audioItemChildCollection;
            var subscriptions = group.List
                                .Connect()
                                .Sort(SortExpressionComparer <SelectableItem <AudioItem> > .Descending(x => x.Item.CreatedDateUtc).ThenByDescending(x => x.Item.Title))
                                .ObserveOn(SynchronizationContext.Current)
                                .Bind(out audioItemChildCollection)
                                .Subscribe();

            DisposableItems.Add(subscriptions);

            audioItemGroup.ChildItems = audioItemChildCollection;
            return(audioItemGroup);
        }
示例#11
0
        protected override void Init()
        {
            BackgroundColor = Color.Yellow;

            var list = new ObservableCollection <GroupedData>();

            for (int i = 1; i <= 2; i++)
            {
                var group = new GroupedData {
                    GroupName = $"Group #{i}"
                };

                for (int j = 1; j < 30; j++)
                {
                    var item = new MyItem {
                        Title = $"Item: #{i}-{j}", Color = (j % 2 == 0) ? Color.Blue : Color.Red
                    };

                    group.Add(item);
                }
                list.Add(group);
            }

            ListItems = list;

            BindingContext = this;
            var lst = new ListView(ListViewCachingStrategy.RecycleElement)
            {
                BackgroundColor       = Color.Transparent,
                ItemTemplate          = new DataTemplate(typeof(ItemTemplate)),
                GroupHeaderTemplate   = new DataTemplate(typeof(GroupHeaderTemplate)),
                IsGroupingEnabled     = true,
                GroupDisplayBinding   = new Binding(nameof(GroupedData.GroupName)),
                GroupShortNameBinding = new Binding(nameof(GroupedData.GroupName)),
            };

            lst.SeparatorVisibility = SeparatorVisibility.None;
            lst.SeparatorColor      = Color.Green;
            lst.SetBinding(ListView.ItemsSourceProperty, nameof(ListItems));
            Content = lst;
        }
        public ReorderableGroupedData(GroupedData <GroupT, ItemT> data, bool draggable, bool displayAddButton, bool displayRemoveButton, bool showButtonsOnBottom, bool showExtraButtonsOnBottom, plyReorderableList.Button[] extraButtons = null)
        {
            Type typeFromHandle = typeof(GroupedDataItem);

            this.displayAddButton              = displayAddButton;
            this.displayRemoveButton           = displayRemoveButton;
            this.extraButtons                  = extraButtons;
            this.currGroupIdx                  = -1;
            this.groupedData                   = data;
            this.currList                      = this.fakeList;
            this.orderList                     = new ReorderableList(this.currList, typeFromHandle, draggable, false, false, false);
            this.orderList.headerHeight        = 0f;
            this.orderList.footerHeight        = 0f;
            this.orderList.drawHeaderCallback  = this.FakeDrawHeader;
            this.orderList.drawElementCallback = this.DrawElement;
            this.orderList.onAddCallback       = this.OnAdd;
            this.orderList.onRemoveCallback    = this.OnRemove;
            this.orderList.onReorderCallback   = this.OnReorder;
            this.orderList.onSelectCallback    = this.OnSelect;
            this.RefreshGroupLabels();
        }
示例#13
0
        async void FillResults(GroupedData results, int items, bool clear)
        {
            results.Clear();

            await Task.Delay(200);

            for (int i = 0; i < items; i++)
            {
                results.Add(new GroupItem {
                    DisplayText = $"Text for ListView item {i}"
                });
            }

            if (!clear)
            {
                return;
            }

            await Task.Delay(1000);

            results.Clear();
        }
示例#14
0
 private static void DecideStage1()
 {
     foreach (Data data in Acces.DataSet)
     {
         var groupOfAmmount = EvaluateGroupOfAmmountStage1(data.Menge);
         var groupOfValue   = EvaluateGroupOfValueStage1(data.Wert * data.Menge);
         var same           = CompareGoup(groupOfValue, groupOfAmmount);
         //TODO: Auslagern
         if (same)
         {
             GroupedData dat = new GroupedData()
             {
                 Data = data, Group = groupOfAmmount
             };
             Acces.groupedData.Add(dat);
         }
         else
         {
             DecideStage2(data, groupOfValue, groupOfAmmount);
         }
     }
     var a = Acces.groupedData;//TODO: Entfernen
 }
        public static string Convert
        (
            int[] aData,
            string aSeparator = CConvertOptions.DefaultSeparator,
            string aJoint     = CConvertOptions.DefaultJoint
        )
        {
            StringBuilder Result = new StringBuilder();


            //   Создаем пронумерованный набор данных.
            IEnumerable <NumberRecord> DataSet = aData.Select
                                                 (
                (NumericValue, Index) =>
                new NumberRecord
            {
                OrderedIndex = Index + 1,
                Data         = NumericValue,
                Difference   = NumericValue - (Index + 1),
            }
                                                 );

            //   Делаем выборку по группам.
            IEnumerable <NumberRange> ResultSet =
                from Data in DataSet
                orderby Data.OrderedIndex
                group Data by Data.Difference into GroupedData
                select new NumberRange()
            {
                DifferenceKey = GroupedData.Key,
                StartValue    = GroupedData.Min(x => x.Data),
                Count         = GroupedData.Count(),
            };

            //   Формируем строку из полученных данных.
            foreach (var R in ResultSet)
            {
                //Result.AppendFormat("\n[Key={0}, Val={1}, Count={2}]", R.DifferenceKey, R.StartValue, R.Count);

                if (R.Count == 1)
                {
                    Result.AppendFormat
                    (
                        "{0}{1}",
                        /* 0 */ R.StartValue,
                        /* 1 */ aSeparator
                    );
                }
                else
                {
                    Result.AppendFormat
                    (
                        "{0}{2}{1}{3}",
                        /* 0 */ R.StartValue,
                        /* 1 */ R.StartValue + R.Count - 1,
                        /* 2 */ aJoint,
                        /* 3 */ aSeparator
                    );
                }
            }

            //   Удаляем побыстрому последний разделитель.
            //   При условии, что хотя бы один элемент был вставлен.
            if (ResultSet.Count() > 0)
            {
                Result.Length -= aSeparator.Length;
            }


            return(Result.ToString());
        }
示例#16
0
        private async Task <IEnumerable> GetUpdatesDataCore()
        {
            //Get all updates
            StorageFolder sf = await ApplicationData.Current.LocalFolder.CreateFolderAsync("Data", CreationCollisionOption.OpenIfExists);

            StorageFile st = await sf.CreateFileAsync("Data.xml", CreationCollisionOption.OpenIfExists);

            var updates = new List <PersonModel>();

            XmlDocument doc = new XmlDocument();

            var content = await FileIO.ReadTextAsync(st);

            if (!string.IsNullOrEmpty(content))
            {
                doc.LoadXml(content);

                var items = doc.GetElementsByTagName("person");

                foreach (var item in items)
                {
                    var person = new PersonModel();

                    foreach (var itemChild in item.ChildNodes)
                    {
                        switch (itemChild.NodeName)
                        {
                        case "Initials":
                            person.Initials = itemChild.InnerText;
                            break;

                        case "Height":
                            person.Height = double.Parse(itemChild.InnerText);
                            break;

                        case "Age":
                            person.Age = int.Parse(itemChild.InnerText);
                            break;

                        case "Bmi":
                            person.Bmi = double.Parse(itemChild.InnerText);
                            break;

                        case "Weight":
                            person.Weight = double.Parse(itemChild.InnerText);
                            break;

                        case "Sex":
                            person.SelectedSex = (SexType)Enum.Parse(typeof(SexType), itemChild.InnerText);
                            break;

                        default:
                            break;
                        }
                    }

                    updates.Add(person);
                }
            }

            var updatesModel = from c in updates
                               select new PersonModel()
            {
                Initials    = c.Initials,
                Height      = c.Height,
                Weight      = c.Weight,
                Age         = c.Age,
                Bmi         = c.Bmi,
                SelectedSex = c.SelectedSex
            };

            var groupedData = from u in updatesModel
                              group u by u.Initials into groupData
                              select new
            {
                Name  = groupData.Key,
                Items = groupData
            };

            ObservableCollection <GroupedData <PersonModel> > data = new ObservableCollection <GroupedData <PersonModel> >();

            foreach (var item in groupedData)
            {
                GroupedData <PersonModel> list = new GroupedData <PersonModel>();
                list.Key = item.Name;
                foreach (var itemInGroup in item.Items)
                {
                    list.Add(itemInGroup);
                }
                data.Add(list);
            }

            return(data);
        }
示例#17
0
        private IEnumerable GetUpdatesCategoriesDataCore()
        {
            var updates = new List <CategoryModel>();

            var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

            if (localSettings.Values.ContainsKey("countCategories"))
            {
                var countCat = int.Parse(localSettings.Values["countCategories"].ToString());
                for (int i = 0; i < countCat; i++)
                {
                    if (localSettings.Values.ContainsKey("category" + i))
                    {
                        ApplicationDataCompositeValue composite = (ApplicationDataCompositeValue)localSettings.Values["category" + i];
                        var cat = new CategoryModel();
                        cat.Title = composite["title"].ToString();
                        cat.From  = double.Parse(composite["from"].ToString());
                        cat.To    = double.Parse(composite["to"].ToString());

                        updates.Add(cat);
                    }
                }
            }


            //var categories = localSettings.Values["category"];
            //var cat = new CategoryModel();
            //if (localSettings.Values["category"])
            //cat.Title = categories["title"];
            //cat.From = categories["from"];
            //cat.To = categories["to"];



            var categoriesModel = from c in updates
                                  select new CategoryModel()
            {
                Title = c.Title,
                From  = c.From,
                To    = c.To,
            };

            var groupedData = from u in categoriesModel
                              group u by u.Title into groupData
                              select new
            {
                Name  = groupData.Key,
                Items = groupData
            };

            ObservableCollection <GroupedData <CategoryModel> > data = new ObservableCollection <GroupedData <CategoryModel> >();

            foreach (var item in groupedData)
            {
                GroupedData <CategoryModel> list = new GroupedData <CategoryModel>();
                list.Key = item.Name;
                foreach (var itemInGroup in item.Items)
                {
                    list.Add(itemInGroup);
                }
                data.Add(list);
            }

            return(data);
        }
示例#18
0
        protected override void Init()
        {
            List <GroupedData> groups = new List <GroupedData>();

            var group1 = new GroupedData {
                GroupName = "Group #1"
            };

            group1.Add(new GroupItem {
                DisplayText = "Text for ListView item 1.1"
            });
            group1.Add(new GroupItem {
                DisplayText = "Text for ListView item 1.2"
            });
            groups.Add(group1);

            var group2 = new GroupedData {
                GroupName = "Group #2"
            };

            group2.Add(new GroupItem {
                DisplayText = "Text for ListVIew item 2.1"
            });
            group2.Add(new GroupItem {
                DisplayText = "Text for ListView item 2.2"
            });
            groups.Add(group2);

            var itemTemplate = new DataTemplate(typeof(GroupItemTemplate));

            itemTemplate.CreateContent();

            var groupHeaderTemplate = new DataTemplate(typeof(GroupHeaderTemplate));

            groupHeaderTemplate.CreateContent();

            var listView = new ListView
            {
                IsGroupingEnabled     = true,
                GroupDisplayBinding   = new Binding("GroupName"),
                GroupShortNameBinding = new Binding("GroupName"),
                HasUnevenRows         = Device.RuntimePlatform == Device.Android,

                ItemTemplate        = itemTemplate,
                GroupHeaderTemplate = groupHeaderTemplate,

                ItemsSource = groups
            };

            Content = new StackLayout
            {
                VerticalOptions = LayoutOptions.Center,
                Children        =
                {
                    new Label       {
                        Text = "The group headers below should extend to the width of the screen. If they aren't the width of the screen, this test has failed."
                    },
                    new ContentView {
                        Content           = listView,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        Padding           = 0
                    }
                }
            };
        }
    private async Task CreateDocumentForCalendarData(GroupedData ParsedJson)
    {
        this.client = new DocumentClient(new Uri(EndpointUri), PrimaryKey);

        await client.CreateDocumentAsync("dbs/{dbname}/colls/{collectionname}", ParsedJson);
    }