/*public static Guid IncidentTypesMapping(string incidentCode) * { * * string incidentType = string.Empty; * try * { * Dictionary<string, string> dictionary = new Dictionary<string, string>(); * dictionary.Add("0", "B6AB99E8-5DA4-4C33-9EDD-08298A1A2104"); * dictionary.Add("1", "036C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("2", "046C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("3", "056C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("4", "066C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("5", "076C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("6", "086C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("7", "096C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("8", "0A6C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("9", "0B6C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("10", "0C6C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("11", "0D6C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("12", "0E6C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("13", "0F6C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("14", "106C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("15", "116C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("16", "126C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("17", "136C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("18", "146C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("19", "156C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("20", "166C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("21", "176C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("22", "186C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("23", "196C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("24", "1A6C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("25", "356C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("26", "1B6C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("27", "1C6C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("28", "366C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("29", "376C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("30", "386C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("31", "396C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("32", "3A6C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("33", "266C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("34", "1D6C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("35", "276C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("37", "286C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("38", "296C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("39", "2A6C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("40", "2B6C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("41", "1E6C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("42", "1F6C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("43", "206C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("44", "216C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("45", "3B6C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("46", "226C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("47", "236C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("48", "2C6C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("49", "2D6C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("50", "2E6C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("51", "2F6C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("52", "306C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("53", "316C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("54", "246C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("55", "256C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("56", "326C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("57", "336C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("58", "346C8AE2-E700-DF11-AD4B-001517C991CF"); * dictionary.Add("59", "66D07173-ADDF-E111-8706-C82A14062982"); * dictionary.Add("60", "E38FD47E-ADDF-E111-8706-C82A14062982"); * dictionary.Add("61", "02F51487-ADDF-E111-8706-C82A14062982"); * dictionary.Add("62", "B5BF249B-ADDF-E111-8706-C82A14062982"); * dictionary.Add("63", "4FF9BDA6-ADDF-E111-8706-C82A14062982"); * dictionary.Add("64", "5B5C35B0-ADDF-E111-8706-C82A14062982"); * dictionary.Add("65", "427406C7-ADDF-E111-8706-C82A14062982"); * dictionary.Add("66", "84E9B6D0-ADDF-E111-8706-C82A14062982"); * dictionary.Add("67", "338455DA-ADDF-E111-8706-C82A14062982"); * dictionary.Add("68", "26E39FE3-ADDF-E111-8706-C82A14062982"); * dictionary.Add("69", "1192DBEE-ADDF-E111-8706-C82A14062982"); * dictionary.Add("70", "13D0B6F9-ADDF-E111-8706-C82A14062982"); * dictionary.Add("71", "65F54D06-AEDF-E111-8706-C82A14062982"); * dictionary.Add("72", "E9135913-AEDF-E111-8706-C82A14062982"); * dictionary.Add("73", "F7FBBF1C-AEDF-E111-8706-C82A14062982"); * dictionary.Add("74", "6F568B24-AEDF-E111-8706-C82A14062982"); * dictionary.Add("75", "4F19482D-AEDF-E111-8706-C82A14062982"); * dictionary.Add("80", "988787B3-45E4-4845-AE6E-3D392ECEA75D"); * dictionary.Add("81", "31B5401D-AEDF-4807-8006-76CAD267ECD4"); * dictionary.Add("82", "B3C59AEC-C343-401F-AC36-855811BBAC97"); * dictionary.Add("84", "D121C4ED-3998-4E3F-A126-8C8D944BD0D8"); * dictionary.Add("87", "B03BE6C0-92D1-462A-B8A1-C463E88752E1"); * dictionary.Add("92", "CF06DED5-5048-46EC-AB28-902E95BBD8F5"); * dictionary.Add("93", "81FCAD31-5A18-4666-89BC-D5E8895E15C3"); * dictionary.Add("94", "7F9746B5-9854-4AA5-A982-E18E54FE2729"); * dictionary.Add("1000", "A0EDDE4E-AB26-DF11-BA8B-001517C991CF"); * dictionary.Add("1001", "5047FF60-AB26-DF11-BA8B-001517C991CF"); * dictionary.Add("1002", "70A24C7A-AB26-DF11-BA8B-001517C991CF"); * dictionary.Add("1003", "3001A02D-AE26-DF11-BA8B-001517C991CF"); * dictionary.Add("1004", "D1E31F77-BC26-DF11-BA8B-001517C991CF"); * dictionary.Add("1005", "B0872692-BC26-DF11-BA8B-001517C991CF"); * dictionary.Add("1006", "000BC09D-BC26-DF11-BA8B-001517C991CF"); * dictionary.Add("1007", "D5CC02E2-ED9E-DF11-A601-001517DD2D44"); * dictionary.Add("5001", "35064552-AEDF-E111-8706-C82A14062982"); * dictionary.Add("5002", "2062AF5A-AEDF-E111-8706-C82A14062982"); * dictionary.Add("5003", "9A60B261-AEDF-E111-8706-C82A14062982"); * dictionary.Add("5004", "8E4ADB6C-AEDF-E111-8706-C82A14062982"); * dictionary.Add("5005", "346E8874-AEDF-E111-8706-C82A14062982"); * dictionary.Add("5006", "356E8874-AEDF-E111-8706-C82A14062982"); * dictionary.Add("5007", "6BA4C782-AEDF-E111-8706-C82A14062982"); * dictionary.Add("5008", "5BF3438A-AEDF-E111-8706-C82A14062982"); * dictionary.Add("5009", "59C10497-AEDF-E111-8706-C82A14062982"); * dictionary.Add("5010", "F20D089E-AEDF-E111-8706-C82A14062982"); * dictionary.Add("5011", "A35DBCA5-AEDF-E111-8706-C82A14062982"); * dictionary.Add("5012", "F1758DAC-AEDF-E111-8706-C82A14062982"); * dictionary.Add("5013", "4DD4A6B2-AEDF-E111-8706-C82A14062982"); * dictionary.Add("5014", "90632CB9-AEDF-E111-8706-C82A14062982"); * dictionary.Add("5015", "BCE785C0-AEDF-E111-8706-C82A14062982"); * dictionary.Add("5016", "921B08C7-AEDF-E111-8706-C82A14062982"); * dictionary.Add("5017", "09CCACCD-AEDF-E111-8706-C82A14062982"); * dictionary.Add("5018", "509516DC-AEDF-E111-8706-C82A14062982"); * dictionary.Add("5019", "204135E4-AEDF-E111-8706-C82A14062982"); * dictionary.Add("5020", "FDADACEB-AEDF-E111-8706-C82A14062982"); * dictionary.Add("5021", "FEADACEB-AEDF-E111-8706-C82A14062982"); * dictionary.Add("5022", "4EB687F5-AEDF-E111-8706-C82A14062982"); * dictionary.Add("5023", "4FB687F5-AEDF-E111-8706-C82A14062982"); * dictionary.Add("5024", "E1F99A03-AFDF-E111-8706-C82A14062982"); * dictionary.Add("5025", "E2F99A03-AFDF-E111-8706-C82A14062982"); * dictionary.Add("5026", "2AD55E10-AFDF-E111-8706-C82A14062982"); * dictionary.Add("5027", "0A51A2F5-B2DF-E111-8706-C82A14062982"); * dictionary.Add("5028", "0AC85655-231C-E211-97C6-E0F8473BA773"); * dictionary.Add("5029", "D05B3362-231C-E211-97C6-E0F8473BA773"); * dictionary.Add("5030", "B67D5432-7B2D-4955-ACE1-BA21F56F155F"); * dictionary.Add("5031", "AB433CA4-EEE2-434E-A4B3-3A73550FEE02"); * dictionary.Add("5032", "28592B49-5215-417A-A6A2-10B4CFEEF7CE"); * dictionary.Add("5033", "30F4A098-245B-46C2-BBC4-EA104F546E56"); * dictionary.Add("5034", "E4898572-0076-49F7-830F-88E37ABE6556"); * dictionary.Add("5035", "0F2197B7-0D82-42C6-B772-DEBAA8624AD5"); * dictionary.Add("5036", "286A5A3B-B496-46B5-B8D7-033CCE9D32E9"); * dictionary.Add("5037", "703ABBC7-7FD2-4161-8081-2D7223C8169A"); * dictionary.Add("5038", "FDDC4B3C-84F0-4B04-ABF8-C19BD58C6A86"); * dictionary.Add("5039", "37138ABA-A01B-442A-86AC-1B060871C98A"); * dictionary.Add("5040", "0606549B-7DFF-4219-9C1A-EC57E479B3B0"); * dictionary.Add("5041", "3A170926-5689-4BEB-B6F1-E5F93452553F"); * dictionary.Add("5042", "A7D5275E-B5DD-40E1-9EAD-FAE96B526E6B"); * dictionary.Add("5043", "D0700273-3E27-40DB-962C-A3DC44AF37BA"); * dictionary.Add("5044", "28BC43D4-C88F-4F02-A5C7-1285F0530706"); * dictionary.Add("5045", "A7020A3C-62F1-478E-A74D-D66BA82F08E0"); * dictionary.Add("5046", "9EA66238-B66B-4BCE-A5CD-7ED40267D31C"); * dictionary.Add("5047", "06B473E6-E7A8-45E4-93BD-B3033CDE7C88"); * dictionary.Add("5048", "2157A470-B777-424C-B4A5-5743459B90E5"); * dictionary.Add("5061", "658F8C01-1BD0-4A52-9870-4482AFBD4655"); * dictionary.Add("5062", "2B12CE23-8C6B-4732-8C7A-B9187B0B538E"); * dictionary.Add("5063", "161A9328-BE23-4C29-B9D6-9C506C9F9F4F"); * dictionary.Add("5064", "7E3C436E-29B3-4E85-BA69-70830ECABCD1"); * dictionary.Add("5065", "9420798F-433B-4245-AF0B-320C8FD39B7A"); * dictionary.Add("5066", "D73B84D4-5E2A-4EA2-9F9D-0916E941B206"); * dictionary.Add("5067", "2D199674-B098-484A-A861-BB0B0E8D1862"); * dictionary.Add("5068", "755DE521-8DA3-4E99-948C-C87C71FAFBF8"); * dictionary.Add("5069", "58640300-C388-43C1-B545-BC656CBE3952"); * dictionary.Add("5100", "7AA9E945-192E-E511-BB65-001917BD1D46"); * dictionary.Add("10000", "CA60A87F-8F5D-DF11-934B-001517C991CF"); * * //Add 300 range * * dictionary.Add("300", "B6AB99E8-5DA4-4C33-9EDD-08298A1A2104");//BatteryCharging = undefined on intertoll * dictionary.Add("301", "FDDC4B3C-84F0-4B04-ABF8-C19BD58C6A86"); //AVC Critical Mode Start * dictionary.Add("302", "37138ABA-A01B-442A-86AC-1B060871C98A");//AVC Critical Mode Ended * dictionary.Add("303", "0606549B-7DFF-4219-9C1A-EC57E479B3B0");//AVC Serious Mode Start * dictionary.Add("304", "3A170926-5689-4BEB-B6F1-E5F93452553F");//AVC Serious Mode Ended * dictionary.Add("305", "B6AB99E8-5DA4-4C33-9EDD-08298A1A2104"); * dictionary.Add("306", "B6AB99E8-5DA4-4C33-9EDD-08298A1A2104"); * dictionary.Add("307", "B6AB99E8-5DA4-4C33-9EDD-08298A1A2104"); * dictionary.Add("308", "B6AB99E8-5DA4-4C33-9EDD-08298A1A2104"); * dictionary.Add("309", "509516DC-AEDF-E111-8706-C82A14062982"); * dictionary.Add("310", "2AD55E10-AFDF-E111-8706-C82A14062982"); * dictionary.Add("311", "B6AB99E8-5DA4-4C33-9EDD-08298A1A2104"); * dictionary.Add("312", "B6AB99E8-5DA4-4C33-9EDD-08298A1A2104"); * dictionary.Add("313", "B6AB99E8-5DA4-4C33-9EDD-08298A1A2104"); * dictionary.Add("314", "B6AB99E8-5DA4-4C33-9EDD-08298A1A2104"); * dictionary.Add("315", "B6AB99E8-5DA4-4C33-9EDD-08298A1A2104"); * dictionary.Add("316", "B6AB99E8-5DA4-4C33-9EDD-08298A1A2104"); * dictionary.Add("317", "B6AB99E8-5DA4-4C33-9EDD-08298A1A2104"); * dictionary.Add("318", "B6AB99E8-5DA4-4C33-9EDD-08298A1A2104"); * dictionary.Add("319", "B6AB99E8-5DA4-4C33-9EDD-08298A1A2104"); * dictionary.Add("320", "B6AB99E8-5DA4-4C33-9EDD-08298A1A2104"); * dictionary.Add("321", "B6AB99E8-5DA4-4C33-9EDD-08298A1A2104"); * dictionary.Add("322", "658F8C01-1BD0-4A52-9870-4482AFBD4655"); * * if (dictionary.ContainsKey(incidentCode) == true) * { * incidentType = dictionary[incidentCode]; * } * } * catch (Exception ex) * { * } * * return Guid.Parse(incidentType); * } */ public static List <TariffMapping> TariffMapping() { using (PCSStagingDataContext dc = new PCSStagingDataContext()) { return(dc.TariffMappings.Get().ToList()); } }
public static Guid IncidentTypes(int incidentCode) { using (PCSStagingDataContext dc = new PCSStagingDataContext()) { return((Guid)dc.GeIncidentTypes().FirstOrDefault(x => x.Id == incidentCode).IncidentGuid); } }
public static List <PaymentTypesMapping> PaymentTypesMapping() { using (PCSStagingDataContext dc = new PCSStagingDataContext()) { return(dc.PaymentTypesMappings.Get().ToList()); } }
private static bool SendIncident(PCSStagingDataContext dc, Incident incidentData) { Log.LogInfoMessage(string.Format("[Enter] sending incident Lane{0} Sequence{1}", incidentData.LaneCode, incidentData.IncidentSeqNr)); //StaffLogin var LaneCode = LookupManager.Lanes(incidentData.LaneCode); var staffLogin = dc.StaffLogins.FirstOrDefault(x => x.LocationGUID == LaneCode && x.StartDate <= incidentData.IncidentSetDate && x.EndDate >= incidentData.IncidentSetDate); if (staffLogin == null) { Log.LogErrorMessage(string.Format("Staff login not found: incidentset date ({0})", incidentData.IncidentSetDate)); return(false); } var syncIncident = new Intertoll.Data.Incident(); //add Incident syncIncident.Description = incidentData.Description; syncIncident.IncidentGUID = Guid.NewGuid(); syncIncident.IncidentSeqNr = (int)incidentData.IncidentSeqNr; syncIncident.IncidentSetDate = incidentData.IncidentSetDate; syncIncident.IncidentStatusGUID = Guid.Parse("F10FE5B2-7ED3-DE11-9533-001517C991CF"); syncIncident.IncidentTypeGUID = LookupManager.IncidentTypes(incidentData.IncidentCode); syncIncident.LaneSeqNr = (int)incidentData.LaneSeqNr; syncIncident.LastIncidentSeqNr = null; syncIncident.StaffLoginGUID = staffLogin.StaffLoginGUID; long Transaction_Identifier = 0; if (long.TryParse(incidentData.Transaction_Identifier, out Transaction_Identifier)) { if (Transaction_Identifier > 0) { var transaction = dc.Transactions.FirstOrDefault(x => x.Transaction_Identifier == incidentData.Transaction_Identifier && x.LaneCode == incidentData.LaneCode); if (transaction != null) { syncIncident.TransactionGUID = transaction.TransGuid == null ? (Guid?)null : transaction.TransGuid; } else { Log.LogFatal(string.Format("Incident without a transaction: Lane{0} Sequence:{1}", incidentData.LaneCode, incidentData.IncidentSeqNr)); return(false); } } } Sync.Client.SyncClient.SubmitIncident(syncIncident); Log.LogInfoMessage(string.Format("[Exit] sending incident Lane{0} Sequence{1}", incidentData.LaneCode, incidentData.IncidentSeqNr)); return(true); }
static public void SendTransactions(int _LaneID, List <int> _SequenceNumbers) { using (PCSStagingDataContext dc = new PCSStagingDataContext()) { int TransactionsFound = 0; //foreach (var sequenceNumber in _SequenceNumbers) { try { string laneCode = LookupManager.Lanes(_LaneID); var foundTransactions = dc.Transactions.Where(x => x.LaneCode == laneCode && _SequenceNumbers.Contains(x.LaneTransSeqNr)); foreach (var foundTransaction in foundTransactions) { Log.LogTrace(foundTransaction.LaneTransSeqNr + " found in sent items "); if (SendTransaction(dc, foundTransaction)) { TransactionsFound++; } } foreach (var sequenceNumber in _SequenceNumbers.Except(foundTransactions.Select(x => x.LaneTransSeqNr))) { Log.LogTrace(string.Format("requesting {0} : {1}", _LaneID, sequenceNumber)); var foundTransactionData = dc.GetTransactionByTransactionSeqNumber(_LaneID, sequenceNumber); if (foundTransactionData != null) { Log.LogTrace(sequenceNumber + " found in SV DB "); if (SendTransaction(dc, foundTransactionData)) { TransactionsFound++; } } } } catch (Exception ex) { Log.LogException(ex); } } Log.LogInfoMessage("Found transactions" + "(" + _LaneID + ")" + TransactionsFound + "/" + _SequenceNumbers.Count); } }
private void SendAudits(int _LaneID, List <int> _Hours) { var AuditsFound = new List <uspGetAuditByLaneAndHour_Result>(); using (PCSStagingDataContext dc = new PCSStagingDataContext()) { foreach (var hour in _Hours) { var foundAudit = dc.GetLaneAudit(_LaneID, hour); if (foundAudit != null) { AuditsFound.Add(foundAudit); } } Log.LogInfoMessage("Found entities " + AuditsFound); } }
public static void SendIncidents(int _LaneID, List <int> _SequenceNumbers) { if (_SequenceNumbers.Count < 11) { Log.LogInfoMessage(_LaneID + ": " + _SequenceNumbers.Aggregate((a, b) => a + ',' + b)); } var IncidentsFound = 0; using (PCSStagingDataContext dc = new PCSStagingDataContext()) { foreach (var sequenceNumber in _SequenceNumbers) { string laneCode = LookupManager.Lanes(_LaneID); var foundIncident = dc.Incidents.FirstOrDefault(x => x.LaneCode == laneCode && x.IncidentSeqNr == sequenceNumber); if (foundIncident != null) { Log.LogTrace(sequenceNumber + " found in sent items "); if (SendIncident(dc, foundIncident)) { IncidentsFound++; } } else { var foundIncidentData = dc.GetIncidentByIncidentSeqNumber(_LaneID, sequenceNumber); Log.LogTrace(sequenceNumber + " found in SV DB "); if (foundIncidentData != null) { if (SendIncident(dc, foundIncidentData)) { IncidentsFound++; } } } } Log.LogInfoMessage("Found incidents " + "(" + _LaneID + ")" + IncidentsFound + "/" + _SequenceNumbers.Count); } }
private static void SaveIncident(Intertoll.Data.Incident realIncident, uspGetIncidentByLaneAndSeq_Result dbIncident, Guid staffLoginGuid, Boolean transactionExist) { try { //Insert into DB using (var context = new PCSStagingDataContext()) { context.Incidents.Insert( new Incident() { CollectorID = dbIncident.CollectorID.HasValue ? (int)dbIncident.CollectorID : (int?)null, Description = dbIncident.Description, Incident_Identifier = dbIncident.Incident_Identifier.ToString(), IncidentAckDate = realIncident.IncidentAckDate, IncidentClearedDate = realIncident.IncidentClearedDate, IncidentCode = dbIncident.IncidentCode, IncidentGUID = realIncident.IncidentGUID, IncidentSeqNr = realIncident.IncidentSeqNr, IncidentSetDate = realIncident.IncidentSetDate, IncidentStatusGUID = realIncident.IncidentStatusGUID, IncidentTypeGUID = realIncident.IncidentTypeGUID, LaneCode = dbIncident.LaneCode, LaneSeqNr = realIncident.LaneSeqNr, LastIncidentSeqNr = realIncident.LastIncidentSeqNr, StaffLoginGUID = staffLoginGuid, TimeStamp = DateTime.Now, Transaction_Identifier = dbIncident.Transaction_Identifier.ToString(), TransactionGUID = realIncident.TransactionGUID, TransactionExist = transactionExist }); context.Save(); } } catch (Exception ex) { Log.LogException(ex); } }
private static bool SendTransaction(PCSStagingDataContext dc, Transaction _Transaction) { Log.LogInfoMessage(string.Format("[Enter] sending previously sent transaction Lane{0} Sequence{1}", _Transaction.LaneCode, _Transaction.LaneTransSeqNr)); var syncTransaction = new Intertoll.Data.Transaction(); // Account user details if (!(string.IsNullOrWhiteSpace(_Transaction.FrequentUserPANNumber))) { var accountuser = dc.GetAccountUserDetails(_Transaction.FrequentUserPANNumber); if (accountuser == null) { Log.LogFatal("Account user details not found PAN: " + _Transaction.FrequentUserPANNumber); return(false); } syncTransaction.AccountGUID = accountuser.AccountGUID; syncTransaction.AccountUserGUID = accountuser.AccountUserGUID; } Log.LogTrace("SessioGuid: " + _Transaction.SessionGuid); //add transaction syncTransaction.AppliedClassGUID = _Transaction.CollectorClass; syncTransaction.AVCClassGUID = _Transaction.AVCClass; syncTransaction.AVCSeqNr = _Transaction.AVCSeqNr; syncTransaction.ColClassGUID = _Transaction.CollectorClass; syncTransaction.CurrencyGUID = new Guid("942190CD-5053-41B4-9A08-CD472C99ECAF"); syncTransaction.ExchangeRate = new Guid("5A5AE37F-AABC-428D-B4DC-2B4C87B8646C"); syncTransaction.IsKeyed = _Transaction.IsKeyed.HasValue && (bool)_Transaction.IsKeyed; syncTransaction.LaneTransSeqNr = (int)(_Transaction.LaneTransSeqNr); syncTransaction.LicensePlate = _Transaction.LicensePlate; syncTransaction.PaymentDetail = EncryptString(_Transaction.LaneCode, _Transaction.BankCardNumber, GetExpiryDateFromTrack2(_Transaction.BankCardExpiryDate, _Transaction.BankCardNumber)); syncTransaction.PaymentGroupGUID = new Guid(_Transaction.PaymentGroup); syncTransaction.PaymentMechGUID = new Guid(_Transaction.PaymentMech); syncTransaction.PaymentMethodGUID = new Guid(_Transaction.PaymentMethod); syncTransaction.PaymentTypeGUID = new Guid(_Transaction.PaymentType); syncTransaction.PreviousLicensePlate = null; syncTransaction.PreviousPaymentMethodGUID = null; syncTransaction.RealClassGUID = null; syncTransaction.ReceiptCount = _Transaction.ReceiptCount.HasValue ? _Transaction.ReceiptCount : null; syncTransaction.ReceiptTaxInvoiceDate = _Transaction.ReceiptTaxInvoiceDate; syncTransaction.SessionGUID = _Transaction.SessionGuid; syncTransaction.TariffAmount = _Transaction.TariffAmount; syncTransaction.TariffGUID = _Transaction.TariffGuid; syncTransaction.TariffVat = 0; syncTransaction.TaxInvNr = _Transaction.TaxInvNr; syncTransaction.TotalInLocalCurrency = _Transaction.TariffAmount; syncTransaction.TransDate = _Transaction.TransactionDate; syncTransaction.TransStartDate = _Transaction.TransactionStartDate; syncTransaction.TransGUID = _Transaction.TransGuid; syncTransaction.AVCDetail = _Transaction.AvcStatus; if (_Transaction.ETCTransactionGUID.HasValue) { var etcTransaction = new Intertoll.Data.ETCTransaction(); var IAuthenticator = new Intertoll.Data.ETCIAuthenticator(); var OAuthenticator = new Intertoll.Data.ETCOAuthenticator(); IAuthenticator.Authenticator = _Transaction.IssuerAuthenticator_DData; IAuthenticator.AuthenticatorGuid = _Transaction.IssuerAuthenticatorGuid.Value; IAuthenticator.KeyRef = _Transaction.IssuerAuthenticator_KRef; IAuthenticator.Nonce = _Transaction.IssuerAuthenticator_MAC; //TODO ??Confirm OAuthenticator.Authenticator = _Transaction.OperatorAuthenticator_DData; OAuthenticator.AuthenticatorGuid = _Transaction.OperatorAuthenticatorGuid.Value; OAuthenticator.KeyRef = _Transaction.OperatorAuthenticator_KRef; OAuthenticator.Nonce = _Transaction.OperatorAuthenticator_MAC; //TODO ??Confirm etcTransaction.ClassGUID = _Transaction.TagClass.HasValue ? LookupManager.Classes((Int32)_Transaction.TagClass) : new Guid("57C3EBAF-AD68-46CB-B048-3E9E9F1D5F74"); etcTransaction.ContextMarkId = short.Parse(_Transaction.ContextMark); etcTransaction.ETCTransactionGuid = _Transaction.ETCTransactionGUID.Value; etcTransaction.ExpiryDate = string.Empty; etcTransaction.IDVL = (long)_Transaction.IDVL; etcTransaction.IssuerAuthenticatorGuid = IAuthenticator.AuthenticatorGuid; etcTransaction.LaneTransSeqNr = _Transaction.LaneTransSeqNr; etcTransaction.LicensePlate = _Transaction.LicensePlate; etcTransaction.OperatorAuthenticatorGuid = OAuthenticator.AuthenticatorGuid; etcTransaction.PAN = long.Parse(_Transaction.PAN); etcTransaction.VehichleState = _Transaction.TagStatus; syncTransaction.ETCTransactionGuid = etcTransaction.ETCTransactionGuid; Sync.Client.SyncClient.SubmitETCTransaction(syncTransaction, etcTransaction, IAuthenticator, OAuthenticator); } else { Sync.Client.SyncClient.SubmitTransaction(syncTransaction); } Log.LogInfoMessage(string.Format("[Exit] sending previously sent transaction Lane{0} Sequence{1}", _Transaction.LaneCode, _Transaction.LaneTransSeqNr)); return(true); }
private static void SaveTransaction(Intertoll.Data.Transaction realTransaction, Intertoll.Data.ETCTransaction etcTransaction, Intertoll.Data.ETCIAuthenticator IAuthenticator, Intertoll.Data.ETCOAuthenticator OAuthenticator, uspGetTransactionByLaneAndSeq_Result dbTransaction) { try { //Insert into DB using (var context = new PCSStagingDataContext()) { context.Transactions.Insert( new Transaction() { ANPRLicensePlate = realTransaction.ANPRLicensePlate, AVCClass = realTransaction.AVCClassGUID.HasValue ? realTransaction.AVCClassGUID : (Guid?)null, AVCSeqNr = realTransaction.AVCSeqNr, AvcStatus = realTransaction.AVCDetail, BankCardExpiryDate = dbTransaction.BankCardExpiryDate, BankCardNumber = dbTransaction.BankCardNumber, CollectorClass = realTransaction.ColClassGUID.HasValue ? realTransaction.ColClassGUID : (Guid?)null, CollectorID = dbTransaction.CollectorID.HasValue ? (int)dbTransaction.CollectorID : 0, SessionGuid = realTransaction.SessionGUID, ContextMark = dbTransaction.ContextMark, ContextMarkId = etcTransaction.ContextMarkId, ETCTransactionGUID = realTransaction.ETCTransactionGuid.HasValue ? realTransaction.ETCTransactionGuid : (Guid?)null, FrequentUserPANNumber = dbTransaction.FrequentUserPANNumber, AccountUserGUID = realTransaction.AccountUserGUID, IDVL = etcTransaction.IDVL, IsKeyed = realTransaction.IsKeyed, IssuerAuthenticator_DData = IAuthenticator.Authenticator, IssuerAuthenticator_DMAC = dbTransaction.IssuerAuthenticator_DMAC, IssuerAuthenticator_KRef = IAuthenticator.KeyRef, IssuerAuthenticator_KSID = dbTransaction.IssuerAuthenticator_KSID, IssuerAuthenticator_KV = dbTransaction.IssuerAuthenticator_KV.ToString(), IssuerAuthenticator_MAC = IAuthenticator.Nonce, IssuerAuthenticatorGuid = etcTransaction.IssuerAuthenticatorGuid, LaneCode = dbTransaction.LaneCode, LaneStatus = realTransaction.LaneStatusGUID.ToString(), LaneTransSeqNr = realTransaction.LaneTransSeqNr, LicensePlate = realTransaction.LicensePlate, OperatorAuthenticator_DData = OAuthenticator.Authenticator, OperatorAuthenticator_DMAC = dbTransaction.OperatorAuthenticator_DMAC, OperatorAuthenticator_KRef = OAuthenticator.KeyRef, OperatorAuthenticator_KSID = dbTransaction.OperatorAuthenticator_KSID, OperatorAuthenticator_KV = dbTransaction.OperatorAuthenticator_MAC, OperatorAuthenticator_MAC = OAuthenticator.Nonce, OperatorAuthenticatorGuid = etcTransaction.OperatorAuthenticatorGuid, PAN = etcTransaction.PAN.ToString(), PaymentGroup = realTransaction.PaymentGroupGUID.ToString(), PaymentMech = realTransaction.PaymentMechGUID.ToString(), PaymentMethod = realTransaction.PaymentMethodGUID.ToString(), PaymentType = realTransaction.PaymentTypeGUID.ToString(), ReceiptCount = realTransaction.ReceiptCount, ReceiptTaxInvoiceDate = realTransaction.ReceiptTaxInvoiceDate, Shift_Identifier = dbTransaction.Shift_Identifier.HasValue ? dbTransaction.Shift_Identifier.ToString() : null, TagClass = dbTransaction.TagClass, TagStatus = etcTransaction.VehichleState, TariffAmount = realTransaction.TariffAmount, TaxInvNr = realTransaction.TaxInvNr, TimeStamp = DateTime.Now, Transaction_Identifier = dbTransaction.Transaction_Identifier.ToString(), TransactionDate = realTransaction.TransDate, TransactionStartDate = realTransaction.TransStartDate, TransGuid = realTransaction.TransGUID, TariffGuid = (Guid)realTransaction.TariffGUID, TAGEFCM = dbTransaction.TAGEFCM, TAGMAID = dbTransaction.TAGMAID, TAGOBUID = dbTransaction.TAGOBUID }); context.Save(); } } catch (Exception ex) { Log.LogException(ex); } }
public static DateTime GetExpiryDateFromTrack2(string data, string bankCardNumber) { var expiryDate = new DateTime(); try { if (string.IsNullOrWhiteSpace(bankCardNumber)) { return(expiryDate); } if (string.IsNullOrWhiteSpace(data)) { //check if processed before and assign that expiry date otherwise next month as expiry date var context = new PCSStagingDataContext(); var trans = context.Transactions.FirstOrDefault(x => x.BankCardNumber == bankCardNumber && !(x.BankCardExpiryDate.Trim() == string.Empty || x.BankCardExpiryDate == null)); if (trans != null && !string.IsNullOrWhiteSpace(trans.BankCardExpiryDate)) { Log.LogTrace(string.Format("bankCardNumber : {0}, has no expiry date, assigned Track2 from previous transaction Track2:{1}, transaction: {2}", bankCardNumber, trans.BankCardExpiryDate, trans.TransGuid)); data = trans.BankCardExpiryDate; //ServiceAgentManager.SendReport(string.Format("bankCardNumber : {0}, has no expiry date, assigned Track2 from previous transaction Track2:{1}, transaction: {2}", bankCardNumber, trans.BankCardExpiryDate, trans.TransGuid), 1); } else { expiryDate = GetDefaultExpiryDate(); Log.LogTrace(string.Format("bankCardNumber : {0}, has no expiry date, default date assigned: {1}", bankCardNumber, expiryDate)); //ServiceAgentManager.SendReport(string.Format("bankCardNumber : {0}, has no expiry date, default date assigned: {1}", bankCardNumber, expiryDate), 1); return(expiryDate); } } var yearMonthStr = data.Split('=')[1]; var pos = data.IndexOf('='); var text = data.Substring(pos + 1); var yearMonthInt = new string(text.Where(c => char.IsDigit(c)).ToArray()); if (yearMonthInt.Length < 4) { expiryDate = GetDefaultExpiryDate(); Log.LogTrace(string.Format("bankCardNumber : {0}, has invalid expiry date from Track2: {1}, default date assigned: {2}", bankCardNumber, data, expiryDate)); //ServiceAgentManager.SendReport(string.Format("bankCardNumber : {0}, has invalid expiry date from Track2: {1}, default date assigned: {2}", bankCardNumber, data, expiryDate), 1); return(expiryDate); } var yearMonth = yearMonthInt.Substring(0, 4); var year = yearMonth.Substring(0, 2); var month = yearMonth.Substring(2, 2); var dateString = "20" + year + "/" + month + "/1"; if (!DateTime.TryParse(dateString, out expiryDate)) { expiryDate = GetDefaultExpiryDate(); Log.LogTrace(string.Format("bankCardNumber : {0}, has invalid expiry date from Track2: {1}, default date assigned {2}", bankCardNumber, data, expiryDate)); //ServiceAgentManager.SendReport(string.Format("bankCardNumber : {0}, has invalid expiry date from Track2: {1}, default date assigned {2}", bankCardNumber, data, expiryDate), 1); return(expiryDate); } } catch (Exception ex) { Log.LogTrace(data); Log.LogException(ex); //ServiceAgentManager.SendReport(string.Format("GetExpiryDateFromTrack2 Failed: Card: {0}; Data: {1}", bankCardNumber, data), 1); return(GetDefaultExpiryDate()); } return(expiryDate); }
private static bool SendTransaction(PCSStagingDataContext dc, uspGetTransactionByLaneAndSeq_Result TransactionData) { Log.LogInfoMessage(string.Format("[Enter] sending transaction Lane{0} Sequence{1}", TransactionData.LaneCode, TransactionData.LaneTransSeqNr)); var syncTransaction = new Intertoll.Data.Transaction(); // Account user details if (!(string.IsNullOrWhiteSpace(TransactionData.FrequentUserPANNumber))) { var accountuser = dc.GetAccountUserDetails(TransactionData.FrequentUserPANNumber); if (accountuser == null) { Log.LogFatal("Account user details not found PAN: " + TransactionData.FrequentUserPANNumber); return(false); } syncTransaction.AccountGUID = accountuser.AccountGUID; syncTransaction.AccountUserGUID = accountuser.AccountUserGUID; } // Session var session = dc.Sessions.FirstOrDefault(x => x.StartDate <= TransactionData.TransactionDate && (x.EndDate >= TransactionData.TransactionDate || x.EndDate == null) && x.LaneCode == TransactionData.LaneCode) ; if (session == null) { Log.LogFatal(string.Format("Session not found: time({0}),lane({1})", TransactionData.TransactionDate, TransactionData.LaneCode)); return(false); } Log.LogTrace("SessioGuid: " + session.SessionGUID); //add transaction syncTransaction.AppliedClassGUID = TransactionData.CollectorClass.MappedClass(); syncTransaction.AVCClassGUID = TransactionData.AVCClass.MappedClass(); syncTransaction.AVCSeqNr = (int)TransactionData.AVCSeqNr; syncTransaction.ColClassGUID = TransactionData.CollectorClass.MappedClass(); syncTransaction.CurrencyGUID = new Guid("942190CD-5053-41B4-9A08-CD472C99ECAF"); syncTransaction.ExchangeRate = new Guid("5A5AE37F-AABC-428D-B4DC-2B4C87B8646C"); syncTransaction.IsKeyed = TransactionData.IsKeyed.HasValue && (bool)TransactionData.IsKeyed; syncTransaction.LaneTransSeqNr = (int)(TransactionData.LaneTransSeqNr); syncTransaction.LicensePlate = TransactionData.LicensePlate; syncTransaction.PaymentDetail = EncryptString(TransactionData.LaneCode, TransactionData.BankCardNumber, GetExpiryDateFromTrack2(TransactionData.BankCardExpiryDate, TransactionData.BankCardNumber)); syncTransaction.PaymentGroupGUID = TransactionData.PaymentGroup.MappedPaymentGroup(); syncTransaction.PaymentMechGUID = TransactionData.PaymentMech.MappedPaymentMech(); syncTransaction.PaymentMethodGUID = TransactionData.PaymentMethod.MappedPaymentMethod(); syncTransaction.PaymentTypeGUID = TransactionData.PaymentType.MappedPaymentType(); syncTransaction.PreviousLicensePlate = null; syncTransaction.PreviousPaymentMethodGUID = null; syncTransaction.RealClassGUID = null; syncTransaction.ReceiptCount = TransactionData.ReceiptCount.HasValue ? (int)TransactionData.ReceiptCount : (int?)null; syncTransaction.ReceiptTaxInvoiceDate = TransactionData.ReceiptTaxInvoiceDate; syncTransaction.SessionGUID = session.SessionGUID; syncTransaction.TariffAmount = (decimal)TransactionData.TariffAmount; syncTransaction.TariffGUID = TransactionData.VirtualPlazaID.MappedTariff(TransactionData.CollectorClass, TransactionData.TollTariffPlanID);; syncTransaction.TariffVat = 0; syncTransaction.TaxInvNr = TransactionData.TaxInvNr; syncTransaction.TotalInLocalCurrency = (decimal)TransactionData.TariffAmount; syncTransaction.TransDate = TransactionData.TransactionDate; syncTransaction.TransStartDate = TransactionData.TransactionStartDate; syncTransaction.TransGUID = Guid.NewGuid(); syncTransaction.AVCDetail = TransactionData.AvcStatus; if (!(string.IsNullOrWhiteSpace(TransactionData.ETCTransactionGUID))) { var etcTransaction = new Intertoll.Data.ETCTransaction(); var IAuthenticator = new Intertoll.Data.ETCIAuthenticator(); var OAuthenticator = new Intertoll.Data.ETCOAuthenticator(); IAuthenticator.Authenticator = TransactionData.IssuerAuthenticator_DData; IAuthenticator.AuthenticatorGuid = Guid.NewGuid(); IAuthenticator.KeyRef = TransactionData.IssuerAuthenticator_KRef.ToString(); IAuthenticator.Nonce = TransactionData.IssuerAuthenticator_MAC; //TODO ??Confirm OAuthenticator.Authenticator = TransactionData.OperatorAuthenticator_DData; OAuthenticator.AuthenticatorGuid = Guid.NewGuid(); OAuthenticator.KeyRef = TransactionData.OperatorAuthenticator_KRef.ToString(); OAuthenticator.Nonce = TransactionData.OperatorAuthenticator_MAC; //TODO ??Confirm etcTransaction.ClassGUID = TransactionData.TagClass.HasValue ? LookupManager.Classes((Int32)TransactionData.TagClass) : new Guid("57C3EBAF-AD68-46CB-B048-3E9E9F1D5F74"); etcTransaction.ContextMarkId = short.Parse(TransactionData.ContextMark); etcTransaction.ETCTransactionGuid = Guid.Parse(TransactionData.ETCTransactionGUID); etcTransaction.ExpiryDate = string.Empty; etcTransaction.IDVL = (long)TransactionData.IDVL; etcTransaction.IssuerAuthenticatorGuid = IAuthenticator.AuthenticatorGuid; etcTransaction.LaneTransSeqNr = TransactionData.LaneTransSeqNr; etcTransaction.LicensePlate = TransactionData.LicensePlate; etcTransaction.OperatorAuthenticatorGuid = OAuthenticator.AuthenticatorGuid; etcTransaction.PAN = long.Parse(TransactionData.PAN); etcTransaction.VehichleState = TransactionData.TagStatus; syncTransaction.ETCTransactionGuid = etcTransaction.ETCTransactionGuid; SaveTransaction(syncTransaction, etcTransaction, IAuthenticator, OAuthenticator, TransactionData); Sync.Client.SyncClient.SubmitETCTransaction(syncTransaction, etcTransaction, IAuthenticator, OAuthenticator); } else { SaveTransaction(syncTransaction, new Intertoll.Data.ETCTransaction(), new Intertoll.Data.ETCIAuthenticator(), new Intertoll.Data.ETCOAuthenticator(), TransactionData); Sync.Client.SyncClient.SubmitTransaction(syncTransaction); } Log.LogInfoMessage(string.Format("[Exit] sending transaction Lane{0} Sequence{1}", TransactionData.LaneCode, TransactionData.LaneTransSeqNr)); return(true); }