Beispiel #1
0
        async override protected void OnAppearing()
        {
            base.OnAppearing();
            NetworkModel.NetworkManager networkManager = new NetworkModel.NetworkManager();
            if (networkManager.IsNetworkAvailable())
            {
                var json = await GetEmployeesList();

                System.Diagnostics.Debug.WriteLine("Employees content json:" + json);
                List <EmployeeVM> employees = JsonConvert.DeserializeObject <List <EmployeeVM> >(json);
                System.Diagnostics.Debug.WriteLine("Employees content employees" + employees.Count);
                foreach (EmployeeVM em in employees)
                {
                    System.Diagnostics.Debug.WriteLine("Employees content ID:" + em.email_id);
                    if (em.email_id != null)
                    {
                        // int id = em.Data.id;
                        string ID = em.email_id;
                        System.Diagnostics.Debug.WriteLine("Employees content:" + ID);

                        EmployeeViewModel employeeViewModel = new EmployeeViewModel();
                        // employeeViewModel.id = id;
                        employeeViewModel.email_id = ID;
                        EmployeeList.Items.Add(ID);
                        employeeVM.EmployeeList.Add(employeeViewModel);
                    }
                }
            }
            else
            {
                await DisplayAlert("Warning", "No network, please check your internet connection and try again", "Ok");
            }
        }
Beispiel #2
0
        async void GetLeaveDetails(string userName)
        {
            NetworkModel.NetworkManager networkManager = new NetworkModel.NetworkManager();
            if (networkManager.IsNetworkAvailable())
            {
                var client  = new HttpClient();
                var RestURL = "http://zymolytic-brass.000webhostapp.com/?id=13&useremail=" + userName;
                //var formContent = new FormUrlEncodedContent(new[]
                // {
                //   new KeyValuePair<string, string>("id", "13"),
                //   new KeyValuePair<string, string>("useremail", userName), });


                client.BaseAddress = new Uri(RestURL);

                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                HttpResponseMessage response = await client.GetAsync(RestURL);

                if (response.IsSuccessStatusCode)
                {
                    string result = await response.Content.ReadAsStringAsync();

                    System.Diagnostics.Debug.WriteLine("success code:" + result);
                    System.Diagnostics.Debug.WriteLine(result);
                    int index = result.IndexOf("<img", 0);
                    if (index != -1)
                    {
                        var source = new HtmlWebViewSource();
                        System.Diagnostics.Debug.WriteLine(result.Substring(0, index));
                        var text = result.Substring(0, index);
                        source.Html    = text;
                        browser.Source = source;
                    }
                    else
                    {
                        var source = new HtmlWebViewSource();

                        var text = result;
                        source.Html    = text;
                        browser.Source = source;
                    }
                }
            }
            else
            {
                await DisplayAlert("Warning", "No network, please check your internet connection and try again", "Ok");
            }
        }
Beispiel #3
0
        async void GetLeaveCounts(string userName, string typeOfLeave)
        {
            NetworkModel.NetworkManager networkManager = new NetworkModel.NetworkManager();
            if (networkManager.IsNetworkAvailable())
            {
                var client  = new HttpClient();
                var RestURL = "http://zymolytic-brass.000webhostapp.com/?id=6&useremail=" + userName + "&type_of_leave=" + typeOfLeave;
                System.Diagnostics.Debug.WriteLine("RestUrl:" + RestURL);
                client.BaseAddress = new Uri(RestURL);

                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                HttpResponseMessage response = await client.GetAsync(RestURL);

                var json = await response.Content.ReadAsStringAsync();

                try
                {
                    var leaveModel = JsonConvert.DeserializeObject <JsonModelClass.UserLeaveCount>(json);
                    if (typeOfLeave.Equals("0"))
                    {
                        sick.Text = "+" + leaveModel.leave_count;
                    }
                    else if (typeOfLeave.Equals("1"))
                    {
                        casual.Text = "+" + leaveModel.leave_count;
                    }
                    else
                    {
                        earned.Text = "+" + leaveModel.leave_count;
                    }
                }
                catch (JsonSerializationException ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.ToString());
                    await DisplayAlert("Warning", "Unable to fetch leave details", "OK");
                }
            }
            else
            {
                await DisplayAlert("Warning", "No network, please check your internet connection and try again", "Ok");
            }
        }