public void Confirm(string CommPartnerId, string TransactionId, ConfirmDoc aConfirmDoc)
        {
            EnterProc();

            ConfirmInsert aConfirmHandler;

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

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

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

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

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


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

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

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

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

            if (p.ErrCode != null)
            {
                if (p.ErrCode.Length > 12)
                {
                    error.AppendLine("Value for ConfirmDoc.ErrCode too long, max 12 chars");
                }

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

            if (p.ErrMsg != null)
            {
                if (p.ErrMsg.Length > 1024)
                {
                    error.AppendLine("Value for ConfirmDoc.ErrMsg too long, max 1024 chars");
                }

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

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

            trans.TransSeq++;

            fStmt.ExecuteNonQuery();
        }