示例#1
0
        public void Send(NativeMsmqMessage message, MsmqTransactionMode transactionMode)
        {
            int error = 0;

            if (RequiresDtcTransaction(transactionMode))
            {
                error = SendDtcTransacted(message, transactionMode);
            }
            else
            {
                MsmqQueueHandle handle = GetHandle();
                IntPtr          nativePropertiesPointer = message.Pin();
                try
                {
                    error = UnsafeNativeMethods.MQSendMessage(handle, nativePropertiesPointer,
                                                              (IntPtr)GetTransactionConstant(transactionMode));
                }
                finally
                {
                    message.Unpin();
                }
            }

            if (error != 0)
            {
                if (IsErrorDueToStaleHandle(error))
                {
                    HandleIsStale(handle);
                }
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MsmqException(SR.GetString(SR.MsmqSendError, MsmqError.GetErrorString(error)), error));
            }
        }
        protected int ReceiveByLookupIdCoreDtcTransacted(MsmqQueueHandle handle, long lookupId, NativeMsmqMessage message, MsmqTransactionMode transactionMode, int action)
        {
            int             num;
            IDtcTransaction nativeTransaction = this.GetNativeTransaction(transactionMode);
            IntPtr          properties        = message.Pin();

            try
            {
                if (nativeTransaction != null)
                {
                    try
                    {
                        return(UnsafeNativeMethods.MQReceiveMessageByLookupId(handle, lookupId, action, properties, null, IntPtr.Zero, nativeTransaction));
                    }
                    finally
                    {
                        Marshal.ReleaseComObject(nativeTransaction);
                    }
                }
                num = UnsafeNativeMethods.MQReceiveMessageByLookupId(handle, lookupId, action, properties, null, IntPtr.Zero, (IntPtr)this.GetTransactionConstant(transactionMode));
            }
            finally
            {
                message.Unpin();
            }
            return(num);
        }
示例#3
0
        unsafe int ReceiveCoreDtcTransacted(MsmqQueueHandle handle, NativeMsmqMessage message, TimeSpan timeout, MsmqTransactionMode transactionMode, int action)
        {
            IDtcTransaction dtcTransaction        = GetNativeTransaction(transactionMode);
            int             timeoutInMilliseconds = TimeoutHelper.ToMilliseconds(timeout);

            IntPtr nativePropertiesPointer = message.Pin();

            try
            {
                if (dtcTransaction != null)
                {
                    try
                    {
                        return(UnsafeNativeMethods.MQReceiveMessage(handle.DangerousGetHandle(), timeoutInMilliseconds,
                                                                    action, nativePropertiesPointer, null, IntPtr.Zero, IntPtr.Zero, dtcTransaction));
                    }
                    finally
                    {
                        Marshal.ReleaseComObject(dtcTransaction);
                    }
                }
                else
                {
                    return(UnsafeNativeMethods.MQReceiveMessage(handle.DangerousGetHandle(), timeoutInMilliseconds,
                                                                action, nativePropertiesPointer, null, IntPtr.Zero, IntPtr.Zero, (IntPtr)GetTransactionConstant(transactionMode)));
                }
            }
            finally
            {
                message.Unpin();
            }
        }
示例#4
0
        protected unsafe int ReceiveByLookupIdCoreDtcTransacted(MsmqQueueHandle handle, long lookupId, NativeMsmqMessage message, MsmqTransactionMode transactionMode, int action)
        {
            IDtcTransaction dtcTransaction = GetNativeTransaction(transactionMode);

            IntPtr nativePropertiesPointer = message.Pin();

            try
            {
                if (dtcTransaction != null)
                {
                    try
                    {
                        return(UnsafeNativeMethods.MQReceiveMessageByLookupId(handle, lookupId, action, nativePropertiesPointer, null, IntPtr.Zero, dtcTransaction));
                    }
                    finally
                    {
                        Marshal.ReleaseComObject(dtcTransaction);
                    }
                }
                else
                {
                    return(UnsafeNativeMethods.MQReceiveMessageByLookupId(handle, lookupId, action, nativePropertiesPointer, null, IntPtr.Zero, (IntPtr)GetTransactionConstant(transactionMode)));
                }
            }
            finally
            {
                message.Unpin();
            }
        }
        private int ReceiveCoreDtcTransacted(MsmqQueueHandle handle, NativeMsmqMessage message, TimeSpan timeout, MsmqTransactionMode transactionMode, int action)
        {
            int             num2;
            IDtcTransaction nativeTransaction = this.GetNativeTransaction(transactionMode);
            int             num        = TimeoutHelper.ToMilliseconds(timeout);
            IntPtr          properties = message.Pin();

            try
            {
                if (nativeTransaction != null)
                {
                    try
                    {
                        return(UnsafeNativeMethods.MQReceiveMessage(handle.DangerousGetHandle(), num, action, properties, null, IntPtr.Zero, IntPtr.Zero, nativeTransaction));
                    }
                    finally
                    {
                        Marshal.ReleaseComObject(nativeTransaction);
                    }
                }
                num2 = UnsafeNativeMethods.MQReceiveMessage(handle.DangerousGetHandle(), num, action, properties, null, IntPtr.Zero, IntPtr.Zero, (IntPtr)this.GetTransactionConstant(transactionMode));
            }
            finally
            {
                message.Unpin();
            }
            return(num2);
        }
        public void Send(NativeMsmqMessage message, MsmqTransactionMode transactionMode)
        {
            int error = 0;

            if (this.RequiresDtcTransaction(transactionMode))
            {
                error = this.SendDtcTransacted(message, transactionMode);
            }
            else
            {
                MsmqQueueHandle handle     = this.GetHandle();
                IntPtr          properties = message.Pin();
                try
                {
                    error = UnsafeNativeMethods.MQSendMessage(handle, properties, (IntPtr)this.GetTransactionConstant(transactionMode));
                }
                finally
                {
                    message.Unpin();
                }
            }
            if (error != 0)
            {
                if (IsErrorDueToStaleHandle(error))
                {
                    this.HandleIsStale(this.handle);
                }
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MsmqException(System.ServiceModel.SR.GetString("MsmqSendError", new object[] { MsmqError.GetErrorString(error) }), error));
            }
        }
示例#7
0
        int SendDtcTransacted(NativeMsmqMessage message, MsmqTransactionMode transactionMode)
        {
            IDtcTransaction dtcTransaction = GetNativeTransaction(transactionMode);

            MsmqQueueHandle handle = GetHandle();
            IntPtr          nativePropertiesPointer = message.Pin();

            try
            {
                if (dtcTransaction != null)
                {
                    try
                    {
                        return(UnsafeNativeMethods.MQSendMessage(handle, nativePropertiesPointer,
                                                                 dtcTransaction));
                    }
                    finally
                    {
                        Marshal.ReleaseComObject(dtcTransaction);
                    }
                }
                else
                {
                    return(UnsafeNativeMethods.MQSendMessage(handle, nativePropertiesPointer,
                                                             (IntPtr)GetTransactionConstant(transactionMode)));
                }
            }
            finally
            {
                message.Unpin();
            }
        }
        private int SendDtcTransacted(NativeMsmqMessage message, MsmqTransactionMode transactionMode)
        {
            int             num;
            IDtcTransaction nativeTransaction = this.GetNativeTransaction(transactionMode);
            MsmqQueueHandle handle            = this.GetHandle();
            IntPtr          properties        = message.Pin();

            try
            {
                if (nativeTransaction != null)
                {
                    try
                    {
                        return(UnsafeNativeMethods.MQSendMessage(handle, properties, nativeTransaction));
                    }
                    finally
                    {
                        Marshal.ReleaseComObject(nativeTransaction);
                    }
                }
                num = UnsafeNativeMethods.MQSendMessage(handle, properties, (IntPtr)this.GetTransactionConstant(transactionMode));
            }
            finally
            {
                message.Unpin();
            }
            return(num);
        }
示例#9
0
 unsafe int ReceiveByLookupIdCore(MsmqQueueHandle handle, long lookupId, NativeMsmqMessage message, MsmqTransactionMode transactionMode, int action)
 {
     if (RequiresDtcTransaction(transactionMode))
     {
         return(ReceiveByLookupIdCoreDtcTransacted(handle, lookupId, message, transactionMode, action));
     }
     else
     {
         IntPtr nativePropertiesPointer = message.Pin();
         try
         {
             return(UnsafeNativeMethods.MQReceiveMessageByLookupId(handle, lookupId, action, nativePropertiesPointer, null, IntPtr.Zero, (IntPtr)GetTransactionConstant(transactionMode)));
         }
         finally
         {
             message.Unpin();
         }
     }
 }
        private int ReceiveByLookupIdCore(MsmqQueueHandle handle, long lookupId, NativeMsmqMessage message, MsmqTransactionMode transactionMode, int action)
        {
            int num;

            if (this.RequiresDtcTransaction(transactionMode))
            {
                return(this.ReceiveByLookupIdCoreDtcTransacted(handle, lookupId, message, transactionMode, action));
            }
            IntPtr properties = message.Pin();

            try
            {
                num = UnsafeNativeMethods.MQReceiveMessageByLookupId(handle, lookupId, action, properties, null, IntPtr.Zero, (IntPtr)this.GetTransactionConstant(transactionMode));
            }
            finally
            {
                message.Unpin();
            }
            return(num);
        }
示例#11
0
 unsafe int ReceiveCore(MsmqQueueHandle handle, NativeMsmqMessage message, TimeSpan timeout, MsmqTransactionMode transactionMode, int action)
 {
     if (RequiresDtcTransaction(transactionMode))
     {
         return(ReceiveCoreDtcTransacted(handle, message, timeout, transactionMode, action));
     }
     else
     {
         int    timeoutInMilliseconds   = TimeoutHelper.ToMilliseconds(timeout);
         IntPtr nativePropertiesPointer = message.Pin();
         try
         {
             return(UnsafeNativeMethods.MQReceiveMessage(handle.DangerousGetHandle(), timeoutInMilliseconds,
                                                         action, nativePropertiesPointer, null, IntPtr.Zero, IntPtr.Zero, (IntPtr)GetTransactionConstant(transactionMode)));
         }
         finally
         {
             message.Unpin();
         }
     }
 }
        private int ReceiveCore(MsmqQueueHandle handle, NativeMsmqMessage message, TimeSpan timeout, MsmqTransactionMode transactionMode, int action)
        {
            int num2;

            if (this.RequiresDtcTransaction(transactionMode))
            {
                return(this.ReceiveCoreDtcTransacted(handle, message, timeout, transactionMode, action));
            }
            int    num        = TimeoutHelper.ToMilliseconds(timeout);
            IntPtr properties = message.Pin();

            try
            {
                num2 = UnsafeNativeMethods.MQReceiveMessage(handle.DangerousGetHandle(), num, action, properties, null, IntPtr.Zero, IntPtr.Zero, (IntPtr)this.GetTransactionConstant(transactionMode));
            }
            finally
            {
                message.Unpin();
            }
            return(num2);
        }
示例#13
0
        protected unsafe int ReceiveByLookupIdCoreDtcTransacted(MsmqQueueHandle handle, long lookupId, NativeMsmqMessage message, MsmqTransactionMode transactionMode, int action)
        {
            IDtcTransaction dtcTransaction = GetNativeTransaction(transactionMode);

            IntPtr nativePropertiesPointer = message.Pin();
            try
            {
                if (dtcTransaction != null)
                {
                    try
                    {
                        return UnsafeNativeMethods.MQReceiveMessageByLookupId(handle, lookupId, action, nativePropertiesPointer, null, IntPtr.Zero, dtcTransaction);
                    }
                    finally
                    {
                        Marshal.ReleaseComObject(dtcTransaction);
                    }
                }
                else
                {
                    return UnsafeNativeMethods.MQReceiveMessageByLookupId(handle, lookupId, action, nativePropertiesPointer, null, IntPtr.Zero, (IntPtr)GetTransactionConstant(transactionMode));
                }
            }
            finally
            {
                message.Unpin();
            }

        }
示例#14
0
        unsafe int ReceiveCoreDtcTransacted(MsmqQueueHandle handle, NativeMsmqMessage message, TimeSpan timeout, MsmqTransactionMode transactionMode, int action)
        {
            IDtcTransaction dtcTransaction = GetNativeTransaction(transactionMode);
            int timeoutInMilliseconds = TimeoutHelper.ToMilliseconds(timeout);

            IntPtr nativePropertiesPointer = message.Pin();
            try
            {
                if (dtcTransaction != null)
                {
                    try
                    {
                        return UnsafeNativeMethods.MQReceiveMessage(handle.DangerousGetHandle(), timeoutInMilliseconds,
                                                                    action, nativePropertiesPointer, null, IntPtr.Zero, IntPtr.Zero, dtcTransaction);
                    }
                    finally
                    {
                        Marshal.ReleaseComObject(dtcTransaction);
                    }
                }
                else
                {
                    return UnsafeNativeMethods.MQReceiveMessage(handle.DangerousGetHandle(), timeoutInMilliseconds,
                                                                action, nativePropertiesPointer, null, IntPtr.Zero, IntPtr.Zero, (IntPtr)GetTransactionConstant(transactionMode));
                }
            }
            finally
            {
                message.Unpin();
            }
        }
示例#15
0
 unsafe int ReceiveCore(MsmqQueueHandle handle, NativeMsmqMessage message, TimeSpan timeout, MsmqTransactionMode transactionMode, int action)
 {
     if (RequiresDtcTransaction(transactionMode))
     {
         return ReceiveCoreDtcTransacted(handle, message, timeout, transactionMode, action);
     }
     else
     {
         int timeoutInMilliseconds = TimeoutHelper.ToMilliseconds(timeout);
         IntPtr nativePropertiesPointer = message.Pin();
         try
         {
             return UnsafeNativeMethods.MQReceiveMessage(handle.DangerousGetHandle(), timeoutInMilliseconds,
                                                         action, nativePropertiesPointer, null, IntPtr.Zero, IntPtr.Zero, (IntPtr)GetTransactionConstant(transactionMode));
         }
         finally
         {
             message.Unpin();
         }
     }
 }
示例#16
0
        int SendDtcTransacted(NativeMsmqMessage message, MsmqTransactionMode transactionMode)
        {
            IDtcTransaction dtcTransaction = GetNativeTransaction(transactionMode);

            MsmqQueueHandle handle = GetHandle();
            IntPtr nativePropertiesPointer = message.Pin();
            try
            {
                if (dtcTransaction != null)
                {
                    try
                    {
                        return UnsafeNativeMethods.MQSendMessage(handle, nativePropertiesPointer,
                                                                 dtcTransaction);
                    }
                    finally
                    {
                        Marshal.ReleaseComObject(dtcTransaction);
                    }
                }
                else
                {
                    return UnsafeNativeMethods.MQSendMessage(handle, nativePropertiesPointer,
                                                             (IntPtr)GetTransactionConstant(transactionMode));
                }
            }
            finally
            {
                message.Unpin();
            }
        }
示例#17
0
        public void Send(NativeMsmqMessage message, MsmqTransactionMode transactionMode)
        {
            int error = 0;
            if (RequiresDtcTransaction(transactionMode))
            {
                error = SendDtcTransacted(message, transactionMode);
            }
            else
            {
                MsmqQueueHandle handle = GetHandle();
                IntPtr nativePropertiesPointer = message.Pin();
                try
                {
                    error = UnsafeNativeMethods.MQSendMessage(handle, nativePropertiesPointer,
                                                              (IntPtr)GetTransactionConstant(transactionMode));
                }
                finally
                {
                    message.Unpin();
                }
            }

            if (error != 0)
            {
                if (IsErrorDueToStaleHandle(error))
                {
                    HandleIsStale(handle);
                }
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MsmqException(SR.GetString(SR.MsmqSendError, MsmqError.GetErrorString(error)), error));
            }
        }
示例#18
0
 unsafe int ReceiveByLookupIdCore(MsmqQueueHandle handle, long lookupId, NativeMsmqMessage message, MsmqTransactionMode transactionMode, int action)
 {
     if (RequiresDtcTransaction(transactionMode))
     {
         return ReceiveByLookupIdCoreDtcTransacted(handle, lookupId, message, transactionMode, action);
     }
     else
     {
         IntPtr nativePropertiesPointer = message.Pin();
         try
         {
             return UnsafeNativeMethods.MQReceiveMessageByLookupId(handle, lookupId, action, nativePropertiesPointer, null, IntPtr.Zero, (IntPtr)GetTransactionConstant(transactionMode));
         }
         finally
         {
             message.Unpin();
         }
     }
 }