Пример #1
0
        void DataDownloaded(IAsyncResult result)
        {
            isBusy = false;
            UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
            end = DateTime.Now;
            var request = result.AsyncState as HttpWebRequest;
            WebServiceResponseDTO dto;
            try {
                HttpWebResponse response = (HttpWebResponse)request.EndGetResponse (result);
                Stream receiveStream = response.GetResponseStream ();
                StreamReader readStream = new StreamReader (receiveStream, Encoding.UTF8);
                string resp = readStream.ReadToEnd ();
                Console.WriteLine ("## GetTariffCodes Response stream received.\n" + resp);
                response.Close ();
                readStream.Close ();
                //get JSON response deserialized
                dto = (WebServiceResponseDTO)JsonConvert.DeserializeObject (
                    resp,
                    typeof(WebServiceResponseDTO)
                );

                if (dto != null) {
                    Tools.SendElapsedTime (start, end, dto.activityID);
                }

                InvokeOnMainThread (delegate {

                    selectedTariff = null;
                    feeAmount.Value = null;
                    BuildInterface ();
                    try {
                        if (dto.responseCode == 0) {
                            tariffList = dto.mobileTariffCodeList;
                            Console.WriteLine ("### tariff codes found: " + tariffList.Count);
                            CreateTariffCache ();
                            BuildInterface ();

                            if (tariffList == null || tariffList.Count == 0) {
                                new UIAlertView (
                                    "Search Result",
                                    "No Activity codes found for matter",
                                    null,
                                    "OK"
                                ).Show ();
                            }
                        } else {
                            new UIAlertView ("Search Result", dto.responseMessage, null, "OK").Show ();
                            return;
                        }
                    } catch (Exception e) {
                        //ignore - trapping event this is not there to host pop up
                        Console.WriteLine ("### IGNORED: " + e.Message);
                    }

                }
                );

            } catch (Exception ex) {
                isBusy = false;
                Console.WriteLine ("### ERROR: " + ex.Message);
                InvokeOnMainThread (delegate {
                    new UIAlertView (
                        "Network Error",
                        "Problem communicating with server.\nPlease try later or call GhostPractice Support",
                        null,
                        "Close"
                    ).Show ();
                }
                );
            }
        }
Пример #2
0
 private void CreateTariffCache()
 {
     if (isTimeBased) {
         cachedTimeTariffList = new List<MobileTariffCodeDTO> ();
         foreach (var t in tariffList) {
             var mtc = new MobileTariffCodeDTO ();
             mtc.amount = t.amount;
             mtc.id = t.id;
             mtc.name = t.name;
             mtc.narration = t.narration;
             mtc.surchargeApplies = t.surchargeApplies;
             mtc.tariffType = t.tariffType;
             mtc.timeBasedCode = t.timeBasedCode;
             mtc.units = t.units;
             cachedTimeTariffList.Add (mtc);
         }
     } else {
         cachedTariffList = new List<MobileTariffCodeDTO> ();
         foreach (var t in tariffList) {
             var mtc = new MobileTariffCodeDTO ();
             mtc.amount = t.amount;
             mtc.id = t.id;
             mtc.name = t.name;
             mtc.narration = t.narration;
             mtc.surchargeApplies = t.surchargeApplies;
             mtc.tariffType = t.tariffType;
             mtc.timeBasedCode = t.timeBasedCode;
             mtc.units = t.units;
             cachedTariffList.Add (mtc);
         }
     }
 }
Пример #3
0
        private void BuildTariffList()
        {
            if (tariffList != null && tariffList.Count > 0) {
                var tariffSection = new Section ("");
                var sel = new StyledStringElement ("Select Activity Code");
                sel.TextColor = ColorHelper.GetGPLightPurple ();
                sel.Alignment = UITextAlignment.Center;
                //sel.BackgroundColor = ColorHelper.GetGPLightPurple ();
                sel.Tapped += delegate {
                    if (isBusy) {
                        Busy ();
                        return;
                    }
                    if (tariffList == null) {
                        if (isTimeBased) {
                            GetTariffCodes (100, DataUtil.TARIFF_CODE_TYPE_FEES);

                        } else {
                            GetTariffCodes (0, DataUtil.TARIFF_CODE_TYPE_FEES);

                        }

                    } else {
                        string[] btns = new string[tariffList.Count];
                        for (int i = 0; i < tariffList.Count; i++) {
                            btns [i] = tariffList [i].name;
                        }
                        var actionSheet = new UIActionSheet (
                                              "Activity Codes",
                                              null,
                                              "Cancel",
                                              null,
                                              btns
                                          ){ Style = UIActionSheetStyle.Default };
                        actionSheet.Clicked += delegate (object sender, UIButtonEventArgs args) {
                            Console.WriteLine ("Clicked on tariff item {0}", args.ButtonIndex);
                            if (args.ButtonIndex == tariffList.Count) {
                                //ignore - Cancel
                            } else {
                                narration.Value = tariffList [args.ButtonIndex].narration;
                                selectedTariff = tariffList [args.ButtonIndex];
                                narrationValue = selectedTariff.narration;
                                BuildInterface ();

                            }

                        };

                        actionSheet.ShowInView (View);
                    }

                };
                tariffSection.Add (sel);
                Root.Add (tariffSection);
            }
        }
Пример #4
0
        private void BuildHeaderLabel()
        {
            string s = "Post Fee";
            if (isUnbillable) {
                s = "Post Unbillable Fee";
            }

            headerLabel = new UILabel (new RectangleF (10, 10, 480, 40)) {
                Font = UIFont.BoldSystemFontOfSize (20),
                BackgroundColor = ColorHelper.GetGPPurple (),
                TextAlignment = UITextAlignment.Center,
                TextColor = UIColor.White,
                Text = s
            };
            var view = new UIViewBordered ();
            view.Frame = new RectangleF (10, 10, 480, 40);
            view.Add (headerLabel);
            var topSection = new Section (view);

            Root.Add (topSection);
            String name = "";
            if (matter != null) {
                name = matter.matterName;
            }
            var sec = new Section (name);
            var timeBased = new BooleanElement (S.GetText (S.TIME_BASED_ACTIVITY), isTimeBased);

            timeBased.ValueChanged += delegate {
                if (isBusy) {
                    Busy ();
                    return;
                }
                selectedTariff = null;
                feeAmount.Value = null;
                if (timeBased.Value == true) {
                    isTimeBased = true;
                    if (IsTariffCacheFilled ()) {
                        RefreshFromCache ();
                        BuildInterface ();
                    } else {
                        GetTariffCodes (100, DataUtil.TARIFF_CODE_TYPE_FEES);
                    }

                } else {
                    isTimeBased = false;
                    if (IsTariffCacheFilled ()) {
                        RefreshFromCache ();
                        BuildInterface ();
                    } else {
                        GetTariffCodes (0, DataUtil.TARIFF_CODE_TYPE_FEES);
                    }
                }
            };
            sec.Add (timeBased);
            Root.Add (sec);
        }
Пример #5
0
        void DataDownloaded(IAsyncResult result)
        {
            isBusy = false;

            UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
            end = DateTime.Now;
            var request = result.AsyncState as HttpWebRequest;
            WebServiceResponseDTO dto;
            try {
                HttpWebResponse response = (HttpWebResponse)request.EndGetResponse (result);
                Stream receiveStream = response.GetResponseStream ();
                StreamReader readStream = new StreamReader (receiveStream, Encoding.UTF8);
                string resp = readStream.ReadToEnd ();
                Console.WriteLine ("$$ GetTariffCodes Response stream received.\n" + resp);
                response.Close ();
                readStream.Close ();
                //get JSON response deserialized
                dto = (WebServiceResponseDTO)JsonConvert.DeserializeObject (
                    resp,
                    typeof(WebServiceResponseDTO)
                );

                if (dto != null) {
                    Tools.SendElapsedTime (start, end, dto.activityID);
                }

                InvokeOnMainThread (delegate {
                    BuildInterface ();
                    selectedTariff = null;
                    if (dto.responseCode == 0) {
                        //insert "none" record on top...
                        MobileTariffCodeDTO d = new MobileTariffCodeDTO ();
                        d.id = 0;
                        d.name = "None";
                        d.narration = "None";
                        tariffList = new List<MobileTariffCodeDTO> ();
                        tariffList.Add (d);
                        foreach (var t in dto.mobileTariffCodeList) {
                            tariffList.Add (t);
                        }
                        BuildInterface ();
                        if (tariffList == null || tariffList.Count == 0) {
                            new UIAlertView (
                                "Activity Code Error",
                                "No Activity codes found for matter",
                                null,
                                "OK"
                            ).Show ();
                        }
                    } else {
                        new UIAlertView ("Activity Code Error", dto.responseMessage, null, "OK").Show ();
                        return;
                    }
                }
                );

            } catch (Exception ex) {
                Console.WriteLine ("### ERROR: " + ex.Message);
                isBusy = false;
                InvokeOnMainThread (delegate {
                    new UIAlertView (
                        "Network Error",
                        "Problem communicating with server.\nPlease try later or call GhostPractice Support",
                        null,
                        "Close"
                    ).Show ();
                }
                );
            }
        }
Пример #6
0
        private void BuildSections()
        {
            var headerLabel = new UILabel (new RectangleF (10, 10, 370, 40)) {
                Font = UIFont.BoldSystemFontOfSize (20),
                BackgroundColor = ColorHelper.GetGPPurple (),
                TextAlignment = UITextAlignment.Center,
                TextColor = UIColor.White,
                Text = "Post Note"
            };
            var view = new UIViewBordered ();
            view.Frame = new RectangleF (10, 10, 370, 40);
            view.Add (headerLabel);
            var topSection = new Section (view);

            Root.Add (topSection);

            string name = "";
            if (matter != null) {
                name = matter.matterName;
            }
            var sec = new Section (name);
            //
            addBusySection ();
            var tarSec = new Section ();
            if (tariffList != null && tariffList.Count > 0) {
                btnTar = new StyledStringElement ("Select Activity Code");
                btnTar.TextColor = ColorHelper.GetGPLightPurple ();
                btnTar.Alignment = UITextAlignment.Center;
                btnTar.Accessory = UITableViewCellAccessory.DisclosureIndicator;
                btnTar.Tapped += delegate {
                    if (tariffList == null) {

                    } else {
                        string[] btns = new string[tariffList.Count];
                        for (int i = 0; i < tariffList.Count; i++) {
                            btns [i] = tariffList [i].name;
                        }
                        actionSheet = new UIActionSheet ("Activity Codes", null, "Cancel", null, btns) {
                            Style = UIActionSheetStyle.Default
                        };

                        actionSheet.Clicked += delegate (object sender, UIButtonEventArgs args) {
                            if (args.ButtonIndex == tariffList.Count) {
                                //ignored - cancelled
                            } else {
                                narration.Value = tariffList [args.ButtonIndex].narration;
                                selectedTariff = tariffList [args.ButtonIndex];
                                BuildInterface ();
                            }

                        };

                        actionSheet.ShowInView (View);
                    }

                };
                tarSec.Add (btnTar);
            }
            //
            var narrSec = new Section ("Note Narration");

            if (selectedTariff == null) {
                narration = new EntryElement ("Narration", "Narration", null);
            } else {
                narrSec = new Section (selectedTariff.name);
                narration = new EntryElement ("Narration", "Narration", selectedTariff.narration);
            }
            narration.KeyboardType = UIKeyboardType.Default;
            narrSec.Add (narration);
            //
            picker = new UIDatePicker ();
            //picker.Frame = new RectangleF (10f, 10f, 320f, 320f);
            picker.Mode = UIDatePickerMode.Date;
            picker.Date = DateTime.Now;

            var pickerSection = new Section (picker);

            Root.Add (sec);
            Root.Add (tarSec);
            Root.Add (narrSec);
            Root.Add (pickerSection);
            BuildButtons ();
        }