public static ServiceResult BarCode(string station, string barCode) { ServiceResult result = new ServiceResult(); if (String.IsNullOrEmpty(barCode)) { result.IsSuccess = false; result.Msg = String.Format("条码为空:{0}", barCode); return(result); } if (barCode.Contains("ERROR") || barCode.Contains("error")) { result.IsSuccess = false; result.Msg = String.Format("错误条码:{0}", barCode); return(result); } FailSafe failSafe = new FailSafe(); if (station == "S") { result = failSafe.CheckSmall(barCode); } else { result = failSafe.CheckLarge(barCode); } return(result); }
public async Task <Airport> GetAirport(string alias) { var cacheElement = this[alias]; if (cacheElement == null) { //flights api throws a lot of timeout exceptions. var airports = await FailSafe.TryTwice(() => _flightsApi.GetAirports(alias)); if (!airports.Any()) { return(null); } if (airports.Count > 1) { var airportWithCorrectAlias = airports.FirstOrDefault(a => string.Equals(a.Alias, alias)); this[alias] = airportWithCorrectAlias; } else { this[alias] = airports.First(); } } return(this[alias]); }
public async Task <List <Route> > GetRoutes(Airport airport) { var cacheElement = this[airport]; if (cacheElement == null) { var plainRoutes = await FailSafe.TryTwice(() => _flightsApi.GetRoutes(airport.Alias)); var convertedPlainRoutes = await Task.WhenAll(plainRoutes.Select(async r => await ConvertToRoute(r))); var airlines = await GetAirlinesForRoutes(convertedPlainRoutes.ToList()); var airlinesDictionary = airlines.ToDictionary(x => x.Alias, x => x); foreach (var route in convertedPlainRoutes) { route.Airline = airlinesDictionary[route.Airline.Alias]; } this[airport] = convertedPlainRoutes.ToList(); } return(this[airport]); }
public static void EndDig(Mobile from, Item tool) { Timer it = (Timer)m_IsDigging[from]; if (it != null) { it.Stop(); } m_IsDigging.Remove(from); BaseHarvestTool t = (BaseHarvestTool)tool; t.UsesRemaining -= 1; if (t.UsesRemaining == 0) { tool.Delete(); from.SendMessage("You have worn out your tool!"); } if (from.CheckSkill(SkillName.Forensics, 0, 100)) { int bonus = 1; if (tool is SturdyShovel) { bonus = 2; } if (tool is GraveDiggersShovel) { bonus = 4; } if (tool is GoldenShovel) { bonus = 6; } if (tool is DiamondShovel) { bonus = 8; } if (tool is SummonShovel) { bonus = 10; } Double chance = from.Skills[SkillName.Forensics].Value / 10 * bonus; if (tool is SummonShovel && Utility.Random(1000) < chance) { int roll = Utility.Random(100); Mobile spawn; if (roll < 50) { spawn = new FailSafe(); spawn.MoveToWorld(from.Location, from.Map); spawn.Combatant = from; spawn.Z++; World.Broadcast(0x35, true, "{0} has summoned Fail Safe!", from.Name); } else { spawn = new Grobbubatus(); spawn.MoveToWorld(from.Location, from.Map); spawn.Combatant = from; spawn.Z++; World.Broadcast(0x35, true, "{0} has summoned Grobbubatus!", from.Name); } } else if (Utility.Random(100) < chance) { int roll = Utility.Random(2); switch (roll) { case 0: from.AddToBackpack(GiveReward(from, tool)); break; case 1: from.AddToBackpack(Runescribing.GetResoureDrop(false, true)); break; } } else { if (Utility.Random(100) < 25 - bonus) { from.SendMessage("You have disturbed the dead!"); BaseCreature m = null; try { m = Activator.CreateInstance(m_Dead[Utility.Random(m_Dead.Length)]) as BaseCreature; } catch { } m.Location = from.Location; m.Map = from.Map; if (m.IsParagon) { m.IsParagon = false; } World.AddMobile(m); m.Combatant = from; m.Z++; } else { from.SendMessage("You skillfully dig the area but do not find anything."); } } } else { if (Utility.Random(100) < 50) { from.SendMessage("You have disturbed the dead!"); BaseCreature m = null; try { m = Activator.CreateInstance(m_Dead[Utility.Random(m_Dead.Length)]) as BaseCreature; } catch { } m.Location = from.Location; m.Map = from.Map; if (m.IsParagon) { m.IsParagon = false; } World.AddMobile(m); m.Combatant = from; m.Z++; } else { from.SendMessage("You fail to discover anything of interest."); } } }