示例#1
0
        public System.Data.SqlClient.SqlTransaction CompleteLoading(Guid truckId)
        {
            IGINProcess    originalGIN = new GINProcessBLL(currentGINProcess.GINProcessInformation.TransactionId);
            SqlTransaction transaction = currentGINProcess.CompleteLoading(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.TruckLoading, "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);
        }
示例#2
0
        public static void CompleteLoading(Guid truckId)
        {
            //check if page being processed outside a workflow context
            PageDataTransfer transferedData = new PageDataTransfer(HttpContext.Current.Request.Path);

            IGINProcess    ginProcess  = GetGINProcess(true);
            SqlTransaction transaction = null;

            try
            {
                AuditTrailWrapper auditTrail = new AuditTrailWrapper(AuditTrailWrapper.TruckLoading, "GIN Process");
                //GINInfo originalGIN = new GINInfo();
                //originalGIN.Copy(ginProcess.GINProcessInformation.Trucks[0].GIN);
                transaction = ginProcess.CompleteLoading(truckId);
                GINTruckInfo theTruck = ginProcess.GINProcessInformation.Trucks.Find(trk => trk.TruckId == truckId);
                foreach (var loadedStack in theTruck.Load.Stacks)
                {
                    InventoryServices.GetInventoryService().LoadFromStack(loadedStack.StackId, loadedStack.Bags, 0, transaction);
                    auditTrail.AddChange(
                        new TruckLoadInfo(),
                        new TruckLoadInfo(loadedStack.TruckId, theTruck.Load.DateLoaded, theTruck.Load.BagType, string.Empty),
                        AuditTrailWrapper.NewRecord);
                    if (!auditTrail.Save())
                    {
                        throw new Exception("Unable to log audit trail");
                    }
                }
                //auditTrail.AddChange(originalGIN, ginProcess.GINProcessInformation.Trucks[0].GIN);
                //if (!auditTrail.Save())
                //    throw new Exception("Failed to save audit trail!");
                CompleteWorkflowTask(ginProcess.GINProcessInformation.Trucks[0].TransactionId);
                //CompleteWorkflowTask(ginProcess.GINProcessInformation.Trucks[0].TransactionId);
                transaction.Commit();
            }
            catch (Exception ex)
            {
                try
                {
                    if (transaction != null)
                    {
                        transaction.Rollback();
                    }
                }
                catch (Exception ex2)
                {
                    throw ex2;
                }
                throw ex;
            }
        }