/// <summary>
        /// Initializes a new instance of the GXInitialActionMessage class.
        /// </summary>
		/// <param name="type">Type of the message</param>
		/// <param name="requestHandler">The handler of request message.</param>
        /// <param name="replyHandler">The handler of reply message.</param>
        /// <param name="isAllSentHandler">The handler of IsAllSent message.</param>
		/// <param name="acknowledge">The handler of Acknowledge message.</param>
        public GXInitialActionMessage(InitialActionType type, string requestHandler, string replyHandler, string isAllSentHandler, string acknowledge)
        {
            Type = type;
            RequestMessageHandler = requestHandler;
            ReplyMessageHandler = replyHandler;
            IsAllSentMessageHandler = isAllSentHandler;
            AcknowledgeMessageHandler = acknowledge;
        }
Пример #2
0
		internal void ExecuteInitialAction(InitialActionType type)
		{
            if (Tracing && m_OnTrace != null)
            {
                m_OnTrace(this, new TraceEventArgs(TraceTypes.Info, type.ToString() + Resources.Started, null));
            }
            //Wait until transaction is ended.
            if (!System.Threading.Monitor.TryEnter(m_transactionsync, this.WaitTime))
            {
                throw new Exception(Resources.TransactionIsAlreadyInProgress);
            }
            try
            {
                if (this.PacketHandler != null)
                {
                    foreach (GXInitialActionMessage it in GetInitialCommunicationMessageAttributes(this, type))
                    {
                        TransactionObject = null;
                        Execute(this, null, this.GXClient, it, true, true);
                        //If transaction is cancelled.
                        if (IsCancelled)
                        {
                            break;
                        }
                    }
                }
            }
            finally
            {
                System.Threading.Monitor.Exit(m_transactionsync);
                if (Tracing && m_OnTrace != null)
                {
                    m_OnTrace(this, new TraceEventArgs(TraceTypes.Info, type.ToString() + Resources.Ended, null));
                }
            }
		}
        /// <summary>
        /// Initializes a new instance of the GXInitialActionMessage class.
        /// </summary>
		/// <param name="type">Type of the message</param>
        /// <param name="requestHandler">The handler of request message.</param>
        /// <param name="replyHandler">The handler of reply message.</param>
        public GXInitialActionMessage(InitialActionType type, string requestHandler, string replyHandler)
        {
            Type = type;
            RequestMessageHandler = requestHandler;
            ReplyMessageHandler = replyHandler;
        }
Пример #4
0
		/// <summary>
		/// Find communication attributes.
		/// </summary>
		/// <param name="target"></param>
		/// <param name="type"></param>
		/// <returns></returns>
		Attribute[] GetInitialCommunicationMessageAttributes(object target, InitialActionType type)
		{
			SortedList<long, Attribute> attributes = new SortedList<long, Attribute>();
			object[] attribs = target.GetType().GetCustomAttributes(typeof(GXInitialActionMessage), true);
			long newIndex = int.MaxValue;
			long index;
			foreach (GXInitialActionMessage it in attribs)
			{
				if (it.Type == type)
				{
					index = it.Index;
					//If index is not givent get new one.
					if (index == 0)
					{
						index = ++newIndex;
					}
					if (attributes.ContainsKey(index))
					{
						GXInitialActionMessage existAttribute = attributes[index] as GXInitialActionMessage;
						throw new Exception(Resources.FailedToExecute + it.RequestMessageHandler + Resources.ItSIndexAlreadyExistsIn + existAttribute.RequestMessageHandler + ".");
					}
					attributes[index] = it;
				}
			}
			Attribute[] tmp = new Attribute[attributes.Count];
			attributes.Values.CopyTo(tmp, 0);
			return tmp;
		}