public void DepartureLoad(string CommPartnerId, string TransactionId, DepartureLoadDoc aDepartureLoadDoc)
        {
            EnterProc();

            DepartureLoadInsert aDepartureLoadHandler;

            try
            {
                MessageTransaction mt = BeginWebmethod(CommPartnerId, TransactionId, "DEP_LOAD");

                try
                {
                    aDepartureLoadHandler = new DepartureLoadInsert(this);
                }
                catch (Exception e)
                {
                    Exception InternalError = new Exception("InternalError: Building insert handler", e);
                    throw (InternalError);
                }

                try
                {
                    if (aDepartureLoadDoc == null)
                    {
                        Exception InternalError = new Exception("DataError: Root object cannot be null");
                        throw (InternalError);
                    }
                    aDepartureLoadHandler.Process(ref mt, null, aDepartureLoadDoc);
                    GetDataBase().Commit();
                }
                catch (Exception e)
                {
                    try
                    {
                        GetDataBase().Rollback();
                    }
                    catch (Exception)
                    {}
                    Exception InternalError = new Exception("DataError: Error processing data", e);
                    throw (InternalError);
                }
            }

            finally
            {
                EndWebmethod();
            }

            ExitProc();

            return;
        }
Beispiel #2
0
        public void Process(ref MessageTransaction trans, SegmentImpl parent, DepartureLoadDoc p)
        {
            StringBuilder error = new StringBuilder();

            if (p == null)
            {
                // No data is available - abort
                throw new NullReferenceException("Failed to process message " + p.GetType() + ". Message structure is empty (null).");
            }

            fStmt.Transaction = trans.Transaction;

            (fStmt.Parameters["MSG_IN_ID"] as IDbDataParameter).Value = StringValue(trans.MsgInId);

            if (p.OPCODE != null)
            {
                if (p.OPCODE.Length > 1)
                {
                    error.AppendLine("Value for DepartureLoadDoc.OPCODE too long, max 1 chars");
                }

                if (p.OPCODE.Length == 0)
                {
                    error.AppendLine("Zero length for mandatory parameter DepartureLoadDoc.OPCODE not allowed");
                }

                (fStmt.Parameters["OPCODE"] as IDbDataParameter).Value = p.OPCODE;
            }
            else
            {
                error.AppendLine("Null value for mandatory parameter DepartureLoadDoc.OPCODE not allowed");
            }


            if (p.DepartureLoadIdentity != null)
            {
                if (p.DepartureLoadIdentity.Length > 35)
                {
                    error.AppendLine("Value for DepartureLoadDoc.DepartureLoadIdentity too long, max 35 chars");
                }

                (fStmt.Parameters["DepartureLoadIdentity"] as IDbDataParameter).Value = p.DepartureLoadIdentity;
            }
            else
            {
                (fStmt.Parameters["DepartureLoadIdentity"] as IDbDataParameter).Value = DBNull.Value;
            }

            if (p.CustomerOrderSequence != null)
            {
                (fStmt.Parameters["CustomerOrderSequence"] as IDbDataParameter).Value = p.CustomerOrderSequence;
            }
            else
            {
                (fStmt.Parameters["CustomerOrderSequence"] as IDbDataParameter).Value = DBNull.Value;
            }

            if (p.DepartureIdentity != null)
            {
                if (p.DepartureIdentity.Length > 35)
                {
                    error.AppendLine("Value for DepartureLoadDoc.DepartureIdentity too long, max 35 chars");
                }

                (fStmt.Parameters["DepartureIdentity"] as IDbDataParameter).Value = p.DepartureIdentity;
            }
            else
            {
                (fStmt.Parameters["DepartureIdentity"] as IDbDataParameter).Value = DBNull.Value;
            }

            if (p.RouteIdentity != null)
            {
                if (p.RouteIdentity.Length > 17)
                {
                    error.AppendLine("Value for DepartureLoadDoc.RouteIdentity too long, max 17 chars");
                }

                (fStmt.Parameters["RouteIdentity"] as IDbDataParameter).Value = p.RouteIdentity;
            }
            else
            {
                (fStmt.Parameters["RouteIdentity"] as IDbDataParameter).Value = DBNull.Value;
            }

            if (p.RouteDescription != null)
            {
                if (p.RouteDescription.Length > 35)
                {
                    error.AppendLine("Value for DepartureLoadDoc.RouteDescription too long, max 35 chars");
                }

                (fStmt.Parameters["RouteDescription"] as IDbDataParameter).Value = p.RouteDescription;
            }
            else
            {
                (fStmt.Parameters["RouteDescription"] as IDbDataParameter).Value = DBNull.Value;
            }

            if (p.CustomerOrderReleaseDateTime != null)
            {
                (fStmt.Parameters["CustomerOrderReleaseDateTime"] as IDbDataParameter).Value = p.CustomerOrderReleaseDateTime;
            }
            else
            {
                (fStmt.Parameters["CustomerOrderReleaseDateTime"] as IDbDataParameter).Value = DBNull.Value;
            }

            if (p.CustomerOrderStopDateTime != null)
            {
                (fStmt.Parameters["CustomerOrderStopDateTime"] as IDbDataParameter).Value = p.CustomerOrderStopDateTime;
            }
            else
            {
                (fStmt.Parameters["CustomerOrderStopDateTime"] as IDbDataParameter).Value = DBNull.Value;
            }

            if (p.PlannedDepartureDateTime != null)
            {
                (fStmt.Parameters["PlannedDepartureDateTime"] as IDbDataParameter).Value = p.PlannedDepartureDateTime;
            }
            else
            {
                (fStmt.Parameters["PlannedDepartureDateTime"] as IDbDataParameter).Value = DBNull.Value;
            }

            if (p.EstimatedArrivalDateTime != null)
            {
                (fStmt.Parameters["EstimatedArrivalDateTime"] as IDbDataParameter).Value = p.EstimatedArrivalDateTime;
            }
            else
            {
                (fStmt.Parameters["EstimatedArrivalDateTime"] as IDbDataParameter).Value = DBNull.Value;
            }

            if (p.LastChainDepartureIdentity != null)
            {
                if (p.LastChainDepartureIdentity.Length > 35)
                {
                    error.AppendLine("Value for DepartureLoadDoc.LastChainDepartureIdentity too long, max 35 chars");
                }

                (fStmt.Parameters["LastChainDepartureIdentity"] as IDbDataParameter).Value = p.LastChainDepartureIdentity;
            }
            else
            {
                (fStmt.Parameters["LastChainDepartureIdentity"] as IDbDataParameter).Value = DBNull.Value;
            }

            if (p.WhyNoDepartureMessage != null)
            {
                if (p.WhyNoDepartureMessage.Length > 2000)
                {
                    error.AppendLine("Value for DepartureLoadDoc.WhyNoDepartureMessage too long, max 2000 chars");
                }

                (fStmt.Parameters["WhyNoDepartureMessage"] as IDbDataParameter).Value = p.WhyNoDepartureMessage;
            }
            else
            {
                (fStmt.Parameters["WhyNoDepartureMessage"] as IDbDataParameter).Value = DBNull.Value;
            }

            if (error.Length > 0)
            {
                throw (new Exception(error.ToString()));
            }

            trans.TransSeq++;

            fStmt.ExecuteNonQuery();
        }