Exemplo n.º 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();
                    }
                }
            }
        }
Exemplo n.º 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();
         }
     }
 }
Exemplo n.º 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;
     }
 }
Exemplo n.º 4
0
 private string GetMessageByStatus(ThreadStatus status, string additionalInfo)
 {
     return ThreadStatuses.GetMessageByStatus(status, additionalInfo);
 }