Exemple #1
0
        public void Product_01(string MHId, string TransactionId, Product_01Doc aProduct_01Doc)
        {
            EnterProc();
            return;

            Product_01Insert aProduct_01Handler;

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

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

                try
                {
                    if (aProduct_01Doc == null)
                    {
                        Exception InternalError = new Exception("DataError: Root object cannot be null");
                        throw (InternalError);
                    }
                    aProduct_01Handler.Process(ref mt, null, aProduct_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, Product_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 Product_01Doc.OPCODE too long, max 1 chars");
                }

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

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


            if (p.OperationalCode != null)
            {
                if (p.OperationalCode.Length > 1)
                {
                    error.AppendLine("Value for Product_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.ProductNumber != null)
            {
                if (p.ProductNumber.Length > 35)
                {
                    error.AppendLine("Value for Product_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.BarCode != null)
            {
                if (p.BarCode.Length > 20)
                {
                    error.AppendLine("Value for Product_01Doc.BarCode too long, max 20 chars");
                }

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

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

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

            if (p.HandlingUnitIdentity != null)
            {
                if (p.HandlingUnitIdentity.Length > 6)
                {
                    error.AppendLine("Value for Product_01Doc.HandlingUnitIdentity too long, max 6 chars");
                }

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

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

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

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

            if (p.BatchType != null)
            {
                if (p.BatchType.Length > 100)
                {
                    error.AppendLine("Value for Product_01Doc.BatchType too long, max 100 chars");
                }

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

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

            trans.TransSeq++;

            fStmt.ExecuteNonQuery();
        }