private void BuildButtons() { var sec = new Section (""); var btnSend = new StyledStringElement ("Send to Office"); btnSend.TextColor = ColorHelper.GetGPLightPurple (); var switchNotify = new BooleanElement ("Notify?", true); btnSend.Tapped += delegate { //test if (isBusy) { Busy (); return; } if (selectedUser == null) { new UIAlertView ("Fee Earner", "Please select a Fee Earner", null, "OK").Show (); return; } var task = new TaskDTO (); DateTime dt = picker.Date; DateTime now = DateTime.Now; Console.WriteLine ("### Task Due Date picked: " + dt.ToLongDateString ()); Console.WriteLine ("### Today is: " + now.ToLongDateString ()); task.dueDate = Tools.ConvertDateTimeToJavaMS (dt); task.matterID = matter.matterID; task.userID = selectedUser.userID; task.taskDescription = narration.Value; if (switchNotify.Value == true) { task.notifyWhenComplete = true; } else { task.notifyWhenComplete = false; } if (narration.Value.Trim () == "") { new UIAlertView ("Description", "Please enter Task description", null, "OK").Show (); return; } sendAssignTaskRequest (task); }; btnSend.Alignment = UITextAlignment.Center; sec.Add (switchNotify); sec.Add (btnSend); Root.Add (sec); }
public void sendAssignTaskRequest(TaskDTO task) { isBusy = true; start = DateTime.Now; UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true; GhostRequestDTO cr = new GhostRequestDTO (); string json, encodedJSON, url; cr.requestType = GhostRequestDTO.ASSIGN_TASK; cr.task = task; Console.WriteLine ("Task Description in getAsyncData: " + cr.task.taskDescription); cr.appID = NSUserDefaults.StandardUserDefaults.IntForKey ("appID"); cr.userID = NSUserDefaults.StandardUserDefaults.IntForKey ("userID"); cr.companyID = NSUserDefaults.StandardUserDefaults.IntForKey ("companyID"); cr.deviceID = NSUserDefaults.StandardUserDefaults.StringForKey ("deviceID"); json = JsonConvert.SerializeObject (cr); Console.WriteLine ("Async JSON = " + json); encodedJSON = HttpUtility.UrlEncode (json); url = Tools.CONSOLE_URL + encodedJSON; try { var request = (HttpWebRequest)WebRequest.Create (url); request.BeginGetResponse (AssignTaskRequestCompleted, request); } catch (WebException e) { isBusy = false; Console.WriteLine ("Exception - " + e.Message); new UIAlertView ("Error", "Server Unavailable at this time.\nPlease try later.", null, "OK").Show (); } }