Esempio n. 1
0
        public static CedaObject ToCedaObject(Message msg)
        {
            if (msg == null)
            {
                return(null);
            }
            CedaObject cedaObject = new CedaObject();

            cedaObject.SvrID = msg.SvrID;
            cedaObject.Topic = msg.Destination.getName();

            MessageBody body = msg.MessageBody;

            if (body == null)
            {
                return(cedaObject);
            }

            if (body.haseField((short)5) != 0)
            {
                try
                {
                    cedaObject.ZipType = body.getInt((short)5);
                }
                catch (Exception ex)
                {
                    LogHelper.Error(ex);
                    cedaObject.ZipType = 0;
                }
            }
            else
            {
                cedaObject.ZipType = 0;
            }

            if (body.haseField((short)4) != 0)
            {
                try
                {
                    cedaObject.MessageType = body.getString((short)4);
                }
                catch (Exception ex)
                {
                    LogHelper.Error(ex);
                }
            }

            if (body.haseField((short)3) != 0)
            {
                string strMsg = "";
                try
                {
                    switch (cedaObject.ZipType)
                    {
                    case 0:
                        strMsg = body.getString((short)3);
                        break;

                    case 1:
                        strMsg = body.getGZIPString((short)3);
                        break;

                    case 3:
                        //strMsg=
                        if (body.haseField((short)1) != 0)
                        {
                            strMsg = com.adaptiveMQ2.utils.Utils.ungzipByte(body.getBlobField());
                        }
                        break;
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.Error(ex);
                }
                finally
                {
                    cedaObject.MessageBody = strMsg;
                }
            }

            if (body.haseField((short)6) != 0)
            {
                try
                {
                    cedaObject.MessageSize = body.getInt((short)6);
                }
                catch (Exception ex)
                {
                    LogHelper.Error(ex);
                }
            }

            if (body.haseField((short)7) != 0)
            {
                try
                {
                    cedaObject.SendTime = body.getString((short)7);
                }
                catch (Exception ex)
                {
                    LogHelper.Error(ex);
                }
            }

            if (body.haseField((short)10) != 0)
            {
                try
                {
                    cedaObject.ResultCode = body.getString((short)10);
                }
                catch (Exception ex)
                {
                    LogHelper.Error(ex);
                }
            }

            if (body.haseField((short)11) != 0)
            {
                try
                {
                    cedaObject.Result = body.getInt((short)11);
                }
                catch (MessageBodyException e)
                {
                    LogHelper.Error(e);
                }
            }

            if (body.haseField((short)1) != 0)
            {
                if (cedaObject.ZipType == 3)
                {
                    cedaObject.BigMessage = body.getBlobField();
                }
            }

            return(cedaObject);
        }
Esempio n. 2
0
        public static CedaObject ToCedaObject(Message msg)
        {
            if (msg == null)
            {
                return(null);
            }
            CedaObject cedaObject = new CedaObject();

            cedaObject.SvrID = msg.SvrID;
            cedaObject.Topic = msg.Destination.getName();
            LogHelper.Debug(string.Format("topic:{0}:{1}", cedaObject.SvrID, cedaObject.Topic));
            MessageBody body = msg.MessageBody;

            if (body == null)
            {
                return(cedaObject);
            }
            var va = body.Values;

            while (va.MoveNext())
            {
                MessageRecord.CField field = va.Current as MessageRecord.CField;
                if (field.oField.GetType().Equals(typeof(byte[])))
                {
                    LogHelper.Debug(string.Format("byte field:{0}:{1}", field.nPosition, body.getGZIPString(field.nPosition)));
                }
                else
                {
                    LogHelper.Debug(string.Format("field:{0}:{1}", field.nPosition, field.oField));
                }
            }
            if (body.haseField((short)5) != 0)
            {
                try
                {
                    cedaObject.ZipType = body.getInt((short)5);
                }
                catch (Exception ex)
                {
                    LogHelper.Error(ex);
                    cedaObject.ZipType = 0;
                }
            }
            else
            {
                cedaObject.ZipType = 0;
            }

            //if (body.haseField((short) 4) != 0)
            //{
            //    try
            //    {
            //        cedaObject.MessageType = body.getString((short) 4);
            //    }
            //    catch (Exception ex)
            //    {
            //        LogHelper.Error(ex);
            //    }
            //}

            if (body.haseField((short)3) != 0)
            {
                string strMsg = "";
                try
                {
                    switch (cedaObject.ZipType)
                    {
                    case 0:
                        try
                        {
                            strMsg = body.getString((short)3);
                        }
                        catch (Exception)
                        {
                            strMsg = body.getGZIPString((short)3);
                        }

                        break;

                    case 1:
                        strMsg = body.getGZIPString((short)3);
                        break;

                    case 3:
                        //strMsg=
                        if (body.haseField((short)1) != 0)
                        {
                            strMsg = com.adaptiveMQ2.utils.Utils.ungzipByte(body.getBlobField());
                        }
                        break;
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.Error(ex);
                }
                finally
                {
                    cedaObject.MessageBody = strMsg;
                }
            }

            if (body.haseField((short)6) != 0)
            {
                try
                {
                    cedaObject.MessageSize = body.getInt((short)6);
                }
                catch (Exception ex)
                {
                    LogHelper.Error(ex);
                }
            }

            if (body.haseField((short)7) != 0)
            {
                try
                {
                    cedaObject.SendTime = body.getString((short)7);
                }
                catch (Exception ex)
                {
                    LogHelper.Error(ex);
                }
            }

            if (body.haseField((short)10) != 0)
            {
                try
                {
                    cedaObject.ResultCode = body.getString((short)10);
                }
                catch (Exception ex)
                {
                    LogHelper.Error(ex);
                }
            }

            if (body.haseField((short)11) != 0)
            {
                try
                {
                    cedaObject.Result = body.getInt((short)11);
                }
                catch (MessageBodyException e)
                {
                    LogHelper.Error(e);
                }
            }

            if (body.haseField((short)1) != 0)
            {
                if (cedaObject.ZipType == 3)
                {
                    cedaObject.BigMessage = body.getBlobField();
                }
            }

            return(cedaObject);
        }