Exemplo n.º 1
0
        private async Task FinishRegistration(IDialogContext context)
        {
            try
            {
                await FireBaseHelper.registerUserInFireBase(new User
                {
                    email = context.PrivateConversationData.GetValue <string>("email")
                    ,
                    // lastname = context.PrivateConversationData.GetValue<string>("LastName")
                    //  ,
                    nickname = context.PrivateConversationData.GetValue <string>("nickname")
                });

                await context.PostAsync($"Registration successfull with following details: ");

                foreach (string key in questions.Keys)
                {
                    await context.SayAsync($"{key}: {context.PrivateConversationData.GetValue<string>(key)}",
                                           $"{key}: {context.PrivateConversationData.GetValue<string>(key)}");

                    //await context.PostAsync($"{key}: { context.PrivateConversationData.GetValue<string>(key)}");
                }
                context.EndConversation("Conversation Ended");
            }
            catch (Exception e)
            {
                await context.PostAsync($"Error occured: {e.Message}");
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            _rawPageViewController = new RawPageViewController();
            _setData = _rawPageViewController;
            var sampleFrame = new CGRect(SubView.Bounds.Location.X,
                                         SubView.Bounds.GetMinY(),
                                         SubView.Bounds.Width,
                                         SubView.Bounds.Height);

            _rawPageViewController.View.Frame = sampleFrame;
            SubView.Add(_rawPageViewController.View);

            var appDelegate = UIApplication.SharedApplication.Delegate as AppDelegate;
            var station     = appDelegate.ActiveStation;
            var flight      = appDelegate.CurrentFlight;

            _firebaseHelper = new FireBaseHelper(station.Key, flight.Key);
            _firebaseHelper.StartRawDataObserver((obj) =>
            {
                Console.WriteLine(obj.EpochTime);
                GpsImage.Image       = new UIImage(GetImageName(obj.GpsStatus));
                SensorImage.Image    = new UIImage(GetImageName(obj.SensorStatus));
                TelemetryImage.Image = new UIImage(GetImageName(obj.TelemetryStatus));
                if (obj.StartDetected)
                {
                    StartTimeText.Text = $"Start Time: {obj.StartTime.FromUnixTime():HH:mm:ss}";
                }
                LastUpdateText.Text = $"Last Update: {obj.EpochTime.FromUnixTime():HH:mm:ss}";
                _setData?.SetData(obj);
            });
        }
Exemplo n.º 3
0
        public AddCardPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService)
        {
            _navigationService = navigationService;

            _pageDialogService = pageDialogService;

            dbLocal = new DbLocal();

            wiFiConection = new WiFiConnection();

            firebase = new FireBaseHelper();
        }
Exemplo n.º 4
0
        public MainPageViewModel(INavigationService navigationService)
        {
            _navigationService = navigationService;

            carCardsData = new DbLocal();

            wiFiConection = new WiFiConnection();

            firebase = new FireBaseHelper();

            Cards = LoadCards();
        }
Exemplo n.º 5
0
        private async Task FetchDataAsync(string ID)
        {
            var resIDList = await myRestaurantManager.FetchRestaurantAsync();

            foreach (var item in resIDList)
            {
                if (ID == item.ID.ToString())
                {
                    var foodList = await FireBaseHelper.GetAllFood(ID);

                    MyMenuList = new ObservableCollection <Food>(foodList);
                }
            }
        }
Exemplo n.º 6
0
        private async void Login()
        {
            if (CrossConnectivity.Current != null && CrossConnectivity.Current.IsConnected == false)
            {
                await App.Current.MainPage.DisplayAlert("Network error", "Please check ur network connection", "OK");
            }
            //null or empty validation, check if Email and Password is null or empty
            if (string.IsNullOrEmpty(Username) || string.IsNullOrEmpty(Password))
            {
                await App.Current.MainPage.DisplayAlert("Empty Value", "Please enter Email and Password", "OK");
            }
            else
            {
                var userLogin = await FireBaseHelper.GetUser(Username);

                if (userLogin != null)
                {
                    if (Username == this.Username && Password == this.Password)
                    {
                        var tabbedPage = new TabbedPage();
                        tabbedPage.Children.Add(new RestaurantPage());
                        //tabbedPage.Children.Add(new UserMapPage());

                        if (string.IsNullOrEmpty(userLogin.PhoneNumber))
                        {
                            tabbedPage.Children.Add(new AccountPage(Username, userLogin.Address, emptyPhoneNo));
                        }
                        else
                        {
                            tabbedPage.Children.Add(new AccountPage(Username, userLogin.Address, userLogin.PhoneNumber));
                        }

                        tabbedPage.UnselectedTabColor = Color.FromHex("#D18402");
                        tabbedPage.SelectedTabColor   = Color.FromHex("#C03251");
                        tabbedPage.BarBackgroundColor = Color.FromHex("#FFFFFF");

                        await App.Current.MainPage.Navigation.PushAsync(tabbedPage);
                    }
                    else
                    {
                        await App.Current.MainPage.DisplayAlert("Login Fail", "Please enter correct Email and Password", "OK");
                    }
                }
                else
                {
                    await App.Current.MainPage.DisplayAlert("Login Fail", "User not found", "OK");
                }
            }
        }
Exemplo n.º 7
0
 public override void ViewDidLoad()
 {
     base.ViewDidLoad();
     Title           = "Station Status".GetLocalString();
     _firebaseHelper = new FireBaseHelper();
     _datasource     = new StationStatusTableViewDataSource()
     {
         ViewController = this
     };
     TableView.Source              = _datasource;
     _refreshControl               = new UIRefreshControl();
     _refreshControl.ValueChanged += (sender, e) => {
         LoadData();
         _refreshControl.EndRefreshing();
     };
     TableView.AddSubview(_refreshControl);
     MenuButton.Clicked += (sender, e) => this.RevealViewController().RevealToggleAnimated(true);
     LoadData();
 }
Exemplo n.º 8
0
        public override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            bool isSuccess = await FireBaseHelper.GetTermYear(isMidTerm? "Mid" : "Final", subjectName);

            SubTermAdapter adapter;

            if (isSuccess)
            {
                textView.Visibility = progress.Visibility = ViewStates.Gone;
                adapter             = new SubTermAdapter(this.Activity, FireBaseHelper.Terms);
                lsSubject.SetAdapter(adapter);
                lsSubject.Visibility = ViewStates.Visible;
            }
            else
            {
                if (File.Exists(DatabaseUtility.jsonPath))
                {
                    List <string> listOfTerm = await FireBaseHelper.LoadTermFromFile(isMidTerm? "Mid" : "Final", subjectName);

                    if (listOfTerm != null)
                    {
                        textView.Visibility = progress.Visibility = ViewStates.Gone;
                        adapter             = new SubTermAdapter(this.Activity, listOfTerm);
                        lsSubject.SetAdapter(adapter);
                        lsSubject.Visibility = ViewStates.Visible;
                    }
                    else
                    {
                        progress.Visibility = ViewStates.Gone;
                        img.Visibility      = textView.Visibility = ViewStates.Visible;
                        textView.Text       = "Không có dữ liệu !!!";
                    }
                }
                else
                {
                    progress.Visibility = ViewStates.Gone;
                    img.Visibility      = textView.Visibility = ViewStates.Visible;
                    textView.Text       = "Không có dữ liệu !!!";
                }
            }
        }
Exemplo n.º 9
0
        private async void Delete()
        {
            try
            {
                var isdelete = await FireBaseHelper.DeleteUser(this.Username);

                if (isdelete)
                {
                    await App.Current.MainPage.Navigation.PopAsync();
                }
                else
                {
                    await App.Current.MainPage.DisplayAlert("Error", "Record not delete", "Ok");
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine($"Error:{e}");
            }
        }
Exemplo n.º 10
0
        async Task <bool> GetQuestions(string year)
        {
            bool isSuccess = (await FireBaseHelper.GetSubExam(DataManager.IsMidTerm ? "Mid" : "Final", subjectName, year).ConfigureAwait(true));

            if (isSuccess)
            {
                int lenOfQuesList = FireBaseHelper.Ques.Count;
                if (lenOfQuesList == 0)
                {
                    await FireBaseHelper.LoadDataFromFile(DataManager.IsMidTerm? "Mid" : "Final", subjectName, year).ConfigureAwait(true);

                    if (FireBaseHelper.Ques == null)
                    {
                        return(false);
                    }
                    lenOfQuesList = FireBaseHelper.Ques.Count;
                    if (lenOfQuesList == 0)
                    {
                        return(false);
                    }
                }
            }
            else
            {
                await FireBaseHelper.LoadDataFromFile(DataManager.IsMidTerm? "Mid" : "Final", subjectName, year).ConfigureAwait(true);

                if (FireBaseHelper.Ques == null)
                {
                    return(false);
                }
                int lenOfQuesList = FireBaseHelper.Ques.Count;
                if (lenOfQuesList == 0)
                {
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 11
0
        //Update user data
        private async void Update()
        {
            try
            {
                if (!string.IsNullOrEmpty(Password) && !string.IsNullOrEmpty(Address))
                {
                    var isupdate = await FireBaseHelper.UpdateUser(this.Username, this.Password, this.Address, this.PhoneNumber);

                    if (isupdate)
                    {
                        await App.Current.MainPage.DisplayAlert("Update Success", "", "Ok");

                        var userInfo = await FireBaseHelper.GetUser(this.Username);

                        if (string.IsNullOrEmpty(userInfo.PhoneNumber))
                        {
                            await App.Current.MainPage.Navigation.PushAsync(new AccountPage(this.Username, this.Address, nullPhoneNumber));
                        }
                        else
                        {
                            await App.Current.MainPage.Navigation.PushAsync(new AccountPage(this.Username, this.Address, this.PhoneNumber));
                        }
                    }
                    else
                    {
                        await App.Current.MainPage.DisplayAlert("Error", "Record not update", "Ok");
                    }
                }
                else
                {
                    await App.Current.MainPage.DisplayAlert("Password and Address Require", "Please Enter your password or address", "Ok");
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine($"Error:{e}");
            }
        }
Exemplo n.º 12
0
        private async void SignUp()
        {
            //null or empty validation, check if Email and Password is null or empty
            if (string.IsNullOrEmpty(Username) || string.IsNullOrEmpty(Password) || string.IsNullOrEmpty(Address))
            {
                await App.Current.MainPage.DisplayAlert("Empty Value", "Please enter Username, Password and Address", "OK");
            }
            else
            {
                var userSignup = await FireBaseHelper.AddUser(Username, Password, Address, PhoneNumber);

                if (userSignup)
                {
                    await App.Current.MainPage.DisplayAlert("SignUp Successed", "", "OK");

                    await App.Current.MainPage.Navigation.PushAsync(new LoginPage());
                }
                else
                {
                    await App.Current.MainPage.DisplayAlert("Error", "SignUp Failed", "OK");
                }
            }
        }
Exemplo n.º 13
0
        void InitializeDatabase()
        {
            //BusyIndicator.Hidden = false;
            ActivityIndicator.StartAnimating();
            TableSource.FlightList.Clear();
            tableView.ReloadData();


            var fireBaseHelper = new FireBaseHelper();

            fireBaseHelper.StartFlightFromStationObserver(UpdateTableData, DeleteTableDate,
                                                          ActiveStation.Key,
                                                          _startTime, _endTime);


            //var rootNode = Firebase.Database.Database.DefaultInstance.GetRootReference();
            //var childNode = rootNode.GetChild("station").GetChild(ActiveStation.Key).GetChild("flights");
            //                       /* .GetQueryOrderedByChild("EpochTime")
            //                        .GetQueryStartingAtValue(NSObject.FromObject(_startTime.GetUnixEpoch()))
            //                        .GetQueryEndingAtValue(NSObject.FromObject(_endTime.GetUnixEpoch()));*/

            //var referenceNode = childNode.ObserveEvent(DataEventType.ChildAdded, (snapshot, prevKey) =>
            //{
            //    var flightData = GetFlightDataFromSnapshot(snapshot);
            //    InvokeOnMainThread(() =>
            //    {
            //        TableSource.FlightList.Add(flightData);
            //        tableView.ReloadData();
            //        View.SetNeedsDisplay();
            //        ActivityIndicator.StopAnimating();
            //        Console.WriteLine("Flight added");
            //    });
            //});

            //var changeNode = childNode.ObserveEvent(DataEventType.Value, (snapshot, prevKey) =>
            //{
            //    if (snapshot == null || !snapshot.HasChildren)
            //    {
            //        InvokeOnMainThread(() =>
            //        {
            //            ActivityIndicator.StopAnimating();
            //            Console.WriteLine("Flight added");
            //        });
            //    }
            //});


            //var deleteNode = childNode.ObserveEvent(DataEventType.ChildRemoved, (snapshot, prevKey) =>
            //{
            //    var flightData = GetFlightDataFromSnapshot(snapshot);
            //    var index = TableSource.FlightList.FindIndex(x => x.Key == flightData.Key);
            //    InvokeOnMainThread(() =>
            //    {
            //        //TableSource.FlightList.RemoveAt(index);
            //        //tableView.BeginUpdates();
            //        tableView.ReloadData();
            //        View.SetNeedsDisplay();
            //        //tableView.EndUpdates();
            //        ActivityIndicator.StopAnimating();
            //        Console.WriteLine("Flight deleted");
            //    });

            //});
        }