Exemplo n.º 1
0
        public App()
        {
            Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("MTA3Mzg5QDMxMzcyZTMxMmUzMEFvL1Y2Sk9XWU9SUU5ENzYxSEZNYUZvWG5OSFM4Uk1hcnFOYng1YmphSE09");

            InitializeComponent();

            if (Ultis.Settings.App.Contains("Tracking") || Ultis.Settings.App.Contains("Business"))
            {
                Ultis.Settings.SessionBaseURI = "https://api.asolute.com/host/api/";
                MainPage = new CustomNavigationPage(new StartUpScreen());
            }
            else
            {
                // MainPage = new yardmaptest();

                if (sessionKey != "")
                {
                    MainPage = new MainPage();
                }
                else
                {
                    if (Ultis.Settings.AppFirstInstall == "First")
                    {
                        MainPage = new CustomNavigationPage(new StartUpScreen());
                    }
                    else
                    {
                        MainPage = new CustomNavigationPage(new LoginPage());
                    }
                }
            }

            /*OneSignal.Current.StartInit("804c5448-99ec-4e95-829f-c98c0ea6acd9")
             *         .InFocusDisplaying(Com.OneSignal.Abstractions.OSInFocusDisplayOption.Notification)
             *         .HandleNotificationReceived(HandleNotificationReceived)
             *         .EndInit(); */
        }
Exemplo n.º 2
0
        async void OnItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            if (Ultis.Settings.SessionSettingKey == "")
            {
                BackgroundTask.Logout(this);
            }
            else
            {
                var item = e.SelectedItem as MasterPageItem;

                if (item != null)
                {
                    if (item.Id.Equals("AddProvider"))
                    {
                        var answer = await DisplayAlert("", "Refresh provider list?", "Yes", "No");

                        if (answer.Equals(true))
                        {
                            try
                            {
                                var content = await CommonFunction.CallWebService(0, null, Ultis.Settings.SessionBaseURI, ControllerUtil.getAutoScanURL(), this);

                                clsResponse autoScan_response = JsonConvert.DeserializeObject <clsResponse>(content);

                                if (autoScan_response.IsGood)
                                {
                                    await DisplayAlert("Success", autoScan_response.Result, "OK");

                                    Ultis.Settings.AppFirstInstall = "Refresh";
                                    Application.Current.MainPage   = new MainPage();
                                }
                            }
                            catch
                            {
                            }
                        }
                    }
                    else if (item.Id.Equals("Panic"))
                    {
                        string panic  = (Ultis.Settings.Language.Equals("English")) ? "Send panic message ?" : "Pasti ?";
                        var    answer = await DisplayAlert("", panic, "Yes", "No");

                        if (answer.Equals(true))
                        {
                            try
                            {
                                var content = await CommonFunction.CallWebService(0, null, Ultis.Settings.SessionBaseURI, ControllerUtil.getPanicURL(), this);

                                clsResponse panic_response = JsonConvert.DeserializeObject <clsResponse>(content);
                                if (panic_response.IsGood)
                                {
                                    string reply = (Ultis.Settings.Language.Equals("English")) ? "Message sent successfully." : "Permintaan anda telah dihantar.";
                                    await DisplayAlert("", reply, "Okay");
                                }
                            }
                            catch
                            {
                            }
                        }
                    }
                    else if (item.Id.Equals("CallOffice"))
                    {
                        try
                        {
                            Device.OpenUri(new Uri(String.Format("tel:{0}", Ultis.Settings.SessionUserItem.OperationPhone)));
                        }
                        catch
                        {
                        }
                    }
                    else if (item.Id.Equals("CallMe"))
                    {
                        string callMe = (Ultis.Settings.Language.Equals("English")) ? "Request controller to call you ?" : "Pasti ?";
                        var    answer = await DisplayAlert("", callMe, "Yes", "No");

                        if (answer.Equals(true))
                        {
                            try
                            {
                                var content = await CommonFunction.CallWebService(0, null, Ultis.Settings.SessionBaseURI, ControllerUtil.getCallOperatorURL(), this);

                                clsResponse callMe_response = JsonConvert.DeserializeObject <clsResponse>(content);
                                if (callMe_response.IsGood == true)
                                {
                                    string reply = (Ultis.Settings.Language.Equals("English")) ? "Your request has been attended" : "Permintaan anda telah dihantar.";
                                    await DisplayAlert("", reply, "Okay");
                                }
                            }
                            catch
                            {
                            }
                        }
                    }
                    else if (item.Id.Equals("Language"))
                    {
                        string language = (Ultis.Settings.Language.Equals("English")) ? "Please choose prefer language" : "Sila pilih bahasa ";
                        var    answer   = await DisplayActionSheet(language, "", null, "English", "Malay");

                        string uri = "";
                        if (answer != null)
                        {
                            if (answer.Equals("English"))
                            {
                                uri = ControllerUtil.getLanguageURL(0);
                                Ultis.Settings.Language = "English";
                            }
                            else if (answer.Equals("Malay"))
                            {
                                uri = ControllerUtil.getLanguageURL(1);
                                Ultis.Settings.Language = "Malay";
                            }

                            try
                            {
                                var content = await CommonFunction.CallWebService(0, null, Ultis.Settings.SessionBaseURI, uri, this);

                                clsResponse json_response = JsonConvert.DeserializeObject <clsResponse>(content);

                                if (json_response.IsGood)
                                {
                                    Ultis.Settings.RefreshListView = "Yes";
                                    string reply = (Ultis.Settings.Language.Equals("English")) ? "Language had been changed." : "Bahasa telah diubah.";
                                    await DisplayAlert("", reply, "Okay");

                                    refreshMainPage();
                                }
                            }
                            catch
                            {
                            }
                        }
                        else
                        {
                        }
                    }
                    else if (item.Id.Equals("LogOff"))
                    {
                        string logoff = (Ultis.Settings.Language.Equals("English")) ? "Are you sure?" : "Pasti ?";
                        var    answer = await DisplayAlert("", logoff, "Yes", "No");

                        if (answer.Equals(true))
                        {
                            try
                            {
                                var content = await CommonFunction.CallWebService(0, null, Ultis.Settings.SessionBaseURI, ControllerUtil.getLogOutURL(), this);

                                clsResponse logoutResponse = JsonConvert.DeserializeObject <clsResponse>(content);

                                if (logoutResponse.IsGood)
                                {
                                    //App.DropDatabase(); the app will crash
                                    BackgroundTask.Logout(this);
                                }
                            }
                            catch
                            {
                            }
                        }
                    }
                    else
                    {
                        Detail = new CustomNavigationPage((Page)Activator.CreateInstance(item.TargetType));
                        masterPage.ListView.SelectedItem = null;
                        IsPresented = false;
                    }
                }
            }
        }