Ejemplo n.º 1
0
    public void Process(ref MessageTransaction trans, SegmentImpl parent, MovementPickUp_01Doc 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;

        if (p.OPCODE == null)
        {
            error.AppendLine("Invalid Opcode (null) in " + p.GetType());
        }
        else
        {
            bool OpcodeValid = false;
            OpcodeValid |= (p.OPCODE == "0");
            OpcodeValid |= (p.OPCODE == "1");

            if (!OpcodeValid)
            {
                error.AppendLine("Opcode not supported/invalid (" + p.OPCODE + ") in " + p.GetType());
            }
        }

        (fStmt.Parameters["MAPI_IN_ID"] as IDbDataParameter).Value = StringValue(trans.MapiInId);

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

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

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

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

            if (p.MaterialHandlingSystemId.Length == 0)
                error.AppendLine("Zero length for mandatory parameter MovementPickUp_01Doc.MaterialHandlingSystemId not allowed");

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


        if (p.MovementOrder != null)
        {
            (fStmt.Parameters["MovementOrder"] as IDbDataParameter).Value = p.MovementOrder;
        }
        else
            error.AppendLine("Null value for mandatory parameter MovementPickUp_01Doc.MovementOrder not allowed");


        if (p.SequenceNumber != null)
        {
            (fStmt.Parameters["SequenceNumber"] as IDbDataParameter).Value = p.SequenceNumber;
        }
        else
            error.AppendLine("Null value for mandatory parameter MovementPickUp_01Doc.SequenceNumber not allowed");


        if (p.MovementTaskStatus != null)
        {
            if (p.MovementTaskStatus.Length > 255)
                error.AppendLine("Value for MovementPickUp_01Doc.MovementTaskStatus too long, max 255 chars");

            if (p.MovementTaskStatus.Length == 0)
                error.AppendLine("Zero length for mandatory parameter MovementPickUp_01Doc.MovementTaskStatus not allowed");

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


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

        trans.TransSeq++;

        fStmt.ExecuteNonQuery();

      }