public async Task RequestToken()
        {
            ToastNotifier.Notify(Interfaces.ToastNotificationType.Info, "Auth", "Выполняется вход", TimeSpan.Zero);
            var loginRequest = new RestRequest($"{restclient.BaseUrl}login", Method.POST);

            loginRequest.AddHeader("Content-Type", "application/x-www-form-urlencoded");
            loginRequest.AddParameter("log", "testuser");
            loginRequest.AddParameter("pwd", "testuser");
            //   loginRequest.
            restclient.FollowRedirects = false;
            restresponse  = restclient.Execute(loginRequest);
            loginresponse = restresponse;
            ToastNotifier.Notify(Interfaces.ToastNotificationType.Info, "Auth", "Cookie получены", TimeSpan.Zero);
            var postloginRequest = new RestRequest($"{restclient.BaseUrl}profile");

            foreach (var cookie in loginresponse.Cookies)
            {
                postloginRequest.AddCookie(cookie.Name, cookie.Value);
            }

            restclient.FollowRedirects = true;
            restresponse = restclient.Execute(postloginRequest);

            postloginResponse = restresponse;
            await Task.Run((Action)DecodeRestResponse);
        }
        private void DecodeRestResponse()
        {
            //    throw new NotImplementedException();
            //Title
            HtmlDocument htmlDocument = new HtmlDocument();

            htmlDocument.LoadHtml(postloginResponse.Content);
            Title = " Настройки пользователя " + htmlDocument.DocumentNode.SelectSingleNode("//*[@id=\"profile\"]/div[1]/div/p").InnerText;
            OnPropertyChanged("");


            ToastNotifier.Notify(Interfaces.ToastNotificationType.Success, "Auth", "Вход выполнен", TimeSpan.Zero);
        }
예제 #3
0
        private async Task LoadBlogs()
        {
            ToastNotifier.Notify(Interfaces.ToastNotificationType.Info, "Auth", "Loading blogs", TimeSpan.Zero);
            var blogsRequest = new RestRequest($"http://shostka.info/profile/?inset=blogs", Method.POST);

            blogsRequest.AddHeader("Content-Type", "application/x-www-form-urlencoded");
            foreach (var cookie in loginresponse.Cookies)
            {
                blogsRequest.AddCookie(cookie.Name, cookie.Value);
            }
            restresponse  = restclient.Execute(blogsRequest);
            blogsresponse = restresponse;
        }
예제 #4
0
        private void ItemsViewModel_URLImageCollReady()
        {
            //if (IsBusy) return;
            //IsBusy = true;
            int counter = 0;

            foreach (var item in Items)
            {
                try
                {
                    //_Items[counter].Links.FeaturedMedia.Add(new HttpsApiWOrgFeaturedmedia { Href = URLImageColl[counter] });
                    // Items[counter].Links.FeaturedMedia.ToList()[0].Href = URLImageColl[counter];
                    if (item.Links.FeaturedMedia != null)
                    {
                        // if (string.IsNullOrEmpty(item.Links.FeaturedMedia.ToList()[1].Href))

                        //дублируется коллекция
                        Items[counter].Links.FeaturedMedia = _Items[counter].Links.FeaturedMedia.ConcatSingle(new HttpsApiWOrgFeaturedmedia {
                            Href = URLImageColl[counter]
                        });
                    }

                    counter++;
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    Crashes.TrackError(e);
                    //  throw;
                }
                finally
                {
                    //   ToastNotifier.Notify(Interfaces.ToastNotificationType.Info, "Images", "Images loaded", TimeSpan.Zero);
                    IsBusy = false;
                    //  LoadMoreButtonVisibility = false;
                }
            }

            ToastNotifier.Notify(Interfaces.ToastNotificationType.Success, "Images", "Картинки загружены. Скоро начнется отображение", TimeSpan.Zero);
            MessagingCenter.Send(this, "ImagesLoaded");
            IsLoading = false;
            //IsBusy = false;
            OnPropertyChanged("");
            //   URLImageColl.Clear();
        }
예제 #5
0
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                URLImageColl.Clear();
                countPage = 2;
                Items.Clear();
                _Items.Clear();
                var latest10post = await wclient.Posts.Get();


                _Items = latest10post.ToList();
                ToastNotifier.Notify(Interfaces.ToastNotificationType.Info, "Images", "Загрузка картинок началась", TimeSpan.Zero);
                Task T = GetImageUrlCollection(latest10post);



                Items = new ObservableCollection <Post>(latest10post.ToList());


                LoadMoreButtonVisibility = false;
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                Crashes.TrackError(ex);
                //Items = new ObservableCollection<Post> { Title = new Title { Rendered = "Не удалось загрузить список новостей" } };//{"Не удалось загрузить список новостей"}
            }
            finally
            {
                OnPropertyChanged("");
                Title = "ШОСТКА.INFO";
                OnPropertyChanged("");
                IsBusy = false;
            }
        }
예제 #6
0
        public async Task RequestToken()
        {
            ToastNotifier.Notify(Interfaces.ToastNotificationType.Info, "Auth", "Signing in", TimeSpan.Zero);
            var loginRequest = new RestRequest($"{restclient.BaseUrl}login", Method.POST);

            loginRequest.AddHeader("Content-Type", "application/x-www-form-urlencoded");
            loginRequest.AddParameter("log", "testuser");
            loginRequest.AddParameter("pwd", "testuser");
            //   loginRequest.
            restclient.FollowRedirects = false;
            restresponse  = restclient.Execute(loginRequest);
            loginresponse = restresponse;
            ToastNotifier.Notify(Interfaces.ToastNotificationType.Info, "Auth", "Cookie recieved", TimeSpan.Zero);
            //  restresponse
            //         await wclient.GetSettings();
            // await wclient.RequestJWToken("testUser", "testuser");

            // var isValidToken = await wclient.IsValidJWToken();
        }
 public void ExecuteSaveSettings()
 {
     ToastNotifier.Notify(Interfaces.ToastNotificationType.Success, "Настройки сохранены", "Настройки успешно сохранены", TimeSpan.Zero);
     OnPropertyChanged("");
 }
예제 #8
0
        public void ToastNotificationSend(string title, string content, string pageUrl, string url)
        {
            var toastNotifier = new ToastNotifier(url);

            toastNotifier.Notify(title, content, pageUrl);
        }