Пример #1
0
        private void TasksDeleteCurrent()
        {
            int currRowIdx = CurrentTaskIndex;

            if (currRowIdx == -1)
            {
                return;
            }
            TaskBase task = Tasks[currRowIdx];

            if (!string.IsNullOrEmpty(task.FileName) &&
                !WinUtil.AskQuestion(string.Format("Remove report {0}/{1} from list?", task.FileName, task.ReportName), true))
            {
                return;
            }
            if (currRowIdx == _taskGrid.Rows.Count - 1)
            {
                --currRowIdx;
            }
            if (currRowIdx >= 0 && currRowIdx < _taskGrid.Rows.Count)
            {
                _desiredTaskId = Tasks[currRowIdx].Id;
            }
            Tasks.RemoveTask(task.Id);
        }
Пример #2
0
        private void ActionsDeleteCurrent()
        {
            if (!CurrentTaskIsReady)
            {
                return;
            }
            int currRowIdx = CurrentActionIndex;

            if (currRowIdx == -1)
            {
                return;
            }
            ActionList actions = CurrentActions;

            if (actions == null)
            {
                return;
            }
            ActionBase action = actions[currRowIdx];

            if (!string.IsNullOrEmpty(action.OutputFileName) && !WinUtil.AskQuestion("Remove action from list?", true))
            {
                return;
            }
            if (currRowIdx == _actionGrid.Rows.Count - 1)
            {
                --currRowIdx;
            }
            if (currRowIdx >= 0 && currRowIdx < _actionGrid.Rows.Count)
            {
                _desiredActionId = actions[currRowIdx].Id;
            }
            actions.RemoveAction(action.Id);
        }
Пример #3
0
        private void ServiceInstall()
        {
            string question = string.Format("This will install {0} service on your system.\r\nDo you want to continue?", C1ReportsSchedulerService.Constants.Name);

            if (WinUtil.AskQuestion(question, false))
            {
                ServiceSetup();
            }
        }
Пример #4
0
 private void TransferTasksToService()
 {
     if (ClientMode)
     {
         return;
     }
     if (!WinUtil.AskQuestion("This will delete all tasks currently handled by the service, and restart it with the current task list.\r\nDo you want to continue?", true))
     {
         return;
     }
     using (ProgressDialog prg = new ProgressDialog())
     {
         ServiceCall(ServiceControllerStatus.Stopped, "Stopping", prg);
         ServiceStart(prg, true);
     }
 }
Пример #5
0
        private void ServiceUninstall()
        {
            string question = string.Format("This will remove {0} service from your system.\r\nDo you want to continue?", C1ReportsSchedulerService.Constants.Name);

            if (!WinUtil.AskQuestion(question, false))
            {
                return;
            }

            using (ProgressDialog prg = new ProgressDialog())
            {
                DisconnectFromService();
                ServiceCall(ServiceControllerStatus.Stopped, "Stopping", prg);
                prg.SetProgress(prg.Complete, "Uninstalling service...");
                ServiceInstaller.InstallService.Uninstall(C1ReportsSchedulerService.Constants.Name);
            }
        }
Пример #6
0
 private bool ConfirmNewOrLoadTasks()
 {
     if (ClientMode)
     {
         if (!WinUtil.AskQuestion(string.Format(
                                      "Loading a new task list will disconnect from the {0} service and switch the application to standalone mode. Do you want to continue?",
                                      C1ReportsSchedulerService.Constants.Name), true))
         {
             return(false);
         }
     }
     else if (Tasks.Count > 0)
     {
         if (!WinUtil.AskQuestion("Overwrite current task list?", true))
         {
             return(false);
         }
     }
     return(true);
 }
Пример #7
0
        void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if ((e.CloseReason == CloseReason.UserClosing || e.CloseReason == CloseReason.ApplicationExitCall) &&
                !ClientMode && _tasksHolder.Tasks.Count > 0)
            {
                string question = "C1ReportsScheduler is currently running in standalone mode.\r\n" +
                                  "If you close it now, scheduled tasks will stop running. To keep them running, either keep the C1ReportsScheduler application open, " +
                                  "or (recommended) install the C1ReportsScheduler service and transfer scheduled tasks to it via the \"Service\" menu.\r\n\r\n" +
                                  "Continue closing C1ReportsScheduler application?";
                if (!WinUtil.AskQuestion(question, true))
                {
                    e.Cancel = true;
                    return;
                }
            }

            _tasksHolder.StopSchedules();
            if (_tasksHolder.Tasks is TaskListClient)
            {
                ((TaskListClient)_tasksHolder.Tasks).Close();
            }
        }
Пример #8
0
        private void ServiceStart(ProgressDialog progress, bool unconditionalTransfer)
        {
            using (ServiceController sc = new ServiceController(C1ReportsSchedulerService.Constants.Name))
            {
                try
                {
                    progress.SetProgress(5, "Checking service status...");
                    sc.WaitForStatus(ServiceControllerStatus.Stopped, c_timeout);
                    ServiceControllerStatus status = sc.Status;
                    if (status != ServiceControllerStatus.Stopped)
                    {
                        WinUtil.ShowError("Service is running or paused!");
                        return;
                    }
                    string currentTaskListFile = null;
                    bool   transfer            = unconditionalTransfer;
                    if (!transfer && _tasksHolder.Tasks.Count > 0)
                    {
                        transfer = WinUtil.AskQuestion("Transfer current task list to service?", false);
                    }

                    if (transfer)
                    {
                        progress.SetProgress(10, "Stopping running schedules...");
                        _tasksHolder.StopSchedules();

                        progress.SetProgress(20, "Preparing current task list for transfer...");
                        currentTaskListFile = Path.GetTempFileName();
                        _tasksHolder.Save(currentTaskListFile);
                    }
                    this.Clear();

                    progress.SetProgress(30, string.Format("Starting {0} service...", C1ReportsSchedulerService.Constants.Name));

                    if (string.IsNullOrEmpty(currentTaskListFile))
                    {
                        sc.Start();
                    }
                    else
                    {
                        sc.Start(new string[] { currentTaskListFile });
                    }

                    WaitForStatus(sc, ServiceControllerStatus.Running, progress);

                    sc.ExecuteCommand((int)C1ReportsSchedulerService.CustomCommands.ResetC1rsconfFileToRegistry);
                    progress.SetProgress(90, "Connecting to service...");
                    ConnectToService(progress);

                    progress.SetProgress(90, "Service successfully started.");

                    if (!string.IsNullOrEmpty(currentTaskListFile))
                    {
                        File.Delete(currentTaskListFile);
                    }
                }
                catch (Exception ex)
                {
                    WinUtil.ShowError(string.Format("Error: {0}", ex.Message));
                }
                finally
                {
                    sc.Close();
                }
            }
        }
Пример #9
0
        private void TestClientModeOnStart()
        {
            if (Properties.Settings.Default.ClientMode)
            {
                return;
            }

            bool serviceInstalled;

            if (CanConnectToService(false, out serviceInstalled))
            {
                // connect to a running service:
                string text =
                    "You're about to start C1ReportsScheduler app in standalone mode.\r\n" +
                    "But, it appears that C1Reports scheduling service is installed and running.\r\n" +
                    "For full functionality it is highly recommended that you connect to the C1Reports scheduling service, " +
                    "and use the C1ReportsScheduler (this application) in client mode to communicate with the service.\r\n\r\n" +
                    "Do you want to connect to the service now?\r\n"
                ;
                if (WinUtil.AskQuestion(text, false))
                {
                    Properties.Settings.Default.ClientMode = true;
                }
            }
            else if (serviceInstalled)
            {
                // warn about a stopped service:
                string text =
                    "You're about to start C1ReportsScheduler app in standalone mode.\r\n" +
                    "But, it appears that C1Reports scheduling service is installed but is not running.\r\n" +
                    "For full functionality it is highly recommended that you start the C1Reports scheduling service, " +
                    "and use the C1ReportsScheduler (this application) in client mode to communicate with the service.\r\n\r\n" +
                    "Use menu Service | Start to start the service and connect to it.\r\n"
                ;
                WinUtil.ShowWarning(text);
            }
            else
            {
                // offer to install and start service:
                string text =
                    "You're about to start C1ReportsScheduler app in standalone mode.\r\n" +
                    "Standalone mode provides limited scheduling functionality, as scheduled reports will not run when the application is closed.\r\n" +
                    "For full functionality it is highly recommended that you install the C1Reports scheduling service, " +
                    "and use the C1ReportsScheduler (this application) in client mode to communicate with the service.\r\n\r\n" +
                    "Do you want to install the service now?\r\n\r\n" +
                    "(You can install or uninstall the service at any time via the \"Service\" menu.)"
                ;
                if (WinUtil.AskQuestion(text, false))
                {
                    try
                    {
                        ServiceSetup();
                        Properties.Settings.Default.ClientMode = true;
                    }
                    catch (Exception ex)
                    {
                        WinUtil.ShowError(ex.Message);
                    }
                }
            }
        }