public System.Data.SqlClient.SqlTransaction SaveGIN(Guid truckId, System.Data.SqlClient.SqlTransaction transaction) { IGINProcess originalGIN = new GINProcessBLL(currentGINProcess.GINProcessInformation.TransactionId); currentGINProcess.SaveGIN(truckId, transaction); //ConfirmNoConcurrency(GIN) var ginChanges = (from oGIN in originalGIN.GINProcessInformation.Trucks join cGIN in currentGINProcess.GINProcessInformation.Trucks on oGIN.TruckId equals cGIN.TruckId where oGIN.TruckId == truckId select new object[] { oGIN, cGIN, AuditTrailWrapper.ExistingRecord }); try { AuditTrailWrapper atw = new AuditTrailWrapper(AuditTrailWrapper.TruckLoading, ginChanges.ToArray(), "GIN Process"); if (!atw.Save()) { transaction.Rollback(); throw new Exception("Failed to save audit trail!"); } } catch (Exception ex) { transaction.Rollback(); throw ex; } return(transaction); }
public System.Data.SqlClient.SqlTransaction SaveTruckRegistration() { IGINProcess originalGIN = new GINProcessBLL(currentGINProcess.GINProcessInformation.TransactionId); SqlTransaction transaction = currentGINProcess.SaveTruckRegistration(); //ConfirmNoConcurrency(Trucks, Loads, Weight) //newly added trucks var newTrucks = (from cTruck in currentGINProcess.GINProcessInformation.Trucks where !(from oTruck in originalGIN.GINProcessInformation.Trucks select oTruck.TruckId).Contains(cTruck.TruckId) select new object[] { null, cTruck, AuditTrailWrapper.NewRecord }); //existing trucks var existingTrucks = (from cTruck in currentGINProcess.GINProcessInformation.Trucks join oTruck in originalGIN.GINProcessInformation.Trucks on cTruck.TruckId equals oTruck.TruckId select new object[] { oTruck, cTruck, AuditTrailWrapper.ExistingRecord }); //deleted trucks var deletedTrucks = (from oTruck in originalGIN.GINProcessInformation.Trucks where !(from cTruck in currentGINProcess.GINProcessInformation.Trucks select cTruck.TruckId).Contains(oTruck.TruckId) select oTruck); try { AuditTrailWrapper atw = new AuditTrailWrapper(AuditTrailWrapper.TruckRegistration, newTrucks.ToArray(), "PUN Process"); atw.AddChange(existingTrucks.ToArray()); if (!atw.Save()) { transaction.Rollback(); throw new Exception("Failed to save audit trail!"); } } catch (Exception ex) { transaction.Rollback(); throw ex; } return(transaction); }
public System.Data.SqlClient.SqlTransaction GINApproved(Guid truckId) { IGINProcess originalGIN = new GINProcessBLL(currentGINProcess.GINProcessInformation.TransactionId); SqlTransaction transaction = currentGINProcess.GINApproved(truckId); var ginChanges = (from oGIN in originalGIN.GINProcessInformation.Trucks join cGIN in currentGINProcess.GINProcessInformation.Trucks on oGIN.TruckId equals cGIN.TruckId where oGIN.TruckId == truckId select new object[] { oGIN, cGIN, AuditTrailWrapper.ExistingRecord }); try { AuditTrailWrapper atw = new AuditTrailWrapper(AuditTrailWrapper.GINApproval, "GIN Process"); atw.AddChange(ginChanges.ToArray()); if (!atw.Save()) { transaction.Rollback(); throw new Exception("Failed to save audit trail!"); } } catch (Exception ex) { transaction.Rollback(); throw ex; } return(transaction); }
public System.Data.SqlClient.SqlTransaction SaveTruck(GINTruckInfo truck, System.Data.SqlClient.SqlTransaction transaction) { IGINProcess originalGIN = new GINProcessBLL(currentGINProcess.GINProcessInformation.TransactionId); currentGINProcess.SaveTruck(truck, transaction); //ConfirmNoConcurrency(Truck, Load, Weight) var truckChanges = (from oTruck in originalGIN.GINProcessInformation.Trucks where oTruck.TruckId == truck.TruckId select new object[] { oTruck, truck, AuditTrailWrapper.ExistingRecord }); try { AuditTrailWrapper atw = new AuditTrailWrapper(AuditTrailWrapper.TruckRegistration, truckChanges.ToArray(), "GIN Process"); if (!atw.Save()) { transaction.Rollback(); throw new Exception("Failed to save audit trail!"); } } catch (Exception ex) { transaction.Rollback(); throw ex; } return(transaction); }
public void SavePhysicalCount(PhysicalCountInfo physicalCount) { PhysicalCountInfo originalPhysicalCount = OpenPhysicalCount(physicalCount.Id); AuditTrailWrapper atw = new AuditTrailWrapper(AuditTrailWrapper.InvCount, new object[][] { new object[] { originalPhysicalCount, physicalCount, AuditTrailWrapper.ExistingRecord } }, "Inventory Control"); foreach (PhysicalCountInspectorInfo inspector in physicalCount.Inspectors) { PhysicalCountInspectorInfo originalInspector = originalPhysicalCount.Inspectors.Find(oi => oi.Id == inspector.Id); if (originalInspector == null) { atw.AddChange(null, inspector, AuditTrailWrapper.NewRecord); } else { atw.AddChange(originalInspector, inspector, AuditTrailWrapper.ExistingRecord); } } foreach (StackPhysicalCountInfo stack in originalPhysicalCount.Stacks) { StackPhysicalCountInfo originalStack = physicalCount.Stacks.Find(os => os.Id == stack.Id); if (originalStack == null) { atw.AddChange(null, stack, AuditTrailWrapper.NewRecord); } else { atw.AddChange(originalStack, stack, AuditTrailWrapper.ExistingRecord); } } Dictionary <string, object> contextParameters = new Dictionary <string, object>(); contextParameters.Add("CurrentUser", new Guid(SystemLookup.LookupSource.GetLookup("CurrentUser")["Id"])); Queue <object> queue = new Queue <object>(new object[] { physicalCount }); foreach (PhysicalCountInspectorInfo inspector in physicalCount.Inspectors) { queue.Enqueue(inspector); } foreach (StackPhysicalCountInfo stack in physicalCount.Stacks) { queue.Enqueue(stack); } try { SqlTransaction transaction = PersistenceTransactionFactory.CreatePersistenceTransaction().Persist( queue, contextParameters); if (!atw.Save()) { transaction.Rollback(); throw new Exception("Failed to save audit trail!"); } transaction.Commit(); } catch (Exception ex) { throw new Exception("Physical Count couldn't be saved to the database", ex); } }
public System.Data.SqlClient.SqlTransaction SaveScaling(Guid truckId) { IGINProcess originalGIN = new GINProcessBLL(currentGINProcess.GINProcessInformation.TransactionId); SqlTransaction transaction = currentGINProcess.SaveScaling(truckId); //ConfirmNoConcurrency(Truck) var truckChanges = (from oTruck in originalGIN.GINProcessInformation.Trucks join cTruck in currentGINProcess.GINProcessInformation.Trucks on oTruck.TruckId equals cTruck.TruckId where oTruck.TruckId == truckId select new object[] { oTruck, cTruck, AuditTrailWrapper.ExistingRecord }); GINTruckInfo origTruck = (GINTruckInfo)truckChanges.Single()[0]; GINTruckInfo currTruck = (GINTruckInfo)truckChanges.Single()[1]; try { AuditTrailWrapper atw = new AuditTrailWrapper(AuditTrailWrapper.TruckWeighing, truckChanges.ToArray(), "GIN Process"); atw.AddChange(origTruck.GIN, currTruck.GIN, AuditTrailWrapper.ExistingRecord); atw.AddChange(origTruck.Weight, currTruck.Weight, AuditTrailWrapper.ExistingRecord); //newly added returned bags and added bags var newRBs = (from cRB in currTruck.Weight.ReturnedBags where !(from oRB in origTruck.Weight.ReturnedBags select oRB.TruckId).Contains(cRB.ReturnedBagsId) select new object[] { null, cRB, AuditTrailWrapper.NewRecord }); atw.AddChange(newRBs.ToArray()); //existing returned bags and added bags var existingRBs = (from oRB in origTruck.Weight.ReturnedBags join cRB in currTruck.Weight.ReturnedBags on oRB.ReturnedBagsId equals cRB.ReturnedBagsId select new object[] { oRB, cRB, AuditTrailWrapper.ExistingRecord }); atw.AddChange(existingRBs.ToArray()); if (!atw.Save()) { transaction.Rollback(); throw new Exception("Failed to save audit trail!"); } } catch (Exception ex) { transaction.Rollback(); throw ex; } return(transaction); }
public System.Data.SqlClient.SqlTransaction AbortGINProcess() { IGINProcess originalGIN = new GINProcessBLL(currentGINProcess.GINProcessInformation.TransactionId); SqlTransaction transaction = currentGINProcess.AbortGINProcess(); try { AuditTrailWrapper atw = new AuditTrailWrapper(AuditTrailWrapper.GINAbortion, "PUN Process"); atw.AddChange(originalGIN.GINProcessInformation, currentGINProcess.GINProcessInformation, AuditTrailWrapper.ExistingRecord); if (!atw.Save()) { transaction.Rollback(); throw new Exception("Failed to save audit trail!"); } } catch (Exception ex) { transaction.Rollback(); throw ex; } return(transaction); }
public SqlTransaction SaveAvailabilityVerification(PUNAcknowledgementInformation punaInformation) { IPickupNotice originalPUN = new PickupNoticeBLL(currentGINProcess.GINProcessInformation.PickupNoticeId); //ConfirmNoConcurrency(PUNAInformation); SqlTransaction transaction = currentGINProcess.SaveAvailabilityVerification(punaInformation); try { AuditTrailWrapper atw = new AuditTrailWrapper(AuditTrailWrapper.PUNInitiation, new object[][] { new object[] { originalPUN.PUNAInformation, punaInformation, AuditTrailWrapper.ExistingRecord } }, "PUN Process"); if (!atw.Save()) { transaction.Rollback(); throw new Exception("Failed to save audit trail!"); } } catch (Exception ex) { transaction.Rollback(); throw ex; } return(transaction); }
public void CreatePhysicalCount(PhysicalCountInfo physicalCount) { AuditTrailWrapper atw = new AuditTrailWrapper(AuditTrailWrapper.InvCount, new object[][] { new object[] { null, physicalCount, AuditTrailWrapper.NewRecord } }, "Inventory Control"); Dictionary <string, object> contextParameters = new Dictionary <string, object>(); contextParameters.Add("CurrentUser", new Guid(SystemLookup.LookupSource.GetLookup("CurrentUser")["Id"])); try { SqlTransaction transaction = PersistenceTransactionFactory.CreatePersistenceTransaction().Persist( new Queue <object>(new object[] { physicalCount }), contextParameters); transaction.Commit(); if (!atw.Save()) { transaction.Rollback(); throw new Exception("Failed to save audit trail!"); } } catch (Exception ex) { throw new Exception("Physical Count couldn't be saved to the database", ex); } }