Example #1
0
        /// <summary>
        /// Modifiy the state of an element.
        /// </summary>
        /// <param name="Name">Name of the element to modify</param>
        /// <param name="State">New state of the element</param>
        public static void ModifyState(string Name, StateSpooledObject State)
        {
            _mutexQueueFIFO.WaitOne();

            try
            {
                // check if the element is in the queue
                int index = -1;

                for (int i = 0; i < _queueFIFO.Count; i++)
                {
                    if (((SpooledObject)_queueFIFO[i]).Name == Name)
                    {
                        index = i;
                        break;
                    }
                }

                if (index >= 0)
                {
                    // element is found, modify its state
                    Global.Log.WriteEvent(LogType.normal, string.Format("[QUEUE STD] Changing state of '{0}', new state is {1}", Name, State));
                    ((SpooledObject)_queueFIFO[index]).State = State;
                }
            }

            catch (Exception ex)
            {
                Global.Log.WriteError("[QUEUE STD] " + ex.Message);
                Global.Log.WriteError("[QUEUE STD] " + ex.StackTrace);
            }

            _mutexQueueFIFO.ReleaseMutex();
        }
Example #2
0
        /// <summary>
        /// Give all element in a array list with the state specified by parameter.
        /// </summary>
        /// <param name="State">State of element to found</param>
        /// <returns>Array list contening the elements found</returns>
        public static ArrayList GiveSpooledObject(StateSpooledObject State)
        {
            ArrayList spooledObjectFiltered = new ArrayList();

            _mutexQueueFIFO.WaitOne();
            try
            {
                if (_queueFIFO.Count > 0)
                {
                    for (int i = 0; i < _queueFIFO.Count; i++)
                    {
                        if (((SpooledObject)_queueFIFO[i]).State == State)
                        {
                            spooledObjectFiltered.Add(((SpooledObject)_queueFIFO[i]));
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                Global.Log.WriteError("[QUEUE STD] " + ex.Message);
                Global.Log.WriteError("[QUEUE STD] " + ex.StackTrace);
            }

            _mutexQueueFIFO.ReleaseMutex();

            return(spooledObjectFiltered);
        }
Example #3
0
		/// <summary>
		/// Modifiy the state of an element.
		/// </summary>
		/// <param name="Name">Name of the element to modify</param>
		/// <param name="State">New state of the element</param>
		public static void ModifyState(string Name,StateSpooledObject State)
		{
			_mutexQueueFIFO.WaitOne();

			try
			{
				// check if the element is in the queue
				int index = -1;

				for(int i = 0 ; i < _queueFIFO.Count ; i++)
					if (((SpooledObject)_queueFIFO[i]).Name == Name)
					{
						index = i;
						break;
					}

				if (index >= 0)
				{
					// element is found, modify its state
					Global.Log.WriteEvent(LogType.normal,string.Format("[QUEUE STD] Changing state of '{0}', new state is {1}",Name,State));
					((SpooledObject)_queueFIFO[index]).State = State;
				}
			}

			catch(Exception ex)
			{
				Global.Log.WriteError("[QUEUE STD] " + ex.Message);
				Global.Log.WriteError("[QUEUE STD] " + ex.StackTrace);
			}

			_mutexQueueFIFO.ReleaseMutex();
		}
Example #4
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="Name">Name</param>
 /// <param name="Type">Type</param>
 /// <param name="ObjectToExecute">Object to execute</param>
 public SpooledObject(string Name, TypeSpooledObject Type, Object ObjectToExecute)
 {
     _name        = Name;
     _type        = Type;
     _object      = ObjectToExecute;
     _state       = StateSpooledObject.queued;
     _addedDate   = DateTime.Now;
     _sendingDate = DateTime.Now;
 }
		/// <summary>
		/// Give all element in a array list with the state specified by parameter.
		/// </summary>
		/// <param name="State">State of element to found</param>
		/// <returns>Array list contening the elements found</returns>
		public static ArrayList GiveSpooledObject(StateSpooledObject State)
		{
			ArrayList spooledObjectFiltered = new ArrayList();

			_mutexQueueScheduled.WaitOne();
			try
			{
				if (_queueScheduled.Count > 0)
				{
					for (int i = 0 ; i < _queueScheduled.Count ; i++)
					{
						if (((SpooledObject)_queueScheduled[i]).State == State)
						{
							spooledObjectFiltered.Add(((SpooledObject)_queueScheduled[i]));
						}
					}
				}

			}

			catch (Exception ex)
			{
				Global.Log.WriteError("[QUEUE SCHEDULED] " + ex.Message);
				Global.Log.WriteError("[QUEUE SCHEDULED] " + ex.StackTrace);
			}

			_mutexQueueScheduled.ReleaseMutex();

			return spooledObjectFiltered;
		}
Example #6
0
		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="Name">Name</param>
		/// <param name="Type">Type</param>
		/// <param name="ObjectToExecute">Object to execute</param>
		public SpooledObject(string Name, TypeSpooledObject Type, Object ObjectToExecute)
		{
			_name = Name;
			_type = Type;
			_object = ObjectToExecute;
			_state = StateSpooledObject.queued;
			_addedDate = DateTime.Now;
			_sendingDate = DateTime.Now;
		}