Ejemplo n.º 1
0
        async Task LoadComments()
        {
            if (Refresh)
            {
                return;
            }

            Refresh = true;

            try
            {
                var placeItem = await restService.FindPlaceItemById(PlaceItem.Id);

                PlaceItem = placeItem;
                Comments.Clear();

                foreach (var comment in placeItem.Comments)
                {
                    Comments.Add(comment);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                Refresh = false;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// edits the Place based on the given PlaceItem except for the ID
        /// </summary>
        /// <param name="id"></param>
        /// <param name="item"></param>
        /// <returns>Place</returns>
        public PlaceItem editPlace(int id, PlaceItem item)
        {   // get the tempfile
            string tempFile = Path.GetTempFileName();

            using (StreamWriter writer = new StreamWriter(tempFile))
                using (StreamReader reader = new StreamReader(place_filename))
                {
                    string line;
                    // if the line exist
                    while ((line = reader.ReadLine()) != null)
                    { // if the id in the file = item Id
                        if (Convert.ToInt32(line.Split(";")[0]) == id)
                        {
                            item.PlaceID = id;
                            writer.WriteLine(id + ";" + item.PlaceName);
                        }
                        else
                        {
                            writer.WriteLine(line);
                        }
                    }
                }
            // delete the old item
            File.Delete(place_filename);
            // save the new item
            File.Move(tempFile, place_filename);
            // return this item
            return(getPlaceItem(id));
        }
Ejemplo n.º 3
0
    // Start is called before the first frame update
    void Start()
    {
        // Chargement des composants
        ARPlaneManager   planeManager   = AR_Session_Origin.GetComponent <ARPlaneManager>();
        ARRaycastManager raycastManager = AR_Session_Origin.GetComponent <ARRaycastManager>();
        PlaceItem        placeItem      = AR_Session_Origin.GetComponent <PlaceItem>();

        // Default scan mode
        Scan_toggle_btn.gameObject.SetActive(true);
        imageManager.enabled = true;

        Build_toggle_btn.gameObject.SetActive(false);
        Library_btn.gameObject.SetActive(false);
        Scale_btn.gameObject.SetActive(false);
        ScaleSlider.gameObject.SetActive(false);
        Rotate_btn.gameObject.SetActive(false);
        Validate_btn.gameObject.SetActive(false);
        planeManager.enabled   = false;
        raycastManager.enabled = false;
        placeItem.enabled      = false;

        LibrairieMenu.gameObject.SetActive(false);

        // Change mode
        Scan_toggle_btn.onClick.AddListener(() => BuildMode(planeManager, raycastManager, placeItem, imageManager));
        Build_toggle_btn.onClick.AddListener(() => ScanMode(planeManager, raycastManager, placeItem, imageManager));
    }
Ejemplo n.º 4
0
        public CommentViewModel(PlaceItem placeItem = null)
        {
            Comments  = new ObservableCollection <CommentItem>();
            PlaceItem = placeItem;

            LoadCommentsCommand = new Command(async() => await LoadComments());
        }
Ejemplo n.º 5
0
        public PlaceItem saveNewPlace(PlaceItem place)
        {

            sqlConnection = null;
            sqlConnection = TimeTableDatabase.getConnection();
            try
            {
                using (sqlConnection)
                {
                    string SQL = "INSERT INTO [foodplace] ([name]) " +
                        "VALUES('" + place.PlaceName + "');" +
                        "SELECT SCOPE_IDENTITY();";
                    sqlConnection.Open();
                    SqlCommand myCommand = new SqlCommand(SQL, sqlConnection);
                    int LastID = Convert.ToInt32(myCommand.ExecuteScalar());
                    sqlConnection.Close();
                    sqlConnection = null;
                    return getPlaceItem(LastID);
                }
            }
            catch (System.Exception ex)
            {

                return null;
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Search for place in file, return Place or null
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public PlaceItem getPlaceItem(int id)
        {
            PlaceItem place = null;

            using (StreamReader sr = new StreamReader(place_filename))
            {
                string line;
                //end if end of file or place is found
                while ((line = sr.ReadLine()) != null && place == null)
                {   // if the given id = the place Id
                    int place_ID = (int)Convert.ToInt64(line.Split(";")[0]);
                    if (place_ID == id)
                    {
                        string[] args = line.Split(";");
                        place = new PlaceItem()
                        {
                            PlaceID   = place_ID,
                            PlaceName = args[1]
                        };
                    }
                }
            }
            // this place
            return(place);
        }
Ejemplo n.º 7
0
        public async Task <PlaceItem> GetPlace(int id)
        {
            Console.WriteLine("\n\n\n------------------\n\n\n------------------Code a tester : GetPlace--------------------\n\n\n------------------\n\n\n");
            HttpClient client = new HttpClient();
            PlaceItem  place  = null;

            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, url + "/places/" + id);

            request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", "__access__token__");

            var uri      = new Uri(string.Format(url + "place/" + id, string.Empty));
            var response = await client.GetAsync(uri);

            if (response.IsSuccessStatusCode)
            {
                var content = await response.Content.ReadAsStringAsync();

                Response <PlaceItem> r = JsonConvert.DeserializeObject <Response <PlaceItem> >(content);
                Console.WriteLine("Dev_is_sucess:" + r.IsSuccess);
                Console.WriteLine("Dev_error_code:" + r.ErrorCode);
                Console.WriteLine("Dev_error_message:" + r.ErrorMessage);

                return(r.Data);
            }


            return(place);
        }
Ejemplo n.º 8
0
        public ActionResult <MealItem> createMeal(MealItem meal)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            // check if this meal exist
            if (meal == null)
            {
                return(BadRequest("MealItem not found"));
            }
            PlaceItem foundedPlace = null;

            foundedPlace = placeDB.getPlaceItemByName(meal.Place.PlaceName);

            if (foundedPlace == null && meal.Place.PlaceID != 0)
            {
                foundedPlace = placeDB.getPlaceItem(meal.Place.PlaceID);
            }

            if (foundedPlace == null)
            {
                return(NotFound("No PlaceItem found for Name or ID: " + meal.Place.PlaceName + ", " + meal.Place.PlaceID));
            }
            meal.Place = foundedPlace;
            // if not then created new mealItem
            MealItem mealNew = mealDB.saveNewMeal(meal);

            return(Created("", mealNew));
        }
Ejemplo n.º 9
0
        public ActionResult <PlaceItem> editPlaceItem(int id, [FromBody] PlaceItem place)
        {
            //Check if id is valid
            if (placeDB.getPlaceItem(id) == null)
            {
                return(NotFound(($"No Place found for id: {id}")));
            }

            //Check if item not null
            if (place == null)
            {
                return(BadRequest("Place not found"));
            }
            PlaceItem[] placeItems = placeDB.getPlaces();
            // for every place in Places List
            foreach (PlaceItem placeItem in placeItems)
            {
                // if the PlaceName is exist
                if (placeItem.PlaceName == place.PlaceName)
                {
                    // then wrong
                    return(BadRequest($"Place is exist : {placeItem.PlaceName}"));
                }
            }

            // else
            //update existing item
            PlaceItem item_out = placeDB.editPlace(id, place);

            //return new item
            return(Ok(item_out));
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Search for all Places in file
        /// </summary>
        /// <returns></returns>
        public PlaceItem[] getPlaces()
        {
            // list for alle Placeitems
            List <PlaceItem> list = new List <PlaceItem>();

            using (StreamReader sr = new StreamReader(this.place_filename))
            {
                string line;
                // if the line exist
                while ((line = sr.ReadLine()) != null)
                {
                    // place
                    string[]  args  = line.Split(";");
                    PlaceItem place = new PlaceItem()
                    {
                        PlaceID   = (int)Convert.ToInt64(args[0]),
                        PlaceName = args[1]
                    };
                    // add this place to the list
                    list.Add(place);
                }
            }
            // return this list as array
            return(list.ToArray());
        }
Ejemplo n.º 11
0
 public DetailItemViewModel(Map map, PlaceItem item = null)
 {
     LoadMap = new Command(async() => await ExecuteLoadMap());
     Map     = map;
     //Title = item?.Title;
     //Description = item?.Description;
     //ImageUrl = item?.ImageUrl;
     Item = item;
     LoadMap.Execute(null);
 }
Ejemplo n.º 12
0
        private async void CreateClick(object sender, RoutedEventArgs e)
        {
            if (price.Text == "" ||
                name.Text == "" ||
                detail.Text == "" ||
                address.Text == "")
            {
                var show = new MessageDialog("各项输入不得为空").ShowAsync();
                return;
            }

            string pattern = @"^[0-9]*$";

            if (!Regex.IsMatch(price.Text, pattern))
            {
                var show = new MessageDialog("价格输入不合法").ShowAsync();
                return;
            }

            if (Double.Parse(price.Text) < 0)
            {
                var show = new MessageDialog("价格不得小于0").ShowAsync();
                return;
            }

            PlaceItem temp = new PlaceItem();

            temp.name    = name.Text;
            temp.address = address.Text;
            temp.detail  = detail.Text;
            temp.price   = Double.Parse(price.Text);
            if ((string)create.Content == "Create")
            {
                string placeName = await Services.PlaceServices.addPlace(Store.getInstance().getToken(), temp.name, temp.address, temp.detail, temp.price, file);

                if (placeName != "")
                {
                    if (name.Tag == null)
                    {
                        ControlBar.Current.NavigateToPage("Index");
                    }
                    else
                    {
                        ControlBar.Current.NavigateToPage("AddActivity", "place" + placeName);
                    }
                }
            }
            else
            {
                if (await Services.PlaceServices.updatePlace(Store.getInstance().getToken(), name.Tag.ToString(), temp.name, temp.address, temp.detail, temp.price, file))
                {
                    ControlBar.Current.NavigateToPage("Index");
                }
            }
        }
Ejemplo n.º 13
0
 void Start()
 {
     placeItemScript = FindObjectOfType <PlaceItem>();
     cachedCounts    = new int[placeItemScript.defenseItemCounts.Length];
     for (var i = 0; i < cachedCounts.Length; i++)
     {
         cachedCounts[i] = placeItemScript.defenseItemCounts[i];
     }
     TrapText.text   = "x " + cachedCounts[0];
     TurretText.text = "x " + cachedCounts[1];
 }
Ejemplo n.º 14
0
        private async void pressMeAction2(object sender, EventArgs e)
        {
            Console.WriteLine("pressMeAction2");

            //binder.lieuCourant = sender.;
            JSONService j = new JSONService();

            j.CodeASupprimer();
            //await j.GetPlaces();
            PlaceItem t = await j.GetPlace(0);

            binder.places.Add(t);
        }
Ejemplo n.º 15
0
        public ActionResult <PlaceItem> getPlace(int id)
        {
            // get the item from database
            PlaceItem item = placeDB.getPlaceItem(id);

            if (item != null)
            {
                return(Ok(item));
            }
            // else retun message
            else
            {
                return(NotFound($" No Place found for id :{ id}"));
            }
        }
Ejemplo n.º 16
0
        async void OnItemSelected(object sender, SelectedItemChangedEventArgs args)
        {
            //DisplayAlert("Alert", "You have been alerted", "OK");
            var item = args.SelectedItem as PlaceItemSummary;

            if (item == null)
            {
                return;
            }

            //DisplayAlert("Item Tapped", ((PlaceItemSummary)args.SelectedItem).Title.ToString(), "Ok");
            PlaceItem place = await placeItemViewModel.restService.FindPlaceItemById(item.Id);

            await Navigation.PushAsync(new ItemDetailPage(place));

            // Manually deselect item.
            ItemsListView.SelectedItem = null;
        }
Ejemplo n.º 17
0
        public ActionResult <PlaceItem> createPlace([FromBody] PlaceItem place)
        {
            // check if the item  null
            if (place == null)
            {// then return ein messege
                return(BadRequest("Place not found"));
            }

            if (placeDB.getPlaceItemByName(place.PlaceName) != null)
            {
                return(BadRequest($"Place {place.PlaceName} already exist"));
            }

            //else
            // if the item not null then save new item
            PlaceItem item_out = placeDB.saveNewPlace(place);

            return(Created("", item_out));
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Search for the PlaceItem
        /// Search for ID and check with the given Name
        /// Or Search for Place by given Name
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        private PlaceItem handlePlaceInput(PlaceItem item)
        {
            PlaceItem foundedItem = null;

            if (item.PlaceID != 0)
            {
                foundedItem = placeDB.getPlaceItem(item.PlaceID);
                if (foundedItem.PlaceName.ToLower() == item.PlaceName.ToLower())   //Both Items are the same
                {
                    return(foundedItem);
                }
            }
            foundedItem = placeDB.getPlaceItemByName(item.PlaceName);
            if (foundedItem == null)
            {
                throw new NotFoundException($"No PlaceItem found for Name: '{item.PlaceName}'");
            }
            return(foundedItem);
        }
Ejemplo n.º 19
0
        public PlaceItem getPlaceItemByName(string name)
        {
            sqlConnection = null;
            sqlConnection = TimeTableDatabase.getConnection();
            try
            {
                using (sqlConnection)
                {
                    PlaceItem SQLItem = new PlaceItem();

                    string SQL = "SELECT [foodplaceid],[name] FROM [foodplace] " +
                        " WHERE [name]='" + name + "';";

                    sqlConnection.Open();
                    SqlDataReader myReader = null;
                    SqlCommand myCommand = new SqlCommand(SQL, sqlConnection);
                    myReader = myCommand.ExecuteReader();

                    if (myReader.Read())
                    {
                        SQLItem.PlaceID = Convert.ToInt32(myReader["foodplaceid"]);
                        SQLItem.PlaceName = myReader["name"].ToString();
                        sqlConnection.Close();
                        sqlConnection = null;
                        return SQLItem;
                    }
                    else
                    {
                        sqlConnection.Close();
                        sqlConnection = null;
                        return null;
                    }
                }

            }
            catch (System.Exception)
            {
                return null;
            }
        }
Ejemplo n.º 20
0
        public async Task<PlaceItem> FindPlaceItemById(int Id)
        {
            PlaceItem item = new PlaceItem();
            var uri = new Uri(url + "places/" + Id);

            try
            {
                var response = await client.GetAsync(uri);

                if (response.IsSuccessStatusCode)
                {
                    var content = await response.Content.ReadAsStringAsync();
                    item = JsonConvert.DeserializeObject<Response<PlaceItem>>(content).Data;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(@"				ERROR {0}", ex.Message);
            }

            return await Task.FromResult(item);
        }
Ejemplo n.º 21
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            if ((string)e.Parameter != null)
            {
                if ((string)e.Parameter == "edit")
                {
                    name.Tag = "edit";
                }
                else
                {
                    PlaceItem place = await Services.PlaceServices.getSingleEvent((string)e.Parameter);

                    name.Text      = place.name;
                    name.Tag       = place.id.ToString();
                    image.Source   = new BitmapImage(new Uri(Global.Config.api + place.img));
                    address.Text   = place.address;
                    price.Text     = place.price.ToString();
                    detail.Text    = place.detail;
                    create.Content = "Update";
                }
            }
        }
Ejemplo n.º 22
0
 public PlaceItem editPlace(int id, PlaceItem place)
 {
     sqlConnection = null;
     sqlConnection = TimeTableDatabase.getConnection();
     try
     {
         using (sqlConnection)
         {
             string SQL = "UPDATE [foodplace] SET [name]='" + place.PlaceName + "'" +
                 " WHERE [foodplaceid] ='" + id.ToString() + "';";
             sqlConnection.Open();
             SqlCommand myCommand = new SqlCommand(SQL, sqlConnection);
             myCommand.ExecuteNonQuery();
             sqlConnection.Close();
             sqlConnection = null;
             return place;
         }
     }
     catch (System.Exception)
     {
         return null;
     }
 }
Ejemplo n.º 23
0
        /// <summary>
        /// Create new place
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public PlaceItem saveNewPlace(PlaceItem item)
        {
            // get all Places
            PlaceItem[] places = getPlaces();
            // the max id = 0
            int max = 0;

            // for every place in Places List
            foreach (PlaceItem place in places)
            {
                // change the max to the maxId from Place
                max = place.PlaceID > max ? place.PlaceID : max;
                if (item.PlaceName == place.PlaceName)
                {
                    return(null);
                }
            }
            // the new Id is max+1
            item.PlaceID = max + 1;
            // save the place item in the file
            File.AppendAllLines(place_filename, new String[] { this.writeLine(item) });
            return(item);
        }
Ejemplo n.º 24
0
        public PlaceItem[] getPlaces()
        {
            sqlConnection = null;
            sqlConnection = TimeTableDatabase.getConnection();
            try
            {
                using (sqlConnection)
                {
                    PlaceItem SQLItem = new PlaceItem();
                    List<PlaceItem> ListPlaceItem = new List<PlaceItem>();
                    string SQL = "SELECT [foodplaceid],[name] FROM [foodplace] " +
                        " ;";

                    sqlConnection.Open();
                    SqlDataReader myReader = null;
                    SqlCommand myCommand = new SqlCommand(SQL, sqlConnection);
                    myReader = myCommand.ExecuteReader();

                    while (myReader.Read())
                    {
                        SQLItem.PlaceID = Convert.ToInt32(myReader["foodplaceid"]);
                        SQLItem.PlaceName = myReader["name"].ToString();
                        ListPlaceItem.Add(SQLItem);
                        SQLItem = new PlaceItem();
                    }

                        sqlConnection.Close();
                        sqlConnection = null;
                        return ListPlaceItem.ToArray();
                }

            }
            catch (System.Exception)
            {
                return null;
            }
        }
Ejemplo n.º 25
0
        private void pressMeAction(object sender, EventArgs e)
        {
            Console.WriteLine("pressMeAction");
            var button = (Button)sender;

            Console.WriteLine("button : " + button);
            var classId = button.ClassId;

            Console.WriteLine("classId : " + classId);

            PlaceItem p = findPlaceById(classId);

            Console.WriteLine("Place : " + p);

            switch (classId)
            {
            case "Paris": break;

            default: break;
            }

            Navigation.PushAsync(new Page2(p));
            //binder.lieuCourant = sender.;
        }
Ejemplo n.º 26
0
        private void PlacesItem_ItemClicked(object sender, ItemClickEventArgs e)
        {
            PlaceItem placeItem = (PlaceItem)e.ClickedItem;

            ControlBar.Current.NavigateToPage("PlaceDetail", placeItem.id.ToString());
        }
Ejemplo n.º 27
0
        public Page2(PlaceItem currentLieu)
        {
            InitializeComponent();
            Console.Write("--------------Page2 constructeur--------------");

            BindingContext              = new Page2ViewModel(currentLieu);
            Map.PinClicked             += (sender, e) => Debug.WriteLine("Pin Clicked");
            Map.PinInfoViewClicked     += (sender, e) => Debug.WriteLine("Info Window Clicked");
            Map.PinInfoViewLongClicked += (sender, e) => Debug.WriteLine("Info Window Long Clicked");
            Map.MapClicked             += (sender, e) => Debug.WriteLine($"Map Clicked, {{latitude: {((Position)e.Value).Latitude} longitude: {((Position)e.Value).Longitude}}}");
            Map.MapLongClicked         += (sender, e) => Debug.WriteLine($"Map Long Clicked, {{latitude: {((Position)e.Value).Latitude} longitude: {((Position)e.Value).Longitude}}}");
            Map.PinLongClicked         += (sender, e) => Debug.WriteLine("Pin Long Clicked");
            Map.PinDragStart           += (sender, e) => Debug.WriteLine($"Pin Drag Start, {{latitude: {((MapPin)e.Value).Location.Latitude} longitude: {((MapPin)e.Value).Location.Longitude}}}");
            Map.PinDragging            += (sender, e) => Debug.WriteLine("Pin Dragging");
            Map.PinDragEnd             += (sender, e) => Debug.WriteLine($"Pin Drag End, {{latitude: {((MapPin)e.Value).Location.Latitude} longitude: {((MapPin)e.Value).Location.Longitude}}}");

            //hhh();
            //Xamarin.FormsMaps.Init();

            /*map = new Map
             * {
             *
             *  HeightRequest = 100,
             *  WidthRequest = 960,
             *  VerticalOptions = LayoutOptions.FillAndExpand
             * };
             *
             *
             * map.MoveToRegion(new MapSpan(new Position(0, 0), 360, 360));
             *
             *
             * var slider = new Slider(1, 18, 1);
             * slider.ValueChanged += (sender, e) => {
             *  var zoomLevel = e.NewValue;
             *  var latlongdegrees = 360 / (Math.Pow(2, zoomLevel));
             *  Debug.WriteLine(zoomLevel + " -> " + latlongdegrees);
             *  if (map.VisibleRegion != null)
             *      map.MoveToRegion(new MapSpan(map.VisibleRegion.Center, latlongdegrees, latlongdegrees));
             * };
             *
             *
             * var street = new Button { Text = "Street" };
             * var hybrid = new Button { Text = "Hybrid" };
             * var satellite = new Button { Text = "Satellite" };
             * street.Clicked += HandleClicked;
             * hybrid.Clicked += HandleClicked;
             * satellite.Clicked += HandleClicked;
             * var segments = new StackLayout
             * {
             *  Spacing = 30,
             *  HorizontalOptions = LayoutOptions.CenterAndExpand,
             *  Orientation = StackOrientation.Horizontal,
             *  Children = { street, hybrid, satellite }
             * };
             *
             *
             * var stack = new StackLayout { Spacing = 0 };
             * stack.Children.Add(map);
             * stack.Children.Add(slider);
             * stack.Children.Add(segments);
             * Content = stack;
             *
             *
             * map.PropertyChanged += (sender, e) => {
             *  Debug.WriteLine(e.PropertyName + " just changed!");
             *  if (e.PropertyName == "VisibleRegion" && map.VisibleRegion != null)
             *      CalculateBoundingCoordinates(map.VisibleRegion);
             * };*/
        }
Ejemplo n.º 28
0
 void Start()
 {
     myRect    = GetComponent <RectTransform>();
     placeItem = FindObjectOfType <PlaceItem>();
 }
Ejemplo n.º 29
0
        //private DataTemplate dt;

        public Page2ViewModel(PlaceItem currentPlace)
        {
            CurrentPlace = currentPlace;
        }
Ejemplo n.º 30
0
 /// <summary>
 /// Creates the string output for Place
 /// </summary>
 /// <param name="place"></param>
 /// <returns></returns>
 private string writeLine(PlaceItem place)
 {
     return(place.PlaceID + ";" +
            place.PlaceName);
 }
        void CreatePlaceItemInstance(PlaceItem pi)
        {
            if (Network.isServer || Network.isClient)
                targetObject = (GameObject)Network.Instantiate (pi.gameObject, Vector3.zero, pi.transform.rotation, 1);
            else
                targetObject = (GameObject)GameObject.Instantiate (pi.gameObject, Vector3.zero, pi.transform.rotation);

            placedItems.Add (targetObject.GetComponent<PlaceItem> ());
            SetCollider (targetObject, false);
            creating = true;
            endCreation = false;
        }