async Task UpdateUserImages(int index)
        {
            //await _user_image_manager.TryLoadByteVector<user_by_circle_wrapper>(index, UsersList.ToList()
            //     , (pos, bytes) =>
            //     {
            //         UsersList[pos].userImage= bytes;
            //     }
            //     , (usr) =>
            //     {
            //         return usr.user.image_url;
            //     });

            await BlockDownload.TryPutBytesInVector <user_by_circle_wrapper>(UsersList.ToList()
                                                                             , (pos, bytes) =>
            {
                if (pos < UsersList.Count)
                {
                    UsersList[pos].userImage = bytes;
                }
            }
                                                                             , (usr) =>
            {
                return(usr.user.image_url);
            });
        }
        async Task UpdateLOImages(int index, ObservableCollection <lo_by_circle_wrapper> list)
        {
            //_locover_manager.TryLoadByteVector<lo_by_circle_wrapper>(index, list.ToList()
            //    , (pos, bytes) =>
            //    {
            //        list[pos].cover_bytes = bytes;
            //    }
            //    , (lo) =>
            //    {
            //        return lo.lo.url_cover;
            //    });

            await BlockDownload.TryPutBytesInVector <lo_by_circle_wrapper>(list.ToList(), (pos, bytes) =>
            {
                if (pos < list.Count)
                {
                    list[pos].cover_bytes = bytes;
                }
            },
                                                                           (lo) => { return(lo.lo.url_cover); });


            await BlockDownload.TryPutBytesInVector <lo_by_circle_wrapper>(list.ToList(), (pos, bytes) =>
            {
                if (pos < list.Count)
                {
                    list[pos].background_bytes = bytes;
                }
            },
                                                                           (lo) => { return(lo.lo.url_background); });
        }
示例#3
0
        //Not incremental
        async Task LoadBackgroundImages()
        {
            //await BlockDownload.TryLoadByteVector<lo_by_circle_wrapper>(LOsInCircle.ToList(),
            //     (pos, bytes) => { LOsInCircle[pos].background_bytes = bytes; },
            //     (lo) => {return lo.lo.url_background;}
            //     );

            await BlockDownload.TryPutBytesInVector <lo_by_circle_wrapper>(LOsInCircle.ToList(),
                                                                           (pos, bytes) => { LOsInCircle[pos].background_bytes = bytes; },
                                                                           (lo) => { return(lo.lo.url_background); }
                                                                           );
        }
        async Task LoadLearningObjects(int circle_id)
        {
            if (LearningOjectsList != null)
            {
                LearningOjectsList.Clear();
            }

            var list = await _mLearningService.GetLOByCircleAndUser(circle_id, UserID);

            int circleIndex = CirclesList.IndexOf(CirclesList.Where(c => c.id == circle_id).First());

            var circleLOList = new List <lo_by_circle_wrapper>();



            foreach (var item in list)
            {
                circleLOList.Add(new lo_by_circle_wrapper {
                    lo = item
                });
            }

            CirclesLearningObjects[circleIndex] = new ObservableCollection <lo_by_circle_wrapper>(circleLOList);

            LearningOjectsList = CirclesLearningObjects[circleIndex];


            await BlockDownload.TryPutBytesInVector <MLearning.Core.ViewModels.MainViewModel.lo_by_circle_wrapper>(LearningOjectsList.ToList(),
                                                                                                                   (pos, bytes) => {
                if (pos < LearningOjectsList.Count)
                {
                    LearningOjectsList[pos].background_bytes = bytes;
                }
            },
                                                                                                                   (lo) => { return(lo.lo.url_background); }
                                                                                                                   );


            _locover_manager.Clear();

            CurrentIndexDisplaying = 0;

            await UpdateLOImages(CurrentIndexDisplaying, CirclesLearningObjects[CirclesList.IndexOf(CirclesList.Where(c => c.id == CircleID).First())]);
        }
示例#5
0
            bool TryInsertBlocks(BlockDownload blockDownload)
            {
                foreach (Block block in blockDownload.Blocks)
                {
                    Console.WriteLine(
                        "Insert block {0} from download {1}",
                        block.Header.Hash.ToHexString(),
                        blockDownload.Index);

                    if (!Blockchain.TryInsertBlock(
                            block,
                            flagValidateHeader: false))
                    {
                        return(false);
                    }

                    Blockchain.ArchiveBlock(
                        block,
                        UTXOIMAGE_INTERVAL_SYNC);
                }

                return(true);
            }
        async Task UpdateUserPostImages(int index)
        {
            //_post_image_manager.TryLoadByteVector<post_with_username_wrapper>(index, PostsList.ToList()
            //    , (pos, bytes) =>
            //    {
            //        PostsList[pos].userImage = bytes;
            //    }
            //    , (post) =>
            //    {
            //        return post.post.image_url;
            //    });

            await BlockDownload.TryPutBytesInVector <post_with_username_wrapper>(PostsList.ToList(), (pos, bytes) =>
            {
                if (pos < PostsList.Count)
                {
                    PostsList[pos].userImage = bytes;
                }
            }
                                                                                 , (post) =>
            {
                return(post.post.image_url);
            });
        }
示例#7
0
            void EnqueueBlockDownloadInvalid(
                BlockDownload download)
            {
                Console.WriteLine(
                    "Enqueue block download {0}",
                    download.Index);

                download.IndexHeaderExpected = 0;
                download.Blocks.Clear();

                int indexdownload = QueueDownloadsInvalid
                                    .FindIndex(b => b.Index > download.Index);

                if (indexdownload == -1)
                {
                    QueueDownloadsInvalid.Add(download);
                }
                else
                {
                    QueueDownloadsInvalid.Insert(
                        indexdownload,
                        download);
                }
            }