Ejemplo n.º 1
0
        public GetCropView()
        {
            InitializeComponent();
            String[] cropList = new String[100];
            float[]  cropid   = new float[100];
            int      j        = 0;
            //cropList = DependencyService.Get<call_web_service>().get_crops(Global_portable.email);
            Email data = new Email();

            data.email = Global_portable.email;
            string json = JsonConvert.SerializeObject(data);
            //System.Diagnostics.Debug.WriteLine("Json object" + json);
            string url     = "http://192.168.0.4:5010/get_crops";
            var    content = new StringContent(json, Encoding.UTF8, "application/json");

            using (var client = new HttpClient())
            {
                var    result = client.PostAsync(url, content).Result;
                string res    = "";
                using (HttpContent content3 = result.Content)
                {
                    // ... Read the string.
                    Task <string> result2 = content3.ReadAsStringAsync();
                    res = result2.Result;
                    //System.Diagnostics.Debug.WriteLine("response in farm data page ress" + res);
                    Selected_class final = JsonConvert.DeserializeObject <Selected_class>(res);
                    foreach (var x in final.crop)
                    {
                        //System.Diagnostics.Debug.WriteLine(x);
                        cropList[j] = x;
                        j           = j + 1;
                    }
                    j = 0;
                    foreach (var x in final.cropid)
                    {
                        //System.Diagnostics.Debug.WriteLine(x);
                        string a = x.ToString();
                        cropid[j] = float.Parse(a, CultureInfo.InvariantCulture.NumberFormat);
                        j         = j + 1;
                    }
                    //System.Diagnostics.Debug.WriteLine("the list is..."+cropList.ToString());
                }
            }
            //System.Diagnostics.Debug.WriteLine("In the getcrops class..."+cropList[0]);
            getCrops = new ObservableCollection <GetCropModel>();
            for (int i = 0; i < j; i++)
            {
                string cropID              = "";
                string cropName            = "";
                string ResourceId          = "AISCM.Resources.AppResource";
                string translated_cropname = "";

                cropName = cropList[i];
                if (Global_portable.default_language != null)
                {
                    CultureInfo.DefaultThreadCurrentCulture = new CultureInfo(Global_portable.default_language);
                    ResourceManager resourceManager = new ResourceManager(ResourceId, typeof(TranslateExtension).GetTypeInfo().Assembly);
                    string          text_converted  = resourceManager.GetString(cropName, CultureInfo.DefaultThreadCurrentCulture);
                    translated_cropname = text_converted;
                }
                else
                {
                    //ResourceManager resourceManager = new ResourceManager(ResourceId, typeof(TranslateExtension).GetTypeInfo().Assembly);
                    string text_converted = cropName;
                    translated_cropname = text_converted;
                }
                getCrops.Add(new GetCropModel {
                    CropName = translated_cropname
                });
            }
            lstView.ItemsSource = getCrops;
        }
Ejemplo n.º 2
0
        public SetNewBidsFarmerView()
        {
            InitializeComponent();



            String[] cropList = new String[100];
            float[]  cropid   = new float[100];
            //cropList = DependencyService.Get<call_web_service>().get_crops(Global_portable.email);
            int j = 0;
            //cropList = DependencyService.Get<call_web_service>().get_crops(Global_portable.email);
            Email data = new Email();

            data.email = Global_portable.email;
            string json = JsonConvert.SerializeObject(data);

            System.Diagnostics.Debug.WriteLine("Json object" + json);
            string url     = "http://192.168.0.4:5010/get_crops";
            var    content = new StringContent(json, Encoding.UTF8, "application/json");

            using (var client = new HttpClient())
            {
                var    result = client.PostAsync(url, content).Result;
                string res    = "";
                using (HttpContent content3 = result.Content)
                {
                    // ... Read the string.
                    Task <string> result2 = content3.ReadAsStringAsync();
                    res = result2.Result;
                    System.Diagnostics.Debug.WriteLine("response in farm data page ress" + res);
                    Selected_class final = JsonConvert.DeserializeObject <Selected_class>(res);
                    foreach (var x in final.crop)
                    {
                        System.Diagnostics.Debug.WriteLine(x);
                        cropList[j] = x;
                        j           = j + 1;
                    }
                    j = 0;
                    foreach (var x in final.cropid)
                    {
                        //System.Diagnostics.Debug.WriteLine(x);
                        string a = x.ToString();
                        cropid[j] = float.Parse(a, CultureInfo.InvariantCulture.NumberFormat);
                        j         = j + 1;
                    }
                    System.Diagnostics.Debug.WriteLine("the list is..." + cropList.ToString());
                }
            }

            crops = new ObservableCollection <SetBidsFarmerModel>();
            System.Diagnostics.Debug.WriteLine("In the set new bids marketting page..." + cropList[0]);
            for (int i = 0; i < j; i++)
            {
                string cropID = "";
                string cName  = "";

                cropID = cropid[i].ToString();

                cName = cropList[i];
                System.Diagnostics.Debug.WriteLine("===={0}===={1}", cropID.ToString(), cName);
                CropItems.Add(cropID.ToString(), cName);
                System.Diagnostics.Debug.WriteLine("successfully added to cropitems..");
                // PickerItems.Add(cropID.ToString(), cName);
                //crops.Add(new SetBidsFarmerModel { cropName = cName,  });
            }
            System.Diagnostics.Debug.WriteLine(CropItems.Keys);
            // System.Diagnostics.Debug.WriteLine(PickerItems.Keys);

            cropPicker.ItemsSource = CropItems.ToList();
            // cont.ItemsSource = PickerItems.ToList();
        }