private static void AddSchedule(TiplocRepository tiprep, List<TiplocCode> tiplocs, ScheduleRepository schedrep, dynamic rowData, int retryCount = 0) { try { AddSchedule(tiplocs, schedrep, rowData); } catch (TiplocNotFoundException tnfe) { TiplocCode t = new TiplocCode { Tiploc = tnfe.Code }; t.TiplocId = tiprep.InsertTiploc(t.Tiploc); tiplocs.Add(t); AddSchedule(tiplocs, schedrep, rowData); } catch (DbException dbe) { Trace.TraceError(dbe.ToString()); if (retryCount <= 3) { Trace.TraceInformation("Retrying"); AddSchedule(tiprep, tiplocs, schedrep, rowData, ++retryCount); } else { Trace.TraceError("Retry count exceeded"); //throw; } } }
private static void AddAssociation(dynamic rowData, List<TiplocCode> tiplocs, TiplocRepository tipRep, AssociationRepository aRep) { try { Association assoc = AssociationJsonMapper.ParseJsonAssociation(rowData.JsonAssociationV1, tiplocs); switch (assoc.TransactionType) { case TransactionType.Create: Trace.TraceInformation("Inserted Association From UID {0} -> {1}, Type {2}, Indicator {3}", assoc.MainTrainUid, assoc.AssocTrainUid, assoc.AssociationType, assoc.STPIndicator); break; case TransactionType.Delete: Trace.TraceInformation("Delete Association UID {0} For {1}", assoc.MainTrainUid, assoc.StartDate); break; } aRep.AddAssociation(assoc); } catch (TiplocNotFoundException tnfe) { TiplocCode t = new TiplocCode { Tiploc = tnfe.Code }; t.TiplocId = tipRep.InsertTiploc(t.Tiploc); tiplocs.Add(t); AddAssociation(rowData, tiplocs, tipRep, aRep); } }
public override int GetHashCode() { unchecked { var hashCode = (int)RecordIdentity; hashCode = (hashCode * 397) ^ (TiplocCode != null ? TiplocCode.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (CapitalsIdentification != null ? CapitalsIdentification.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Nalco != null ? Nalco.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Nlc != null ? Nlc.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (TpsDescription != null ? TpsDescription.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Stanox != null ? Stanox.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (PoMcbCode != null ? PoMcbCode.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (CrsCode != null ? CrsCode.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (CapriDescription != null ? CapriDescription.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (OldTiploc != null ? OldTiploc.GetHashCode() : 0); return(hashCode); } }
private static CachedTrainDetails GetTrainSchedule(string describer, TiplocCode tiploc) { if (string.IsNullOrEmpty(describer) || tiploc == null) return null; return _tmRepo.GetActivatedTrainMovementByHeadcodeAndStop(describer, DateTime.UtcNow, tiploc.Stanox); }
public void InsertTiploc(TiplocCode tiploc) { const string sql = @" INSERT INTO [Tiploc] ([Tiploc] ,[Nalco] ,[Description] ,[Stanox] ,[CRS]) VALUES (@tiploc ,@nalco ,@description ,@stanox ,@crs)"; Query<short>(sql, new { tiploc = tiploc.Tiploc, nalco = tiploc.Nalco, description = tiploc.Description, stanox = tiploc.Stanox, crs = tiploc.CRS }); }