public Places Add(Places entity) { this._context.Add(entity); this._context.SaveChanges(); return(entity); }
public IHttpActionResult GetPlaceAction(string token, int id) { if (token != null && token.Length > 0) { var tenants = db.JDE_Tenants.Where(t => t.TenantToken == token.Trim()); if (tenants.Any()) { var items = (from pa in db.JDE_PlaceActions join p in db.JDE_Places on pa.PlaceId equals p.PlaceId into Places from pls in Places.DefaultIfEmpty() join a in db.JDE_Actions on pa.ActionId equals a.ActionId into Actions from acs in Actions.DefaultIfEmpty() join u in db.JDE_Users on pa.CreatedBy equals u.UserId join u2 in db.JDE_Users on pa.LmBy equals u2.UserId into LmByNames from lms in LmByNames.DefaultIfEmpty() join t in db.JDE_Tenants on pa.TenantId equals t.TenantId where pa.TenantId == tenants.FirstOrDefault().TenantId&& pa.PlaceActionId == id orderby pa.CreatedOn descending select new { PlaceActionId = pa.PlaceActionId, PlaceId = pa.PlaceId, PlaceName = pls.Name, ActionId = pa.ActionId, ActionName = acs.Name, GivenTime = acs.GivenTime, Type = acs.Type, CreatedBy = u.UserId, CreatedByName = u.Name + " " + u.Surname, CreatedOn = pa.CreatedOn, LmBy = pa.LmBy, LmByName = lms.Name + " " + lms.Surname, TenantId = pa.TenantId, TenantName = t.TenantName, LastChecks = (from pact in db.JDE_ProcessActions join h in db.JDE_Handlings on pact.HandlingId equals h.HandlingId into Handlings from hs in Handlings.DefaultIfEmpty() where pact.ActionId == pa.ActionId && pact.IsChecked == true orderby hs.FinishedOn descending select hs.FinishedOn).Take(1) }); if (items.Any()) { return(Ok(items.FirstOrDefault())); } else { return(StatusCode(HttpStatusCode.NoContent)); } } else { return(NotFound()); } } else { return(NotFound()); } }
private async void OnHelperSearch(object sender, EventArgs e) { if (!string.IsNullOrEmpty(entrySearch.Text)) { listView.IsVisible = false; listView.SelectedItem = null; string selectedLoc = entrySearch.Text; //selectedLoc = selectedLoc.Split(',')[0]; var loc = selectedPrediction.Where(x => x.Description == selectedLoc).FirstOrDefault(); selectedPlace = await Places.GetPlace(loc.Place_ID, Constants.googlePlaceApiKey); HelpersServices helpersServices = new HelpersServices(); var h = await helpersServices.GetHelpersList(0, selectedService.Id, selectedScope.Id, selectedPlace.Latitude, selectedPlace.Longitude); if (filteredLocationType != '\0') { h = h.Where(x => x.LocationType.Equals(filteredLocationType)); } if (h != null && h.Count() != 0) { helpersViewModel.SetLocationOnMap(new ObservableCollection <HelperHomeModel>(h)); } } }
public virtual Tuple <bool, byte> DeletePlace(int id) { Place place = Places.SingleOrDefault(p => p.ID == id); byte errors = (byte)ModelType.Model; bool success = false; if (place != null) { if (place.Animals.Count > 0) { errors |= (byte)ModelType.Animal; } if (place.Attractions.Count > 0) { errors |= (byte)ModelType.Attraction; } if (place.Workers.Count > 0) { errors |= (byte)ModelType.Worker; return(new Tuple <bool, byte>(false, errors)); } Places.Remove(place); try { SaveChanges(); success = true; } catch (Exception e) { Logger.LogError($"Exception removing place! Exception: {e.ToString()}", GetType(), $"DeletePlace(id: {id})"); } } return(new Tuple <bool, byte>(success, errors)); }
public async Task <IActionResult> PutPlaces([FromRoute] int id, [FromBody] Places places) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != places.Id) { return(BadRequest()); } _context.Entry(places).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PlacesExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public CartoPlaceInfo FindLocalityPlace(CartoPlaceInfo place) { if (String.IsNullOrWhiteSpace(place.Locality)) { return(null); } var places = Places.Where(x => x.Country.CountryID == place.Country.CountryID && String.Compare(x.Name, place.Locality, true) == 0); if (place.Region == null) { return(places.FirstOrDefault()); } else { var p = places.Where(x => x.Region != null && x.Region.RegionID == place.Region.RegionID).FirstOrDefault(); if (p != null) { return(p); } else { return(places.FirstOrDefault()); } } }
private async Task HandlePlacePredictionTap(AutoCompletePrediction prediction) { if (FromAutoCompletePredictions != null) { IsFromVisible = false; _selectedFromPlace = prediction; FromAutoCompletePredictions = null; FromText = prediction.Description; var place = await Places.GetPlace(prediction.Place_ID, App.GooglePlacesApi); NewRide.FromLong = place.Longitude; NewRide.FromLat = place.Latitude; NewRide.FromCity = place.Name; } else { IsToVisible = false; _selectedToPlace = prediction; ToAutoCompletePredictions = null; ToText = prediction.Description; var place = await Places.GetPlace(prediction.Place_ID, App.GooglePlacesApi); NewRide.ToLong = place.Longitude; NewRide.ToLat = place.Latitude; NewRide.ToCity = place.Name; } }
public Car GetCar(Int32 i) { if (Places.Contains(i)) { Places.Remove(i); TimeSpan time = DateTime.Now.Subtract(Time[i]); int t = Convert.ToInt32(time.TotalSeconds) / 3600; if (t == 0) { Console.WriteLine("You have to pay 10$"); } else { Console.WriteLine($"You have to pay {t + 10}$"); } Car car = Cars[i]; Time.Remove(i); Cars.Remove(i); return(car); } else { throw new Exception("There is no car with this number"); } }
public Int32 FindPlace() { int max = 0; for (Int32 i = 0; i < Places.Count; i++) { if (!Places.Contains(i)) { Places.Add(i); return(i); } if (max < i) { max = i; } } if (max < Capasity) { Places.Add(max); return(max); } else { throw new ArgumentException("Parking if out of free space"); } }
private async Task <ResourceResponse> ReplyWithVisitedPlaceAsync(Places place, Activity activity, ConnectorClient connector) { var replyMessage = string.Format(Messages.PreviouslyChosenResturantFormattingMessage, place.Location, place.PickedBy, place.Date); var reply = activity.CreateReply(replyMessage); return(await connector.Conversations.ReplyToActivityAsync(reply)); }
private async void ExecuteLoadDataCommand(object obj) { IsBusy = true; try { Cars.Clear(); var task1 = CarsService.GetCarsAsync(); var task2 = PlacesService.GetPlacesAsync(); foreach (var car in await task1) { Cars.Add(car); } foreach (var place in await task2) { if (!place.occupied) { Places.Add(place); } } } catch (Exception ex) { Debug.WriteLine(ex); await Application.Current.MainPage.DisplayAlert("BŁĄD", "Nie udało się wczytać samochodów", "ANULUJ"); } finally { IsBusy = false; } }
private bool DustBucle(Places myPosition, Dictionary <Places, PositionState> positionStates, bool force = false) { bool roundPlayed = false; for (int r = ((int)myPosition - 1); r >= 1; r--) { roundPlayed = DustWorker(r, positionStates, force); if (roundPlayed) { break; } } if (roundPlayed == false) { for (int r = 10; r > (int)myPosition; r--) { roundPlayed = DustWorker(r, positionStates, force); if (roundPlayed) { break; } } } return(roundPlayed); }
private async void OnPlacesRetrieved(object sender, AutoCompleteResult result) { if (!(result.Status == "OK")) { return; } ObservableCollection <LocationModel> addresses = new ObservableCollection <LocationModel>(); //List<string> addresses = new List<string>(); List <AutoCompletePrediction> selectedPrediction = result.AutoCompletePlaces; foreach (AutoCompletePrediction autoCompletePlace in result.AutoCompletePlaces) { Place place = await Places.GetPlace(autoCompletePlace.Place_ID, Constants.googlePlaceApiKey); addresses.Add(new LocationModel { Address = autoCompletePlace.Description, Latitude = place.Latitude.ToString(), Longitude = place.Longitude.ToString() }); } if (addresses.Count == 0) { return; } lvAddresses.ItemsSource = addresses; }
public void SaveState() { if (OptionFolder == null) { return; } if (!locked) { OptionFolder.Option("Places").Value = Places.ToString(); } if (!locked || Places) { OptionFolder.Option("Free").Value = Free.ToString(); OptionFolder.Option("Insiders").Value = Insiders.ToString(); } if (!locked || !Places) { OptionFolder.Option("Guests").Value = Guests.ToString(); } SaveID(); OptionFolder.Save(); }
private void OnReloadPlacesEvent(object payload) { LoadPlaces(() => { Listening.Place = Places.LastOrDefault(); }); }
private async void CheckPlaces() { if (mCacheService.CurrentLat == 0 && mCacheService.CurrentLng == 0) { if (View != null) { View.StartGetLocation(); } //do get the location in view, then please call this command again, it should query the 'places' } else { Mvx.Resolve <IMvxMessenger>().Publish(new ProgressMessage(this, true)); var result = await mApiService.CheckPlaces(string.Format("{0} {1}", StrNumber, Street), mCacheService.CurrentLat, mCacheService.CurrentLng); Places.Clear(); if (result != null && result.Response != null && result.Response.View.Count > 0) { Places = new ObservableCollection <HereMapView>(result.Response.View); } else { Mvx.Resolve <IMvxMessenger>().Publish(new ToastMessage(this, "No places found!")); } Mvx.Resolve <IMvxMessenger>().Publish(new ProgressMessage(this, false)); } }
public ActionResult Place(Guid ID, string content) { DataManager db = new DataManager(); Places place = db.GetItemByID(ID); return(View(place)); }
public async static Task <Places> GetPlaceById(string id) { var placesList = new List <Places>(); Places place = new Places(); if (!await Initialize()) { return(place); } var itemQuery = docClient.CreateDocumentQuery <Places>( UriFactory.CreateDocumentCollectionUri(databaseName, collectionName), new FeedOptions { MaxItemCount = -1, EnableCrossPartitionQuery = true }) .Where(places => places.Id == id) .AsDocumentQuery(); while (itemQuery.HasMoreResults) { var queryResult = await itemQuery.ExecuteNextAsync <Places>(); placesList.AddRange(queryResult); place = placesList[0]; } return(place); }
public List <PlacesRatingDomain> GetPlacesRatingSelectByplaceId(int placeId) { List <PlacesRatingDomain> Places = null; DataProvider.ExecuteCmd(GetConnection, "dbo.PlacesRatings_SelectByPlacesId" , inputParamMapper : delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@PlaceId", placeId); } , map : delegate(IDataReader reader, short set) { PlacesRatingDomain Place = new PlacesRatingDomain(); int startingIndex = 0; Place.Id = reader.GetSafeInt32(startingIndex++); Place.Created = reader.GetSafeDateTime(startingIndex++); Place.PlaceId = reader.GetSafeInt32(startingIndex++); Place.RatingType = reader.GetSafeEnum <RatingType>(startingIndex++); Place.Rating = reader.GetSafeDecimal(startingIndex++); Place.UserId = reader.GetSafeString(startingIndex++); Place.GroupId = reader.GetSafeInt32(startingIndex++); Place.AspectId = reader.GetSafeInt32(startingIndex++); if (Places == null) { Places = new List <PlacesRatingDomain>(); } Places.Add(Place); } ); return(Places); }
/// <summary> /// Creates a new <see cref="Place"/> and adds it to the net. /// </summary> /// <param name="name">The Name of the new <see cref="Place"/>.</param> /// <param name="tokenNumber">The amount of tokens lying on the new <see cref="Place"/>.</param> /// <returns>Returns the new place for future reference.</returns> public Place AddPlace(String name = "", int tokenNumber = 0) { Place newPlace = new Place(name, tokenNumber); Places.Add(newPlace); return(newPlace); }
void AddPlace(Place place) { MinLatitude = Math.Min(MinLatitude, place.location.lat); MinLongitude = Math.Min(MinLongitude, place.location.lon); MaxLatitude = Math.Max(MaxLatitude, place.location.lat); MaxLongitude = Math.Max(MaxLongitude, place.location.lon); if (place.title == null) { // Set the text between the <a> tags of urlhtml as the title of place if it is missing HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(place.urlhtml); place.title = doc.DocumentNode.SelectNodes("//a[@href]")[0].InnerText; } if (Places.Add(place)) { string placeName = place.title; if (!placesByName.ContainsKey(placeName)) { placesByName.Add(placeName, new List <Place>()); } placesByName[placeName].Add(place); if (tilesGenerated) { if (tiling == Tiling.City) { UpdatePlacesByCity(place); } else if (tiling == Tiling.Coordinates) { UpdatePlacesByArea(place); } } } }
/// <summary> /// Converts the net more or less reliable to a string which can be read as a *.dot-File by Graphviz (http://www.graphviz.org/) /// </summary> /// <returns>Returns said string, which you have to put into a file.</returns> public String ConvertToDot() { StringBuilder content = new StringBuilder(); content.Append("digraph TC {\n"); content.Append("node[shape=circle];\nrankdir=LR\n"); // draw all places with their respective labels and amount of tokens (p0 [label="A (1)"]) for (int index = 0; index <= Places.Count() - 1; index++) { content.Append("p" + index + " [label=\"" + Places[index].Name + " (" + Places[index].Token + ")\"]\n"); } content.Append("node[shape=rect];\n"); // draw all transitions with their respective labels (t0 [label="AtoB"]) for (int index = 0; index <= Transitions.Count() - 1; index++) { content.Append("t" + index + " [label=\"" + Transitions[index].Name + "\"]\n"); // and for each transition draw the incoming (p0 -> t0)... foreach (Place incomingPlace in Transitions[index].IncomingPlaces) { content.Append("p" + Places.IndexOf(incomingPlace) + " -> " + "t" + index + "\n"); } // ... and outgoing (t0 -> p1) connections foreach (Place outgoingPlace in Transitions[index].OutgoingPlaces) { content.Append("t" + index + " -> " + "p" + Places.IndexOf(outgoingPlace) + "\n"); } } content.Append("}"); return(content.ToString()); }
public void Equals_ReturnsTrueIfIDsAreTheSame_Place() { Places firstPlace = new Places(1, "Starbucks", "123 Fake St.", "Coffee Shop", "8", "8", "97202"); Places secondPlace = new Places(2, "Starbucks", "123 Fake St.", "Coffee Shop", "6", "7", "97219"); Assert.AreEqual(firstPlace, secondPlace); }
private void PlacePickedCallBack(Place place, NSError error) { if (place != null) { var name = place.Name; var placeId = place.PlaceID; var coordinate = place.Coordinate; Coordinates coordinates = new Coordinates(coordinate.Latitude, coordinate.Longitude); var phone = place.PhoneNumber; var address = place.FormattedAddress; var attribution = place.Attributions?.ToString(); var weburi = place.Website?.ToString(); var priceLevel = (long)place.PriceLevel; var rating = place.Rating; var swlatitude = place.Viewport?.SouthWest.Latitude; var swlongitude = place.Viewport?.SouthWest.Longitude; var nelatitude = place.Viewport?.NorthEast.Latitude; var nelongitude = place.Viewport?.NorthEast.Longitude; Abstractions.CoordinateBounds bounds = null; if (swlatitude != null && swlongitude != null && nelatitude != null && nelongitude != null) { bounds = new Abstractions.CoordinateBounds(new Coordinates(swlatitude.Value, swlongitude.Value), new Coordinates(nelatitude.Value, nelongitude.Value)); } Places places = new Places(name, placeId, coordinates, phone, address, attribution, weburi, Convert.ToInt32(priceLevel), rating, bounds); OnPlaceSelected(new PlacePickedEventArgs(currentRequest.Value, false, places)); } else if (error != null) { OnPlaceSelected(new PlacePickedEventArgs(currentRequest.Value, new Exception(error.LocalizedFailureReason))); } else { OnPlaceSelected(new PlacePickedEventArgs(currentRequest.Value, true)); } }
public ListeningEditViewModel(IUnityContainer container, IEventAggregator eventAggregator, IDataService dataService) : base(container, eventAggregator) { this.dataService = dataService; SubscribeEvents(); SearchAlbumCommand = new DelegateCommand <object>(OnSearchAlbumCommand); CreatePlaceCommand = new DelegateCommand <object>(OnCreatePlaceCommand); CreateMoodCommand = new DelegateCommand <object>(OnCreateMoodCommand); LoadDictionaries(() => { if (Listening.IsNew) { bool originalValue = Listening.NeedValidate; Listening.NeedValidate = false; // force reset to avoid initial validation errors Listening.Mood = Moods.FirstOrDefault(); Listening.Place = Places.FirstOrDefault(); // restore to original value Listening.NeedValidate = originalValue; } }); }
public void GetAll_ReturnsAllInstancesOfPlaces_PlacesList() { Places newPlace = new Places("test", "test", "test"); List <Places> newList = Places.GetAll(); Assert.AreEqual(newList, Places.GetAll()); }
private void PopulatePlaces() { if (_selectedCategory == Categories.Bars.ToString() || _selectedCategory == Categories.Hotels.ToString() || _selectedCategory == Categories.Museums.ToString() || _selectedCategory == Categories.Restaurants.ToString()) { if (_selectedCategory == Categories.Hotels.ToString()) { _xmlElementOfInterrest = "quality"; } if (_selectedCategory == Categories.Museums.ToString()) { _xmlElementOfInterrest = "subtitle"; } } try { foreach (XElement place in xml) { string name = place.Attribute("name").Value; string subtitle = place.Element(_xmlElementOfInterrest).Value; string imagePath = place.Element("imageURL").Value; Places.Add(new GenericModel(name, subtitle, _selectedCategory, imagePath)); } } catch (Exception) { } }
private async void FindPlacesButton_Click(object sender, RoutedEventArgs e) { var db = new Places(ConnectionString); var data = await db.SearchAsync(QueryTextBox.Text); PlacesListView.ItemsSource = data; }
public ActionResult AddNewPlace() { Places newPlace = new Places(Request.Form["new-location"], Request.Form["new-dates"], Request.Form["new-picture"]); List <Places> allPlaces = Places.GetAll(); return(View("List", allPlaces)); }
public CreatePetriNet WithPlaces(params string[] placeNames) { Contract.Requires(placeNames.Count() != 0); Contract.Requires(placeNames.All(s1 => !string.IsNullOrWhiteSpace(s1))); Contract.Requires(placeNames.All(s1 => s1.All(Char.IsLetterOrDigit))); if (Places == null) { Places = new Dictionary <int, string>(); } var tmp = placeNames.Select((s, i) => Tuple.Create(i, s)).ToDictionary(tuple => tuple.Item1, tuple1 => tuple1.Item2); int count = (Places.Count > 0? Places.Keys.Max():-1) + 1; foreach (var item in tmp) { if (!Places.ContainsValue(item.Value)) { Places[count] = item.Value; count++; } } return(this); }
public TasSayEventArgs(Origins origin, Places place, string channel, string username, string text, bool isEmote) { Origin = origin; Place = place; UserName = username; Text = text; IsEmote = isEmote; Channel = channel; }
public void Yahoo_GeoPlanet_Places_ShouldBePublic() { var it = new Places { Items = new ReadOnlyCollection<Place>(new List<Place>()), }; it.ShouldNotBeNull(); it.Items.ShouldNotBeNull(); }
public TasSayEventArgs(Origins origin, Places place, string channel, string username, string text, bool isEmote) { this.origin = origin; this.place = place; this.userName = username; this.text = text; this.isEmote = isEmote; this.channel = channel; }
public void ResetStats() { speed = .015f; isTurboEnabled = false; isMoving = false; isLaggy = false; earnedMoney = 0; currentPlace = Places.CENTER; turboTime = 0; discounts = 0; }
public void Yahoo_GeoPlanet_Places_ShouldImplementIEnumerableOfPlaces() { var it = new Places { Items = new ReadOnlyCollection<Place>(new List<Place>()), }; it.ShouldNotBeNull(); it.ShouldImplement<IEnumerable<Place>>(); it.GetEnumerator().ShouldNotBeNull(); ((IEnumerable) it).GetEnumerator().ShouldNotBeNull(); }
public ActionResult Create(PlaceCreator model, HttpPostedFileBase[] files) { int res = 0; if (ModelState.IsValid) { if (files.Count() > 5) { return Create("Не можна додавати більше 5 фото"); } using (var db = new RazomContext()) { Places p = new Places() { CityID = model.SelectedCity, Name = model.Place.Name, PlaceTypeID = model.SelectedPlaceType, Address = model.Place.Address, }; db.Places.Add(p); db.SaveChanges(); res = p.PlaceID; foreach (var file in files) { byte[] image = new byte[file.ContentLength]; using (BinaryReader r = new BinaryReader(file.InputStream)) { image = r.ReadBytes(file.ContentLength); } db.Database.ExecuteSqlCommand("INSERT INTO PhotosPlace(PlaceID,FileFoto) Values({0},{1})", p.PlaceID, image); } } return RedirectToAction("Show", "Place", new { id = res }); } return Create("Не введена назва або адреса"); }
double averageBatUsedByDay(Places p) { double d = 0; List<double> bl = batUsedByDay(p); if (bl.Count > 0) { for (int i = 0; i < bl.Count; i++ ) { d += bl[i]; } } return d/Math.Max(1,bl.Count-1); }
List<double> batUsedByDay(Places p) { List<double> bl = new List<double>(); List<Locations> l = Locations.ToList(); int day = 0; double bat1 = 0; double bat2 = 0; DateTime date = DateTime.Now; foreach (Locations m in l) { //System.Diagnostics.Debug.WriteLine("batttt00"); if(m.LocationsPlace==(int)p){ //System.Diagnostics.Debug.WriteLine("batttt0"); //if (!m.LocationsTime.Day.Equals(date.Day)) //{ if (m.LocationsTime.Day.Equals(day) == false) { //System.Diagnostics.Debug.WriteLine("batttt" ); bl.Add(bat1 - bat2); day = m.LocationsTime.Day; bat1 = m.LocationsBatteryLevel; } else { //double d = (bl.Count != 0) ? bl[bl.Count - 1] : -1; //if (d >0) //{ //System.Diagnostics.Debug.WriteLine("batttt2" ); bat2 = m.LocationsBatteryLevel; //} } //} } } bl.Add(bat1 - bat2); return bl; }
public void GoToPlace(Places place) { switch (place) { case Places.SaintPetersburg_VO: Yaw = 0.52932849788406378; Pitch = -1.0458657020378879; break; case Places.Vladivostok: Yaw = DMathUtil.DegreesToRadians(131.881642); Pitch = -DMathUtil.DegreesToRadians(43.111248); break; } }
int getAverageBatteryUsage(Places place) { int average = 0; int cpt = 0; foreach (BatteryUsageDB batteryUsagesValue in BatteryUsage) { cpt++; average += batteryUsagesValue.BatteryUsageValue; //System.Diagnostics.Debug.WriteLine("DEBUG batteryUsageValue loop value" + batteryUsagesValue.BatteryUsageValue); //System.Diagnostics.Debug.WriteLine("DEBUG batteryUsageValue loop average" + average); } if (cpt == 0) { return 0; } return (int)(average/ cpt); }
private void Button_Click_2(object sender, RoutedEventArgs e) { placetoshow = Places.HOME; currentPlace = Places.HOME; place.Text = "home"; //List<double> bl = batUsedByDay(Places.HOME); //double d = (bl.Count != 0) ? bl[bl.Count-1] : -1; double d = averageBatUsedByDay(Places.HOME); String s =""+d; batteryUsed.Text = s; if(d>60){ MessageBox.Show("You shell need battery charge to go home, last time you used "+d+"% battery", "Attention", MessageBoxButton.OKCancel); } //MessageBox.Show("Hello Word"); }
void symulateplaces(double lat, double l, Places place, DateTime date,int dropbat,int col) { double[] d = new double[] {lat, l }; double[][] rans = Place_symylator.randomPlace(d, 0.0005); int bat = 100; for (int i = 0; i < rans.Length; i++) { //System.Diagnostics.Debug.WriteLine("DEBUG remaining battery " + batteryLevelWhenEnteringCurrentPlace); insertNewLocationsValue(date, d[0], d[1], bat, place); insertNewBatteryUsageValue(place, batteryLevelWhenEnteringCurrentPlace); //Display the average of all the values in BatteryUsageTable for this newPlace getAverageBatteryUsage(place); date.AddMinutes(30); bat -= dropbat; ShowMyLocationOnTheMap(rans[i][0], rans[i][1], tabColor[col]); } }
/* Leaving the current place. This suppose that we previously entered a place. It's now time to check the battery level, */ void leavingCurrentPlace() { //How much did we used the battery at that place ? var myBattery = Battery.GetDefault(); //By doing this we also suppose that the user didn't charge his phone (otherwise the value will be negative) //int batteryUsage = this.batteryLevelWhenEnteringCurrentPlace - myBattery.RemainingChargePercent; //Here we have to Save the data usage for currentPlace (batteryUsage) insertNewBatteryUsageValue(currentPlace, myBattery.RemainingChargePercent); this.currentPlace = Places.UNKNOWN; }
void insertNewLocationsValue(DateTime date, Double longitude, Double latitude, int battery_level, Places place) { // Create a new item based on the text box. Locations newLocation = new Locations { LocationsTime = date, LocationsLongitude = longitude, LocationsLatitude = latitude , LocationsBatteryLevel = battery_level , LocationsPlace = (int)place}; // Add anew item to the observable collection. Locations.Add(newLocation); //System.Diagnostics.Debug.WriteLine("DEBUG locations size" + Locations.Count); // Add a to-do item to the local database. locationsBaterryDB.locations.InsertOnSubmit(newLocation); //foreach (Locations m in getAllLocation()) // System.Diagnostics.Debug.WriteLine("locations id : " + m.LocationsTime); }
void insertNewBatteryUsageValue(Places place, int batteryUsageValue) { // Create a new item based on the text box. BatteryUsageDB newbatteryUsage = new BatteryUsageDB { Place = (int)place , BatteryUsageValue = batteryUsageValue}; // Add anew item to the observable collection. BatteryUsage.Add(newbatteryUsage); System.Diagnostics.Debug.WriteLine("DEBUG batteryusage size" + BatteryUsage.Count); // Add a to-do item to the local database. locationsBaterryDB.batteryUsage.InsertOnSubmit(newbatteryUsage); }
private void button_openPlacesWindow_Click(object sender, RoutedEventArgs e) { NymphAppNetTester.Places window = new Places(textboxAccessToken.Text); window.Show(); }
private void Button_Click_1(object sender, RoutedEventArgs e) { placetoshow = Places.SCHOOL; currentPlace = Places.SCHOOL; place.Text = "school"; double d = averageBatUsedByDay(Places.SCHOOL); String s = "" + d; batteryUsed.Text = s; if (d > 60) { MessageBox.Show("You shell need battery charge to go to school, last time you used " + d + "% battery", "Attention", MessageBoxButton.OKCancel); } }
public void GoToPlace(Places place) { switch (place) { case Places.VasilIsland: { Transform = Matrix.Scaling(2695866.0f/1280.0f); Transform = Transform*Matrix.Translation(-1573813.0f, -783398.6f, 0.0f); break; } } }
/* Entering in a new place = check if enough battery compared to the former battery usage data and start recording the battery usage to improve the datas. */ void enteringAPlace(Places newPlace) { this.currentPlace = newPlace; //current battery level var myBattery = Battery.GetDefault(); this.batteryLevelWhenEnteringCurrentPlace = myBattery.RemainingChargePercent; System.Diagnostics.Debug.WriteLine("DEBUG remaining battery " + batteryLevelWhenEnteringCurrentPlace); DateTime date = DateTime.Now; insertNewLocationsValue(date, myCurrentLongitude, myCurrentLatitude, batteryLevelWhenEnteringCurrentPlace, newPlace); insertNewBatteryUsageValue(newPlace, batteryLevelWhenEnteringCurrentPlace); //Display the average of all the values in BatteryUsageTable for this newPlace getAverageBatteryUsage(newPlace); //start recording the positions and save it with the Place name //launch a timeout which call insertNewLocationsValue every minute }