Exemple #1
0
#pragma warning disable RECS0165 // Asynchronous methods should return a Task instead of void
        public async void GetJobSearchData()
#pragma warning restore RECS0165 // Asynchronous methods should return a Task instead of void

        {
            NetworkStatus remoteHostStatus = Reachability.RemoteHostStatus();

            if (remoteHostStatus == NetworkStatus.NotReachable)
            {
                var alert = UIAlertController.Create("Network Error", "Please check your internet connection", UIAlertControllerStyle.Alert);
                alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));
                PresentViewController(alert, animated: true, completionHandler: null);

                return;
            }

            BTProgressHUD.Show("Loading...", -1, ProgressHUD.MaskType.Black);


            if (!Constants.FilterURL.Contains("&r=") && Constants.FilterURL.Contains("&xy"))
            {
                //Constants.FilterURL = Constants.FilterURL + "&r=" + Constants.selectedRadius;
                Constants.FilterURL = Constants.FilterURL + Constants.selectedRadius;
            }
            // Refine result if filter appiled.
            if (!string.IsNullOrEmpty(Constants.FilterURL))
            {
                this.jobRequest.FilterURL = Constants.FilterURL;
            }

            ServiceManager jobService = new ServiceManager();

            Constants.jobSearchResponse = await jobService.AsyncJobSearch(this.jobRequest);


            if (Constants.jobSearchResponse.ContainsKey("presentationFacetResultList"))
            {
                this.presentationFacetResultList = Constants.jobSearchResponse["presentationFacetResultList"];

                Table.Source = new ExpandableTableSource(this.presentationFacetResultList, Table, this);
                this.appliedFilterList();
                Table.ReloadData();
            }
            else
            {
                var alert = UIAlertController.Create("Adecco", "Oops! Something went wrong!", UIAlertControllerStyle.Alert);
                alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));
                PresentViewController(alert, animated: true, completionHandler: null);
            }

            BTProgressHUD.Dismiss();
        }
#pragma warning disable RECS0165 // Asynchronous methods should return a Task instead of void
        private async void GetJobSearchData(string keyword, string location)
#pragma warning restore RECS0165 // Asynchronous methods should return a Task instead of void
        {
            NetworkStatus remoteHostStatus = Reachability.RemoteHostStatus();

            if (remoteHostStatus == NetworkStatus.NotReachable)
            {
                var alert = UIAlertController.Create("Network Error", "Please check your internet connection", UIAlertControllerStyle.Alert);
                alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));
                PresentViewController(alert, animated: true, completionHandler: null);

                return;
            }
            //var _JobAlertVC = (JobAlertVC)Storyboard.InstantiateViewController("JobAlertVC");
            //NavController.PushViewController(_JobAlertVC, true);

            //return;

            //location = "nederland";
            //Constants.LocationLatLong = "";

            if (keyword.Equals("N/A"))
            {
                keyword = "";
            }

            if (location.Equals("N/A"))
            {
                location = "";
            }

            Constants.JobKeyword  = keyword.Trim();
            Constants.JobLocation = location.Trim();



            location = System.Net.WebUtility.UrlEncode(location);
            keyword  = System.Net.WebUtility.UrlEncode(keyword);


            BTProgressHUD.Show("Loading...", -1, ProgressHUD.MaskType.Black);


            jobRequest          = new JobRequest();
            jobRequest.Keyword  = "";
            jobRequest.Location = "";

            //jobRequest.CurrentLanguage = "nl-NL";
            //jobRequest.SitenameForRegister = Constants.JobDetailSiteName;

            jobRequest.CurrentLanguage     = Constants.JobDetailCurrentLanguage;
            jobRequest.SitenameForRegister = Constants.JobDetailSiteName;


            jobRequest.FilterURL = Constants.JobSearchFilterURL + "pageNum=" + Constants.CurrentpageNum + "&display=" + Constants.displayCount + "&k=" + keyword + "&l=" + location;

            if (!Constants.LocationLatLong.Equals("") && location.Contains("%2C"))
            {
                jobRequest.FilterURL = jobRequest.FilterURL + "&xy=" + Constants.LocationLatLong;
            }


            jobRequest.FacetSettingId = Constants.JobSearchFacetSettingID;
            jobRequest.BaseAddress    = Constants.JobBaseAddress;


            List <JobCMS> searchResults = new List <JobCMS>();

            ServiceManager jobService = new ServiceManager();

            Dictionary <string, dynamic> serverResponse = await jobService.AsyncJobSearch(jobRequest);

            Constants.jobSearchResponse = serverResponse;

            if (searchJobButtonPressed)
            {
                if (serverResponse.ContainsKey("jobList"))
                {
                    searchResults = serverResponse["jobList"];
                }
            }
            else
            {
                if (serverResponse.ContainsKey("jobList"))
                {
                    jobList = serverResponse["jobList"];
                }
            }


            BTProgressHUD.Dismiss();


            if (jobList == null)
            {
                BTProgressHUD.ShowToast("No record found.", false, 3000);
                return;
            }

            if (searchResults == null)
            {
                BTProgressHUD.ShowToast("No record found.", false, 3000);
                return;
            }

            if (jobList == null)
            {
                jobList = new List <JobCMS>();
            }

            if (searchJobButtonPressed)
            {
                if (searchResults == null)
                {
                    searchResults = new List <JobCMS>();
                }

                var searchResultVC = (SearchResultVC)Storyboard.InstantiateViewController("SearchResultVC");
                searchResultVC.jobList         = searchResults;
                searchResultVC.isFavoriteJob   = false;
                searchResultVC._keyword        = this.txtKeyword.Text.Trim();
                searchResultVC._location       = this.txtLocation.Text.Trim();
                searchResultVC.LocationLatLong = Constants.LocationLatLong;
                searchResultVC.aJobRequest     = jobRequest;
                NavController.PushViewController(searchResultVC, true);
                searchJobButtonPressed = false;
            }
            else
            {
                tblView.Source = new TableSource(jobList, _recentSearchs, isRecentSearch, this);
                //Delegate = new TableViewDelegate(list);
                //tblView.Delegate = new TableViewDelegate(jobList);
                //tblView.WeakDelegate = this;
                tblView.ReloadData();
            }


            tblView.AllowsSelection        = true;
            tblView.UserInteractionEnabled = true;
        }
                #pragma warning disable RECS0165 // Asynchronous methods should return a Task instead of void
        private async void GetJobSearchData(string keyword, string location)
                #pragma warning restore RECS0165 // Asynchronous methods should return a Task instead of void
        {
            NetworkStatus remoteHostStatus = Reachability.RemoteHostStatus();

            if (remoteHostStatus == NetworkStatus.NotReachable)
            {
                var alert = UIAlertController.Create("Network Error", "Please check your internet connection", UIAlertControllerStyle.Alert);
                alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));
                PresentViewController(alert, animated: true, completionHandler: null);

                return;
            }

            location = System.Net.WebUtility.UrlEncode(location);
            keyword  = System.Net.WebUtility.UrlEncode(keyword);

            // Add table footer view if this is not a fav job screen
            if (!isFavoriteJob)
            {
                this.AddTableFooterView();
            }

            JobRequest jobRequest = new JobRequest();

            jobRequest.Keyword             = "";
            jobRequest.Location            = "";
            jobRequest.CurrentLanguage     = "nl-NL";
            jobRequest.SitenameForRegister = Constants.JobDetailSiteName;

            jobRequest.FilterURL = Constants.JobSearchFilterURL + "pageNum=" + this.CurrentpageNum.ToString() + "&display=" + Constants.displayCount + "&k=" + keyword + "&l=" + location;

            // Refine result if filter appiled.
            if (!string.IsNullOrEmpty(Constants.FilterURL))
            {
                jobRequest.FilterURL = Constants.FilterURL;
            }


            if (!this.isLoadingMoreData)
            {
                BTProgressHUD.Show("Loading...", -1, ProgressHUD.MaskType.Black);
            }


            if (!this.LocationLatLong.Equals("") && location.Contains("%2C"))
            {
                jobRequest.FilterURL = jobRequest.FilterURL + "&xy=" + this.LocationLatLong;
            }
            jobRequest.FacetSettingId = Constants.JobSearchFacetSettingID;
            jobRequest.BaseAddress    = Constants.JobBaseAddress;


            this.aJobRequest = jobRequest;

            ServiceManager jobService = new ServiceManager();
            //List<JobCMS> jobList2 = await jobService.AsyncJobSearch(jobRequest);

            Dictionary <string, dynamic> responseDict = await jobService.AsyncJobSearch(jobRequest);

            Constants.jobSearchResponse = responseDict;

            if (!Constants.jobSearchResponse.ContainsKey("jobList"))
            {
                BTProgressHUD.Dismiss();
                return;
            }
            List <JobCMS> jobList2 = responseDict["jobList"];


            // If we are fetching more data then append into joblist
            if (this.isLoadingMoreData)
            {
                jobList.AddRange(jobList2);
            }
            else
            {
                // else  simple refresh the job list
                jobList = jobList2;
            }

            //jobList = (System.Collections.Generic.List<AdeccoNL.JobCMS>)jobList.Concat(jobList2);

            tblView.Source = new TableSource(jobList, this, this.isFavoriteJob);

            this.appliedFilterList();

            tblView.ReloadData();

            tblView.AllowsSelection        = true;
            tblView.UserInteractionEnabled = true;

            // Remove table footer view
            tblView.TableFooterView = new UIView();

            // Refine result if filter appiled.
            BTProgressHUD.Dismiss();
            this.headerLabel.Text = "  " + Constants.JobCount;
        }