Example #1
0
        private void dispatcherTimer_Tick(object sender, EventArgs e)
        {
            try
            {
                if (_wkDTOInProgress == null)
                {
                    return;
                }
                if (lstLog.Items.Count > 20)
                {
                    lstLog.Items.Clear();
                }
                int idleTime = (int)(TimeControl.GetIdleTime() / 1000);
                if (idleTime >= configdto.IdleCicle)
                {
                    lstLog.Items.Add(FindResource("IdleTime").ToString() + ": " + idleTime);
                    btnStatus.Fill = new SolidColorBrush(Colors.Red);
                }
                else
                {
                    btnStatus.Fill = new SolidColorBrush(Colors.LightGreen);
                    _wkDTOInProgress.TimeWorked += configdto.UpdateCicle;
                }

                if (_wkDTOInProgress.TimeWorked >= configdto.SyncCicle)
                {
                    var boWkInProgress = _wkBO.GetValidInProgress();
                    if (boWkInProgress.isValid())
                    {
                        if (boWkInProgress.ObjectList.Count() > 1)
                        {
                            ni.ShowBalloonTip(50000, FindResource("Job").ToString(), FindResource("MultiProgressMsg").ToString(), System.Windows.Forms.ToolTipIcon.Warning);
                            return;
                        }
                        if (_wkDTOInProgress.RemainingWork == 0)
                        {
                            ni.ShowBalloonTip(50000, FindResource("Job").ToString(), FindResource("JobTimeMsg").ToString(), System.Windows.Forms.ToolTipIcon.Warning);
                            return;
                        }
                        double percentTime = _wkDTOInProgress.TimeWorkedPercent;
                        _wkDTOInProgress = boWkInProgress.ObjectList.First();
                        _wkDTOInProgress.CompletedWork += percentTime;
                        var boUpdate = _wkBO.UpdateWorked(_wkDTOInProgress);
                        if (boUpdate.isValid())
                        {
                            _wkDTOInProgress            = boUpdate.ObjectList.First();
                            _wkDTOInProgress.TimeWorked = 0;
                        }
                    }
                    new Thread(() => { Start(); }).Start();
                }
                if (_wkDTOInProgress.TimeWorked >= configdto.UpdateCicle * 20)
                {
                    checkVersion();
                }
            }
            catch (Exception ex) {
                lstLog.Items.Add(ex.Message);
            }
        }