Beispiel #1
0
 /// <summary>
 /// MUST be called after de-serializing (i.e. after parameterless ctor was used).
 /// </summary>
 /// <param name="owner"></param>
 internal override void SetOwner(TaskBase owner)
 {
     System.Diagnostics.Debug.Assert(_timer == null);
     base.SetOwner(owner);
     _timer = new Timer(new TimerCallback(TimerCbk));
     if (Enabled)
     {
         Start(); // will account for paused as well
     }
 }
Beispiel #2
0
        private void PauseResumeSchedule()
        {
            TaskBase task = CurrentTask;

            if (task == null || !task.Schedule.Enabled)
            {
                return;
            }
            task.Schedule.Paused = !task.Schedule.Paused;
        }
Beispiel #3
0
        private void CheckCurrentTask()
        {
            TaskBase task = CurrentTask;

            if (task != null)
            {
                task.Check(true);
                statusTextTask.Text = task.Message;
            }
        }
Beispiel #4
0
        private void actionToolStripMenuItem_DropDownOpening(object sender, EventArgs e)
        {
            TaskBase   task    = CurrentTask;
            ActionBase action  = CurrentAction;
            ActionList actions = action == null ? null : action.Task.Actions;

            actionAddToolStripMenuItem.Enabled      = task != null && task.IsReady;
            actionDeleteToolStripMenuItem.Enabled   = actions != null && task.IsReady;
            actionMoveDownToolStripMenuItem.Enabled = actions != null && task.IsReady && actions.IndexOf(action) < actions.Count - 1;
            actionMoveUpToolStripMenuItem.Enabled   = actions != null && task.IsReady && actions.IndexOf(action) > 0;
        }
Beispiel #5
0
 public override void RemoveTask(long taskId)
 {
     lock (SyncRoot)
     {
         int      index;
         TaskBase task = this.TaskById(taskId, out index);
         if (task != null)
         {
             this.RemoveAt(index);
         }
     }
 }
Beispiel #6
0
        private void PreviewCurrentTask()
        {
            TaskBase task = CurrentTask;

            if (!CurrentTaskIsReady || !task.Check(false))
            {
                return;
            }
            C1.Win.C1Preview.C1PrintPreviewDialog pview = new C1.Win.C1Preview.C1PrintPreviewDialog();
            pview.Show(this);
            pview.Document = task.Document;
        }
Beispiel #7
0
 /// <summary>
 /// MUST be called after de-serializing (i.e. after parameterless ctor was used).
 /// </summary>
 /// <param name="owner"></param>
 internal void SetOwner(TaskBase owner)
 {
     System.Diagnostics.Debug.Assert(owner != null && _owner == null);
     lock (SyncRoot)
     {
         _owner = owner;
         foreach (ActionBase action in this)
         {
             action.SetOwner(_owner);
         }
     }
 }
Beispiel #8
0
        private void taskToolStripMenuItem_DropDownOpening(object sender, EventArgs e)
        {
            TaskBase task      = CurrentTask;
            int      taskIdx   = CurrentTaskIndex;
            int      taskCount = _taskGrid.Rows.Count;

            taskAddToolStripMenuItem.Enabled      = true;
            taskDeleteToolStripMenuItem.Enabled   = task != null && task.IsReady;
            taskMoveUpToolStripMenuItem.Enabled   = taskIdx > 0;
            taskMoveDownToolStripMenuItem.Enabled = taskIdx >= 0 && taskIdx < taskCount - 1;
            taskPreviewToolStripMenuItem.Enabled  = task != null && task.IsReady && task.ReportKind != ReportKind.Program;
            taskCheckToolStripMenuItem.Enabled    = task != null && task.IsReady;
            taskCheckAllToolStripMenuItem.Enabled = taskCount > 0;
        }
Beispiel #9
0
        private bool UiTaskSelectFileName(TaskBase task)
        {
            try
            {
                using (OpenFileDialog ofd = new OpenFileDialog())
                {
                    ofd.Filter =
                        "Report definition files (*.xml)|*.xml|C1DX documents(*.c1dx)|*.c1dx|C1D documents (*.c1d)|*.c1d|Executable files (*.exe)|*.exe|All files (*.*)|*.*";
                    if (ofd.ShowDialog() == DialogResult.OK)
                    {
                        task.FileName = ofd.FileName;
                        switch (Path.GetExtension(ofd.FileName).ToLowerInvariant())
                        {
                        case ".xml":
                            if (task.ReportKind == ReportKind.C1dDocument)
                            {
                                task.ReportKind = ReportKind.XmlReport;
                            }
                            break;

                        case ".c1d":
                        case ".c1dx":
                            if (task.ReportKind != ReportKind.C1dDocument)
                            {
                                task.ReportKind = ReportKind.C1dDocument;
                            }
                            break;

                        case ".exe":
                            if (task.ReportKind != ReportKind.Program)
                            {
                                task.ReportKind = ReportKind.Program;
                            }
                            break;
                        }
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                WinUtil.ShowError(ex.Message);
                return(false);
            }
        }
Beispiel #10
0
        void _actionGrid_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
        {
            TaskBase task = CurrentTask;

            System.Diagnostics.Debug.Assert(task != null);
            if (task == null)
            {
                return;
            }
            for (int i = 0; i < e.RowCount; ++i)
            {
                ActionBase action = task.Actions[e.RowIndex + i];
                UpdateActionGridFormatList(action);
                UpdateActionGridActionKindList(action);
                action.PropertyChanged += new PropertyChangedEventHandler(ActionPropertyChanged);
            }
        }
Beispiel #11
0
 protected override void RemoveItem(int index)
 {
     lock (SyncRoot)
     {
         TaskBase task = this[index];
         if (!_movingTask)
         {
             task.Schedule.Exit();
         }
         long id = task.Id;
         base.RemoveItem(index);
         if (_wcfCallback != null)
         {
             _wcfCallback.TaskRemoved(id);
         }
     }
 }
Beispiel #12
0
        protected override void OnPropertyChanged(string propertyName)
        {
            base.OnPropertyChanged(propertyName);

            TaskBase owner = _owner;

            if (propertyName != "CheckedStatus" && propertyName != "State")
            {
                CheckedStatus = CheckedStatus.Unknown;
                if (owner != null)
                {
                    owner.CheckedStatus = CheckedStatus.Unknown;
                }
            }

            if (owner == null)
            {
                return;
            }

            TaskListServer tasks = owner.Owner as TaskListServer;

            if (tasks == null)
            {
                return;
            }

            IC1ReportsSchedulerWcfCallback callback = tasks.WcfCallback;

            if (callback != null)
            {
                try
                {
                    callback.ActionPropertyChanged(owner.Id, this.Id, ToProxyXml(), propertyName);
                }
                catch (Exception ex)
                {
                    IC1ReportsSchedulerWcf wcfService = tasks.WcfService;
                    if (wcfService != null)
                    {
                        wcfService.Disconnect(ex.Message);
                    }
                }
            }
        }
Beispiel #13
0
        private void OnCurrentTaskChanged(bool forceUpdate)
        {
            TaskBase newCurrentTask = GetCurrentTask();

            if (_currentTask == newCurrentTask && !forceUpdate)
            {
                return;
            }

            if (_currentTask != null)
            {
                _currentTask.Schedule.PropertyChanged -= new PropertyChangedEventHandler(_currSchedule_PropertyChanged);
            }

            _currentTask = newCurrentTask;

            if (_currentTask != null)
            {
                _currentTask.Schedule.PropertyChanged += new PropertyChangedEventHandler(_currSchedule_PropertyChanged);
            }

            this.SuspendLayout();
            try
            {
                if (_currentTask == null)
                {
                    _actionGrid.DataSource = null;
                }
                else
                {
                    System.Diagnostics.Debug.Assert(_currentTask.Actions.Invoker == this);
                    _actionGrid.DataSource = _currentTask.Actions;
                    UpdateActionGridDropDowns();
                    UpdateSchedule(_currentTask);
                }
                UpdateCurrentTaskUi();
                UpdateCurrentActionUi();
                UpdateScheduleUi();
                OnTaskStateChanged(_currentTask);
            }
            finally
            {
                this.ResumeLayout();
            }
        }
Beispiel #14
0
 void _taskGrid_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
 {
     try
     {
         for (int i = 0; i < e.RowCount; ++i)
         {
             TaskBase task = Tasks[e.RowIndex + i];
             task.Actions.Invoker = this;
             UpdateTaskGridReportList(e.RowIndex + i);
             OnTaskStateChanged(task);
             task.PropertyChanged += new PropertyChangedEventHandler(TaskPropertyChanged);
         }
     }
     catch (Exception ex)
     {
         WinUtil.ShowError(ex.Message);
     }
 }
Beispiel #15
0
        private void UpdateTaskGridReportList(int rowIdx)
        {
            if (rowIdx < 0)
            {
                return;
            }

            // update list of reports:
            TaskBase task = Tasks[rowIdx];
            DataGridViewComboBoxCell cell = (DataGridViewComboBoxCell)_taskGrid[_taskGridInfo.ReportNameColIdx, rowIdx];

            if (cell.DataSource != task.ReportNames)
            {
                cell.DataSource = task.ReportNames;
                if (task.ReportNames != null && task.ReportNames.Length > 0 && !task.ReportNames.Contains <string>(task.ReportName))
                {
                    task.ReportName = task.ReportNames[0];
                }
            }
        }
Beispiel #16
0
        private void scheduleToolStripMenuItem_DropDownOpening(object sender, EventArgs e)
        {
            // if service is not running, disable all schedule commands:
            bool serviceRunning;

            if (ClientMode)
            {
                using (ServiceController sc = new ServiceController(C1ReportsSchedulerService.Constants.Name))
                {
                    try
                    {
                        serviceRunning = sc.Status == ServiceControllerStatus.Running;
                    }
                    catch
                    {
                        serviceRunning = false;
                    }
                    finally
                    {
                        sc.Close();
                    }
                }
                if (!serviceRunning)
                {
                    btnScheduleStart.Enabled = false;
                    btnSchedulePause.Enabled = false;
                }
            }
            else
            {
                serviceRunning = true;
            }
            TaskBase task    = CurrentTask;
            bool     running = task != null && task.Schedule.Enabled;
            bool     paused  = task != null && task.Schedule.Paused;

            scheduleStartToolStripMenuItem.Enabled  = serviceRunning && task != null && !running;
            scheduleStopToolStripMenuItem.Enabled   = serviceRunning && running && !paused;
            schedulePauseToolStripMenuItem.Enabled  = serviceRunning && running && !paused;
            scheduleResumeToolStripMenuItem.Enabled = serviceRunning && running && paused;
        }
Beispiel #17
0
 void _actionGrid_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex < 0)
     {
         return; // caption was clicked
     }
     if (e.ColumnIndex == _actionGridInfo.OutputNameSelectColIdx)
     {
         TaskBase task = CurrentTask;
         if (task != null)
         {
             ActionBase action = task.Actions[e.RowIndex];
             if (UiActionSelectFileName(action))
             {
                 UpdateActionGridFormatList(action);
                 UpdateActionGridActionKindList(action);
             }
         }
     }
     // ...
 }
Beispiel #18
0
 /// <summary>
 /// Set task grid row's properties according to task state.
 /// If the passed task is current, also updates actions and schedule panels.
 /// </summary>
 /// <param name="task"></param>
 private void OnTaskStateChanged(TaskBase task)
 {
     if (task == null)
     {
         return;
     }
     try
     {
         int taskIdx = Tasks.IndexOf(task);
         // ignore state change from task if it's not in grid - assume
         // that it was removed while executing:
         // System.Diagnostics.Debug.Assert(taskIdx >= 0);
         if (taskIdx < 0)
         {
             return;
         }
         bool ro = task.State != TaskState.Ready;
         _taskGrid.Rows[taskIdx].ReadOnly = ro;
         if (task == CurrentTask)
         {
             _actionGrid.ReadOnly = ro;
             foreach (ActionBase a in task.Actions)
             {
                 UpdateActionGridCellsReadonlyState(a);
             }
             SetReadOnlyRecursive(grpSchedule.Controls, ro);
             // for "one time" schedules, repeat freq/unit must be adjusted:
             numScheduleRepeatFreq.Enabled = chkScheduleRepeat.Checked;
             cmbScheduleRepeatUnit.Enabled = chkScheduleRepeat.Checked;
             SetReadOnlyRecursive(flwScheduleFrequency.Controls, ro);
             dtpScheduleDate.Enabled = !ro;
             dtpScheduleTime.Enabled = !ro;
         }
     }
     catch (Exception ex)
     {
         WinUtil.ShowError(ex.Message);
     }
 }
Beispiel #19
0
 private string GetTaskErrorMessage(TaskBase task)
 {
     if (task == null)
     {
         return(string.Empty);
     }
     else if (!string.IsNullOrEmpty(task.Message))
     {
         return(task.Message);
     }
     else
     {
         foreach (ActionBase action in task.Actions)
         {
             if (!string.IsNullOrEmpty(action.Message))
             {
                 return(string.Format("One or more actions have errors: {0}", action.Message));
             }
         }
     }
     return(string.Empty);
 }
Beispiel #20
0
        private void UpdateCurrentTaskUi()
        {
            try
            {
                TaskBase task      = CurrentTask;
                int      taskIdx   = CurrentTaskIndex;
                int      taskCount = _taskGrid.Rows.Count;

                this.tbtnTaskRemove.Enabled   = task != null && task.IsReady;
                this.tbtnTaskMoveUp.Enabled   = taskIdx > 0;
                this.tbtnTaskMoveDown.Enabled = taskIdx >= 0 && taskIdx < taskCount - 1;
                this.tbtnTaskPreview.Enabled  = task != null && task.IsReady && task.ReportKind != ReportKind.Program;

                // update status bar:
                if (task == null)
                {
                    statusTextTask.Text  = string.Empty;
                    statusTextTask.Image = null;
                }
                else
                {
                    statusTextTask.Text = GetTaskErrorMessage(task);
                    if (string.IsNullOrEmpty(statusTextTask.Text))
                    {
                        statusTextTask.Image = null;
                    }
                    else
                    {
                        statusTextTask.Image = global::C1ReportsScheduler.Properties.Resources.StateError;
                    }
                }
                ShowHidePleaseAddTask();
            }
            catch
            {
            }
        }
Beispiel #21
0
 public ActionClient(TaskBase owner)
     : base(owner)
 {
 }
Beispiel #22
0
        void _actionGrid_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }
            try
            {
                TaskBase task = CurrentTask;
                if (task == null)
                {
                    return;
                }

                bool readOnly = task.State != TaskState.Ready;
                _actionGrid.ReadOnly  = readOnly;
                e.CellStyle.ForeColor = readOnly ? SystemColors.GrayText : SystemColors.ControlText;

                if (e.ColumnIndex == _actionGridInfo.CheckedStatusColIdx)
                {
                    CheckedStatus cs;
                    string        message;
                    if (e.RowIndex >= task.Actions.Count)
                    {
                        return;
                    }
                    cs      = task.Actions[e.RowIndex].CheckedStatus;
                    message = task.Actions[e.RowIndex].Message;
                    switch (cs)
                    {
                    case CheckedStatus.Unknown:
                        e.Value = global::C1ReportsScheduler.Properties.Resources.GrayBall;
                        _actionGrid[e.ColumnIndex, e.RowIndex].ToolTipText = string.Empty;
                        break;

                    case CheckedStatus.Invalid:
                        e.Value = global::C1ReportsScheduler.Properties.Resources.StateError;
                        _actionGrid[e.ColumnIndex, e.RowIndex].ToolTipText = message;
                        break;

                    case CheckedStatus.CheckedOk:
                        e.Value = global::C1ReportsScheduler.Properties.Resources.StateOk;
                        _actionGrid[e.ColumnIndex, e.RowIndex].ToolTipText = string.Empty;
                        break;

                    case CheckedStatus.Working:
                        e.Value = global::C1ReportsScheduler.Properties.Resources.Working;
                        _actionGrid[e.ColumnIndex, e.RowIndex].ToolTipText = string.Empty;
                        break;

                    default:
                        System.Diagnostics.Debug.Assert(false);
                        break;
                    }
                }
                else if (e.ColumnIndex == _actionGridInfo.OutputNameColIdx)
                {
                    if (readOnly || task.ReportKind == ReportKind.Program)
                    {
                        e.CellStyle.ForeColor = SystemColors.GrayText;
                    }
                }
            }
            catch
            {
            }
        }
Beispiel #23
0
        private void UpdateSchedule(TaskBase task)
        {
            this.dtpScheduleDate.DataBindings.Clear();
            this.dtpScheduleDate.DataBindings.Add("Value", task.Schedule, "StartTime");
            this.dtpScheduleTime.DataBindings.Clear();
            this.dtpScheduleTime.DataBindings.Add("Value", task.Schedule, "StartTime");

            this.rbtScheduleOnce.DataBindings.Clear();
            this.rbtScheduleOnce.DataBindings.Add("Checked", task.Schedule, "FrequencyOnce");
            this.rbtScheduleDaily.DataBindings.Clear();
            this.rbtScheduleDaily.DataBindings.Add("Checked", task.Schedule, "FrequencyDaily");
            this.rbtScheduleWeekly.DataBindings.Clear();
            this.rbtScheduleWeekly.DataBindings.Add("Checked", task.Schedule, "FrequencyWeekly");
            this.rbtScheduleMonthly.DataBindings.Clear();
            this.rbtScheduleMonthly.DataBindings.Add("Checked", task.Schedule, "FrequencyMonthly");

            this.numScheduleDays.DataBindings.Clear();
            // NOTE: when Value of a numeric updown is bound, typing a value does not update data:
            // this.numScheduleDays.DataBindings.Add("Value", task.Schedule, "RecurEveryDays");
            this.numScheduleDays.DataBindings.Add("Text", task.Schedule, "RecurEveryDays");

            this.numScheduleWeeks.DataBindings.Clear();
            // this.numScheduleWeeks.DataBindings.Add("Value", task.Schedule, "RecurEveryWeeks");
            this.numScheduleWeeks.DataBindings.Add("Text", task.Schedule, "RecurEveryWeeks");

            this.chkScheduleSunday.DataBindings.Clear();
            this.chkScheduleSunday.DataBindings.Add("Checked", task.Schedule, "Sunday");
            this.chkScheduleMonday.DataBindings.Clear();
            this.chkScheduleMonday.DataBindings.Add("Checked", task.Schedule, "Monday");
            this.chkScheduleTuesday.DataBindings.Clear();
            this.chkScheduleTuesday.DataBindings.Add("Checked", task.Schedule, "Tuesday");
            this.chkScheduleWednesday.DataBindings.Clear();
            this.chkScheduleWednesday.DataBindings.Add("Checked", task.Schedule, "Wednesday");
            this.chkScheduleThursday.DataBindings.Clear();
            this.chkScheduleThursday.DataBindings.Add("Checked", task.Schedule, "Thursday");
            this.chkScheduleFriday.DataBindings.Clear();
            this.chkScheduleFriday.DataBindings.Add("Checked", task.Schedule, "Friday");
            this.chkScheduleSaturday.DataBindings.Clear();
            this.chkScheduleSaturday.DataBindings.Add("Checked", task.Schedule, "Saturday");

            this.chkScheduleJan.DataBindings.Clear();
            this.chkScheduleJan.DataBindings.Add("Checked", task.Schedule, "January");
            this.chkScheduleFeb.DataBindings.Clear();
            this.chkScheduleFeb.DataBindings.Add("Checked", task.Schedule, "February");
            this.chkScheduleMar.DataBindings.Clear();
            this.chkScheduleMar.DataBindings.Add("Checked", task.Schedule, "March");
            this.chkScheduleApr.DataBindings.Clear();
            this.chkScheduleApr.DataBindings.Add("Checked", task.Schedule, "April");
            this.chkScheduleMay.DataBindings.Clear();
            this.chkScheduleMay.DataBindings.Add("Checked", task.Schedule, "May");
            this.chkScheduleJun.DataBindings.Clear();
            this.chkScheduleJun.DataBindings.Add("Checked", task.Schedule, "June");
            this.chkScheduleJul.DataBindings.Clear();
            this.chkScheduleJul.DataBindings.Add("Checked", task.Schedule, "July");
            this.chkScheduleAug.DataBindings.Clear();
            this.chkScheduleAug.DataBindings.Add("Checked", task.Schedule, "August");
            this.chkScheduleSep.DataBindings.Clear();
            this.chkScheduleSep.DataBindings.Add("Checked", task.Schedule, "September");
            this.chkScheduleOct.DataBindings.Clear();
            this.chkScheduleOct.DataBindings.Add("Checked", task.Schedule, "October");
            this.chkScheduleNov.DataBindings.Clear();
            this.chkScheduleNov.DataBindings.Add("Checked", task.Schedule, "November");
            this.chkScheduleDec.DataBindings.Clear();
            this.chkScheduleDec.DataBindings.Add("Checked", task.Schedule, "December");

            this.chkScheduleDay1.DataBindings.Clear();
            this.chkScheduleDay1.DataBindings.Add("Checked", task.Schedule, "Day1");
            this.chkScheduleDay2.DataBindings.Clear();
            this.chkScheduleDay2.DataBindings.Add("Checked", task.Schedule, "Day2");
            this.chkScheduleDay3.DataBindings.Clear();
            this.chkScheduleDay3.DataBindings.Add("Checked", task.Schedule, "Day3");
            this.chkScheduleDay4.DataBindings.Clear();
            this.chkScheduleDay4.DataBindings.Add("Checked", task.Schedule, "Day4");
            this.chkScheduleDay5.DataBindings.Clear();
            this.chkScheduleDay5.DataBindings.Add("Checked", task.Schedule, "Day5");
            this.chkScheduleDay6.DataBindings.Clear();
            this.chkScheduleDay6.DataBindings.Add("Checked", task.Schedule, "Day6");
            this.chkScheduleDay7.DataBindings.Clear();
            this.chkScheduleDay7.DataBindings.Add("Checked", task.Schedule, "Day7");
            this.chkScheduleDay8.DataBindings.Clear();
            this.chkScheduleDay8.DataBindings.Add("Checked", task.Schedule, "Day8");
            this.chkScheduleDay9.DataBindings.Clear();
            this.chkScheduleDay9.DataBindings.Add("Checked", task.Schedule, "Day9");
            this.chkScheduleDay10.DataBindings.Clear();
            this.chkScheduleDay10.DataBindings.Add("Checked", task.Schedule, "Day10");

            this.chkScheduleDay11.DataBindings.Clear();
            this.chkScheduleDay11.DataBindings.Add("Checked", task.Schedule, "Day11");
            this.chkScheduleDay12.DataBindings.Clear();
            this.chkScheduleDay12.DataBindings.Add("Checked", task.Schedule, "Day12");
            this.chkScheduleDay13.DataBindings.Clear();
            this.chkScheduleDay13.DataBindings.Add("Checked", task.Schedule, "Day13");
            this.chkScheduleDay14.DataBindings.Clear();
            this.chkScheduleDay14.DataBindings.Add("Checked", task.Schedule, "Day14");
            this.chkScheduleDay15.DataBindings.Clear();
            this.chkScheduleDay15.DataBindings.Add("Checked", task.Schedule, "Day15");
            this.chkScheduleDay16.DataBindings.Clear();
            this.chkScheduleDay16.DataBindings.Add("Checked", task.Schedule, "Day16");
            this.chkScheduleDay17.DataBindings.Clear();
            this.chkScheduleDay17.DataBindings.Add("Checked", task.Schedule, "Day17");
            this.chkScheduleDay18.DataBindings.Clear();
            this.chkScheduleDay18.DataBindings.Add("Checked", task.Schedule, "Day18");
            this.chkScheduleDay19.DataBindings.Clear();
            this.chkScheduleDay19.DataBindings.Add("Checked", task.Schedule, "Day19");
            this.chkScheduleDay20.DataBindings.Clear();
            this.chkScheduleDay20.DataBindings.Add("Checked", task.Schedule, "Day20");

            this.chkScheduleDay21.DataBindings.Clear();
            this.chkScheduleDay21.DataBindings.Add("Checked", task.Schedule, "Day21");
            this.chkScheduleDay22.DataBindings.Clear();
            this.chkScheduleDay22.DataBindings.Add("Checked", task.Schedule, "Day22");
            this.chkScheduleDay23.DataBindings.Clear();
            this.chkScheduleDay23.DataBindings.Add("Checked", task.Schedule, "Day23");
            this.chkScheduleDay24.DataBindings.Clear();
            this.chkScheduleDay24.DataBindings.Add("Checked", task.Schedule, "Day24");
            this.chkScheduleDay25.DataBindings.Clear();
            this.chkScheduleDay25.DataBindings.Add("Checked", task.Schedule, "Day25");
            this.chkScheduleDay26.DataBindings.Clear();
            this.chkScheduleDay26.DataBindings.Add("Checked", task.Schedule, "Day26");
            this.chkScheduleDay27.DataBindings.Clear();
            this.chkScheduleDay27.DataBindings.Add("Checked", task.Schedule, "Day27");
            this.chkScheduleDay28.DataBindings.Clear();
            this.chkScheduleDay28.DataBindings.Add("Checked", task.Schedule, "Day28");
            this.chkScheduleDay29.DataBindings.Clear();
            this.chkScheduleDay29.DataBindings.Add("Checked", task.Schedule, "Day29");
            this.chkScheduleDay30.DataBindings.Clear();
            this.chkScheduleDay30.DataBindings.Add("Checked", task.Schedule, "Day30");

            this.chkScheduleDay31.DataBindings.Clear();
            this.chkScheduleDay31.DataBindings.Add("Checked", task.Schedule, "Day31");
            this.chkScheduleDayLast.DataBindings.Clear();
            this.chkScheduleDayLast.DataBindings.Add("Checked", task.Schedule, "DayLast");

            this.chkScheduleRepeat.DataBindings.Clear();
            this.chkScheduleRepeat.DataBindings.Add("Checked", task.Schedule, "Repeat");
            this.numScheduleRepeatFreq.DataBindings.Clear();
            // this.numScheduleRepeatFreq.DataBindings.Add("Value", task.Schedule, "RepeatFrequency");
            this.numScheduleRepeatFreq.DataBindings.Add("Text", task.Schedule, "RepeatFrequency");
            this.cmbScheduleRepeatUnit.DataSource = Enum.GetValues(typeof(ScheduleRepeatUnit));
            this.cmbScheduleRepeatUnit.DataBindings.Clear();
            this.cmbScheduleRepeatUnit.DataBindings.Add("SelectedItem", task.Schedule, "RepeatUnit");
        }
Beispiel #24
0
 private void UpdateScheduleUi()
 {
     try
     {
         TaskBase task = CurrentTask;
         if (task == null)
         {
             // Note: disabling buttons may result in .net trying to move focus to the task grid,
             // and if that grid is empty that may cause SetCurrentCellAddressCore exception,
             // hence this (TFS~~14180):
             BeginInvoke((Action)(() => UpdateScheduleUiNoTask()));
         }
         else
         {
             flwScheduleFrequency.Enabled  = true;
             dtpScheduleDate.Enabled       = dtpScheduleTime.Enabled = task.State == TaskState.Ready;
             grpSchedule.Visible           = true;
             flwScheduleOnce.Visible       = task.Schedule.FrequencyOnce;
             flwScheduleDaily.Visible      = task.Schedule.FrequencyDaily;
             pnlScheduleWeek.Visible       = task.Schedule.FrequencyWeekly;
             pnlScheduleMonth.Visible      = task.Schedule.FrequencyMonthly;
             pnlScheduleMonthDays.Visible  = task.Schedule.FrequencyMonthly;
             numScheduleRepeatFreq.Enabled = chkScheduleRepeat.Checked;
             cmbScheduleRepeatUnit.Enabled = chkScheduleRepeat.Checked;
             btnScheduleStart.Enabled      = true;
             if (task.Schedule.Enabled)
             {
                 btnScheduleStart.Text    = "Stop";
                 btnScheduleStart.Image   = global::C1ReportsScheduler.Properties.Resources.Stop;
                 btnSchedulePause.Enabled = true;
             }
             else
             {
                 btnScheduleStart.Text    = "Start";
                 btnScheduleStart.Image   = global::C1ReportsScheduler.Properties.Resources.Start;
                 btnSchedulePause.Enabled = false;
             }
             if (task.Schedule.Paused)
             {
                 btnSchedulePause.Text  = "Resume";
                 btnSchedulePause.Image = global::C1ReportsScheduler.Properties.Resources.Resume;
             }
             else
             {
                 btnSchedulePause.Text  = "Pause";
                 btnSchedulePause.Image = global::C1ReportsScheduler.Properties.Resources.Pause;
             }
             // in client mode, if service is paused, disable both start and stop:
             if (ClientMode)
             {
                 bool serviceRunning;
                 using (ServiceController sc = new ServiceController(C1ReportsSchedulerService.Constants.Name))
                 {
                     try
                     {
                         serviceRunning = sc.Status == ServiceControllerStatus.Running;
                     }
                     catch
                     {
                         serviceRunning = false;
                     }
                     finally
                     {
                         sc.Close();
                     }
                 }
                 if (!serviceRunning)
                 {
                     btnScheduleStart.Enabled = false;
                     btnSchedulePause.Enabled = false;
                 }
             }
             DateTime nextDueTime = task.Schedule.NextDueTime;
             if (nextDueTime == ScheduleBase.c_DateTimeNever)
             {
                 lblScheduleNextDueTime.Text = "Never";
             }
             else
             {
                 lblScheduleNextDueTime.Text = nextDueTime.ToString();
             }
         }
     }
     catch
     {
     }
 }
Beispiel #25
0
 public ScheduleBase(TaskBase owner)
 {
     SetOwner(owner);
 }
Beispiel #26
0
 /// <summary>
 /// MUST be called after de-serializing (i.e. after parameterless ctor was used).
 /// </summary>
 /// <param name="owner"></param>
 internal virtual void SetOwner(TaskBase owner)
 {
     System.Diagnostics.Debug.Assert(owner != null && _owner == null);
     _owner = owner;
 }
Beispiel #27
0
        protected override void OnListChanged(ListChangedEventArgs e)
        {
            base.OnListChanged(e);

            TaskBase owner = _owner;

            if (owner == null)
            {
                return;
            }

            if (e.ListChangedType == ListChangedType.ItemAdded || e.ListChangedType == ListChangedType.ItemDeleted)
            {
                owner.CheckedStatus = CheckedStatus.Unknown;
            }

            TaskListServer tasks = owner.Owner as TaskListServer;

            if (tasks == null)
            {
                return;
            }

            IC1ReportsSchedulerWcfCallback wcfCallback = tasks.WcfCallback;

            if (wcfCallback == null)
            {
                return;
            }

            try
            {
                switch (e.ListChangedType)
                {
                case ListChangedType.ItemAdded:
                    try
                    {
                        ActionServer action = (ActionServer)this[e.NewIndex];
                        long         ownerId;
                        long         actionId;
                        string       xml;
                        lock (action.SyncRoot)
                        {
                            ownerId  = owner.Id;
                            actionId = action.Id;
                            xml      = action.ToProxyXml();
                        }
                        wcfCallback.ActionAdded(ownerId, e.NewIndex, actionId, xml);
                    }
                    catch (Exception ex)
                    {
                        AltUtil.ShowError(ex.Message);
                    }
                    break;

                case ListChangedType.ItemChanged:
                    try
                    {
                        ActionServer action = (ActionServer)this[e.NewIndex];
                        long         ownerId;
                        long         actionId;
                        string       xml;
                        lock (action.SyncRoot)
                        {
                            ownerId  = owner.Id;
                            actionId = action.Id;
                            xml      = action.ToProxyXml();
                        }
                        wcfCallback.ActionPropertyChanged(ownerId, actionId, xml, e.PropertyDescriptor.Name);
                    }
                    catch (Exception ex)
                    {
                        AltUtil.ShowError(ex.Message);
                    }
                    break;

                case ListChangedType.ItemDeleted:
                    // we need removed task's id, hence TaskRemoved must be called from RemoveItem override:
                    // wcfCallback.TaskRemoved(TaskId(e.NewIndex));
                    break;

                case ListChangedType.ItemMoved:
                    break;

                case ListChangedType.Reset:
                    break;
                }
            }
            catch (Exception ex)
            {
                AltUtil.ShowError(ex.Message);
                IC1ReportsSchedulerWcf wcfService = tasks.WcfService;
                if (wcfService != null)
                {
                    wcfService.Disconnect(ex.Message);
                }
            }
        }
Beispiel #28
0
 public ScheduleServer(TaskBase owner)
     : base(owner)
 {
 }
Beispiel #29
0
        private void _taskGrid_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }

            bool readOnly = _taskGrid.Rows[e.RowIndex].ReadOnly;

            e.CellStyle.ForeColor = readOnly ? SystemColors.GrayText : SystemColors.ControlText;

            if (e.ColumnIndex == _taskGridInfo.ReadyColIdx)
            {
                switch (Tasks[e.RowIndex].State)
                {
                case TaskState.Ready:
                    e.Value = "Ready";
                    break;

                case TaskState.Busy:
                    e.Value = "Busy";
                    break;

                case TaskState.Scheduled:
                    e.Value = "Scheduled";
                    break;

                case TaskState.Paused:
                    e.Value = "Paused";
                    break;

                default:
                    System.Diagnostics.Debug.Assert(false);
                    break;
                }
            }
            else if (e.ColumnIndex == _taskGridInfo.TaskKindColIdx)
            {
                TaskBase task = Tasks[e.RowIndex];
                e.Value = c_taskKindNames[task.ReportKind].Name;
                _taskGrid[e.ColumnIndex, e.RowIndex].ToolTipText = c_taskKindNames[task.ReportKind].ToolTip;
            }
            else if (e.ColumnIndex == _taskGridInfo.CheckedStatusColIdx)
            {
                TaskBase task = Tasks[e.RowIndex];
                switch (task.CheckedStatus)
                {
                case CheckedStatus.Unknown:
                    e.Value = global::C1ReportsScheduler.Properties.Resources.GrayBall;
                    _taskGrid[e.ColumnIndex, e.RowIndex].ToolTipText = string.Empty;
                    break;

                case CheckedStatus.Invalid:
                    e.Value = global::C1ReportsScheduler.Properties.Resources.StateError;
                    _taskGrid[e.ColumnIndex, e.RowIndex].ToolTipText = GetTaskErrorMessage(task);
                    break;

                case CheckedStatus.CheckedOk:
                    e.Value = global::C1ReportsScheduler.Properties.Resources.StateOk;
                    _taskGrid[e.ColumnIndex, e.RowIndex].ToolTipText = string.Empty;
                    break;

                case CheckedStatus.Working:
                    e.Value = global::C1ReportsScheduler.Properties.Resources.Working;
                    _taskGrid[e.ColumnIndex, e.RowIndex].ToolTipText = string.Empty;
                    break;

                default:
                    System.Diagnostics.Debug.Assert(false);
                    break;
                }
            }
            else if (e.ColumnIndex == _taskGridInfo.ReportNameColIdx)
            {
                TaskBase task = Tasks[e.RowIndex];
                switch (task.ReportKind)
                {
                case ReportKind.XmlReport:
                case ReportKind.ImportedReport:
                    _taskGrid[e.ColumnIndex, e.RowIndex].ReadOnly = false;
                    break;

                case ReportKind.C1dDocument:
                case ReportKind.Program:
                    _taskGrid[e.ColumnIndex, e.RowIndex].ReadOnly = true;
                    break;

                default:
                    System.Diagnostics.Debug.Assert(false);
                    break;
                }
            }
        }