Ejemplo n.º 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="identityID">标识ID</param>
        /// <param name="providerType">数据驱动连接提供者类型</param>
        /// <param name="connectingStr"></param>
        /// <param name="aCommandType"></param>
        /// <param name="aCommandText"></param>
        /// <param name="aParamters"></param>
        public void SendSqlCmd(int identityID, string providerType, string connectingStr, CommandType aCommandType, String aCommandText, DbParameter[] aParamters)
        {
            try
            {
                if (System.Threading.Monitor.TryEnter(SourceText.StLockMsmq, 3000))
                {

                    try
                    {
                        this.msmqCmd = MSMQCmd.SendSQLCmd;
                        this.oSqlMessageQueue = new SqlMessageQueue();
                        this.oSqlMessageQueue.CreateBody(identityID, providerType, connectingStr, aCommandType, aCommandText, aParamters);
                        this.SendMessage(MSMQCmd.SendSQLCmd, this.oSqlMessageQueue);
                    }
                    finally
                    {
                        System.Threading.Monitor.Exit(SourceText.StLockMsmq);
                    }
                }
                else
                {
                    throw new Exception("SendTimeOut");
                }
            }
            catch (Exception ex)
            {
                BaseLog baselog = new BaseLog("ActionMsmq");
                baselog.SaveLog(aCommandText, ex);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="aCmd"></param>
 /// <param name="aObjectBody"></param>
 public void SendMessage(MSMQCmd aCmd, object aObjectBody)
 {
     MessageQueue mq = null;
     Message message = new Message();
     message.Label = Convert.ToString(aCmd);
     switch (aCmd)
     {
         case MSMQCmd.SendSQLCmd:
             SqlMessageQueue sqlmq = (SqlMessageQueue)aObjectBody;
             TryMQ(sqlmq, out mq);
             message.Formatter = new XmlMessageFormatter(new Type[] { typeof(SqlMessageQueue) });
             message.Body = sqlmq;
             break;
     }
     if (mq != null)
     {
         mq.Send(message, trantype);
     }
     else
     {
         throw new Exception("MessageQueue is null.");
     }
 }