void loadData(JobCIS jobDetail) { ///string htmlString = "<html><body><p style='font-family:verdana;margin-left:10px;font-size:15px;'>The MonoTouch API supports two styles of event notification: the Objective-C style that uses a delegate class or the C# style using event notifications.\n\nThe C# style allows the user to add or remove event handlers at runtime by assigning to the events of properties of this class. Event handlers can be anyone of a method, an anonymous methods or a lambda expression. Using the C# style events or properties will override any manual settings to the Objective-C Delegate or WeakDelegate settings.\n\nThe Objective-C style requires the user to create a new class derived from UIWebViewDelegate class and assign it to the UIKit.Delegate property. Alternatively, for low-level control, by creating a class derived from NSObject which has every entry point properly decorated with an [Export] attribute. The instance of this object can then be assigned to the UIWebView.WeakDelegate property.</p><p><b>Hey</b> you. My <b>name </b> is <h1> Joe </h1></p> </body></html>"; //string htmlString = "<html><body><p style='font-family:verdana;margin-left:10px;font-size:15px;'>The MonoTouch API supports two styles of event notification: the Objective-C style that uses a delegate class or the C# style using event notifications.\n\nThe C# style allows the user to add or remove event handlers at runtime by assigning to the events of properties of this class. Event handlers can be anyone of a method, an anonymous methods or a lambda expression. Using the C# style events or properties will override any manual settings to the Objective-C Delegate or WeakDelegate settings.\n\nThe Objective-C style requires the user to create a new class derived from UIWebViewDelegate class and assign it to the UIKit.Delegate property. Alternatively, for low-level control, by creating a class derived from NSObject which has every entry point properly decorated with an [Export] attribute. The instance of this object can then be assigned to the UIWebView.WeakDelegate property.</p><p><b>Hey</b> you. My <b>name </b> is <h1> Joe </h1></p> </body></html>"; string endDate = ""; if (!string.IsNullOrEmpty(jobDetail.PostingEndDate)) { string[] tokens = jobDetail.PostingEndDate.Split(new[] { " " }, StringSplitOptions.None); endDate = tokens[0]; } else if (!string.IsNullOrEmpty(jobDetail.PostedDate)) { string[] tokens = jobDetail.PostedDate.Split(new[] { " " }, StringSplitOptions.None); endDate = tokens[0]; } NSDateFormatter dateFormat = new NSDateFormatter(); dateFormat.DateFormat = "MM/dd/yyyy"; NSDate date = dateFormat.Parse(endDate); DateTime dt = ConvertNsDateToDateTime(date); endDate = calculateJobPostedDate(dt); if (!string.IsNullOrEmpty(endDate) && !(endDate.Equals("NoContent"))) { this.PostedDateLabel.Text = endDate; } else { this.PostedDateLabel.Hidden = true; this.btnPostedDate.Hidden = true; } //var htmlString = String.Format("<html><body><p style='font-family:verdana;margin-left:10px;font-size:13px;’> {0} </p></body></html>", jobDetail.Description); //= String.Format("<font face='Helvetica' size='2'> {0}", jobDetail.Description); if (!string.IsNullOrEmpty(jobDetail.Description)) { var htmlString = String.Format("<font face='Helvetica' size='2'> {0}", jobDetail.Description); webView.LoadHtmlString(htmlString, null); } else { webView.LoadHtmlString(string.Format("<html><center><font size=+5 color='red'>An error occurred:<br></font></center></html>"), null); } }
public async System.Threading.Tasks.Task <JobCIS> GetJobDetails(string JobId) { JobCIS jobDetail = new JobCIS(); //var baseAddress = new Uri(Constants.JobBaseAddress); var cookieContainer = new CookieContainer(); CFNetworkHandler networkHandler = new CFNetworkHandler(); networkHandler.UseSystemProxy = true; networkHandler.CookieContainer = cookieContainer; using (var handler = new HttpClientHandler() { CookieContainer = cookieContainer }) using (var client = new HttpClient(handler)) { try { string JobURL = Constants.JobBaseAddress + Constants.JobDetailURL + JobId; var httpResponse = await client.GetAsync(JobURL); if (httpResponse.StatusCode == HttpStatusCode.OK) { string responseContent = await httpResponse.Content.ReadAsStringAsync(); dynamic responseObj = Newtonsoft.Json.JsonConvert.DeserializeObject(responseContent); jobDetail = responseObj.ToObject <JobCIS>(); } } catch (Exception ex) { string str = ex.Message; } } return(jobDetail); }
#pragma warning disable RECS0165 // Asynchronous methods should return a Task instead of void private async void GetJobDetails() #pragma warning restore RECS0165 // Asynchronous methods should return a Task instead of void { if (!string.IsNullOrEmpty(this.jobTitle) && !(this.jobTitle.Equals("NoContent"))) { this.titleLabel.Text = this.jobTitle; } else { this.titleLabel.Hidden = true; } if (!string.IsNullOrEmpty(this.isNew)) { this.lblNew.Hidden = false; } else { this.lblNew.Hidden = true; this.favorateButton.Frame = new CGRect(315, 20, 30, 30); } if (aJob.isFavorote) { favorateButton.SetImage(UIImage.FromFile("heart-icon-selected.png"), UIControlState.Normal); } else { favorateButton.SetImage(UIImage.FromFile("fav-icon.png"), UIControlState.Normal); } if (!string.IsNullOrEmpty(this.loaction) && !(this.loaction.Equals("NoContent"))) { this.locationLabel.Text = this.loaction; } else { this.locationLabel.Text = "No Content"; //this.locationLabel.Hidden = true; //this.btnLocation.Hidden = true; } //if (!string.IsNullOrEmpty(this.salary) && !(this.salary.Equals("NoContent"))) //{ // this.salaryLabel.Text = this.salary; //} //else //{ // this.salaryLabel.Hidden = true; // this.btnSalary.Hidden = true; //} if (!string.IsNullOrEmpty(this.jobCategory) && !(this.jobCategory.Equals("NoContent"))) { this.categoryLabel.Text = this.jobCategory; } else { this.categoryLabel.Text = "N/A"; //this.btnCategory.Hidden = true; } if (!string.IsNullOrEmpty(aJob.ContractTypeTitle) && !(aJob.ContractTypeTitle.Equals("NoContent"))) { this.ContractTypeLabel.Text = aJob.ContractTypeTitle; } else { this.ContractTypeLabel.Hidden = true; this.btnContractType.Hidden = true; } if (Constants.JobDetailSiteName.Equals("adecco.fr")) { } try { 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); aJobDetail = new JobCIS(); ServiceManager jobService = new ServiceManager(); this.aJobDetail = await jobService.GetJobDetails(this.JobId); loadData(aJobDetail); } catch (Exception ex) { string str = ex.Message; } }