Exemplo n.º 1
0
        //Download pages and tags info
        async Task FetchLOData(int lo_id, bool images)
        {
            int LOID = lo_id;

            var list = await _mLearningService.GetPagesByLO(LOID);



            if (images)
            {
                IncrementalDownload _manager = new IncrementalDownload();
                await _manager.TryLoadByteVector <Page>(0, list
                                                        , (pos, bytes) =>
                {
                }
                                                        , (page) =>
                {
                    return(page.url_img);
                });
            }



            var tags = await _mLearningService.GetTagsByLO(LOID);


            //Download xmls

            //foreach (var item in list)
            //{

            //    await _mLearningService.OpenLOPage(item.url_xml);
            //}
        }
Exemplo n.º 2
0
        async Task LoadPages(int loListIndex, bool images)
        {
            var lo_obj = LOsInCircle[loListIndex];
            var LOID   = lo_obj.lo.id;

            var list = await _mLearningService.GetPagesByLO(LOID);



            var AllPagesList = new ObservableCollection <page_wrapper>();

            //Loading json content to memory
            foreach (var item in list)
            {
                Mvx.Trace("Id: " + item.id);
                LOContent locontent = null;
                try
                {
                    locontent = JsonConvert.DeserializeObject <LOContent>(item.content);
                }
                catch (Exception e)
                {
                    Mvx.Trace("Serialization error: " + e.Message);
                }


                AllPagesList.Add(new page_wrapper {
                    page = item, content = locontent                                                 /*, id=pagecount*/
                });
                pagecount++;
            }


            var tags = await _mLearningService.GetTagsByLO(LOID);

            PageTags = new ObservableCollection <tag_by_page>(tags);

            var tlist = tags.GroupBy(t => t.name).Select(t => t).ToList();

            var GroupedPagesList = new ObservableCollection <page_collection_wrapper>();

            for (int i = 0; i < tlist.Count; i++)
            {
                IEnumerable <tag_by_page> group = tlist[i];
                var groupCollection             = new ObservableCollection <page_wrapper>();

                foreach (var item in group)
                {
                    groupCollection.Add(AllPagesList.Where(p => p.page.id == item.page_id).First());
                }

                GroupedPagesList.Add(new page_collection_wrapper {
                    PagesList = groupCollection, TagName = group.FirstOrDefault().name
                });

                if (images)
                {
                    UpdatePagesImages(0, GroupedPagesList[i].PagesList);
                }

                //  GroupedPagesList.Add(AllPagesList.Where(p => p.page.id == item.page_id).First());
            }


            LOsInCircle[loListIndex].stack.StacksList = GroupedPagesList;
            LOsInCircle[loListIndex].stack.IsLoaded   = true;

            LOCurrentIndex = loListIndex;

            UpdateExtraInfo(LOCurrentIndex);

            //Download xmls

            //foreach (var item in list)
            //{

            //    await _mLearningService.OpenLOPage(item.url_xml);
            //}
        }