Ejemplo n.º 1
0
        async void ChangePassword_Clicked(object sender, EventArgs e)
        {
            try
            {
                if (!(string.IsNullOrEmpty(newPasswordEntry.Text) && string.IsNullOrEmpty(confirmPasswordEntry.Text)))
                {
                    if (newPasswordEntry.Text.Equals(confirmPasswordEntry.Text))
                    {
                        string encryptedNewPassword = clsCommonFunc.AES_Encrypt(newPasswordEntry.Text);

                        var content = await CommonFunction.CallWebService(0, null, Ultis.Settings.SessionBaseURI, ControllerUtil.getChangePasswordURL(encryptedNewPassword), this);

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

                        if (json_response.IsGood)
                        {
                            string response = (Ultis.Settings.Language.Equals("English")) ? "Change Password is Successful! Please login again." : "Berjaya ! Sila login semula.";

                            await DisplayAlert("", response, "OK");

                            BackgroundTask.Logout(this);
                        }
                    }
                    else
                    {
                        await DisplayAlert("New Password Not Match", "Entered New Password and Confirm New Password must be the same.", "Okay");
                    }
                }
                else
                {
                    await DisplayAlert("Field missing", "Entered all field before proceed.", "Okay");
                }
            }
            catch (Exception)
            {
            }
        }
Ejemplo 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;
                    }
                }
            }
        }