Exemple #1
0
        public static void AcknowledgePickupNotice(PUNAcknowledgementInformation puna)//, AuditTrailWrapper auditTrail)
        {
            IPickupNotice                 pun         = GetPUN(true);
            AuditTrailWrapper             auditTrail  = new AuditTrailWrapper(AuditTrailWrapper.PUNInitiation, "PUN Process");
            PUNAcknowledgementInformation originalPUN = new PUNAcknowledgementInformation();

            originalPUN.Copy(pun.PUNAInformation);
            auditTrail.AddChange(new object[][] { new object[] { originalPUN, puna, AuditTrailWrapper.NewRecord } });
            SqlTransaction transaction   = null;
            string         transactionId = null;

            try
            {
                transaction   = pun.AcknowledgePickupNotice(puna);
                transactionId = StartPUNWorkflow();
                if (transactionId != string.Empty)
                {
                    puna.TransactionId = transactionId;
                    pun.AcknowledgePickupNotice(puna, transaction);
                    if (!WarehouseTrackingNoBLL.Save(transactionId, transaction))
                    {
                        GINProcessWrapper.RemoveWorkflowTask(transactionId);
                        throw new Exception("Failed to start PUN Transaction");
                    }
                }
                else
                {
                    throw new Exception("Failed to start PUN Transaction");
                }
                if (!auditTrail.Save())
                {
                    throw new Exception("Failed to save audit trail");
                }
                transaction.Commit();
            }
            catch (Exception ex)
            {
                try
                {
                    if ((transactionId != null) && (transactionId != string.Empty))
                    {
                        GINProcessWrapper.RemoveWorkflowTask(transactionId);
                    }
                }
                catch (Exception ex2)
                {
                    throw ex2;
                }
                finally
                {
                    if (transaction != null)
                    {
                        transaction.Rollback();
                    }
                }
                throw ex;
            }
        }
Exemple #2
0
        public static void SaveTruckRegistration()
        {
            IGINProcess ginProcess = GetGINProcess(true);
            bool        bPunClosed = Math.Abs(ginProcess.GINProcessInformation.PledgedWeight - ginProcess.GINProcessInformation.IssuedWeight) <= 0.0001M;

            if (bPunClosed)
            {
                CompleteWorkflowTask(ginProcess.GINProcessInformation.TransactionId);
            }
            else
            {
                SqlTransaction transaction   = null;
                string         transactionId = null;
                if (ginProcess.GINProcessInformation.RegisteredTrucks.Count == 0)
                {
                    throw new Exception("No Truck has been registered");
                }
                foreach (GINTruckInfo truck in ginProcess.GINProcessInformation.RegisteredTrucks)
                {
                    try
                    {
                        transactionId = StartWorkflowTask(new Guid("e92633bb-3a48-4ddd-ae13-970bb32ddf36"));
                        if (transactionId != string.Empty)
                        {
                            truck.TransactionId = transactionId;
                        }
                        else
                        {
                            throw new Exception("Failed to start GIN Transaction");
                        }
                        transaction = ginProcess.SaveTruck(truck);
                        if (!WarehouseTrackingNoBLL.Save(transactionId, transaction))
                        {
                            throw new Exception("Failed to start GIN Transaction");
                        }
                        if (truck.Status == (int)GINStatusType.ReadyToLoad)
                        {
                            //ECXWF.ECXEngine eng = new WarehouseApplication.ECXWF.ECXEngine();
                            //eng.OpenTransaction(,
                            //    new Guid(SystemLookup.LookupSource.GetLookup("CurrentUser")["Id"]),
                            //    new string[] { "" }, "1", out transactionId);
                            //truck.TransactionId = transactionId;
                            //string transactionId = StartWorkflowTask(new Guid("e92633bb-3a48-4ddd-ae13-970bb32ddf36"));
                            //if (transactionId != string.Empty)
                            //{
                            //    truck.TransactionId = transactionId;
                            //}
                            //ginProcess.SaveTruck(truck, transaction);
                        }
                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        if (transactionId != null)
                        {
                            RemoveWorkflowTask(transactionId);
                        }
                        try
                        {
                            if (transaction != null)
                            {
                                transaction.Rollback();
                            }
                        }
                        catch (Exception ex2)
                        {
                            throw ex2;
                        }
                        throw ex;
                    }
                }
            }
        }