コード例 #1
0
        public async void CallWebServiceForPhotoGalleryList(string pageid)
        {
            if (!App.CheckInternetConnection())
            {
                // Loading(false);
                await DisplayAlert(AppResources.LNetworkError, AppResources.LNoInternetConnection, AppResources.LOk);
            }
            else
            {
                try
                {
                    string lang = "";
                    if (Application.Current.Properties.ContainsKey("Language"))
                    {
                        lang = Application.Current.Properties["Language"] as string;
                    }

                    List <KeyValuePair <string, string> > values = new List <KeyValuePair <string, string> >();
                    values.Add(new KeyValuePair <string, string>("lang", lang));
                    // values.Add(new KeyValuePair<string, string>("page_id", "456"));
                    values.Add(new KeyValuePair <string, string>("page_id", pageid));
                    var response = await GeneralClass.GetResponse <CMO.ServicesClasses.RootObjectPhotoDetailResponse>("https://cmo.maharashtra.gov.in/api/getphotogallerylistbyid", values);

                    if (response != null)
                    {
                        if (response._resultflag != 0)
                        {
                            foreach (var item in response.gallery_list.photo)
                            {
                                PopupPhotoList.Add(item);
                            }
                            //  PopupPhotoList=  response.gallery_list.photo;
                            await BindingListInPhotosList();
                        }
                    }
                    else
                    {
                        if (App.CurrentPage() == "photogallerylist")
                        {
                            await DisplayAlert(AppResources.LError, AppResources.LSomethingWentWrong, AppResources.LOk);
                        }
                    }
                }
                catch (WebException exception)
                {
                    if (App.CurrentPage() == "photogallerylist")
                    {
                        if (exception.Message.Contains("Network"))
                        {
                            await DisplayAlert(AppResources.LError, AppResources.LWebserverNotResponding, AppResources.LOk);
                        }
                    }
                }
            }
        }
        public async Task CallWebServiceForForiegnVisits(string countrytitle)
        {
            if (!App.CheckInternetConnection())
            {
                await DisplayAlert(AppResources.LNetworkError, AppResources.LNoInternetConnection, AppResources.LOk);
            }
            else
            {
                try
                {
                    string lang = "";
                    if (Application.Current.Properties.ContainsKey("Language"))
                    {
                        lang = Application.Current.Properties["Language"] as string;
                    }
                    #region key value data
                    List <KeyValuePair <string, string> > values = new List <KeyValuePair <string, string> >();
                    values.Add(new KeyValuePair <string, string>("lang", lang));
                    values.Add(new KeyValuePair <string, string>("title", ""));
                    values.Add(new KeyValuePair <string, string>("page_id", countrytitle));
                    values.Add(new KeyValuePair <string, string>("country", ""));
                    values.Add(new KeyValuePair <string, string>("index", "0"));
                    values.Add(new KeyValuePair <string, string>("limit", "1"));
                    #endregion
                    var response = await GeneralClass.GetResponse <CMO.ServicesClasses.RootObjectCMVisitList>(CMO.ServiceLayer.ServiceLinks.international_DetailUrl, values);

                    if (response != null)
                    {
                        if (response._resultflag == 1)
                        {
                            CountryList = new List <CmVisit>();
                            for (int i = 0; i < response.cm_visit.Count; i++)
                            {
                                DateTime oDate = Convert.ToDateTime(response.cm_visit[i].date);
                                CountryList = new List <CmVisit>();
                                CountryList = response.cm_visit;
                                response.cm_visit[i].date = oDate.ToString("MMM. dd, yyyy");
                                //Title = response.cm_visit[i].title.ToUpper();
                                JalyuktaDetailImage.Source                = response.cm_visit[i].image;
                                JalyuktaVisittitle.Text                   = response.cm_visit[i].title;
                                JalyuktaVisitDate.Text                    = response.cm_visit[i].date;
                                JalyuktaVisitDetail.Text                  = response.cm_visit[i].description.Replace("<p>", "").Replace("</p>", "");
                                JalyuktaDetailImage.HeightRequest         = App.DeviceHeight * 0.40;
                                JalyuktaDetailImageBackgrnd.HeightRequest = App.DeviceHeight * 0.40;
                                Mainstack1.IsVisible = true;
                                Mainstack2.IsVisible = true;
                                if ((CountryList[0].photo_page_id != "") && (CountryList[0].photo_page_id != null))
                                {
                                    PhotoGrid.IsVisible = true; PhotoGrid.IsEnabled = true;
                                }
                                if ((CountryList[0].video_gallery_id != "") && (CountryList[0].video_gallery_id != null))
                                {
                                    VideoGrid.IsVisible = true; VideoGrid.IsEnabled = true;
                                }
                                if ((CountryList[0].twitter_link != "") && (CountryList[0].twitter_link != null))
                                {
                                    TwitterGrid.IsVisible = true; TwitterGrid.IsEnabled = true;
                                }
                            }
                        }
                    }
                }
                catch (WebException exception)
                {
                    await DisplayAlert(AppResources.LError, AppResources.LWebserverNotResponding, AppResources.LOk);
                }
            }
            loading.IsVisible = false;
            loading.IsRunning = false;
        }
コード例 #3
0
        public async Task CallWebServiceForPressRelease(int index)
        {
            FilterPressList.IsEnabled = false;
            if (!App.CheckInternetConnection())
            {
                await DisplayAlert(AppResources.LNetworkError, AppResources.LNoInternetConnection, AppResources.LOk);
            }
            else
            {
                try
                {
                    #region Key value pairs
                    string lang = "";
                    if (Application.Current.Properties.ContainsKey("Language"))
                    {
                        lang = Application.Current.Properties["Language"] as string;
                    }
                    List <KeyValuePair <string, string> > values = new List <KeyValuePair <string, string> >();
                    values.Add(new KeyValuePair <string, string>("lang", lang));
                    values.Add(new KeyValuePair <string, string>("title", SearchFilterText));
                    values.Add(new KeyValuePair <string, string>("index", Convert.ToString(index)));
                    if (Device.Idiom == TargetIdiom.Phone)
                    {
                        values.Add(new KeyValuePair <string, string>("limit", "7"));
                    }
                    else
                    {
                        values.Add(new KeyValuePair <string, string>("limit", "10"));
                    }
                    //lang=en&title=&index=0&limit=10
                    #endregion
                    var response = await GeneralClass.GetResponse <CMO.ServicesClasses.RootObjectPressRelease>(CMO.ServiceLayer.ServiceLinks.PressRelease_ListURL, values);

                    if (response != null)
                    {
                        if (response._resultflag == 1)
                        {
                            totalItems     = response.total_results;
                            totalListItems = response.search_results;
                            var x = lstPressRelease.RowHeight;
                            if (PressReleaseList == null || index == 0)
                            {
                                PressReleaseList = new ObservableCollection <Pressrelease>();
                                //EventGroupedList = new ObservableCollection<GroupedEventListModel>();
                                //TodayGrouped = new GroupedEventListModel() { LongName = "Today", ShortName = "v" };
                                //TomorrowGrouped = new GroupedEventListModel() { LongName = "Tomorrow", ShortName = "f" };
                            }
                            for (int i = 0; i < response.pressreleaselist.Count; i++)
                            {
                                var ObjectPress = new Pressrelease();

                                ObjectPress.SetFontSize = App.GetFontSizeMedium();
                                DateTime oDate = Convert.ToDateTime(response.pressreleaselist[i].date);
                                response.pressreleaselist[i].date = oDate.ToString("MMM. dd, yyyy");
                                ObjectPress.date      = response.pressreleaselist[i].date;
                                ObjectPress.file_path = response.pressreleaselist[i].file_path;
                                ObjectPress.title     = response.pressreleaselist[i].title;
                                ObjectPress.content   = response.pressreleaselist[i].content;
                                PressReleaseList.Add(ObjectPress);
                            }
                            #region (Row Height) Specific Design implemention for phone and tablet
                            if (Device.Idiom == TargetIdiom.Phone)
                            {
                                lstPressRelease.RowHeight = 100;
                            }
                            else if (Device.Idiom == TargetIdiom.Tablet)
                            {
                                lstPressRelease.RowHeight = 150;
                            }
                            else if (Device.Idiom == TargetIdiom.Desktop)
                            {
                                lstPressRelease.RowHeight = 3 * 100;
                            }
                            else
                            {
                                lstPressRelease.RowHeight = 150;
                            }
                            #endregion
                            lstPressRelease.ItemsSource = PressReleaseList;
                            //   EventVisitLists.ItemsSource = EventGroupedList;
                            lstPressRelease.IsRefreshing = false;
                            // EventVisitLists.IsVisible = true;
                        }
                        else
                        {
                            if (index == 0)
                            {
                                lblNoRecord.IsVisible = true;
                                //   EventVisitLists.IsVisible = true;
                                PressReleaseList.Clear();
                                lstPressRelease.IsRefreshing = false;
                            }
                        }
                    }
                    else
                    {
                        if (App.CurrentPage() == "pressrelease")
                        {
                            await DisplayAlert(AppResources.LError, AppResources.LSomethingWentWrong, AppResources.LOk);
                        }
                    }
                }

                catch (WebException exception)
                {
                    if (App.CurrentPage() == "pressrelease")
                    {
                        if (exception.Message.Contains("Network"))
                        {
                            await DisplayAlert(AppResources.LError, AppResources.LWebserverNotResponding, AppResources.LOk);
                        }
                    }
                }
            }
            loadingIndicator.IsVisible   = false;
            loading.IsRunning            = false;
            loading.IsVisible            = false;
            lstPressRelease.IsRefreshing = false;
            FilterPressList.IsEnabled    = true;
        }