예제 #1
0
        public async Task<List<Models.Ui.HomeItem>> GetUpdates(string category, Interfaces.IStorage storage)
        {
          

            List<Models.Ui.HomeItem> LastResult = new List<Models.Ui.HomeItem>();
            List<Models.Ui.HomeItem> OutResult = new List<Models.Ui.HomeItem>();
            try
            {
                var onld = await storage.Exists(Constants.StorageKeys.AGENT_DATA);
                if (onld)
                {
                    var lastResultjson = await storage.ReadData(Constants.StorageKeys.AGENT_DATA);
                    LastResult = lastResultjson.LoadFromJson<List<Models.Ui.HomeItem>>();
                }
                var current = await service.GetPostsFrom(category, 0);

                foreach (var item in current.posts)
                {
                    string img = item.thumbnail;
                    if (string.IsNullOrEmpty(img))
                    {

                        img = Regex.Match(item.content, "<img.+?src=[\"'](.+?)[\"'].+?>", RegexOptions.IgnoreCase).Groups[1].Value;
                    }
                    var p = new Models.Ui.HomeItem
                    {
                        Title = item.title_plain,
                        Resume = item.excerpt,
                        CategoryId = "112",
                        Date = item.date,
                        UniqueId = item.id.ToString(),
                        Url = img,
                        Author = item.author.name
                    };

                    if (!LastResult.Any(o => o.UniqueId ==p.UniqueId))
                    {
                        OutResult.Add(p);
                    }
                }
            }
            catch (Exception ex)
            {
                
                throw ex;
            }

            // await storage.WriteData(Constants.StorageKeys.AGENT_DATA, Result.SaveAsJson());


            return OutResult;
        }
예제 #2
0
        public async Task <List <Models.Ui.HomeItem> > GetUpdates(string category, Interfaces.IStorage storage)
        {
            List <Models.Ui.HomeItem> LastResult = new List <Models.Ui.HomeItem>();
            List <Models.Ui.HomeItem> OutResult  = new List <Models.Ui.HomeItem>();

            try
            {
                var onld = await storage.Exists(Constants.StorageKeys.AGENT_DATA);

                if (onld)
                {
                    var lastResultjson = await storage.ReadData(Constants.StorageKeys.AGENT_DATA);

                    LastResult = lastResultjson.LoadFromJson <List <Models.Ui.HomeItem> >();
                }
                var current = await service.GetPostsFrom(category, 0);

                foreach (var item in current.posts)
                {
                    string img = item.thumbnail;
                    if (string.IsNullOrEmpty(img))
                    {
                        img = Regex.Match(item.content, "<img.+?src=[\"'](.+?)[\"'].+?>", RegexOptions.IgnoreCase).Groups[1].Value;
                    }
                    var p = new Models.Ui.HomeItem
                    {
                        Title      = item.title_plain,
                        Resume     = item.excerpt,
                        CategoryId = "112",
                        Date       = item.date,
                        UniqueId   = item.id.ToString(),
                        Url        = img,
                        Author     = item.author.name
                    };

                    if (!LastResult.Any(o => o.UniqueId == p.UniqueId))
                    {
                        OutResult.Add(p);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            // await storage.WriteData(Constants.StorageKeys.AGENT_DATA, Result.SaveAsJson());


            return(OutResult);
        }
예제 #3
0
        private async Task LoadLastPosts()
        {
            AppBase.Current.Posts = new Dictionary <string, Models.REST.CategoryPosts.RootObject>();
            var latest = await Broker.GetPostsFrom("112", 0);

            Items.Clear();

            foreach (var item in latest.posts)
            {
                AppBase.Current.Posts["112"] = latest;

                string img = item.thumbnail;
                if (string.IsNullOrEmpty(img))
                {
                    img = Regex.Match(item.content, "<img.+?src=[\"'](.+?)[\"'].+?>", RegexOptions.IgnoreCase).Groups[1].Value;
                }
                var p = new Models.Ui.HomeItem
                {
                    Title      = _uxService.CleanHTML(item.title_plain),
                    Resume     = item.excerpt,
                    CategoryId = "112",
                    Date       = item.date,
                    UniqueId   = item.id.ToString(),
                    Url        = img,
                    Author     = item.author.name
                };
                this.Items.Add(p);
            }

            await _storageService.WriteData(Constants.StorageKeys.AGENT_DATA, Items.SaveAsJson());

            if (latest.posts[0].attachments != null && latest.posts[0].attachments.Count > 0)
            {
                BigImage = latest.posts[0].attachments[0].images.full.url;
            }
        }
예제 #4
0
        private async Task LoadLastPosts()
        {
            AppBase.Current.Posts = new Dictionary<string, Models.REST.CategoryPosts.RootObject>();
            var latest = await Broker.GetPostsFrom("112", 0);
            Items.Clear();

            foreach (var item in latest.posts)
            {
                AppBase.Current.Posts["112"] = latest;

                string img = item.thumbnail;
                if (string.IsNullOrEmpty(img))
                {

                    img = Regex.Match(item.content, "<img.+?src=[\"'](.+?)[\"'].+?>", RegexOptions.IgnoreCase).Groups[1].Value;
                }
                var p = new Models.Ui.HomeItem
                {
                    Title = _uxService.CleanHTML(item.title_plain),
                    Resume = item.excerpt,
                    CategoryId = "112",
                    Date = item.date,
                    UniqueId = item.id.ToString(),
                    Url = img,
                    Author = item.author.name
                };
                this.Items.Add(p);

            }

            await _storageService.WriteData(Constants.StorageKeys.AGENT_DATA, Items.SaveAsJson());

            if (latest.posts[0].attachments != null && latest.posts[0].attachments.Count > 0)
                BigImage = latest.posts[0].attachments[0].images.full.url;
        }
 private async void LoadAppItems()
 {
     var apps = await serviceBroker.GetAppreCommended();
     this.AppItems.Clear();
     if (apps.count > 0)
     {
         foreach(var item in apps.posts)
         {
             var img = item.thumbnail;
             var p = new Models.Ui.HomeItem
             {
                 Title = item.title,
                 UniqueId = item.id.ToString(),
                 Url = img,
             };
             this.AppItems.Add(p);
         }
     }
     this._progressService.Hide();
 }
        private async Task LoadLastPosts()
        {
            var latest = await serviceBroker.GetLatestPosts(0);
            Items.Clear();
            if (latest.count > 0)
            {
                foreach (var item in latest.posts)
                {
                    string img = item.thumbnail;
                    var p = new Models.Ui.HomeItem
                    {
                        Title = item.title,
                        UniqueId = item.id.ToString(),
                        Url = img,
                    };
                    this.Items.Add(p);
                }
                if (latest.posts[0].attachments != null && latest.posts[0].attachments.Count > 0)
                    BigImage = latest.posts[0].thumbnail;//[0].images.medium.url;
            }
            this.LoadAppItems();

        }