コード例 #1
0
 // The following code obtains the logs corresponding to a selected scheduled job from the server
 // for the period of 100 days prior to the current date
 // and displays the total number of obtained logs.
 private void SchedulerJobResults_Load(object sender, EventArgs e)
 {
     splashScreenManager1.ShowWaitForm();
     serverConnection.DoWithScheduledJobAsync(x => x.GetScheduledJobLogsAsync(scheduledJobId,
                                                                              new DataPaginationByDate()
     {
         From     = DateTime.Now - TimeSpan.FromDays(100),
         Interval = TimeSpan.FromDays(100)
     }, null))
     .ContinueWith(taskFunc => {
         splashScreenManager1.CloseWaitForm();
         if (taskFunc.IsFaulted)
         {
             MessageBox.Show(taskFunc.Exception.GetBaseException().Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else
         {
             FillScheduledJobLogs(taskFunc.Result);
         }
     }, TaskScheduler.FromCurrentSynchronizationContext())
     .ContinueWith((taskFunc) => {
         return(serverConnection.DoWithScheduledJobAsync(x => x.GetScheduledJobLogsCountAsync(scheduledJobId, null)));
     })
     .Unwrap()
     .ContinueWith(taskFunc => {
         logsLabel.Text = string.Format("Logs count: {0}", taskFunc.Result);
     }, TaskScheduler.FromCurrentSynchronizationContext());
 }
        // The following method obtains the list of all scheduled jobs from the server
        // and displays this list in a grid control.
        void MainForm_Load(object sender, EventArgs e)
        {
            splashScreenManager1.ShowWaitForm();

            serverConnection.DoWithScheduledJobAsync(x => x.GetScheduledJobsAsync(null))
            .ContinueWith(taskFunc => {
                splashScreenManager1.CloseWaitForm();
                if (taskFunc.IsFaulted)
                {
                    MessageBox.Show(taskFunc.Exception.Flatten().InnerException.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    FillScheduledJobListBox(taskFunc.Result);
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
 // The following code obtains information about a specific scheduled job from the server
 // and enables you to remotely manage scheduled jobs on the client.
 // Please note that managing jobs requires that appropriate access permissions are attributed
 // to the user account under which this application is connected to the Server.
 private void SchedulerJobViewerForm_Load(object sender, EventArgs e)
 {
     serverConnection.DoWithScheduledJobAsync(x => x.GetScheduledJobAsync(scheduledJobId, null))
     .ContinueWith(taskFunc => {
         if (taskFunc.IsFaulted)
         {
             MessageBox.Show(taskFunc.Exception.GetBaseException().Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);     //
         }
         else
         {
             FillScheduledJob(taskFunc.Result);
         }
     }, TaskScheduler.FromCurrentSynchronizationContext());
 }