예제 #1
0
        private void OnTimedEvent(Object source, System.Timers.ElapsedEventArgs e)
        {
            if (_isScheduleMode)
            {
                bool allDownloaded = true;

                foreach (var thread in _threadsMap)
                {
                    if (ThreadStatuses.GetThreadStatusTypeByStatus(thread.Value.Status) == ThreadStatusType.Failed)
                    {
                        thread.Value.StartThread();
                        allDownloaded = false;
                    }
                }

                if (allDownloaded)
                {
                    _time.Enabled = false;
                    MessageBox.Show(@"Заявки скопированы");
                    MessageBox.Show(@"Все заявки скопированы. Дата/Время:" + DateTime.Now);
                }
            }

            if (_isAutoMode)
            {
                foreach (var thread in _threadsMap)
                {
                    if (ThreadStatuses.GetThreadStatusTypeByStatus(thread.Value.Status) == ThreadStatusType.Failed)
                    {
                        thread.Value.StartThread();
                    }
                }
            }
        }
예제 #2
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     foreach (var thread in _threadsMap)
     {
         if (ThreadStatuses.GetThreadStatusTypeByStatus(thread.Value.Status) != ThreadStatusType.Failed)
         {
             thread.Value.SetThreadToStop();
         }
     }
 }
예제 #3
0
 private void UpdateStatusWithAdditionalInfo(ThreadStatus newStatus, string additionalInfo)
 {
     Status = newStatus;
     string newText = GetMessageByStatus(Status, additionalInfo);
     Color newColor = ThreadStatuses.GetColorByStatus(Status);
     if (_textBox.InvokeRequired)
         _textBox.Invoke(new Action<string, Color>((text, color) =>
         {
             _textBox.Text = text;
             _textBox.BackColor = color;
         }), newText, newColor);
     else
     {
         _textBox.Text = newText;
         _textBox.BackColor = newColor;
     }
 }
예제 #4
0
 private string GetMessageByStatus(ThreadStatus status, string additionalInfo)
 {
     return ThreadStatuses.GetMessageByStatus(status, additionalInfo);
 }