public async Task BenchAsync(LocationBase destination, BenchOption option, CancellationToken ct) { option.OutputType = "json"; var args = $"bench {destination} {option} --cancel-from-stdin"; await this.StartAZCopyAsync(args, ct); }
public async Task CopyAsync(LocationBase src, LocationBase dst, CopyOption option, CancellationToken ct = default) { option.OutputType = "json"; var args = $"copy {src} {dst} {option} --cancel-from-stdin"; await this.StartAZCopyAsync(args, ct); }
public async Task ListAsync(LocationBase location, ListOption option, CancellationToken ct) { option.OutputType = "json"; var args = $"list {location} {option} --cancel-from-stdin"; await this.StartAZCopyAsync(args, ct); }
public async Task MakeAsync(LocationBase dst, MakeOption option, CancellationToken ct) { option.OutputType = "json"; var args = $"make {dst} {option} --cancel-from-stdin"; await this.StartAZCopyAsync(args, ct); }
protected override void CommonControl_BindingComplete(object sender, BindingCompleteEventArgs e) { base.CommonControl_BindingComplete(sender, e); if (this.EditableMode) { if (sender.Equals(this.bindingForecastLocationID) && this.combexForecastLocationID.SelectedItem != null) { LocationBase locationBase = (LocationBase)this.combexForecastLocationID.SelectedItem; this.forecastViewModel.ForecastLocationName = locationBase.Name; } } if (sender.Equals(this.bindingEntryDate)) { if (this.forecastDate != this.forecastViewModel.EntryDate) { this.forecastDate = this.forecastViewModel.EntryDate; this.Quantity.HeaderText = "Forecast." + ((DateTime)this.forecastViewModel.EntryDate).ToString("MMM-yy"); this.QuantityM1.HeaderText = "Forecast." + ((DateTime)this.forecastViewModel.EntryDate).AddMonths(1).ToString("MMM-yy"); this.QuantityM2.HeaderText = "Forecast." + ((DateTime)this.forecastViewModel.EntryDate).AddMonths(2).ToString("MMM-yy"); this.QuantityM3.HeaderText = "Forecast." + ((DateTime)this.forecastViewModel.EntryDate).AddMonths(3).ToString("MMM-yy"); this.LineVolume.HeaderText = this.Quantity.HeaderText; this.LineVolumeM1.HeaderText = this.QuantityM1.HeaderText; this.LineVolumeM2.HeaderText = this.QuantityM2.HeaderText; this.LineVolumeM3.HeaderText = this.QuantityM3.HeaderText; StackedHeaderDecorator stackedHeaderDecorator = new StackedHeaderDecorator(this.gridexViewDetails); } } }
public async Task RemoveAsync(LocationBase dst, RemoveOption option, CancellationToken ct = default) { // Lcations must be in quotes. It could have spaces in the name and the CLI would interpret as separate parameters. option.OutputType = "json"; var args = $"rm \"{dst}\" {option} --cancel-from-stdin"; await this.StartAZCopyAsync(args, ct); }
public void DeleteLocation(LocationBase location) { Requires.NotNull(location); Requires.PropertyNotNegative(location, "LocationId"); using (var context = DataContext.Instance()) { var rep = context.GetRepository <LocationBase>(); rep.Delete(location); } }
public IHttpActionResult getFreeDrivers(int id) { try { lock (DB) { RideBase ride = DB.RideDb.ToList().Find(x => x.ID == id); List <Driver> drivers = new List <Driver>(); DB.DriverDb.ToList().ForEach(x => { CarBase car = DB.CarDb.ToList().Find(y => y.TaxiCarID == x.CarID); if (ride.CarType == car.CarType || ride.CarType == CarRole.Not_Specified) { if (!DB.RideDb.ToList().Exists(z => z.Status == RideStatus.Accepted && z.TaxiRiderID == id)) { drivers.Add(x); } } }); LocationBase location = DB.LocationDb.ToList().Find(x => x.ID == ride.Location.ID); List <Tuple <double, Driver> > freeDrivers = new List <Tuple <double, Driver> >(); drivers.ForEach(x => { x.Location = DB.LocationDb.ToList().Find(y => y.ID == x.Location.ID); double lentgh = Math.Abs (Math.Sqrt(Math.Pow((location.XCoordinate - x.Location.XCoordinate), 2) + Math.Pow((location.YCoordinate - x.Location.YCoordinate), 2))); freeDrivers.Add(new Tuple <double, Driver>(lentgh, x)); }); freeDrivers = freeDrivers.OrderByDescending(x => x.Item1).ToList(); int driverCount = freeDrivers.Count; drivers = new List <Driver>(); for (int i = 0; i < 5; i++) { if (driverCount == 0) { break; } drivers.Add(freeDrivers[i].Item2); driverCount--; } return(Ok(drivers)); } } catch { return(NotFound()); } }
public override void RenameVariable(string oldName, string newName) { foreach (InstructionsSet instruction in InputInstructions.Concat(OutputInstructions)) { if (instruction.Instructions.ContainsKey(oldName)) { LocationBase loc = instruction.Instructions[oldName]; instruction.Instructions[newName] = loc; instruction.Instructions.Remove(oldName); } } }
private void CommonControl_BindingComplete(object sender, BindingCompleteEventArgs e) { if (e.BindingCompleteState == BindingCompleteState.Exception) { ExceptionHandlers.ShowExceptionMessageBox(this, e.ErrorText); e.Cancel = true; } if (sender.Equals(this.bindingForecastLocationID) && this.combexForecastLocationID.SelectedItem != null) { LocationBase locationBase = (LocationBase)this.combexForecastLocationID.SelectedItem; this.forecastViewModel.ForecastLocationName = locationBase.Name; } }
public void UpdateLocation(LocationBase location, int userId) { Requires.NotNull(location); Requires.PropertyNotNegative(location, "LocationId"); location.LastModifiedByUserID = userId; location.LastModifiedOnDate = DateTime.Now; using (var context = DataContext.Instance()) { var rep = context.GetRepository <LocationBase>(); rep.Update(location); } }
public int AddLocation(ref LocationBase location, int userId) { Requires.NotNull(location); location.CreatedByUserID = userId; location.CreatedOnDate = DateTime.Now; location.LastModifiedByUserID = userId; location.LastModifiedOnDate = DateTime.Now; using (var context = DataContext.Instance()) { var rep = context.GetRepository <LocationBase>(); rep.Insert(location); } return(location.LocationId); }
public IHttpActionResult SetLocation(LocationBase data) { lock (DB) { DB.DriverDb.ToList().Find(x => x.Username == AuthUser.Username).Location = new LocationBase() { Place = data.Place, StreetName = data.StreetName, XCoordinate = data.XCoordinate, YCoordinate = data.YCoordinate, ZipCode = data.ZipCode }; DB.SaveChanges(); return(Ok()); } }
public ActionResult Edit(LocationBase location) { var previousRecord = _repository.GetLocation(location.ConferenceId, location.LocationId); if (previousRecord == null) { _repository.AddLocation(ref location, User.UserID); } else { location.CreatedOnDate = previousRecord.CreatedOnDate; location.CreatedByUserID = previousRecord.CreatedByUserID; _repository.UpdateLocation(location, User.UserID); } return(ReturnRoute(location.ConferenceId, View("View", _repository.GetLocation(location.ConferenceId, location.LocationId)))); }
public IHttpActionResult AddDestination(LocationBase data) { lock (DB) { int taxiDriverID = DB.DriverDb.ToList().Find(x => x.Username == AuthUser.Username).ID; RideBase currentRide = DB.RideDb.ToList().Find(x => x.TaxiRiderID == taxiDriverID && x.ID == currentRideID); LocationBase l = DB.LocationDb.ToList().Find(x => x.ID == currentRide.Destination.ID); l.Place = data.Place; l.StreetName = data.StreetName; l.ZipCode = data.ZipCode; l.XCoordinate = data.XCoordinate; l.YCoordinate = data.YCoordinate; DB.SaveChanges(); return(Ok()); } }
public LocationUnlockEncounter(Func <DisplayBase> targetDisplay, Func <LocationBase> constructor) { if (constructor is null) { throw new ArgumentNullException(nameof(constructor)); } LocationBase result = constructor(); if (result is null) { throw new ArgumentException("constructor cannot return a null value"); } GetCurrentDisplay = targetDisplay ?? throw new ArgumentNullException(nameof(targetDisplay)); locationType = result.GetType(); unlockTrigger = result.unlockLevel; ran = false; }
/// <summary> /// 플레이어의 맵 이동 /// </summary> public void ChangeLocation(LocationCode nextLocation) { LocationBase nextLocationScript = LocationManager.inst.locationScript[(int)nextLocation]; LocationManager.inst.OffLocationUI(currentLocation); currentLocation = nextLocation; LocationManager.inst.CurrentLocationMapping(currentLocation); LocationManager.inst.OnLocationUI(currentLocation); Debug.Log("Change Location: " + currentLocation); // 처음 방문 시 location의 isActive(방문 유무) true if (nextLocationScript.GetActive() == false) { nextLocationScript.SetActive(); } }
private void button1_Click(object sender, EventArgs e) { PlaceSuggestionService pSSv = new PlaceSuggestionService(); JObject jObj = pSSv.Suggestion("WeWork", "上海"); PlaceSuggestionWrp rslt = jObj.ToObject <PlaceSuggestionWrp>(); LocationLL loc = rslt.result[1].location; double diffLat = LocationBase.Get1KMLat(); double diffLng = LocationBase.Get1KMLng(loc.lat); LocationTravelData data = new LocationTravelData(); TravelFullData fullData = new TravelFullData(); StringBuilder sb = new StringBuilder(); { LocationLL eastOceanLoc = new LocationLL(121.487487, 31.236564); LocationLL yunnanLoc = new LocationLL(121.487264, 31.233405); loc = yunnanLoc; } int range = 10; double gap = 0.5; for (int i = -range; i < range; i++) { for (int j = -range; j < range; j++) { if (i == 0 && j == 0) { continue; } try { LocationLL loc2 = loc.Clone <LocationLL>(); loc2.lat += diffLat * i * gap; loc2.lng += diffLng * j * gap; DirectionV1Wrp dirV1 = DirectionV1Wrp.DirectionByTransit(loc, loc2, "上海"); LocationTravelData.Data dataItem = new LocationTravelData.Data(); dataItem.Loc = loc2; dataItem.Distance = dirV1.result.routes[0].scheme[0].distance; dataItem.Duration = dirV1.result.routes[0].scheme[0].duration; data.DataList.Add(dataItem); GeoDecodingServiceWrp deCdWrp = GeoDecodingServiceWrp.GeoDecoding(loc2.Clone <LocationXY>()); sb.AppendLine(deCdWrp.result.addressComponent.street + deCdWrp.result.addressComponent.street_number + "; " + dataItem.Distance.ToString() + "; " + dataItem.Duration.ToString() + "//r"); TravelFullData.Data dataItemB = new TravelFullData.Data(); dataItemB.Target = loc2; dataItemB.TargetAddress = deCdWrp.result.addressComponent; dataItemB.OneTravelScheme = dirV1.result.routes[0].scheme[0]; fullData.DataList.Add(dataItemB); } catch { } } rTxBx.Text = sb.ToString(); } JsonSerializer serializer = new JsonSerializer(); serializer.NullValueHandling = NullValueHandling.Ignore; using (StreamWriter sw0 = new StreamWriter(@"C:\dev\baidu\json0.txt")) using (StreamWriter sw1 = new StreamWriter(@"C:\dev\baidu\json1.txt")) using (JsonWriter writer0 = new JsonTextWriter(sw0)) using (JsonWriter writer1 = new JsonTextWriter(sw1)) { serializer.Serialize(writer0, fullData); serializer.Serialize(writer1, data); } }
void FakeTradeBetweenAdjacentLocations() { #region FOOD_TRADE if (Resources[(int)RESOURCES.FOOD].Stockpile < Resources[(int)RESOURCES.FOOD].Demand * Resources[(int)RESOURCES.FOOD].PreferredRatio) { //find cheapest food location float cheapest = float.PositiveInfinity; LocationBase bestLocation = null; LocationBase secondBestLocation = null; foreach (LocationBase location in AdjacentLocations) { float price = location.GetPrice(RESOURCES.FOOD); if (price < cheapest) { cheapest = price; secondBestLocation = bestLocation; bestLocation = location; } } if (bestLocation == null) { return; } //buy food to match demand and preference float currentNeed = Resources[(int)RESOURCES.FOOD].Demand * Resources[(int)RESOURCES.FOOD].PreferredRatio - CurrentFood; float requiredValue = currentNeed * cheapest; if (requiredValue <= CurrentMoney * Resources[(int)RESOURCES.MONEY].Value) { //buy with money float offerMoney = requiredValue / Resources[(int)RESOURCES.MONEY].Value; float refund = 0; float returningQuantity = bestLocation.TradeResourceWithLocation(RESOURCES.FOOD, offerMoney, RESOURCES.MONEY, out refund); CurrentFood += returningQuantity; CurrentMoney -= offerMoney - refund; currentNeed -= returningQuantity; } else if (requiredValue <= CurrentWood * Resources[(int)RESOURCES.WOOD].Value) { //barter with wood float offerWood = requiredValue / Resources[(int)RESOURCES.WOOD].Value; float refund = 0; float returningQuantity = bestLocation.TradeResourceWithLocation(RESOURCES.FOOD, offerWood, RESOURCES.WOOD, out refund); CurrentFood += returningQuantity; CurrentWood -= offerWood - refund; currentNeed -= returningQuantity; } else { //buy with what money is available float refund = 0; float returningQuantity = bestLocation.TradeResourceWithLocation(RESOURCES.FOOD, CurrentMoney, RESOURCES.MONEY, out refund); CurrentFood += returningQuantity; CurrentMoney -= CurrentMoney - refund; currentNeed -= returningQuantity; } if (currentNeed > 0 && secondBestLocation != null) { requiredValue = currentNeed * secondBestLocation.GetPrice(RESOURCES.FOOD); if (requiredValue <= CurrentMoney * Resources[(int)RESOURCES.MONEY].Value) { //buy with money float offerMoney = requiredValue / Resources[(int)RESOURCES.MONEY].Value; float refund = 0; CurrentFood += secondBestLocation.TradeResourceWithLocation(RESOURCES.FOOD, offerMoney, RESOURCES.MONEY, out refund); CurrentMoney -= offerMoney - refund; } else if (requiredValue <= CurrentWood * Resources[(int)RESOURCES.WOOD].Value) { //barter with wood float offerWood = requiredValue / Resources[(int)RESOURCES.WOOD].Value; float refund = 0; CurrentFood += secondBestLocation.TradeResourceWithLocation(RESOURCES.FOOD, offerWood, RESOURCES.WOOD, out refund); CurrentWood -= offerWood - refund; } else { //buy with what money is available float refund = 0; CurrentFood += secondBestLocation.TradeResourceWithLocation(RESOURCES.FOOD, CurrentMoney, RESOURCES.MONEY, out refund); CurrentMoney -= CurrentMoney - refund; } } } //else if (Resources[(int)RESOURCES.FOOD].Stockpile > Resources[(int)RESOURCES.FOOD].Demand //* Resources[(int)RESOURCES.FOOD].PreferredRatio) { // //sell surplus food to highest adjacent // float highest = 0; // LocationBase bestLocation = null; // foreach (LocationBase location in AdjacentLocations) { // float price = location.GetPrice(RESOURCES.FOOD); // if (price > highest) { // highest = price; // bestLocation = location; // } // } // if (bestLocation == null) // return; // //sell surplus // float currentSurplus = CurrentFood - Resources[(int)RESOURCES.FOOD].Demand * Resources[(int)RESOURCES.FOOD].PreferredRatio; // if (CurrentWood * Resources[(int)RESOURCES.WOOD].Value < CurrentMoney * Resources[(int)RESOURCES.MONEY].Value) { // //barter for wood; // float refund = 0; // CurrentWood += bestLocation.TradeResourceWithLocation(RESOURCES.WOOD, currentSurplus, RESOURCES.FOOD, out refund); // CurrentFood -= currentSurplus - refund; // } // else { // //sell for money // float refund = 0; // CurrentMoney += bestLocation.TradeResourceWithLocation(RESOURCES.MONEY, currentSurplus, RESOURCES.FOOD, out refund); // CurrentFood -= currentSurplus - refund; // } //} #endregion #region WOOD_TRADE if (Resources[(int)RESOURCES.WOOD].Stockpile < Resources[(int)RESOURCES.WOOD].Demand * Resources[(int)RESOURCES.WOOD].PreferredRatio) { //find cheapest wood location float cheapest = float.PositiveInfinity; LocationBase bestLocation = null; LocationBase secondBestLocation = null; foreach (LocationBase location in AdjacentLocations) { float price = location.GetPrice(RESOURCES.WOOD); if (price < cheapest) { cheapest = price; secondBestLocation = bestLocation; bestLocation = location; } } if (bestLocation == null) { return; } //buy wood to match demand and preference float currentNeed = Resources[(int)RESOURCES.WOOD].Demand * Resources[(int)RESOURCES.WOOD].PreferredRatio - CurrentWood; float requiredValue = currentNeed * cheapest; if (requiredValue <= CurrentMoney * Resources[(int)RESOURCES.MONEY].Value) { //buy with money float offerMoney = requiredValue / Resources[(int)RESOURCES.MONEY].Value; float refund = 0; float returningQuantity = bestLocation.TradeResourceWithLocation(RESOURCES.WOOD, offerMoney, RESOURCES.MONEY, out refund); CurrentWood += returningQuantity; CurrentMoney -= offerMoney - refund; currentNeed -= returningQuantity; } else if (requiredValue <= CurrentFood * Resources[(int)RESOURCES.FOOD].Value) { //barter with food float offerFood = requiredValue / Resources[(int)RESOURCES.FOOD].Value; float refund = 0; float returningQuantity = bestLocation.TradeResourceWithLocation(RESOURCES.WOOD, offerFood, RESOURCES.FOOD, out refund); CurrentWood += returningQuantity; CurrentFood -= offerFood - refund; currentNeed -= returningQuantity; } else { //buy with what money is available float refund = 0; float returningQuantity = bestLocation.TradeResourceWithLocation(RESOURCES.WOOD, CurrentMoney, RESOURCES.MONEY, out refund); CurrentWood += returningQuantity; CurrentMoney -= CurrentMoney - refund; currentNeed -= returningQuantity; } if (currentNeed > 0 && secondBestLocation != null) { requiredValue = currentNeed * secondBestLocation.GetPrice(RESOURCES.WOOD); if (requiredValue <= CurrentMoney * Resources[(int)RESOURCES.MONEY].Value) { //buy with money float offerMoney = requiredValue / Resources[(int)RESOURCES.MONEY].Value; float refund = 0; CurrentWood += secondBestLocation.TradeResourceWithLocation(RESOURCES.WOOD, offerMoney, RESOURCES.MONEY, out refund); CurrentMoney -= offerMoney - refund; } else if (requiredValue <= CurrentFood * Resources[(int)RESOURCES.FOOD].Value) { //barter with food float offerFood = requiredValue / Resources[(int)RESOURCES.FOOD].Value; float refund = 0; CurrentWood += secondBestLocation.TradeResourceWithLocation(RESOURCES.WOOD, offerFood, RESOURCES.FOOD, out refund); CurrentFood -= offerFood - refund; } else { //buy with what money is available float refund = 0; CurrentWood += secondBestLocation.TradeResourceWithLocation(RESOURCES.WOOD, CurrentMoney, RESOURCES.MONEY, out refund); CurrentMoney -= CurrentMoney - refund; } } } //else if (Resources[(int)RESOURCES.WOOD].Stockpile > Resources[(int)RESOURCES.WOOD].Demand //* Resources[(int)RESOURCES.WOOD].PreferredRatio) { // //sell surplus wood to highest adjacent // float highest = 0; // LocationBase bestLocation = null; // foreach (LocationBase location in AdjacentLocations) { // float price = location.GetPrice(RESOURCES.WOOD); // if (price > highest) { // highest = price; // bestLocation = location; // } // } // if (bestLocation == null) // return; // //sell surplus // float currentSurplus = CurrentWood - Resources[(int)RESOURCES.WOOD].Demand * Resources[(int)RESOURCES.WOOD].PreferredRatio; // if (CurrentFood * Resources[(int)RESOURCES.FOOD].Value < CurrentMoney * Resources[(int)RESOURCES.MONEY].Value) { // //barter for food; // float refund = 0; // CurrentFood += bestLocation.TradeResourceWithLocation(RESOURCES.FOOD, currentSurplus, RESOURCES.WOOD, out refund); // CurrentWood -= currentSurplus - refund; // } // else { // //sell for money // float refund = 0; // CurrentMoney += bestLocation.TradeResourceWithLocation(RESOURCES.MONEY, currentSurplus, RESOURCES.WOOD, out refund); // CurrentWood -= currentSurplus - refund; // } //} #endregion }
public IHttpActionResult AddLocation(LocationBase data) { CurrentLocation = data; return(Ok()); }