public void DepartureNode(string CommPartnerId, string TransactionId, DepartureNodeDoc aDepartureNodeDoc)
        {
            EnterProc();

            DepartureNodeInsert aDepartureNodeHandler;

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

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

                try
                {
                    if (aDepartureNodeDoc == null)
                    {
                        Exception InternalError = new Exception("DataError: Root object cannot be null");
                        throw (InternalError);
                    }
                    aDepartureNodeHandler.Process(ref mt, null, aDepartureNodeDoc);
                    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;
        }
Example #2
0
        public void Process(ref MessageTransaction trans, SegmentImpl parent, DepartureNodeDoc 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 DepartureNodeDoc.OPCODE too long, max 1 chars");
                }

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

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


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

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

            (fStmt.Parameters["SEQNUM"] as IDbDataParameter).Value = NumberValue(trans.TransSeq);

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

                (fStmt.Parameters["ToNodeIdentity"] as IDbDataParameter).Value = p.ToNodeIdentity;
            }
            else
            {
                (fStmt.Parameters["ToNodeIdentity"] 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.ReceiveTransitGoods != null)
            {
                if (p.ReceiveTransitGoods.Length > 1)
                {
                    error.AppendLine("Value for DepartureNodeDoc.ReceiveTransitGoods too long, max 1 chars");
                }

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

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

            trans.TransSeq++;

            fStmt.ExecuteNonQuery();
        }