Ejemplo n.º 1
0
        public System.Data.SqlClient.SqlTransaction SaveTruck(GINTruckInfo truck)
        {
            IGINProcess    originalGIN = new GINProcessBLL(currentGINProcess.GINProcessInformation.TransactionId);
            SqlTransaction transaction = currentGINProcess.SaveTruck(truck);
            //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);
        }
Ejemplo n.º 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;
                    }
                }
            }
        }
Ejemplo n.º 3
0
 void linkCommand_Command(object sender, CommandEventArgs e)
 {
     if (e.CommandName == "EditTruck")
     {
         GINDataEditor2.IsNew = false;
         var truckToEdit = from truck in ginProcess.GINProcessInformation.Trucks
                           where truck.TruckId == new Guid((string)e.CommandArgument)
                           select truck;
         GINDataEditor2.DataSource = truckToEdit.ElementAt(0);
         GINDataEditor2.DataBind();
         mpeTruckDataEditorExtender.Show();
     }
     else if (e.CommandName == "LoadTruck")
     {
         try
         {
             if (GINDataEditor2.DataSource != null)
             {
                 ginProcess.SaveTruck((GINTruckInfo)GINDataEditor2.DataSource);
             }
             PageDataTransfer truckTransfer = new PageDataTransfer(HttpContext.Current.Request.ApplicationPath + "/TruckLoading.aspx");
             truckTransfer.RemoveAllData();
             truckTransfer.TransferData["TruckId"]      = new Guid((string)e.CommandArgument);
             truckTransfer.TransferData["GINProcessId"] = ginProcess.GINProcessInformation.GINProcessId;
             truckTransfer.TransferData["ReturnPage"]   = HttpContext.Current.Request.Path;
             truckTransfer.TransferData["WorkflowTask"] = transferedData.GetTransferedData("WorkflowTask");
             GINProcessWrapper.RemoveGINProcessInformation();
             transferedData.RemoveAllData();
             truckTransfer.Navigate();
         }
         catch (Exception ex)
         {
             errorDisplayer.ShowErrorMessage(ex.Message);
         }
     }
     else if (e.CommandName == "ScaleTruck")
     {
         try
         {
             if (GINDataEditor2.DataSource != null)
             {
                 ginProcess.SaveTruck((GINTruckInfo)GINDataEditor2.DataSource);
             }
             PageDataTransfer truckTransfer = new PageDataTransfer(HttpContext.Current.Request.ApplicationPath + "/TruckScaling.aspx");
             truckTransfer.TransferData["TruckId"]      = new Guid((string)e.CommandArgument);
             truckTransfer.TransferData["GINProcessId"] = ginProcess.GINProcessInformation.GINProcessId;
             truckTransfer.TransferData["WorkflowTask"] = transferedData.GetTransferedData("WorkflowTask");
             truckTransfer.TransferData["ReturnPage"]   = HttpContext.Current.Request.Path;
             GINProcessWrapper.RemoveGINProcessInformation();
             transferedData.RemoveAllData();
             truckTransfer.Navigate();
         }
         catch (Exception ex)
         {
             lblMessage.Text = ex.Message;
         }
     }
     else if (e.CommandName == "GenerateGIN")
     {
         try
         {
             if (GINDataEditor2.DataSource != null)
             {
                 ginProcess.SaveTruck((GINTruckInfo)GINDataEditor2.DataSource);
             }
             PageDataTransfer truckTransfer = new PageDataTransfer(HttpContext.Current.Request.ApplicationPath + "/GenerateGIN.aspx");
             truckTransfer.TransferData["TruckId"]      = new Guid((string)e.CommandArgument);
             truckTransfer.TransferData["GINProcessId"] = ginProcess.GINProcessInformation.GINProcessId;
             truckTransfer.TransferData["WorkflowTask"] = transferedData.GetTransferedData("WorkflowTask");
             truckTransfer.TransferData["ReturnPage"]   = HttpContext.Current.Request.Path;
             GINProcessWrapper.RemoveGINProcessInformation();
             transferedData.RemoveAllData();
             truckTransfer.Navigate();
         }
         catch (Exception ex)
         {
             errorDisplayer.ShowErrorMessage(ex.Message);
         }
     }
 }