public async Task <List <ModelTemplate> > LoadData(string url, HttpControler httpControler) { using (HttpResponseMessage response = await httpControler.ApiClient.GetAsync(url)) { if (response.IsSuccessStatusCode) { List <ModelTemplate> models = await response.Content.ReadAsAsync <List <ModelTemplate> >(); return(models); } throw new Exception(response.ReasonPhrase); } }
public Program() { _mainWindow = new MainWindow(); _layoutControler = new LayoutControler(_mainWindow, this); _pagesControler = new PagesControler(this); _httpControler = new HttpControler(); _layoutControler.ChangeLayout("PlainLayout"); _pagesControler.PushPage("LoginPage"); _httpControler.InitializeClient(); Application.Run(_mainWindow._form); }
public async Task <List <ModelTemplate> > SendData(string url, HttpControler httpControler, HttpContent content) { using (HttpResponseMessage response = await httpControler.ApiClient.PostAsync(url, content)) { if (response.IsSuccessStatusCode) { List <ModelTemplate> models = await response.Content.ReadAsAsync <List <ModelTemplate> >(); /* * var str = await response.Content.ReadAsStringAsync(); * Console.WriteLine(str); * Console.WriteLine(response.StatusCode); * //*/ return(models); //return true; } Console.WriteLine(response.StatusCode); Console.WriteLine(response.ReasonPhrase); Console.WriteLine(response.Content.ReadAsStringAsync().Result); //throw new Exception(response.ReasonPhrase); return(new List <ModelTemplate>()); } }
public App(IntPtr context) { InitializeComponent(); string _login = CrossSettings.Current.GetValueOrDefault("sipPhoneLogin", ""); string deviceId = CrossDeviceInfo.Current.Id; string deviceInfo = CrossDeviceInfo.Current.Manufacturer + " " + CrossDeviceInfo.Current.Model + " " + CrossDeviceInfo.Current.Platform + " " + CrossDeviceInfo.Current.Version; try { Manager = new LinphoneManager(); Manager.Init(ConfigFilePath, FactoryFilePath, context); } catch (Exception ex) { HttpControler.ErrorLogSend(_login, deviceInfo, deviceId, "Core init fail. App.xaml.cs " + ex.Message); } //MainPage = new NavigationPage(new TestPage()); if (_login == "") { MainPage = new NavigationPage(new LoginPage()) { BarBackgroundColor = Color.FromHex("#FFFFFF"), BarTextColor = Color.FromHex("#000000") }; //((NavigationPage)Xamarin.Forms.Application.Current.MainPage).BarBackgroundColor = Color.FromHex("#FF4C3F"); } else { MainPage = new NavigationPage(new MasterDetailMain()) { BarBackgroundColor = Color.FromHex("#FFFFFF"), BarTextColor = Color.FromHex("#000000") }; //((NavigationPage)Xamarin.Forms.Application.Current.MainPage).BarBackgroundColor = Color.FromHex("#FF4C3F"); } flagSleep = 0; }