// later work on it
        public async void test_fun(string warning_id)
        {
            try
            {
                var client = new HttpClient();
                client.BaseAddress = new Uri(App.api_url);
                var values = new Dictionary <string, string>();
                values.Add("session_string", App.session_string);
                values.Add("data", "{\"table\":\"warnings\",\"fields\":\"id,modified as date,warnings\"}");
                values.Add("extra", "{\"id\":\"" + warning_id + "\"}");
                values.Add("join", "[{\"table\":\"devices\",\"fields\":\"name\",\"where\":\"id\",\"is\":\"warnings.device_id\"}]");
                var content = new FormUrlEncodedContent(values);
                HttpResponseMessage response = await client.PostAsync("/itcrm/getElements/", content);

                var result = await response.Content.ReadAsStringAsync();
                await DisplayAlert("result!", result, "ok");

                WarningsResult warningDetail = JsonConvert.DeserializeObject <WarningsResult>(result);
                var            lst           = warningDetail.result[0];
                var            warning_list  = lst.warnings_warnings;
                await DisplayAlert("warning_list!", warning_list.ToString(), "ok");

                // OS
                try
                {
                    var  opSystem  = warning_list.os;
                    bool os_status = opSystem.status;
                    if (os_status)
                    {
                        //lblWarningOS.Text = opSystem.warning;
                        dt.Add(new WarningDetailLv()
                        {
                            title = "Operating System",
                            value = opSystem.warning
                        });
                        warning_detail = warning_detail + opSystem.warning + ", ";
                    }
                    else
                    {
                        //lblWarningOS.Text = "No errors found";
                    }
                }
                catch (Exception r)
                {
                    await DisplayAlert("OS!", r.Message.ToString(), "ok");

                    //lblWarningOS.Text = "Something went wrong";
                }
            }
            catch (Exception r)
            {
                await DisplayAlert("whole!", r.Message.ToString(), "ok");

                //lblWarningOS.Text = "Something went wrong";
            }
        }
        private async void GetWarningDetails(string warning_id)
        {
            if (comfun.isConnected())
            {
                var client = new HttpClient();
                client.BaseAddress = new Uri(App.api_url);
                var values = new Dictionary <string, string>();
                values.Add("operation", "query");
                values.Add("session_string", App.session_string);
                values.Add("query", "select * from warnings where id = " + warning_id);
                var content = new FormUrlEncodedContent(values);
                HttpResponseMessage response = await client.PostAsync("/itcrm/webservices/", content);

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

                //await DisplayAlert("Info!", result, "ok");
                WarningsResult warningDetail = JsonConvert.DeserializeObject <WarningsResult>(result);

                var detail = warningDetail.result[0];
                device_id = detail.warnings_device_id;
                // Device name
                try
                {
                    var clientsID = new HttpClient();
                    clientsID.BaseAddress = new Uri(App.api_url);
                    var valuesID = new Dictionary <string, string>();
                    valuesID.Add("session_string", App.session_string);
                    valuesID.Add("data", "{\"table\": \"devices\"}");
                    valuesID.Add("extra", "{\"id\": \"" + device_id + "\"}");
                    var contentID = new FormUrlEncodedContent(valuesID);
                    HttpResponseMessage responseID = await clientsID.PostAsync("/itcrm/getElements/", contentID);

                    var resultID = await responseID.Content.ReadAsStringAsync();

                    // await DisplayAlert("Alert", "You have been alerted" + resultID, "OK");
                    HealthResult health_list = JsonConvert.DeserializeObject <HealthResult>(resultID);
                    var          detailID    = health_list.result[0];
                    //lblWarningID.Text = detailID.name;
                    dt.Add(new WarningDetailLv()
                    {
                        title = "Name: ",
                        value = detailID.name
                    });
                }
                catch (Exception e)
                {
                    //    await DisplayAlert("Error!", e.Message, "ok");
                }
                var lst          = warningDetail.result[0];
                var warning_list = lst.warnings_warnings;
                // OS
                try
                {
                    var  opSystem  = warning_list.os;
                    bool os_status = opSystem.status;
                    if (os_status)
                    {
                        //lblWarningOS.Text = opSystem.warning;
                        dt.Add(new WarningDetailLv()
                        {
                            title = "Operating System: ",
                            value = opSystem.warning
                        });
                        warning_detail = warning_detail + opSystem.warning + ", ";
                    }
                    else
                    {
                        //lblWarningOS.Text = "No errors found";
                    }
                }
                catch (Exception r)
                {
                    //lblWarningOS.Text = "Something went wrong";
                }
                // hard disk
                try
                {
                    var hardDisk  = warning_list.hdd_status;
                    var hd_status = hardDisk.status;
                    if (hd_status)
                    {
                        //lblWarningHDDStatus.Text = hardDisk.warning;
                        dt.Add(new WarningDetailLv()
                        {
                            title = "HDD Status: ",
                            value = hardDisk.warning
                        });
                        warning_detail = warning_detail + hardDisk.warning + ", ";
                    }
                    else
                    {
                        //lblWarningHDDStatus.Text = "No errors found";
                    }
                }
                catch (Exception w)
                {
                    //lblWarningHDDStatus.Text = "Something went wrong";
                }
                // temp
                try
                {
                    var  temperature = warning_list.temperature;
                    bool temp_status = temperature.status;
                    if (temp_status)
                    {
                        //lblWarningTemperature.Text = temperature.warning;
                        dt.Add(new WarningDetailLv()
                        {
                            title = "Temprature: ",
                            value = temperature.warning
                        });
                        warning_detail = warning_detail + temperature.warning + ", ";
                    }
                    else
                    {
                        //lblWarningTemperature.Text = "No errors found";
                    }
                }
                catch (Exception r)
                {
                    //lblWarningTemperature.Text = "Something went wrong";
                }
                // ram
                try
                {
                    var  memory     = warning_list.ram;
                    bool ram_status = memory.status;
                    if (ram_status)
                    {
                        dt.Add(new WarningDetailLv()
                        {
                            title = "Momeory: ",
                            value = memory.warning
                        });
                        warning_detail = warning_detail + memory.warning + ", ";
                    }
                    else
                    {
                        //lblWarningRAM.Text = "No errors found";
                    }
                }
                catch (Exception r)
                {
                    //lblWarningRAM.Text = "Something went wrong";
                }
                // cpu
                try
                {
                    var  cpu_use    = warning_list.cpu;
                    bool cpu_status = cpu_use.status;
                    if (cpu_status)
                    {
                        //lblWarningCPUUsage.Text = cpu_use.warning;
                        dt.Add(new WarningDetailLv()
                        {
                            title = "CPU: ",
                            value = cpu_use.warning
                        });
                        warning_detail = warning_detail + cpu_use.warning + ", ";
                    }
                    else
                    {
                        //lblWarningCPUUsage.Text = "No errors found";
                    }
                }
                catch (Exception r)
                {
                    //lblWarningCPUUsage.Text = "Something went wrong";
                }
                // antivirus
                try
                {
                    var  antivirus = warning_list.antivirus;
                    bool av_status = antivirus.status;
                    if (av_status)
                    {
                        //lblWarningAntivirus.Text = antivirus.warning;
                        dt.Add(new WarningDetailLv()
                        {
                            title = "Antivirus: ",
                            value = antivirus.warning
                        });
                        warning_detail = warning_detail + antivirus.warning + " ";
                    }
                    else
                    {
                        //lblWarningAntivirus.Text = "No errors found";
                    }
                }
                catch (Exception r)
                {
                    //lblWarningAntivirus.Text = "Something went wrong";
                }
                // created on
                dt.Add(new WarningDetailLv()
                {
                    title = "Created on: ",
                    value = detail.warnings_created
                });
                activityIndicator.IsRunning = false;
            }
            else
            {
                await DisplayAlert("Connection", "Internet Connection Disabled", "Ok");
            }
        }
        private async void GetWarnings()
        {
            if (comfun.isConnected())
            {
                try
                {
                    var client = new HttpClient();
                    client.BaseAddress = new Uri(App.api_url);
                    var values = new Dictionary <string, string>();

                    values.Add("session_string", App.session_string);
                    values.Add("data", "{\"table\":\"warnings\",\"fields\":\"id,modified as date,warnings_count\"}");
                    values.Add("extra", "{\"has_warning\":\"1\"}");
                    values.Add("join", "[{\"table\":\"devices\",\"fields\":\"name\",\"where\":\"id\",\"is\":\"warnings.device_id\"}]");
                    var content = new FormUrlEncodedContent(values);
                    HttpResponseMessage response = await client.PostAsync("/itcrm/getElements/", content);

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

                    // await DisplayAlert("result!", result, "ok");
                    statusCheck chk_status = JsonConvert.DeserializeObject <statusCheck>(result);
                    if (chk_status.status)
                    {
                        try
                        {
                            WarningsResult warnings_list = JsonConvert.DeserializeObject <WarningsResult>(result);
                            dt = new ObservableCollection <SetWarningsList>();
                            //lvWarningsList.ItemsSource = dt;
                            var lst = warnings_list.result;
                            for (int i = 0; i < lst.Length; i++)
                            {
                                try
                                {
                                    //  await DisplayAlert("id", lst[i].id.ToString(), "ok");
                                    list.Add(lst[i].id);
                                }
                                catch (Exception e)
                                {
                                }
                            }
                            try
                            {
                                for (int i = 0; i < lst.Length; i++)
                                {
                                    try
                                    {
                                        string ionline        = "https://cloudschool.management/itcrm/media/images/offline.png";
                                        string ionline_status = "Offline";
                                        bool   status         = await getDeviceOnlineStatus(lst[i].id);

                                        if (status)
                                        {
                                            await DisplayAlert("device id", lst[i].id + "status true", "ok");

                                            ionline        = "https://cloudschool.management/itcrm/media/images/online.png";
                                            ionline_status = "Online";
                                        }
                                        //  await DisplayAlert("device id", lst[i].id + "status true", "ok");
                                        dt.Add(new SetWarningsList()
                                        {
                                            id             = lst[i].id,
                                            name           = lst[i].name,
                                            date           = lst[i].date,
                                            warnings_count = lst[i].warnings_count + " warning(s)",
                                            color          = colors[count],
                                            icon           = frstWord(lst[i].name), //"https://cloudschool.management/itcrm/media/images/warningBlack.png",
                                            online         = ionline,
                                            online_status  = ionline_status
                                        });
                                    }

                                    catch (Exception e)
                                    {
                                        //await DisplayAlert("Error!", e.Message, "ok");
                                    }
                                    if (count > 3)
                                    {
                                        count = 0;
                                    }
                                    count++;
                                }
                                aiDevices.IsRunning        = false;
                                lvWarningsList.ItemsSource = dt;
                            }
                            catch { }
                            aiDevices.IsRunning = false;
                        }
                        catch { }
                    }
                    else
                    {
                        await DisplayAlert("Error!", "Task not Added", "ok");
                    }
                    aiDevices.IsRunning = false;
                }
                catch { }
            }
            else
            {
                await DisplayAlert("Connection", "Internet Connection Disabled", "Ok");
            }
        }