private static void WalkVehicleMileageRetForAdd(XmlNode VehicleMileageRet) { if (VehicleMileageRet == null) { return; } RotoTrackDb db = new RotoTrackDb(); //Get value of Notes--we should have the ServiceEntry GUID encoded in it as well. string seGUID = ""; if (VehicleMileageRet.SelectSingleNode("./Notes") != null) { string Notes = VehicleMileageRet.SelectSingleNode("./Notes").InnerText; seGUID = QBUtils.GetGuidFromNotes(Notes); } string TxnID = ""; if (VehicleMileageRet.SelectSingleNode("./TxnID") != null) { TxnID = VehicleMileageRet.SelectSingleNode("./TxnID").InnerText; } if (seGUID != "" && TxnID != "") { ServiceEntry se = null; if (db.ServiceEntries.Any(f => f.GUID == seGUID)) { se = db.ServiceEntries.First(f => f.GUID == seGUID); } if (se != null) { se.QBListIdForMileage = TxnID; db.Entry(se).State = EntityState.Modified; db.SaveChanges(); } } }
private static void WalkTimeTrackingRetForAdd(XmlNode TimeTrackingRet) { if (TimeTrackingRet == null) { return; } string Duration = TimeTrackingRet.SelectSingleNode("./Duration").InnerText; HoursMinutes hrsMins = GetHoursMinutesFromDuration(Duration); if (hrsMins == null) { return; } RotoTrackDb db = new RotoTrackDb(); string TxnID = ""; string seGUID = ""; string ItemServiceListID = ""; if (TimeTrackingRet.SelectSingleNode("./TxnID") != null) { TxnID = TimeTrackingRet.SelectSingleNode("./TxnID").InnerText; } if (TimeTrackingRet.SelectSingleNode("./Notes") != null) { string Notes = TimeTrackingRet.SelectSingleNode("./Notes").InnerText; seGUID = QBUtils.GetGuidFromNotes(Notes); } XmlNode ItemServiceRef = TimeTrackingRet.SelectSingleNode("./ItemServiceRef"); if (ItemServiceRef != null) { if (ItemServiceRef.SelectSingleNode("./ListID") != null) { ItemServiceListID = ItemServiceRef.SelectSingleNode("./ListID").InnerText; } } if (TxnID != null && seGUID != null && ItemServiceListID != null) { ServiceEntry se = null; if (db.ServiceEntries.Any(f => f.GUID == seGUID)) { se = db.ServiceEntries.First(f => f.GUID == seGUID); } if (se != null) { ServiceDetail sd = db.ServiceDetails.Find(se.ServiceDetailId); if (sd != null) { ServiceType regST = db.ServiceTypes.Find(sd.ServiceTypeId); ServiceType otST = db.ServiceTypes.Find(sd.OTServiceTypeId); if (regST != null && otST != null) { // We always update the regular hours first, so if reg and OT both have the same service list ID, then we need to also check if we already // wrote out the regular hours or not--else we will put both the reg and ot hours into regular hours since we match on reg hours first. // I was going to also look at the actual hours and minutes, but if those are identical, too, then this reduces to the same problem we have // solved here--we just have to assume reg hours are always written first, which they are. Also, I don't want to compare on hours/minutes // because that may fail due to rounding errors. if (ItemServiceListID == regST.QBListId && se.QBListIdForRegularHours == null) { se.QBListIdForRegularHours = TxnID; db.Entry(se).State = EntityState.Modified; db.SaveChanges(); } else if (ItemServiceListID == otST.QBListId && se.QBListIdForOTHours == null) { se.QBListIdForOTHours = TxnID; db.Entry(se).State = EntityState.Modified; db.SaveChanges(); } } } } } }