Beispiel #1
0
        async void DoOpenFirstSlidePage(lo_by_circle_wrapper learningobj)
        {
            //await  _mLearningService.OpenLearningObject(learningobj.lo.id,learningobj.lo.url_package,UserID);

            try
            {
                //Download all the data of the selected LO

                foreach (var item in LearningOjectsList)
                {
                    if (item.lo.id == learningobj.lo.id)
                    {
                        var list = await _mLearningService.GetPagesByLO(learningobj.lo.id);

                        //Page result = await this._mLearningService.GetFirstSlidePageByLOSection(item.lo.id);
                        if (list != null)
                        {
                            Debug.WriteLine("indexList", "result...: " + list.Count);

                            /** Problema: Datos no Ordenados por ID
                             *  Solucion: Usar in SortedDictionary
                             * */
                            var indexTmp = new SortedDictionary <int, IList <Page> > ();
                            foreach (var page in list)
                            {
                                IList <Page> resultTmp;
                                if (!indexTmp.TryGetValue((int)page.LOsection_id, out resultTmp))
                                {
                                    var ls = new List <Page>();
                                    ls.Add(page);

                                    indexTmp [(int)page.LOsection_id] = ls;
                                }
                                else
                                {
                                    resultTmp.Add(page);
                                }
                            }


                            ContentByUnit = new ObservableDictionary <int, IList <Page> >(indexTmp);
                        }
                    }
                }
            }
            catch (WebException e)
            {
                ConnectionOK = false;
            }
            catch (HttpRequestException e)
            {
                ConnectionOK = false;
            }
            catch (MobileServiceInvalidOperationException e)
            {
                Mvx.Trace("MobileServiceInvalidOperationException " + e.Message);
                OperationOK = false;
            }
        }
Beispiel #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);
            //}
        }