public void StationIsCreatedAtProperPosition() { var st = new Station( 0, 0, 2, 1 ); Assert.AreEqual( (uint) 2, st.StartPosition ); Assert.AreEqual( (uint) 3, st.EndPosition ); }
public void SetStations(Station[] InitialStationList) { this.InitialStationList = InitialStationList; FilterStations = InitialStationList.OrderByDescending(o => o.LastSeenDate).ToArray(); StationList.VirtualListSize = FilterStations.Length; }
public List<Station> GetSites(string locationText) { var path = string.Format( "sl/realtid/GetSite.json?stationSearch={0}&key=72c26d46c3efc6d5158d1dfc89b5f6fd", locationText); var response = this.ApiClient.GetAsync(path).Result; if (!response.IsSuccessStatusCode) { return new List<Station>(); } var result = response.Content.ReadAsStringAsync().Result; dynamic test = JsonConvert.DeserializeObject(result); var siteList = new List<Station>(); var siteTest = test.Hafas.Sites.Site; if (siteTest.GetType().ToString() == "Newtonsoft.Json.Linq.JObject") { var site = new Station { Name = siteTest.Name, Id = siteTest.Number }; siteList.Add(site); } else { foreach (var item in siteTest) { var site = new Station { Name = item.Name, Id = item.Number }; siteList.Add(site); } } return siteList; }
/// <summary> /// Create and remember a reference to an Instance. /// </summary> /// <param name="instance"></param> /// <param name="station">station to which this instance belongs</param> /// <returns>new instance reference</returns> public InstanceRef AddRef(Instance instance, Station station) { long id = NextId(); InstanceRef iRef = new InstanceRefImpl(id, instance, station); refs.Add(id, iRef); return iRef; }
public void TestHandoverEventActionCallHandover() { int dropped = 0; int createdhandover = 0; int createdend = 0; var data = new CallData( 1, 5, 20, 0 ); var tostation = new Station( 1, 0, 10, 10 ); var fromstation = new Station( 1, 0, 0, 10 ); fromstation.ClaimChannel( true ); var e = new HandoverEvent( fromstation, tostation, () => { dropped++; }, ( d, cd ) => { createdend++; }, ( d, cd ) => { createdhandover++; Assert.AreEqual( data, cd ); Assert.AreEqual( (uint) 15, d ); }, 5, data ); e.Action(); Assert.AreEqual( 0, dropped ); Assert.AreEqual( 0, createdend ); Assert.AreEqual( 1, createdhandover ); }
public void setUp() { station = new Station(); station.Input = Inputs.Ant_Two; station.VirtualChannel = 67; }
/// <summary> /// /// </summary> /// <param name="db"></param> /// <param name="s"></param> private static void CreateDeviceCollection(DB db, Station s) { DataTable tbl = db.GetDeviceDataTable ( s.ID ); foreach (DataRow row in tbl.Rows) { Device d = new Device(s); d.ID = Convert.ToInt32(row["DeviceID"]); d.Name = row["name"].ToString().Trim(); s.DeviceCollection.Add(d); //if (_request.IsReady()) if (_client.IsRequestReady()) { object state = new object[] { d.Station.Group.Name , d.Station.Name , d.Name }; //RequestResult r = _request.Request("", RequestNameEnum.GetDeviceID, state); RequestResult r = _client.ExecuteRequestDeviceID(state); if (r.ResultEnum == RequestResultEnum.OK) { int remoteDeviceID = (int)r.Result; d.RemoteID = remoteDeviceID; } } } }
/// <summary> /// Initializes a new instance of the <see cref="NPCCorporation"/> class. /// </summary> /// <param name="station">The station.</param> /// <exception cref="System.ArgumentNullException">station</exception> public NPCCorporation(Station station) { station.ThrowIfNull(nameof(station)); ID = station.CorporationID; Name = station.CorporationName; }
public void AddExistingStationTest() { Administration admin = new Administration(); Station station = new Station("station1"); admin.Add(station); Assert.AreEqual(station, admin.Add(station)); }
bool TryGrowHub(Station v, bool useHalfEdgesAsIdealR) { double oldR = v.Radius; double allowedRadius = CalculateAllowedHubRadius(v); Debug.Assert(allowedRadius > 0); if (v.Radius >= allowedRadius) return false; double idealR = useHalfEdgesAsIdealR ? CalculateIdealHubRadiusWithAdjacentEdges(metroGraphData, bundlingSettings, v) : v.cachedIdealRadius; Debug.Assert(idealR > 0); if (v.Radius >= idealR) return false; double step = 0.05; double delta = step * (idealR - v.Radius); if (delta < 1.0) delta = 1.0; double newR = Math.Min(v.Radius + delta, allowedRadius); if (newR <= v.Radius) return false; v.Radius = newR; return true; }
public Task AddStation(Station station) { var connection = _context.CreateConnection(); var findedStation=connection.GetAsync<Station>(station.Id); if (findedStation == null) return Task.CompletedTask; return connection.InsertAsync(station); }
public Line.Type getLineTypeTo(Station station) { if ((line() == null || station.getLine() != line())) return Line.Type.None; else return line().type; }
/// <summary> /// Create html file with information about timetable and save it /// </summary> /// <param name="Path">Where html file should be saved</param> /// <param name="station">Station</param> public void SaveTimetables(string Path, Station station) { FileStream fs = new FileStream(Path, FileMode.Create); XDocument document = new XDocument(); document.AddFirst(new XElement("html")); document.Root.Add(new XElement("head", new XElement("title", station.Name))); XElement body = new XElement("body"); XElement div = new XElement("div"); foreach (Timetable tt in station) { XElement inner = new XElement("div", new XAttribute("style", "width:800px;")); inner.Add(new XElement("div", tt.FirstStation + " - " + tt.LastStation, new XAttribute("style", "border:solid; float:left; width:400px; heigth:20px;"), new XAttribute("align", "center")), new XElement("div", tt.TimeOfArrival.ToString() + " - " + tt.TimeOfDeparture.ToString(), new XAttribute("style", "border:solid; float:left; width:150px; heigth:20px;"), new XAttribute("align", "center")), new XElement("div", tt.FreqType, new XAttribute("style", "border:solid; float:left; width:150px; heigth:20px;"), new XAttribute("align", "center")), new XElement("br")); div.Add(inner); } body.Add(div); document.Root.Add(body); document.Save(fs); fs.Close(); }
public List<Station> getStations(Inputs input) { List<Station> ret = new List<Station>(); RegistryManager registry = new RegistryManager(); byte[] value = registry.getStations(input); int segmentLength = 40; int stationEndpoint = segmentLength * registry.getStationCount(input); for (int i = 8; i < stationEndpoint; i += segmentLength) { ArraySegment<byte> segment = new ArraySegment<byte>(value, i, segmentLength); Station s = new Station(); s.Input = input; s.PhysicalChannel = BitConverter.ToInt16(segment.Array, segment.Offset + (int)StationBytePositions.PhysicalChannel); s.VirtualChannel = BitConverter.ToInt16(segment.Array, segment.Offset + (int)StationBytePositions.VirtualChannel); s.SubChannel = segment.Array[segment.Offset + (int)StationBytePositions.SubChannel]; // TODO: (KJM 02/21/06) Figure out how to treat 0xFF as -1 rather than 255. int minorChannel = segment.Array[segment.Offset + (int)StationBytePositions.MinorChannel]; if (255 == minorChannel) { minorChannel = -1; } s.MinorChannel = minorChannel; // TODO: (KJM 02/21/06) Figure out a way of actually reading in the name without dying on channels without names. //s.Name = System.Text.Encoding.ASCII.GetString(segment.Array, segment.Offset + 16, 5); ret.Add(s); } return ret; }
public GoForwardStage(float position, Station station, Platoon platoon) { _Station = station; this._Position = position; _Platoon = platoon; _Agent = new Standalong.Agent(); }
public void AddedStationCanBeFoundTest() { Administration admin = new Administration(); Station station = new Station("station1"); admin.Add(station); Station foundStation = admin.FindStation("station1"); Assert.AreEqual(foundStation, station); }
public void LastStationTest() { Station station = new Station("test"); Train lastTrain = new Train(1, 2); station.LastTrain = lastTrain; Assert.AreEqual(lastTrain, station.LastTrain); Assert.AreEqual(1, lastTrain.TrainUnit); }
public void NextStationTest() { Station station = new Station("test"); Train nextTrain = new Train(1, 2); station.NextTrain = nextTrain; Assert.AreEqual(nextTrain, station.NextTrain); Assert.AreEqual(1, nextTrain.TrainUnit); }
private static Station CreateStation2() { var station = new Station("Ytterby", "Yb"); station.Add(new StationExit("Vänster")); station.Add(new StationExit("Höger")); station.Add(new StationTrack("1")); station.Add(new StationTrack("2")); return station; }
private static Station CreateStation3() { var station = new Station("Stenungsund", "Snu"); station.Add(new StationExit("Vänster")); station.Add(new StationExit("Höger")); station.Add(new StationTrack("1")); station.Add(new StationTrack("2")); return station; }
public void StationNameLong() { string longStationName = "He was a boy. She was a girl. Could I be anymore obvious? All around the world statues crumble for me." + "Why did this happen to me. I tried so hard, and got so far.But in the end it didn't even matter. I'm blue daba dee daba da. " + "Never gonna give you up. Never gonna let you down. What is love. Baby dont hurt me. Dont hurt me. No more."; Station station = new Station(longStationName); Assert.AreEqual(longStationName, station.StationName); }
internal double GetMinimalDistanceToObstacles(Station node, Point nodePosition, double upperBound) { List<Tuple<Polyline, Point>> touchedObstacles = new List<Tuple<Polyline, Point>>(); double minimalDistance = upperBound; if (!IntersectCircleWithTree(obstacleTree, nodePosition, upperBound, obstaclesToIgnore(node), touchedObstacles, ref minimalDistance)) return 0; return minimalDistance; }
public void Render(Station from, Station to) { Vector3 fromPosition = from.transform.position; Vector3 toPosition = to.transform.position; Vector3 direction = toPosition - fromPosition; float headLength = 20f * GameMapSizeFactor.GetFactorForCurrentMapRelativeToFirstMap(); DrawArrow.ForGizmo(fromPosition, direction, headLength); }
internal static Station CreateStation1() { var station = new Station("Göteborg", "G"); station.Add(new StationExit("Vänster")); station.Add(new StationTrack("1")); station.Add(new StationTrack("2")); station.Add(new StationTrack("3")); station.Add(new StationTrack("4")); return station; }
public void StationHandlesEqualsNull() { var st = new Station( 1, 0, 0, 0 ); object o = null; Assert.IsFalse( st.Equals( null ) ); Assert.IsTrue( st.Equals( (object) st ) ); Assert.IsFalse( st.Equals( 33 ) ); Assert.IsFalse( st.Equals( o ) ); }
static internal void ShowHubs(MetroGraphData mgd, BundlingSettings bundlingSettings, Station highlightedNode) { HubDebugger hd = new HubDebugger(mgd, bundlingSettings); List<DebugCurve> debugCurves = hd.CreateDebugCurves(); debugCurves.Add(new DebugCurve(100,1, "magenta", CurveFactory.CreateCircle(3, highlightedNode.Position))); debugCurves.Add(new DebugCurve(100, 0.1, "green", highlightedNode.BoundaryCurve)); Console.WriteLine(highlightedNode.SerialNumber); LayoutAlgorithmSettings.ShowDebugCurvesEnumeration(debugCurves); }
public void StationHoldsHashCode() { var st = new Station( 1, 0, 0, 0 ); var st2 = new Station( 1, 0, 0, 0 ); Assert.AreNotSame( st2, st ); Assert.AreEqual( st.GetHashCode(), st2.GetHashCode() ); var st3 = new Station( 2, 0, 0, 0 ); Assert.AreNotEqual( st.GetHashCode(), st3.GetHashCode() ); }
private bool inList(Station station, Station[] stations) { foreach (Station s in stations) { if (station == s) { return true; } } return false; }
public void StationHandlesEquals() { var st = new Station( 0, 0, 2, 1 ); var st2 = new Station( 0, 0, 2, 1 ); var st3 = new Station( 0, 0, 2, 3 ); Assert.AreEqual( st, st2 ); Assert.AreNotEqual( st, st3 ); Assert.AreNotSame( st, st2 ); }
internal Set<Polyline> ObstaclesToIgnoreForBundle(Station node, Station adj) { if (node != null && adj != null) return obstaclesToIgnore(node) + obstaclesToIgnore(adj); if (node == null && adj == null) return new Set<Polyline>(); if (node != null) return obstaclesToIgnore(node); else return obstaclesToIgnore(adj); }
void OnTriggerEnter(Collider hitObject) { if (hitObject.gameObject.tag == "HitBox") { if (hitObject.transform.root.gameObject.tag == "Ship") { Ship hitShip = hitObject.transform.root.gameObject.GetComponent <Ship>(); if (GetShipManager().isEnemy(hitShip)) { float range = (new Vector2(transform.position.x - Origin.x, transform.position.z - Origin.z)).sqrMagnitude; float damage = GetDamage(range); //Add damage bonus damage += damage * attachedWeapon.GetDamageBonus(); attachedWeapon.RecordDamage(damage); hitShip.TakeDamage(attachedWeapon, transform.position, Origin, damage, GetShieldIgnore(), GetArmorIgnore(), GetArmorRatingIgnore()); Die(); } } else if (hitObject.transform.root.gameObject.tag == "Station") { Station hitStation = hitObject.transform.root.gameObject.GetComponent <Station>(); if (GetShipManager().isEnemy(hitStation)) { float range = (new Vector2(transform.position.x - Origin.x, transform.position.z - Origin.z)).sqrMagnitude; float damage = GetDamage(range); //Add damage bonus damage += damage * attachedWeapon.GetDamageBonus(); attachedWeapon.RecordDamage(damage); hitStation.TakeDamage(attachedWeapon, transform.position, Origin, damage, GetShieldIgnore(), GetArmorIgnore(), GetArmorRatingIgnore()); Die(); } } else if (hitObject.transform.root.gameObject.tag == "Fighter") { Fighter hitFighter = hitObject.transform.root.gameObject.GetComponent <Fighter>(); if (GetShipManager().isEnemy(hitFighter)) { float range = (new Vector2(transform.position.x - Origin.x, transform.position.z - Origin.z)).sqrMagnitude; float damage = GetDamage(range); //Add damage bonus damage += damage * attachedWeapon.GetDamageBonus(); attachedWeapon.RecordDamage(damage); hitFighter.CheckShieldHit(transform.position, Vector2.zero); hitFighter.TakeDamage(attachedWeapon, damage, GetShieldIgnore(), GetArmorIgnore(), GetArmorRatingIgnore()); Die(); } } } else if (PrimaryWeapon.PointDefense && hitObject.gameObject.tag == "PDTarget") { Projectile hitProjectile = hitObject.transform.root.gameObject.GetComponent <Projectile>(); if (GetShipManager().isEnemy(hitProjectile)) { float range = (new Vector2(transform.position.x - Origin.x, transform.position.z - Origin.z)).sqrMagnitude; float damage = GetDamage(range); //Add damage bonus damage += damage * attachedWeapon.GetDamageBonus(); attachedWeapon.RecordDamage(damage); hitProjectile.TakeDamage(PrimaryWeapon, damage); if (PrimaryWeapon.dieOnProjectileCollision) { Die(); } } } }
public StationViewModel(Station station) { this.model = station; }
static void Main(string[] args) { HistoryContainer history = new HistoryContainer(); HistorySorter sorter = new HistorySorter(); Billing billing = new Billing(); Station station = new Station(billing); Customer customer1 = new Customer("John", "Doe"); Contract contract1 = new Contract(customer1, TariffType.Basic, DateTime.Now); IPort port1 = new Port(); ITerminal terminal1 = new Terminal(contract1.Number, port1); Customer customer2 = new Customer("Dow", "Jones"); Contract contract2 = new Contract(customer2, TariffType.Comfort, DateTime.Now); IPort port2 = new Port(); ITerminal terminal2 = new Terminal(contract2.Number, port2); Customer customer3 = new Customer("Nas", "Daq"); Contract contract3 = new Contract(customer3, TariffType.Business, DateTime.Now); IPort port3 = new Port(); ITerminal terminal3 = new Terminal(contract3.Number, port3); billing.RegisterContract(contract1); billing.RegisterContract(contract2); billing.RegisterContract(contract3); station.AddUsersData(terminal1); station.AddUsersData(terminal2); station.AddUsersData(terminal3); terminal1.SetPortConnected(); terminal2.SetPortConnected(); terminal3.SetPortConnected(); terminal1.CallingTo(terminal2.phoneNumber); terminal2.EndCall(terminal2.phoneNumber, RespondState.Ending); Console.WriteLine(); terminal3.CallingTo(terminal1.phoneNumber); terminal1.EndCall(terminal1.phoneNumber, RespondState.Ending); Console.WriteLine(); terminal1.CallingTo(terminal3.phoneNumber); terminal3.EndCall(terminal1.phoneNumber, RespondState.Ending); Console.WriteLine(); terminal2.SetPortDisconnected(); terminal1.CallingTo(terminal2.phoneNumber); Console.WriteLine(); Console.WriteLine("Invoice for payment: {0}", billing.PayInvoice(contract1, DateTime.Now.Month)); Console.WriteLine("Current balance: {0}", customer1.GetBalance()); customer1.DecreaseBalance(billing.PayInvoice(contract1, DateTime.Now.Month)); Console.WriteLine("Monthly payment accepted."); Console.WriteLine("Current balance: {0}", customer1.GetBalance()); customer1.IcreaseBalance(30); Console.WriteLine("Balance increased by 30 common units"); Console.WriteLine("Current balance: {0}", customer1.GetBalance()); Console.WriteLine(); Console.WriteLine(contract1.ChangeTariff(TariffType.Comfort) ? "Tariff has changed." : "It's impossible to change tariff right now. Wait until {0}.", contract1.GetDateOfPossibleTariffChange()); Console.WriteLine(); sorter.ShowSortedCallInfo(billing, terminal1); Console.ReadKey(); }
public void JumpTo(Station station) { CurrentPlayer.Location = station; Db.Jump(CurrentPlayer); }
/// <summary> /// The button accept on click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void ButtonAcceptOnClick([CanBeNull] object sender, [CanBeNull] RoutedEventArgs e) { if (string.IsNullOrWhiteSpace(this.ComboBoxZoneName.Text) || string.IsNullOrWhiteSpace(this.ComboBoxDivisionName.Text) || string.IsNullOrWhiteSpace(this.TextBoxStationCode.Text) || string.IsNullOrWhiteSpace(this.TextBoxStationName.Text) || string.IsNullOrWhiteSpace(this.TextBoxPinCode.Text)) { MessageBox.Show("Please fill up all the fields!"); return; } if (this.TextBoxPinCode.Text.Length < 6) { MessageBox.Show("Pin Code must have SIX digits!"); return; } var s = MessageBox.Show( "Are you sure you want to continue? You cannot undo this operation", "Question", MessageBoxButton.YesNo); if (s == MessageBoxResult.No) { return; } ButtonProgressAssist.SetIsIndicatorVisible(this.ButtonAccept, true); var station = new Station { Zone = this.ComboBoxZoneName.Text, RailwayDivision = this.ComboBoxDivisionName.Text, StationCode = this.TextBoxStationCode.Text, StationName = this.TextBoxStationName.Text, StationPinCode = Convert.ToInt32(this.TextBoxPinCode.Text) }; var backgroundWorker2 = new BackgroundWorker(); backgroundWorker2.DoWork += (o, args) => { var task = this.AddStationAsync(station); Task.WaitAll(task); }; backgroundWorker2.RunWorkerCompleted += (o, args) => { ButtonProgressAssist.SetIsIndicatorVisible(this.ButtonAccept, false); MessageBox.Show("Data Successfully added"); }; try { backgroundWorker2.RunWorkerAsync(); this.Refresh(); } catch (Exception exception) { MessageBox.Show(exception.Message); } }
//加载文本格式地图 private void LoadTxtMap(string txtMapPath) { try { using (StreamReader sr = new StreamReader(txtMapPath)) { string line; while (true) { SubwayLine subwayLine = new SubwayLine(); subwayLine.IsCircle = false; subwayLine.InLineSubwayStationsNames = new List <string>(); string[] stationsInfo; //获取地铁线路名 if ((line = sr.ReadLine()) != null) { Match lineNameMatch = Regex.Match(line, @"^@([0-9a-zA-Z\u4E00-\u9FA5]+)"); if (lineNameMatch.Success) { subwayLine.IsCircle = true; subwayLine.Name = lineNameMatch.Groups[1].Value; } else if (Regex.Match(line, @"^([0-9a-zA-Z\u4E00-\u9FA5]+)").Success) { subwayLine.Name = line; } else { throw new Exception("地铁线路名格式有误"); } } else { return; } //获取此地铁线上所有地铁站名与地铁站所在地铁线路名 line = sr.ReadLine(); stationsInfo = Regex.Split(line, " "); foreach (string stationInfo in stationsInfo) { //添加地铁站点名 Match stationNameMatch = Regex.Match(stationInfo, @"^[0-9a-zA-Z\u4E00-\u9FA5]+"); if (!stationNameMatch.Success) { throw new Exception("地铁站名格式有误"); } subwayLine.InLineSubwayStationsNames.Add(stationNameMatch.Value); //若地铁站为记录于系统中,则添加到stations中 if (!stations.Contains(stationNameMatch.Value)) { Station station = new Station(); station.PlacedSubwayLineName = new List <string>(); station.Name = stationNameMatch.Value; //添加所在地铁线路名 station.PlacedSubwayLineName.Add(subwayLine.Name); MatchCollection subwayLineMatchCollection = Regex.Matches(stationInfo, @"\[([0-9a-zA-Z\u4E00-\u9FA5]+)\]"); foreach (Match m in subwayLineMatchCollection) { if (!m.Success) { throw new Exception("地铁站名格式有误"); } station.IsTransferStation = true; station.PlacedSubwayLineName.Add(m.Groups[1].Value); } stations.Add(station.Name, station); } } subwayLines.Add(subwayLine.Name, subwayLine); } } } catch (Exception e) { Console.WriteLine("文件无法读取"); Console.WriteLine(e.Message); System.Environment.Exit(0); } return; }
public Station Update(Station station) { return(_repository.Update(station)); }
// 인접역의 FGH를 계산하여 열린목록에 추가하는 함수 private void AddNowStationToOpenList(Station st) { FGHCalculation(st); openedList.Add(st); }
public static List <Station> StationsFromEDDP(string systemName, JObject json) { List <Station> Stations = new List <Station>(); if (json["stations"] != null) { foreach (JObject station in json["stations"]) { Station Station = new Station(); Station.EDDBID = (long)station["id"]; Station.name = (string)station["name"]; Station.systemname = systemName; Station.primaryeconomy = (string)station["primary_economy"]; Station.allegiance = (string)station["allegiance"]; Station.government = (string)station["government"]; Station.faction = (string)station["controlling_faction"]; Station.state = (string)station["state"] == "None" ? null : (string)station["state"]; Station.distancefromstar = (long?)station["distance_to_star"]; Station.hasrefuel = (bool?)station["has_refuel"]; Station.hasrearm = (bool?)station["has_rearm"]; Station.hasrepair = (bool?)station["has_repair"]; Station.hasoutfitting = (bool?)station["has_outfitting"]; Station.hasshipyard = (bool?)station["has_shipyard"]; Station.hasmarket = (bool?)station["has_market"]; Station.hasblackmarket = (bool?)station["has_blackmarket"]; Station.updatedat = (long?)station["updated_at"]; Station.outfittingupdatedat = (long?)station["outfitting_updated_at"]; if (((string)station["type"]) != null) { Station.model = ((string)station["type"]); if (!stationModels.Contains((string)station["type"])) { Logging.Info("Unknown station model " + ((string)station["type"])); } } string largestpad = (string)station["max_landing_pad_size"]; if (largestpad == "S") { largestpad = "Small"; } if (largestpad == "M") { largestpad = "Medium"; } if (largestpad == "L") { largestpad = "Large"; } Station.largestpad = largestpad; Station.commodities = CommodityQuotesFromEDDP(station); Station.commoditiesupdatedat = (long?)station["market_updated_at"]; Logging.Debug("Station is " + JsonConvert.SerializeObject(Station)); Stations.Add(Station); } } return(Stations); }
protected void Page_Load(object sender, EventArgs e) { checkoutButton.Click += new EventHandler(checkoutButton_Click); paypalButton.Click += new ImageClickEventHandler(paypalButton_Click); shippingRepeater.ItemDataBound += new RepeaterItemEventHandler(shippingRepeater_ItemDataBound); pickUpRepeater.ItemDataBound += new RepeaterItemEventHandler(pickUpRepeater_ItemDataBound); if (Order == null || Order.StationId != StationId || Order.OrderStatusId != (int)OrderStatus.New) { OrderId = 0; Response.Redirect("~/Cart.aspx"); } if (Order.LineItems.Count == 0) { Response.Redirect("~/Cart.aspx"); } if (!Page.IsPostBack) { if (!Order.IsShippingEmailNull()) { emailBox.Text = Order.ShippingEmail; confirmEmailBox.Text = Order.ShippingEmail; } else if (DsCookie["_c"] == "1") { emailBox.Text = Cipher.Decrypt2(DsCookie["_c_e"]); confirmEmailBox.Text = emailBox.Text; } if (DsCookie["_c"] == "1") { rememberMeBox.Checked = true; } if (Order.PrintingRequired) { viewAndPrintHolder.Visible = true; } else { viewAndPrintHolder.Visible = false; } if (Order.PickUpRequired) { pickUpHolder.Visible = true; noDeliveryHolder.Visible = false; pickUpRepeater.DataSource = Order.PickUpItems.Rows; pickUpRepeater.DataBind(); } else { pickUpHolder.Visible = false; } if (Order.ShippingRequired) { shippingHolder.Visible = true; noDeliveryHolder.Visible = false; shippingRepeater.DataSource = Order.ShipItems.Rows; shippingRepeater.DataBind(); StateTableAdapter stateAdapter = new StateTableAdapter(); DollarSaverDB.StateDataTable states = stateAdapter.GetStates(); stateList.DataSource = states.Rows; stateList.DataTextField = "Summary"; stateList.DataValueField = "StateCode"; stateList.DataBind(); if (!Order.IsShippingFirstNameNull()) { if (!Order.IsShippingFirstNameNull()) { firstNameBox.Text = Order.ShippingFirstName; } if (!Order.IsShippingLastNameNull()) { lastNameBox.Text = Order.ShippingLastName; } if (!Order.IsShippingAddress1Null()) { address1Box.Text = Order.ShippingAddress1; } if (!Order.IsShippingAddress2Null()) { address2Box.Text = Order.ShippingAddress2; } if (!Order.IsShippingCityNull()) { cityBox.Text = Order.ShippingCity; } if (!Order.IsShippingStateCodeNull()) { stateList.SelectedValue = Order.ShippingStateCode; } else if (!Station.IsStateCodeNull()) { stateList.SelectedValue = Station.StateCode; } if (!Order.IsShippingZipCodeNull()) { zipCodeBox.Text = Order.ShippingZipCode; } if (!Order.IsShippingPhoneNull()) { phoneNumberBox.Text = Order.ShippingPhone; } } else if (DsCookie["_c"] == "1") { firstNameBox.Text = Cipher.Decrypt2(DsCookie["_c_sa"]); lastNameBox.Text = Cipher.Decrypt2(DsCookie["_c_sb"]); address1Box.Text = Cipher.Decrypt2(DsCookie["_c_sc"]); address2Box.Text = Cipher.Decrypt2(DsCookie["_c_sd"]); cityBox.Text = Cipher.Decrypt2(DsCookie["_c_se"]); stateList.SelectedValue = Cipher.Decrypt2(DsCookie["_c_sf"]); zipCodeBox.Text = Cipher.Decrypt2(DsCookie["_c_sg"]); phoneNumberBox.Text = Cipher.Decrypt2(DsCookie["_c_sh"]); } else { stateList.SelectedValue = Station.StateCode; } } else { shippingHolder.Visible = false; } } }
public Gate NewGate(Station s) { return(g.NewInstance(s)); }
private void tsmManuStation_Click(object sender, EventArgs e) { try { if (Current.TaskMode == TaskMode.自动任务) { Tip.Alert("请切换至手动任务模式!"); return; } if (!TengDa.WF.Current.IsTerminalInitFinished) { Tip.Alert("烤箱信息初始化尚未完成,请稍后!"); return; } bool isGet = false, isPut = false; // (sender as ToolStripItem).Name.Contains("Get"); if ((sender as ToolStripItem).Name.Contains("Get")) { isGet = true; } else if ((sender as ToolStripItem).Name.Contains("Put")) { isPut = true; } Station station = Station.StationList.First(s => s.Name == (sender as ToolStripItem).Name.Split('_')[2]); if (isGet) { if (station.ClampStatus == ClampStatus.无夹具) { Tip.Alert("该位置无夹具,不能取盘!"); return; } //if (Current.Robot.ClampStatus != ClampStatus.无夹具) //{ // Tip.Alert(Current.Robot.Name + "上有夹具,不能取盘!"); // return; //} if (station.DoorStatus != DoorStatus.打开) { Tip.Alert(station.Name + "门未打开,不能取盘!"); return; } Current.Task.StartTime = DateTime.Now; Current.Task.TaskId = -1; Current.Task.NextFromStationId = station.Id; } else if (isPut) { //if (Current.Task.Status == TaskStatus.就绪 || Current.Task.Status == TaskStatus.可取 || Current.Task.Status == TaskStatus.正取) //{ // Tip.Alert("取盘任务尚未完成!"); // return; //} if (station.ClampStatus != ClampStatus.无夹具) { Tip.Alert("该位置有夹具,不能放盘!"); return; } if (Current.Task.FromStationId > 0 && station.ClampOri != Current.Task.FromStation.ClampOri) { Tip.Alert("夹具方向相反,不能放盘!"); return; } //if (Current.Task.FromClampStatus == ClampStatus.满夹具 && station.GetPutType == GetPutType.上料机) //{ // Tip.Alert(station.Name + "不允许放满夹具!"); // return; //} //if (Current.Robot.ClampStatus == ClampStatus.无夹具) //{ // Tip.Alert(Current.Robot.Name + "上无夹具,不能放盘!"); // return; //} if (station.DoorStatus != DoorStatus.打开) { Tip.Alert(station.Name + "门未打开,不能放盘!"); return; } if (Current.Task.StartTime == TengDa.Common.DefaultTime) { Current.Task.StartTime = DateTime.Now; } Current.Task.TaskId = -1; Current.Task.NextToStationId = station.Id; //if (Current.Task.Status != TaskStatus.正取 && Current.Task.Status != TaskStatus.取完) //{ // Current.Task.Status = TaskStatus.取完; //} //if (Current.Task.FromClampStatus != ClampStatus.空夹具 && Current.Task.FromClampStatus != ClampStatus.满夹具) //{ // Current.Task.FromClampStatus = Current.Robot.ClampStatus; //} } } catch (Exception ex) { Error.Alert(ex); } }
private void bgwInsert_DoWork(object sender, DoWorkEventArgs e) { Random random = new Random(); if ((int)e.Argument == 1) { // Entity에 값 넣기 List <Station> stations = new List <Station>(); List <FootTraffic> footTraffics = new List <FootTraffic>(); List <SubwayCard> subwayCards = new List <SubwayCard>(); List <Revenue> revenues = new List <Revenue>(); List <Transfer> transfers = new List <Transfer>(); using (var context = DbContextCreator.Create()) { footTraffics = context.FootTraffics.ToList(); stations = context.Stations.ToList(); subwayCards = context.SubwayCards.ToList(); transfers = context.Transfers.ToList(); } for (int i = 0; i < rows.Count; ++i) { // Station Station station = new Station(); if (stations.Find(x => x.Name == rows[i][1]) == null) { // 역이 없을 경우 추가해주기 station.Name = rows[i][1]; stations.Add(station); } else { // 역이 있을 경우 연결 station = stations.Find(x => x.Name == rows[i][1]); } // FootTraffic FootTraffic footTraffic = new FootTraffic() { Station = station, TransferId = transfers.Find(x => x.Name == rows[i][2]).TransferId }; double dateNumber = 0; dateNumber = double.Parse(rows[i][0]); if (dateNumber > 60d) { dateNumber = dateNumber - 2; } else { dateNumber = dateNumber - 1; } DateTime dateTime = new DateTime(1900, 1, 1); dateTime = dateTime.AddDays(dateNumber); footTraffic.Date = dateTime; footTraffic.BeforeSix = int.Parse(rows[i][3]); footTraffic.SixToSeven = int.Parse(rows[i][4]); footTraffic.SevenToEight = int.Parse(rows[i][5]); footTraffic.EightToNine = int.Parse(rows[i][6]); footTraffic.NineToTen = int.Parse(rows[i][7]); footTraffic.TenToEleven = int.Parse(rows[i][8]); footTraffic.ElevenToTwelve = int.Parse(rows[i][9]); footTraffic.TwelveToThirteen = int.Parse(rows[i][10]); footTraffic.ThirteenToFourteen = int.Parse(rows[i][11]); footTraffic.FourteenToFifteen = int.Parse(rows[i][12]); footTraffic.FifteenToSixteen = int.Parse(rows[i][13]); footTraffic.SixteenToSeventeen = int.Parse(rows[i][14]); footTraffic.SeventeenToEighteen = int.Parse(rows[i][15]); footTraffic.EighteenToNineteen = int.Parse(rows[i][16]); footTraffic.NineteenToTwenty = int.Parse(rows[i][17]); footTraffic.TwentyToTwentyOne = int.Parse(rows[i][18]); footTraffic.TwnetyOneToTwentyTwo = int.Parse(rows[i][19]); footTraffic.TwentyTwoToTwentyThree = int.Parse(rows[i][20]); footTraffic.TwentyThreeToTwentyFour = int.Parse(rows[i][21]); footTraffic.AfterTwentyFour = int.Parse(rows[i][22]); footTraffics.Add(footTraffic); } //SubwayCard // 1.Wayne shipping, 2.DK Transport, 3.Gotham Credit List <SubwayCard> subwayCardList = new List <SubwayCard>(); subwayCardList.Add(new SubwayCard() { CompanyName = "Wayne shipping" }); subwayCardList.Add(new SubwayCard() { CompanyName = "DK Transport" }); subwayCardList.Add(new SubwayCard() { CompanyName = "Gotham Credit" }); subwayCards.AddRange(subwayCardList); for (int i = 1; i <= 12; i++) { for (int j = 0; j < stations.Count; j++) { List <FootTraffic> list = footTraffics.FindAll(x => x.Date.Month == i && x.StationId == (j + 1)); int sum = 0; foreach (var item in list) { sum = item.BeforeSix + item.SixToSeven + item.SevenToEight + item.EightToNine + item.NineToTen + item.TenToEleven + item.ElevenToTwelve + item.TwelveToThirteen + item.ThirteenToFourteen + item.FourteenToFifteen + item.FifteenToSixteen + item.SixteenToSeventeen + item.SeventeenToEighteen + item.EighteenToNineteen + item.NineteenToTwenty + item.TwentyToTwentyOne + item.TwnetyOneToTwentyTwo + item.TwentyTwoToTwentyThree + item.TwentyThreeToTwentyFour + item.AfterTwentyFour; } sum *= 1300; for (int k = 0; k < 3; k++) { Revenue revenue = new Revenue(); revenue.StationId = j + 1; revenue.Month = new DateTime(list.First().Date.Year - 1, i, 1); revenue.SubwayCardId = k + 1; if (k < 2) { int income = (int)(sum * (random.NextDouble() % 0.4)); revenue.Income = income; sum -= income; } else { revenue.Income = sum; sum = 0; } revenues.Add(revenue); } } } // Entity를 DB에 저장 using (var context = DbContextCreator.Create()) { for (int i = context.Stations.Count(); i < stations.Count; i++) { context.Stations.Add(stations[i]); } for (int i = context.SubwayCards.Count(); i < subwayCards.Count; i++) { context.SubwayCards.Add(subwayCards[i]); } context.FootTraffics.AddRange(footTraffics); context.Revenues.AddRange(revenues); context.SaveChanges(); } } else if ((int)e.Argument == 2) { // Entity에 값 넣기 List <Satisfaction> satisfactions = new List <Satisfaction>(); List <SatisfactionCategory> satisfactionCategories = new List <SatisfactionCategory>(); int maxFirstId; int beforeSatisfactionCategoryCount; using (var context = DbContextCreator.Create()) { satisfactionCategories = context.SatisfactionCategories.ToList(); if (satisfactionCategories.Count != 0) { maxFirstId = (context.SatisfactionCategories.Max(x => x.SatisfactionCategoryId)) / 100; } else { maxFirstId = 1; } beforeSatisfactionCategoryCount = satisfactionCategories.Count; } for (int i = 0; i < rows.Count; ++i) { // SatisfactionCategory SatisfactionCategory firstSatisfactionCategory = new SatisfactionCategory(); // 카테고리1이 없을 떄 만들어주기 if (satisfactionCategories.Find(x => x.Item == rows[i][0]) == null) { firstSatisfactionCategory.Item = rows[i][0]; firstSatisfactionCategory.SatisfactionCategoryId = maxFirstId * 100; maxFirstId += 1; satisfactionCategories.Add(firstSatisfactionCategory); } int upperId = satisfactionCategories.Find(x => x.Item == rows[i][0]).SatisfactionCategoryId; SatisfactionCategory secondSatisfactionCategory = new SatisfactionCategory(); // 카테고리2가 없을 때, 또는 카테고리2가 있는데 카테고리1이 다를 때 if (satisfactionCategories.Find(x => x.Item == rows[i][1]) == null || ((satisfactionCategories.Find(x => x.Item == rows[i][1]) != null) && satisfactionCategories.Find(x => x.Item == rows[i][1]).UpperId != upperId)) { secondSatisfactionCategory.Item = rows[i][1]; secondSatisfactionCategory.UpperId = upperId; if (satisfactionCategories.Find(x => x.UpperId == upperId) == null) { secondSatisfactionCategory.SatisfactionCategoryId = upperId + 1; } else { secondSatisfactionCategory.SatisfactionCategoryId = satisfactionCategories.Where(x => x.UpperId == upperId).Max(x => x.SatisfactionCategoryId) + 1; } secondSatisfactionCategory.SatisfactionCategory2 = satisfactionCategories.Find(x => x.SatisfactionCategoryId == secondSatisfactionCategory.UpperId); satisfactionCategories.Add(secondSatisfactionCategory); } else { secondSatisfactionCategory = satisfactionCategories.Find(x => x.Item == rows[i][1] && x.UpperId == upperId); } // Satisfaction Satisfaction satisfaction = new Satisfaction() { SatisfactionCategory = secondSatisfactionCategory }; satisfaction.Excellent = decimal.Parse(rows[i][2]); satisfaction.Good = decimal.Parse(rows[i][3]); satisfaction.Soso = decimal.Parse(rows[i][4]); satisfaction.Bad = decimal.Parse(rows[i][5]); satisfaction.Terrible = decimal.Parse(rows[i][6]); satisfactions.Add(satisfaction); } foreach (var s in satisfactionCategories) { if (s.SatisfactionCategoryId == 0) { bgwInsert.ReportProgress(0, "error"); } } // Entity를 DB에 저장 using (var context = DbContextCreator.Create()) { for (int i = beforeSatisfactionCategoryCount; i < satisfactionCategories.Count; ++i) { context.SatisfactionCategories.Add(satisfactionCategories[i]); } context.Satisfactions.AddRange(satisfactions); context.SaveChanges(); } } else if ((int)e.Argument == 3) { // Entity에 값 넣기 List <Electricity> electricities = new List <Electricity>(); for (int i = 0; i < rows.Count; ++i) { Electricity electricity = new Electricity(); double dateNumber = 0; dateNumber = double.Parse(rows[i][0]); if (dateNumber > 60d) { dateNumber = dateNumber - 2; } else { dateNumber = dateNumber - 1; } DateTime dateTime = new DateTime(1900, 1, 1); dateTime = dateTime.AddDays(dateNumber); electricity.Month = dateTime; electricity.Usage = int.Parse(rows[i][1]); electricity.Bill = int.Parse(rows[i][2]); electricities.Add(electricity); bgwInsert.ReportProgress(0, i.ToString()); } // Entity를 DB에 저장하기 using (var context = DbContextCreator.Create()) { //foreach (Electricity electricity in electricities) context.Electricities.AddRange(electricities); context.SaveChanges(); } } else if ((int)e.Argument == 4) { // Satisfaction List <Satisfaction> satisfactions = Dao.Satisfaction.GetAll(); List <Satisfaction> newSatisfactions = new List <Satisfaction>(); for (int i = 0; i < satisfactions.Count; i++) { List <int> randomNumbers = new List <int>(); int sum = 0; for (int j = 0; j < 5; j++) { randomNumbers.Add(random.Next(1500, 2000)); sum += randomNumbers[j]; } Satisfaction satisfaction = new Satisfaction() { SatisfactionCategoryId = satisfactions[i].SatisfactionCategoryId, Excellent = (decimal)((randomNumbers[0] * 100.0) / (double)sum), Good = (decimal)((randomNumbers[1] * 100.0) / (double)sum), Soso = (decimal)((randomNumbers[2] * 100.0) / (double)sum), Bad = (decimal)((randomNumbers[3] * 100.0) / (double)sum), Terrible = (decimal)((randomNumbers[4] * 100.0) / (double)sum) }; newSatisfactions.Add(satisfaction); } using (var context = DbContextCreator.Create()) { context.Satisfactions.AddRange(newSatisfactions); context.SaveChanges(); } } }
public virtual void RegisterStationEventHandlers(Station station) { station.CallEvent += OnCallHappened; }
public void CreateTile(Vector2Int position, Station station) { this.station = station; tilemapPosition = position; }
// Update is called once per frame void Update() { if (IsFederationStarBase) { Station scr = gameObject.GetComponent <Station>(); if (!scr.AI && !scr.FreandAI && !scr.Neutral && !scr.NeutralAgrass) { GameObject.FindGameObjectWithTag("MainUI").GetComponent <GlobalLockingSystem>().IsFederationStarBase = true; } else if (scr.AI && scr.FreandAI) { scr.Owner.GetComponent <GlobalLockingSystem>().IsFederationStarBase = true; } } if (IsFederationMiningStation) { Station scr = gameObject.GetComponent <Station>(); if (!scr.AI && !scr.FreandAI && !scr.Neutral && !scr.NeutralAgrass) { GameObject.FindGameObjectWithTag("MainUI").GetComponent <GlobalLockingSystem>().IsFederationMiningStation = true; } else if (scr.AI && scr.FreandAI) { scr.Owner.GetComponent <GlobalLockingSystem>().IsFederationMiningStation = true; } } if (IsFederationDock1) { Station scr = gameObject.GetComponent <Station>(); if (!scr.AI && !scr.FreandAI && !scr.Neutral && !scr.NeutralAgrass) { GameObject.FindGameObjectWithTag("MainUI").GetComponent <GlobalLockingSystem>().IsFederationDock1 = true; } else if (scr.AI && scr.FreandAI) { scr.Owner.GetComponent <GlobalLockingSystem>().IsFederationDock1 = true; } } if (IsFederationDock2) { Station scr = gameObject.GetComponent <Station>(); if (!scr.AI && !scr.FreandAI && !scr.Neutral && !scr.NeutralAgrass) { GameObject.FindGameObjectWithTag("MainUI").GetComponent <GlobalLockingSystem>().IsFederationDock2 = true; } else if (scr.AI && scr.FreandAI) { scr.Owner.GetComponent <GlobalLockingSystem>().IsFederationDock2 = true; } } if (IsFederationSciStation) { Station scr = gameObject.GetComponent <Station>(); if (!scr.AI && !scr.FreandAI && !scr.Neutral && !scr.NeutralAgrass) { GameObject.FindGameObjectWithTag("MainUI").GetComponent <GlobalLockingSystem>().IsFederationSciStation = true; } else if (scr.AI && scr.FreandAI) { scr.Owner.GetComponent <GlobalLockingSystem>().IsFederationSciStation = true; } } if (IsFederationDefenceStation) { Station scr = gameObject.GetComponent <Station>(); if (!scr.AI && !scr.FreandAI && !scr.Neutral && !scr.NeutralAgrass) { GameObject.FindGameObjectWithTag("MainUI").GetComponent <GlobalLockingSystem>().IsFederationDefenceStation = true; } else if (scr.AI && scr.FreandAI) { scr.Owner.GetComponent <GlobalLockingSystem>().IsFederationDefenceStation = true; } } if (IsFederationTradingStation) { Station scr = gameObject.GetComponent <Station>(); if (!scr.AI && !scr.FreandAI && !scr.Neutral && !scr.NeutralAgrass) { GameObject.FindGameObjectWithTag("MainUI").GetComponent <GlobalLockingSystem>().IsFederationTradingStation = true; } else if (scr.AI && scr.FreandAI) { scr.Owner.GetComponent <GlobalLockingSystem>().IsFederationTradingStation = true; } } if (IsBorgNexus) { Station scr = gameObject.GetComponent <Station>(); if (!scr.AI && !scr.FreandAI && !scr.Neutral && !scr.NeutralAgrass) { GameObject.FindGameObjectWithTag("MainUI").GetComponent <GlobalLockingSystem>().IsBorgNexus = true; } else if (scr.AI && scr.FreandAI) { scr.Owner.GetComponent <GlobalLockingSystem>().IsBorgNexus = true; } } if (IsBorgMiningStation) { Station scr = gameObject.GetComponent <Station>(); if (!scr.AI && !scr.FreandAI && !scr.Neutral && !scr.NeutralAgrass) { GameObject.FindGameObjectWithTag("MainUI").GetComponent <GlobalLockingSystem>().IsBorgMiningStation = true; } else if (scr.AI && scr.FreandAI) { scr.Owner.GetComponent <GlobalLockingSystem>().IsBorgMiningStation = true; } } if (IsBorgDock1) { Station scr = gameObject.GetComponent <Station>(); if (!scr.AI && !scr.FreandAI && !scr.Neutral && !scr.NeutralAgrass) { GameObject.FindGameObjectWithTag("MainUI").GetComponent <GlobalLockingSystem>().IsBorgDock1 = true; } else if (scr.AI && scr.FreandAI) { scr.Owner.GetComponent <GlobalLockingSystem>().IsBorgDock1 = true; } } if (IsBorgDock2) { Station scr = gameObject.GetComponent <Station>(); if (!scr.AI && !scr.FreandAI && !scr.Neutral && !scr.NeutralAgrass) { GameObject.FindGameObjectWithTag("MainUI").GetComponent <GlobalLockingSystem>().IsBorgDock2 = true; } else if (scr.AI && scr.FreandAI) { scr.Owner.GetComponent <GlobalLockingSystem>().IsBorgDock2 = true; } } if (IsBorgSciStation) { Station scr = gameObject.GetComponent <Station>(); if (!scr.AI && !scr.FreandAI && !scr.Neutral && !scr.NeutralAgrass) { GameObject.FindGameObjectWithTag("MainUI").GetComponent <GlobalLockingSystem>().IsBorgSciStation = true; } else if (scr.AI && scr.FreandAI) { scr.Owner.GetComponent <GlobalLockingSystem>().IsBorgSciStation = true; } } if (IsBorgDefenceStation) { Station scr = gameObject.GetComponent <Station>(); if (!scr.AI && !scr.FreandAI && !scr.Neutral && !scr.NeutralAgrass) { GameObject.FindGameObjectWithTag("MainUI").GetComponent <GlobalLockingSystem>().IsBorgDefenceStation = true; } else if (scr.AI && scr.FreandAI) { scr.Owner.GetComponent <GlobalLockingSystem>().IsBorgDefenceStation = true; } } if (IsBorgTorpedoTurret) { Station scr = gameObject.GetComponent <Station>(); if (!scr.AI && !scr.FreandAI && !scr.Neutral && !scr.NeutralAgrass) { GameObject.FindGameObjectWithTag("MainUI").GetComponent <GlobalLockingSystem>().IsBorgTorpedoTurret = true; } else if (scr.AI && scr.FreandAI) { scr.Owner.GetComponent <GlobalLockingSystem>().IsBorgTorpedoTurret = true; } } if (IsBorgCutterTurret) { Station scr = gameObject.GetComponent <Station>(); if (!scr.AI && !scr.FreandAI && !scr.Neutral && !scr.NeutralAgrass) { GameObject.FindGameObjectWithTag("MainUI").GetComponent <GlobalLockingSystem>().IsBorgCutterTurret = true; } else if (scr.AI && scr.FreandAI) { scr.Owner.GetComponent <GlobalLockingSystem>().IsBorgCutterTurret = true; } } }
public StationPassengersRpcCallSenderProcessor(Station station) : base(RPC_NAME) { this.station = station; }
public static string ImportTrips(StationsDbContext context, string jsonString) { TripDto[] tripsFromJson = ImportFromJson <TripDto>(jsonString, true); StringBuilder sb = new StringBuilder(); List <Trip> resultTrips = new List <Trip>(); foreach (TripDto tripDto in tripsFromJson) { if (!IsValid(tripDto)) { sb.AppendLine(FailureMessage); continue; } Train train = context.Trains.SingleOrDefault(t => t.TrainNumber == tripDto.Train); Station originStation = context.Stations.SingleOrDefault(s => s.Name == tripDto.OriginStation); Station destinationStation = context.Stations.SingleOrDefault(s => s.Name == tripDto.DestinationStation); if (train == null || originStation == null || destinationStation == null) { sb.AppendLine(FailureMessage); continue; } DateTime departureTime = DateTime.ParseExact(tripDto.DepartureTime, "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture); DateTime arrivalTime = DateTime.ParseExact(tripDto.ArrivalTime, "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture); if (departureTime > arrivalTime) { sb.AppendLine(FailureMessage); continue; } TripStatus status = Enum.Parse <TripStatus>(tripDto.Status); TimeSpan?timeDifference = null; if (tripDto.TimeDifference != null) { timeDifference = TimeSpan.ParseExact(tripDto.TimeDifference, @"hh\:mm", CultureInfo.InvariantCulture); } Trip currentTrip = new Trip { ArrivalTime = arrivalTime, DepartureTime = departureTime, Train = train, Status = status, OriginStation = originStation, DestinationStation = destinationStation, TimeDifference = timeDifference }; resultTrips.Add(currentTrip); sb.AppendLine($"Trip from {currentTrip.OriginStation.Name} to {currentTrip.DestinationStation.Name} imported."); } context.Trips.AddRange(resultTrips); context.SaveChanges(); string result = sb.ToString().Trim(); return(result); }
StationEdgeInfo GetUnorderedIjInfo(Station i, Station j) { Debug.Assert(i != j); return(i < j ? GetOrderedIjInfo(i, j) : GetOrderedIjInfo(j, i)); }
public Platform NewPlatform(RailNode on, Station s) { return(p.NewInstance(on, s)); }
protected override void GenerateJob(Station jobOriginStation, float jobTimeLimit = 0, float initialWage = 0, string forcedJobId = null, JobLicenses requiredLicenses = JobLicenses.Basic) { if ((trainCarsToTransport == null) || (trainCarsToTransport.Count == 0) || (startingTrack == null) || (destinationTrack == null)) { trainCarsToTransport = null; startingTrack = null; destinationTrack = null; return; } // Get total cargo capacity float totalCapacity = 0; foreach (var car in trainCarsToTransport) { //car.DumpCargo(); totalCapacity += car.capacity; } Track departTrack = startingTrack; Track arriveTrack = destinationTrack; var taskList = new List <Task>(); // Check for loading task PlatformController loadPlatform = null; if (loadMachine != null) { departTrack = loadMachine.WarehouseTrack; Task stageCarsTask = JobsGenerator.CreateTransportTask(trainCarsToTransport, departTrack, startingTrack); taskList.Add(stageCarsTask); Task loadTask = new WarehouseTask(trainCarsToTransport, WarehouseTaskType.Loading, loadMachine, CargoType.Passengers, totalCapacity); taskList.Add(loadTask); // check to register for unloading display if ((PlatformManager.GetPlatformByTrackId(loadMachine.WarehouseTrack.ID.FullID) is PlatformDefinition pdef) && pdef.Initialized) { loadPlatform = pdef.Controller; } } else { foreach (var car in trainCarsToTransport) { car.LoadCargo(car.capacity, CargoType.Passengers); } } if (unloadMachine != null) { arriveTrack = unloadMachine.WarehouseTrack; } // actual move between stations Task transportTask = JobsGenerator.CreateTransportTask( trainCarsToTransport, arriveTrack, departTrack, Enumerable.Repeat(CargoType.Passengers, trainCarsToTransport.Count).ToList()); taskList.Add(transportTask); // check for unloading task PlatformController unloadPlatform = null; if (unloadMachine != null) { Task unloadTask = new WarehouseTask(trainCarsToTransport, WarehouseTaskType.Unloading, unloadMachine, CargoType.Passengers, totalCapacity); taskList.Add(unloadTask); Task storeCarsTask = JobsGenerator.CreateTransportTask(trainCarsToTransport, destinationTrack, arriveTrack); taskList.Add(storeCarsTask); // check to register for unloading display if ((PlatformManager.GetPlatformByTrackId(unloadMachine.WarehouseTrack.ID.FullID) is PlatformDefinition pdef) && pdef.Initialized) { unloadPlatform = pdef.Controller; } } Task superTask = new SequentialTasks(taskList); // check if we should generate a special job ID if (string.IsNullOrEmpty(forcedJobId) && (specialDefinition != null)) { forcedJobId = IG_GenerateJobId_Patch.GetNamedExpressId(specialDefinition); } job = new Job(superTask, subType, jobTimeLimit, initialWage, chainData, forcedJobId, requiredLicenses); // set up platform displays if (loadPlatform != null) { loadPlatform.AddOutgoingJobToDisplay(job); } if (unloadPlatform != null) { job.JobTaken += unloadPlatform.AddIncomingJobToDisplay; } // track the job if it's a special, for booklet info etc if (specialDefinition != null) { SpecialConsistManager.JobToSpecialMap.Add(job.ID, specialDefinition); } jobOriginStation.AddJobToStation(job); }
/// <summary> /// real edges passing the edge uv /// </summary> internal StationEdgeInfo GetIjInfo(Station u, Station v) { var couple = u < v ? new Tuple <Station, Station>(u, v) : new Tuple <Station, Station>(v, u); return(edgeInfoDictionary[couple]); }
public Form1() { InitializeComponent(); station = new Station(this); buttonStop.Enabled = false; }
/// <summary> /// real edges passing the node /// </summary> internal List <MetroNodeInfo> MetroNodeInfosOfNode(Station node) { return(node.MetroNodeInfos); }
public void addDestination(Station station, string sArivalTime) { vDestinationList.Add(station); vDepartureTime.Add(sArivalTime); }
public Station getStationAt(int i) { Station station = vDestinationList[i]; return(station); }
/// <summary>Called every frame to update the plugin.</summary> public void UpdatePlugin() { if (Train.Cars == null || Train.Cars.Length == 0) { return; } /* * Prepare the vehicle state. * */ double location = this.Train.Cars[0].FrontAxle.Follower.TrackPosition - this.Train.Cars[0].FrontAxle.Position + 0.5 * this.Train.Cars[0].Length; //If the list of stations has not been loaded, do so if (!StationsLoaded) { currentRouteStations = new List <Station>(); int s = 0; foreach (RouteStation selectedStation in TrainManagerBase.CurrentRoute.Stations) { double stopPosition = -1; int stopIdx = TrainManagerBase.CurrentRoute.Stations[s].GetStopIndex(Train.NumberOfCars); if (selectedStation.Stops.Length != 0) { stopPosition = selectedStation.Stops[stopIdx].TrackPosition; } Station i = new Station(selectedStation, stopPosition); currentRouteStations.Add(i); s++; } StationsLoaded = true; } //End of additions double speed = this.Train.Cars[this.Train.DriverCar].Specs.PerceivedSpeed; double bcPressure = this.Train.Cars[this.Train.DriverCar].CarBrake.brakeCylinder.CurrentPressure; double mrPressure = this.Train.Cars[this.Train.DriverCar].CarBrake.mainReservoir.CurrentPressure; double erPressure = this.Train.Cars[this.Train.DriverCar].CarBrake.equalizingReservoir.CurrentPressure; double bpPressure = this.Train.Cars[this.Train.DriverCar].CarBrake.brakePipe.CurrentPressure; double sapPressure = this.Train.Cars[this.Train.DriverCar].CarBrake.straightAirPipe.CurrentPressure; VehicleState vehicle = new VehicleState(location, new Speed(speed), bcPressure, mrPressure, erPressure, bpPressure, sapPressure, this.Train.Cars[0].FrontAxle.Follower); /* * Prepare the preceding vehicle state. * */ double bestLocation = double.MaxValue; double bestSpeed = 0.0; PrecedingVehicleState precedingVehicle; try { for (int i = 0; i < TrainManagerBase.Trains.Length; i++) { if (TrainManagerBase.Trains[i] != this.Train & TrainManagerBase.Trains[i].State == TrainState.Available & Train.Cars.Length > 0) { int c = TrainManagerBase.Trains[i].Cars.Length - 1; double z = TrainManagerBase.Trains[i].Cars[c].RearAxle.Follower.TrackPosition - TrainManagerBase.Trains[i].Cars[c].RearAxle.Position - 0.5 * TrainManagerBase.Trains[i].Cars[c].Length; if (z >= location & z < bestLocation) { bestLocation = z; bestSpeed = TrainManagerBase.Trains[i].CurrentSpeed; } } } precedingVehicle = bestLocation != double.MaxValue ? new PrecedingVehicleState(bestLocation, bestLocation - location, new Speed(bestSpeed)) : null; } catch { precedingVehicle = null; } /* * Get the driver handles. * */ OpenBveApi.Runtime.Handles handles = GetHandles(); /* * Update the plugin. * */ double totalTime = TrainManagerBase.currentHost.InGameTime; double elapsedTime = TrainManagerBase.currentHost.InGameTime - LastTime; ElapseData data = new ElapseData(vehicle, precedingVehicle, handles, this.Train.SafetySystems.DoorInterlockState, new Time(totalTime), new Time(elapsedTime), currentRouteStations, TrainManagerBase.Renderer.Camera.CurrentMode, Translations.CurrentLanguageCode, this.Train.Destination); ElapseData inputDevicePluginData = data; LastTime = TrainManagerBase.currentHost.InGameTime; Elapse(data); this.PluginMessage = data.DebugMessage; this.Train.SafetySystems.DoorInterlockState = data.DoorInterlockState; DisableTimeAcceleration = data.DisableTimeAcceleration; for (int i = 0; i < InputDevicePlugin.AvailablePluginInfos.Count; i++) { if (InputDevicePlugin.AvailablePluginInfos[i].Status == InputDevicePlugin.PluginInfo.PluginStatus.Enable) { InputDevicePlugin.AvailablePlugins[i].SetElapseData(inputDevicePluginData); } } /* * Set the virtual handles. * */ this.PluginValid = true; SetHandles(data.Handles, true); this.Train.Destination = data.Destination; }
StructStore() { station = new Station(); userCells = new PlayerBuilt(); // List<cell> PlayerList = new List<cell>(); }
public Station Create(Station station) { return(_repository.Create(station)); }
public async Task <Station> AlterAsync(int id, Station station) { await _stationRepository.AlterAsync(station).ConfigureAwait(false); return(station); }