コード例 #1
0
        /// <summary>
        /// The methods provided in this section are simply used to allow
        /// NavigationHelper to respond to the page's navigation methods.
        /// <para>
        /// Page specific logic should be placed in event handlers for the
        /// <see cref="NavigationHelper.LoadState"/>
        /// and <see cref="NavigationHelper.SaveState"/>.
        /// The navigation parameter is available in the LoadState method
        /// in addition to page state preserved during an earlier session.
        /// </para>
        /// </summary>
        /// <param name="e">Provides data for navigation methods and event
        /// handlers that cannot cancel the navigation request.</param>
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            Random random = new Random();

            try
            {
                header.Text = MainPage.SelectorHeader;
                Windows.Web.Http.HttpClient httpClient = new Windows.Web.Http.HttpClient();
                string response = await httpClient.GetStringAsync(
                    new Uri(MainPage.ServerLink + "index.php?format=" + MainPage.FromPageParam + "&passCategorie=" + Selector.passCategorie + "&random=" +
                            random.Next().ToString())
                    );

                myClassBinder root = JsonConvert.DeserializeObject <myClassBinder>(response);
                progress.Opacity          = 0;
                listSelector1.ItemsSource = root.item;
                if (MainPage.FromPageParam == "help")
                {
                    MainPage.remember_help_askhelp = true;
                }
            }
            catch (Exception ex)
            {
                FadeImageStoryboard.Begin();
                imgmoveStoryBoard.Begin();
                blockmoveStoryBoard.Begin();
            }
        }
コード例 #2
0
        private async void myTime_Tick(object sender, object e)
        {
            Random random = new Random();//generating a random number

            try
            {
                gui.Content = "looking...";
                //this httpClient is to check whether there is a job or not
                Windows.Web.Http.HttpClient httpClient = new Windows.Web.Http.HttpClient();
                string response = await httpClient.GetStringAsync(
                    new Uri(MainPage.ServerLink + "fixdetect.php?categorie=" + Selector.passCategorie + "&random=" + random.Next().ToString())
                    );

                //the part is to convert the response from the json to a list of the type myClassBinder
                myClassBinder root = JsonConvert.DeserializeObject <myClassBinder>(response);
                //this is to get the tel lat and long from the list
                MainPage.DestinationPhone     = root.item[0].tel;
                MainPage.DestinationLatitude  = root.item[0].latitude;
                MainPage.DestinationLongitude = root.item[0].longitude;
                gui.Content   = "Take the job";
                gui.Content   = MainPage.DestinationPhone;
                gui.IsEnabled = true;
                mytimer.Stop();
            }
            catch (Exception ex)
            {
                gui.Content = "wrong";
            }
        }
コード例 #3
0
        /// <summary>
        /// The methods provided in this section are simply used to allow
        /// NavigationHelper to respond to the page's navigation methods.
        /// <para>
        /// Page specific logic should be placed in event handlers for the
        /// <see cref="NavigationHelper.LoadState"/>
        /// and <see cref="NavigationHelper.SaveState"/>.
        /// The navigation parameter is available in the LoadState method
        /// in addition to page state preserved during an earlier session.
        /// </para>
        /// </summary>
        /// <param name="e">Provides data for navigation methods and event
        /// handlers that cannot cancel the navigation request.</param>
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            //this part is to fill the listbox
            header.Text = MainPage.SelectorHeader;
            Random random = new Random();//generate a random number

            try
            {
                //this is the httpClient
                Windows.Web.Http.HttpClient httpClient = new Windows.Web.Http.HttpClient();
                string response = await httpClient.GetStringAsync(
                    new Uri(MainPage.ServerLink + "index.php?format=" + MainPage.FromPageParam + "&random=" + random.Next().ToString())
                    );

                //convert the json format to the list for the listbox
                myClassBinder root = JsonConvert.DeserializeObject <myClassBinder>(response);
                progress.Opacity = 0;
                //binding the listbox to the list
                listSelector1.ItemsSource = root.item;
            }
            catch (Exception ex)
            {
                progress.Opacity = 0;
                FadeImageStoryboard.Begin();
                imgmoveStoryBoard.Begin();
                blockmoveStoryBoard.Begin();
            }
        }
コード例 #4
0
        }                                                                                             // this butto is to go to the signup page

        private async void submitt_Click(object sender, RoutedEventArgs e)
        {
            //this part is to handel all the possibilities for the login
            if (password.Text == "" || user_name.Text == "")
            {
                var dialog_empty = new MessageDialog("Enter username and password");
                await dialog_empty.ShowAsync();
            }
            else
            {
                try
                {
                    buttom_text.Text = "Looking.....";
                    Windows.Web.Http.HttpClient httpClient = new Windows.Web.Http.HttpClient();
                    string response = await httpClient.GetStringAsync(
                        new Uri(MainPage.ServerLink + "login.php?username="******"&random=" + (new Random()).Next().ToString())
                        );

                    myClassBinder root = JsonConvert.DeserializeObject <myClassBinder>(response);
                    string        til  = root.item[0].password;
                    MainPage.MyPhone = root.item[0].tel;
                    //var dialogx = new MessageDialog(til);
                    //await dialogx.ShowAsync();
                    if (password.Text == til)
                    {
                        //if the password is true then save it and the user name, then go to the main menu
                        Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
                        localSettings.Values["phone"]    = user_name.Text;
                        localSettings.Values["password"] = password.Text;
                        Frame.Navigate(typeof(MainPage));
                    }
                    else if (til == "")
                    {
                        var dialog_wrong_user = new MessageDialog("Wrong user name");
                        await dialog_wrong_user.ShowAsync();
                    }
                    else
                    {
                        var dialog_wrong_pass = new MessageDialog("Wrong password");
                        await dialog_wrong_pass.ShowAsync();
                    }
                }
                catch (Exception ex)
                {
                    buttom_text.Text = "Follow us on";
                    var dialog_catch = new MessageDialog("Something Went wrong, check your internet connection!");
                    await dialog_catch.ShowAsync();
                }
            }
        }
コード例 #5
0
        //this button is to activate the service
        private async void activate_Click(object sender, RoutedEventArgs e)
        {
            Random random = new Random();//generate a random number

            try
            {
                Windows.Web.Http.HttpClient httpClient = new Windows.Web.Http.HttpClient();//this is the httpClient to modify the state of the employee in the data base
                string response = await httpClient.GetStringAsync(
                    new Uri(MainPage.ServerLink + "activeservice.php?phone=" + MainPage.MyPhone + "&side=do&random=" + random.Next().ToString())
                    );

                myClassBinder root = JsonConvert.DeserializeObject <myClassBinder>(response);
                Selector.passCategorie = root.item[0].categorie;
                gui.Content            = Selector.passCategorie;
                mytimer.Start();//starting looking for jobs
            }
            catch (Exception ex)
            {
                var dialog = new MessageDialog("Something went wrong");
                await dialog.ShowAsync();
            }
            subtitle.Text = "Waite for requests";
        }