Beispiel #1
0
        }// ProcessRequest()

        //
        //
        //
        //
        //
        //
        // ****                     Timer_Elapsed()                 ****
        //
        private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs eventArgs)
        {
            m_Timer.Enabled = false;            // stop the timer - if any
            lock (m_WaitingRequests)
            {
                while (m_WaitingRequests.Count > 0)
                {
                    RequestEventArgs request = m_WaitingRequests[0];
                    m_WaitingRequests.RemoveAt(0);
                    this.HubEventEnqueue(request);
                }
            }
            m_Timer.Enabled = true;
        }// Timer_Elapsed()
Beispiel #2
0
        //
        //
        #endregion//Constructors


        #region no Properties
        // *****************************************************************
        // ****                     Properties                          ****
        // *****************************************************************
        //
        //
        #endregion//Properties


        #region Public Methods
        // *****************************************************************
        // ****                     Public Methods                      ****
        // *****************************************************************
        public bool Request(RequestEventArgs request)
        {
            return(this.HubEventEnqueue(request));
        }
Beispiel #3
0
        }// HubEventHandler()

        //
        //
        // ****             ProcessRequest()                    ****
        //
        private void ProcessRequest(RequestEventArgs eventArg)
        {
            if (eventArg.Type == RequestType.GetNewFiles)
            {
                List <string> filesFound;
                if (TryCopyNewFilesToLocal(out filesFound))
                {                                                    // Success!
                    eventArg.Status = RequestStatus.Success;
                    eventArg.Data   = new List <object>(filesFound); // pass the file names copied back to subscribers.
                    lock (m_WaitingRequests)
                    {
                        if (m_WaitingRequests.Contains(eventArg))
                        {
                            m_WaitingRequests.Remove(eventArg);
                        }
                    }
                }
                else
                {     // Failure
                    if (DateTime.Now.CompareTo(eventArg.GiveUpTime) > 0)
                    { // Give up!
                        eventArg.Status = RequestStatus.Failed;
                        lock (m_WaitingRequests)
                        {
                            if (m_WaitingRequests.Contains(eventArg))
                            {
                                m_WaitingRequests.Remove(eventArg);
                            }
                        }
                    }
                    else
                    {   // Keep trying
                        eventArg.Status = RequestStatus.StillWorking;
                        lock (m_WaitingRequests)
                        {
                            if (!m_WaitingRequests.Contains(eventArg))
                            {
                                m_WaitingRequests.Add(eventArg);
                            }
                        }
                    }
                }
                // Report results
                OnRequestCompleted(eventArg);
                Log.NewEntry(LogLevel.Major, "ProcessRequest: {0} {1}.", eventArg, eventArg.Status);
            }
            else if (eventArg.Type == RequestType.Stop)
            {
                if (m_Timer != null)
                {
                    m_Timer.Stop();
                    m_Timer.Elapsed -= new System.Timers.ElapsedEventHandler(Timer_Elapsed);
                    m_Timer          = null;
                }
                base.Stop();
            }
            else
            {
                Log.NewEntry(LogLevel.Major, "ProcessRequest: RequestType {0} not implemented.", eventArg.Type);
            }
        }// ProcessRequest()
Beispiel #4
0
        //
        //
        #endregion//Constructors



        #region Public Methods
        // *****************************************************************
        // ****                     Public Methods                      ****
        // *****************************************************************
        //
        //
        //
        //
        //
        #endregion//Public Methods


        #region Private Methods
        // *****************************************************************
        // ****                     Private Methods                     ****
        // *****************************************************************
        //
        //
        // ******************************************************************
        // ****             FtpReader RequestCompleted()                *****
        // ******************************************************************
        private void FtpReader_RequestCompleted(object sender, EventArgs eventArgs)
        {
            Ftp.RequestEventArgs request = (Ftp.RequestEventArgs)eventArgs;
        }