Ejemplo n.º 1
0
        public static void SaveLoading(Guid truckId)
        {
            IGINProcess ginProcess = GetGINProcess(true);

            if (!PostGINEditRequest(ginProcess, truckId))
            {
                SqlTransaction transaction = null;
                try
                {
                    transaction = ginProcess.SaveLoading(truckId);
                    transaction.Commit();
                }
                catch (Exception ex)
                {
                    try
                    {
                        if (transaction != null)
                        {
                            transaction.Rollback();
                        }
                    }
                    catch (Exception ex2)
                    {
                        throw ex2;
                    }
                    throw ex;
                }
            }
        }
Ejemplo n.º 2
0
        public System.Data.SqlClient.SqlTransaction SaveLoading(Guid truckId)
        {
            IGINProcess    originalGIN = new GINProcessBLL(currentGINProcess.GINProcessInformation.TransactionId);
            SqlTransaction transaction = currentGINProcess.SaveLoading(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.TruckLoading, truckChanges.ToArray(), "GIN Process");
                atw.AddChange(origTruck.GIN, currTruck.GIN, AuditTrailWrapper.ExistingRecord);
                atw.AddChange(origTruck.Load, currTruck.Load, AuditTrailWrapper.ExistingRecord);
                //newly added stacks
                var newStacks = (from cStack in currTruck.Load.Stacks
                                 where !(from oStack in origTruck.Load.Stacks select oStack.TruckId).Contains(cStack.TruckStackId)
                                 select new object[] { null, cStack, AuditTrailWrapper.NewRecord });
                atw.AddChange(newStacks.ToArray());
                //existing stacks
                var existingStacks = (from oStack in origTruck.Load.Stacks
                                      join cStack in currTruck.Load.Stacks
                                      on oStack.TruckStackId equals cStack.TruckStackId
                                      select new object[] { oStack, cStack, AuditTrailWrapper.ExistingRecord });
                atw.AddChange(existingStacks.ToArray());

                if (!atw.Save())
                {
                    transaction.Rollback();
                    throw new Exception("Failed to save audit trail!");
                }
            }
            catch (Exception ex)
            {
                transaction.Rollback();
                throw ex;
            }
            return(transaction);
        }