Exemple #1
0
        public void MovementOut_01(string MHId, string TransactionId, MovementOut_01Doc aMovementOut_01Doc)
        {
            EnterProc();
            return;

            MovementOut_01Insert aMovementOut_01Handler;

            try
            {
                MessageTransaction mt = BeginWebmethod(MHId, TransactionId, "MAPI_OUT_MOVEMENT_OUT_01");

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

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

            finally
            {
                EndWebmethod();
            }

            ExitProc();

            return;
        }
        public void Process(ref MessageTransaction trans, SegmentImpl parent, MovementOut_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;

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

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

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

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


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

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

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

            if (p.MovementOrderType != null)
            {
                if (p.MovementOrderType.Length > 2)
                {
                    error.AppendLine("Value for MovementOut_01Doc.MovementOrderType too long, max 2 chars");
                }

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

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

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

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

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

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

            if (p.ProductionLotIdentity != null)
            {
                if (p.ProductionLotIdentity.Length > 40)
                {
                    error.AppendLine("Value for MovementOut_01Doc.ProductionLotIdentity too long, max 40 chars");
                }

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

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

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

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

            trans.TransSeq++;

            fStmt.ExecuteNonQuery();
        }