public bool OrderGetDetailByID(DataOrders order) { bool noError = true; try { using (SqlConnection connection = new SqlConnection(ConnectionString)) { connection.Open(); using (SqlCommand command = new SqlCommand("dbo.sp_OrderGetDetailByID", connection)) { command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("@OrderID", order.OrderID); connection.Open(); command.ExecuteNonQuery(); } } } catch (Exception exception) { Logger.LogError(exception); } return(noError); }
IStandingsItem ISessionInfo.FindPosition(int pos, DataOrders order, string classname) { return FindPosition(pos, order, classname) as IStandingsItem; }
public StandingsItem FindPosition(int pos, DataOrders order, string classname) { int index = -1; int i = 1; IEnumerable<StandingsItem> query; logger.Trace("FindPosition({0} , {1} , {2}) ...", pos, order, classname); switch (order) { case DataOrders.fastestlap: Int32 lastpos = SharedData.Drivers.Count; if (classname == null) query = SharedData.Sessions.CurrentSession.Standings.OrderBy(s => s.FastestLap); else query = SharedData.Sessions.CurrentSession.Standings.Where(s => s.Driver.CarClassName == classname).OrderBy(s => s.FastestLap); logger.Trace("FastestLap query contains {0}", query.Count()); foreach (StandingsItem si in query) { if (si.FastestLap > 0) { if (i == pos) { index = standings.IndexOf(standings.Where(f => f.Driver.CarIdx.Equals(si.Driver.CarIdx)).FirstOrDefault()); break; } i++; } } // if not found then driver has no finished laps if (index < 0) { if (classname == null) query = SharedData.Sessions.CurrentSession.Standings.Where(s => s.FastestLap <= 0); else query = SharedData.Sessions.CurrentSession.Standings.Where(s => s.Driver.CarClassName == classname).Where(s => s.FastestLap <= 0); foreach (StandingsItem si in query) { if (i == pos) { index = standings.IndexOf(standings.Where(f => f.Driver.CarIdx.Equals(si.Driver.CarIdx)).FirstOrDefault()); break; } i++; } } break; case DataOrders.previouslap: if (classname == null) query = SharedData.Sessions.CurrentSession.Standings.OrderBy(s => s.PreviousLap.LapTime); else query = SharedData.Sessions.CurrentSession.Standings.Where(s => s.Driver.CarClassName == classname).OrderBy(s => s.PreviousLap.LapTime); try { foreach (StandingsItem si in query) { if (si.PreviousLap.LapTime > 0) { if (i == pos) { index = standings.IndexOf(standings.Where(f => f.Driver.CarIdx.Equals(si.Driver.CarIdx)).FirstOrDefault()); break; } i++; } } } catch { index = -1; } // if not found then driver has no finished laps if (index < 0) { if (classname == null) query = SharedData.Sessions.CurrentSession.Standings.Where(s => s.PreviousLap.LapTime <= 0); else query = SharedData.Sessions.CurrentSession.Standings.Where(s => s.Driver.CarClassName == classname).Where(s => s.PreviousLap.LapTime <= 0); foreach (StandingsItem si in query) { if (i == pos) { index = standings.IndexOf(standings.Where(f => f.Driver.CarIdx.Equals(si.Driver.CarIdx)).FirstOrDefault()); break; } i++; } } break; case DataOrders.classposition: query = SharedData.Sessions.CurrentSession.Standings.OrderBy(s => s.Driver.CarClassOrder + s.Position).Skip(pos - 1); if (query.Count() > 0) { StandingsItem si = query.First(); return si; } else return new StandingsItem(); case DataOrders.points: query = SharedData.Sessions.CurrentSession.Standings.OrderByDescending(s => Convert.ToInt32(s.Driver.ExternalData[SharedData.theme.pointscol])).Skip(pos - 1); if (query.Count() > 0) { StandingsItem si = query.First(); return si; } else return new StandingsItem(); case DataOrders.liveposition: if (classname == null) index = standings.IndexOf(standings.Where(f => f.PositionLive.Equals(pos)).FirstOrDefault()); else { query = SharedData.Sessions.CurrentSession.Standings.Where(s => s.Driver.CarClassName == classname).OrderBy(s => s.PositionLive).Skip(pos - 1); if (query.Count() > 0) { StandingsItem si = query.First(); return si; } else return new StandingsItem(); } break; case DataOrders.trackposition: if (pos < 0) { // infront int skip = (-pos) - 1; query = SharedData.Sessions.CurrentSession.Standings.Where(s => s.DistanceToFollowed > 0 && s.TrackSurface != SurfaceTypes.NotInWorld).OrderBy(s => s.DistanceToFollowed); if (query.Count() <= skip) { query = SharedData.Sessions.CurrentSession.Standings.Where(s => s.DistanceToFollowed < 0 && s.TrackSurface != SurfaceTypes.NotInWorld).OrderBy(s => s.DistanceToFollowed).Skip((-pos) - 1 - query.Count()); } else query = query.Skip(skip); } else if (pos > 0) { // behind int skip = pos - 1; query = SharedData.Sessions.CurrentSession.Standings.Where(s => s.DistanceToFollowed < 0 && s.TrackSurface != SurfaceTypes.NotInWorld).OrderByDescending(s => s.DistanceToFollowed); if (query.Count() <= skip) { query = SharedData.Sessions.CurrentSession.Standings.Where(s => s.DistanceToFollowed > 0 && s.TrackSurface != SurfaceTypes.NotInWorld).OrderByDescending(s => s.DistanceToFollowed).Skip(pos - 1 - query.Count()); } else query = query.Skip(skip); } else // me return SharedData.Sessions.CurrentSession.followedDriver; if (query.Count() > 0) { StandingsItem si = query.First(); return si; } else return new StandingsItem(); default: if (classname == null) index = standings.IndexOf(standings.Where(f => f.Position.Equals(pos)).FirstOrDefault()); else { query = SharedData.Sessions.CurrentSession.Standings.Where(s => s.Driver.CarClassName == classname).OrderBy(s => s.Position).Skip(pos - 1); if (query.Count() > 0) { StandingsItem si = query.First(); return si; } else return new StandingsItem(); } break; } if (index >= 0) return standings[index]; else return new StandingsItem(); }
IStandingsItem ISessionInfo.FindPosition(int pos, DataOrders order) { return FindPosition(pos, order) as IStandingsItem; }
public StandingsItem FindPosition(int pos, DataOrders order) { return this.FindPosition(pos, order, null); }
IStandingsItem ISessionInfo.FindPosition(int pos, DataOrders order, string classname) { return(FindPosition(pos, order, classname) as IStandingsItem); }
IStandingsItem ISessionInfo.FindPosition(int pos, DataOrders order) { return(FindPosition(pos, order) as IStandingsItem); }
public StandingsItem FindPosition(int pos, DataOrders order, string classname) { int index = -1; int i = 1; IEnumerable <StandingsItem> query; logger.Trace("FindPosition({0} , {1} , {2}) ...", pos, order, classname); switch (order) { case DataOrders.fastestlap: Int32 lastpos = SharedData.Drivers.Count; if (classname == null) { query = SharedData.Sessions.CurrentSession.Standings.OrderBy(s => s.FastestLap); } else { query = SharedData.Sessions.CurrentSession.Standings.Where(s => s.Driver.CarClassName == classname).OrderBy(s => s.FastestLap); } logger.Trace("FastestLap query contains {0}", query.Count()); foreach (StandingsItem si in query) { if (si.FastestLap > 0) { if (i == pos) { index = standings.IndexOf(standings.Where(f => f.Driver.CarIdx.Equals(si.Driver.CarIdx)).FirstOrDefault()); break; } i++; } } // if not found then driver has no finished laps if (index < 0) { if (classname == null) { query = SharedData.Sessions.CurrentSession.Standings.Where(s => s.FastestLap <= 0); } else { query = SharedData.Sessions.CurrentSession.Standings.Where(s => s.Driver.CarClassName == classname).Where(s => s.FastestLap <= 0); } foreach (StandingsItem si in query) { if (i == pos) { index = standings.IndexOf(standings.Where(f => f.Driver.CarIdx.Equals(si.Driver.CarIdx)).FirstOrDefault()); break; } i++; } } break; case DataOrders.previouslap: if (classname == null) { query = SharedData.Sessions.CurrentSession.Standings.OrderBy(s => s.PreviousLap.LapTime); } else { query = SharedData.Sessions.CurrentSession.Standings.Where(s => s.Driver.CarClassName == classname).OrderBy(s => s.PreviousLap.LapTime); } try { foreach (StandingsItem si in query) { if (si.PreviousLap.LapTime > 0) { if (i == pos) { index = standings.IndexOf(standings.Where(f => f.Driver.CarIdx.Equals(si.Driver.CarIdx)).FirstOrDefault()); break; } i++; } } } catch { index = -1; } // if not found then driver has no finished laps if (index < 0) { if (classname == null) { query = SharedData.Sessions.CurrentSession.Standings.Where(s => s.PreviousLap.LapTime <= 0); } else { query = SharedData.Sessions.CurrentSession.Standings.Where(s => s.Driver.CarClassName == classname).Where(s => s.PreviousLap.LapTime <= 0); } foreach (StandingsItem si in query) { if (i == pos) { index = standings.IndexOf(standings.Where(f => f.Driver.CarIdx.Equals(si.Driver.CarIdx)).FirstOrDefault()); break; } i++; } } break; case DataOrders.classposition: query = SharedData.Sessions.CurrentSession.Standings.OrderBy(s => s.Driver.CarClassOrder + s.Position).Skip(pos - 1); if (query.Count() > 0) { StandingsItem si = query.First(); return(si); } else { return(new StandingsItem()); } case DataOrders.points: query = SharedData.Sessions.CurrentSession.Standings.OrderByDescending(s => Convert.ToInt32(s.Driver.ExternalData[SharedData.theme.pointscol])).Skip(pos - 1); if (query.Count() > 0) { StandingsItem si = query.First(); return(si); } else { return(new StandingsItem()); } case DataOrders.liveposition: if (classname == null) { index = standings.IndexOf(standings.Where(f => f.PositionLive.Equals(pos)).FirstOrDefault()); } else { query = SharedData.Sessions.CurrentSession.Standings.Where(s => s.Driver.CarClassName == classname).OrderBy(s => s.PositionLive).Skip(pos - 1); if (query.Count() > 0) { StandingsItem si = query.First(); return(si); } else { return(new StandingsItem()); } } break; case DataOrders.trackposition: if (pos < 0) { // infront int skip = (-pos) - 1; query = SharedData.Sessions.CurrentSession.Standings.Where(s => s.DistanceToFollowed > 0 && s.TrackSurface != SurfaceTypes.NotInWorld).OrderBy(s => s.DistanceToFollowed); if (query.Count() <= skip) { query = SharedData.Sessions.CurrentSession.Standings.Where(s => s.DistanceToFollowed < 0 && s.TrackSurface != SurfaceTypes.NotInWorld).OrderBy(s => s.DistanceToFollowed).Skip((-pos) - 1 - query.Count()); } else { query = query.Skip(skip); } } else if (pos > 0) { // behind int skip = pos - 1; query = SharedData.Sessions.CurrentSession.Standings.Where(s => s.DistanceToFollowed < 0 && s.TrackSurface != SurfaceTypes.NotInWorld).OrderByDescending(s => s.DistanceToFollowed); if (query.Count() <= skip) { query = SharedData.Sessions.CurrentSession.Standings.Where(s => s.DistanceToFollowed > 0 && s.TrackSurface != SurfaceTypes.NotInWorld).OrderByDescending(s => s.DistanceToFollowed).Skip(pos - 1 - query.Count()); } else { query = query.Skip(skip); } } else // me { return(SharedData.Sessions.CurrentSession.followedDriver); } if (query.Count() > 0) { StandingsItem si = query.First(); return(si); } else { return(new StandingsItem()); } default: if (classname == null) { index = standings.IndexOf(standings.Where(f => f.Position.Equals(pos)).FirstOrDefault()); } else { query = SharedData.Sessions.CurrentSession.Standings.Where(s => s.Driver.CarClassName == classname).OrderBy(s => s.Position).Skip(pos - 1); if (query.Count() > 0) { StandingsItem si = query.First(); return(si); } else { return(new StandingsItem()); } } break; } if (index >= 0) { return(standings[index]); } else { return(new StandingsItem()); } }
public StandingsItem FindPosition(int pos, DataOrders order) { return(this.FindPosition(pos, order, null)); }