void GetClientJobs()
        {
            _gridViewClientJobs.DataBind();
            // Get all jobs related to this client
            GetClientJobsRequest getClientJobsRequest = new GetClientJobsRequest();

            getClientJobsRequest.UserToken = _hiddenFieldClientMetadata.Value;
            GetClientJobsResponse getClientJobsResponse = _jobService.GetClientJobs(getClientJobsRequest);

            if (getClientJobsResponse != null && getClientJobsResponse.JobsIds != null && getClientJobsResponse.JobsIds.Length > 0)
            {
                // First, delete all elements form the grid
                ViewState["CurrentData"] = null;

                foreach (string id in getClientJobsResponse.JobsIds)
                {
                    GetJobInformationRequest getJobInfoRequest = new GetJobInformationRequest();
                    getJobInfoRequest.ID = id;
                    GetJobInformationResponse getJobInfoResponse = _jobService.GetJobInformation(getJobInfoRequest);
                    AddJobToGridView(getJobInfoResponse.JobInformation);
                }
            }
            else
            {
                AddJobToGridView(null); // just display an empty grid view
            }
            string sortExpression = ViewState["SortExpression"] as string;

            SortGridView(sortExpression, false);
            RefreshGridView();
        }
Exemplo n.º 2
0
        void GetClientJobsThreadProc()
        {
            _retrievingJobs = true;
            try
            {
                using (JobServiceClient jobService = new JobServiceClient())
                {
                    string address = string.Format("{0}/JobService.svc", _wcfAddress);
                    jobService.Endpoint.Address = new System.ServiceModel.EndpointAddress(address);

                    GetClientJobsRequest getClientJobsRequest = new GetClientJobsRequest();
                    getClientJobsRequest.UserToken = _userName;
                    GetClientJobsResponse getClientJobsResponse = jobService.GetClientJobs(getClientJobsRequest);

                    this.Invoke(new MethodInvoker(delegate()
                    {
                        _jobsDataTable.Clear();

                        _jobsDataTable.BeginLoadData();

                        foreach (string jobID in getClientJobsResponse.JobsIds)
                        {
                            GetJobInformationRequest getJobInformationRequest = new GetJobInformationRequest();
                            getJobInformationRequest.ID = jobID;
                            GetJobInformationResponse getJobInformationResponse = jobService.GetJobInformation(getJobInformationRequest);

                            DataRow jobRow = _jobsDataTable.NewRow();
                            jobRow[JobProcessorConstants.Database.AddedTimeColumn]       = getJobInformationResponse.JobInformation.AddedTime;
                            jobRow[JobProcessorConstants.Database.AttemptsColumn]        = getJobInformationResponse.JobInformation.Attempts;
                            jobRow[JobProcessorConstants.Database.CompletedTimeColumn]   = getJobInformationResponse.JobInformation.CompletedTime;
                            jobRow[JobProcessorConstants.Database.FailedErrorIDColumn]   = getJobInformationResponse.JobInformation.FailureInformation.FailedErrorID;
                            jobRow[JobProcessorConstants.Database.FailedMessageColumn]   = getJobInformationResponse.JobInformation.FailureInformation.FailedMessage;
                            jobRow[JobProcessorConstants.Database.FailedTimeColumn]      = getJobInformationResponse.JobInformation.FailedTime;
                            jobRow[JobProcessorConstants.Database.GuidColumn]            = getJobInformationResponse.JobInformation.ID;
                            jobRow[JobProcessorConstants.Database.JobMetadataColumn]     = getJobInformationResponse.JobInformation.Metadata.JobMetadata;
                            jobRow[JobProcessorConstants.Database.JobTypeColumn]         = getJobInformationResponse.JobInformation.JobType;
                            jobRow[JobProcessorConstants.Database.LastStartedTimeColumn] = getJobInformationResponse.JobInformation.LastStartedTime;
                            jobRow[JobProcessorConstants.Database.LastUpdatedTimeColumn] = getJobInformationResponse.JobInformation.LastUpdatedTime;
                            jobRow[JobProcessorConstants.Database.MustAbortColumn]       = getJobInformationResponse.JobInformation.Abort.MustAbort;
                            jobRow[JobProcessorConstants.Database.AbortReasonColumn]     = getJobInformationResponse.JobInformation.Abort.AbortReason;
                            jobRow[JobProcessorConstants.Database.PercentageColumn]      = getJobInformationResponse.JobInformation.Percentage;
                            jobRow[JobProcessorConstants.Database.StatusColumn]          = getJobInformationResponse.JobInformation.Status;
                            jobRow[JobProcessorConstants.Database.UserTokenColumn]       = getJobInformationResponse.JobInformation.Metadata.UserToken;
                            jobRow[JobProcessorConstants.Database.WorkerColumn]          = getJobInformationResponse.JobInformation.Worker;
                            jobRow[JobProcessorConstants.Database.WorkerMetadataColumn]  = getJobInformationResponse.JobInformation.Metadata.WorkerMetadata;

                            _jobsDataTable.Rows.Add(jobRow);
                        }

                        _jobsDataTable.EndLoadData();
                    }));


                    this.BeginInvoke(new MethodInvoker(delegate()
                    {
                        _dgvJobs.DataSource = _jobsDataTable;
                        UpdateUI();
                    }));
                }
            }
            catch (Exception ex)
            {
                this.Invoke(new MethodInvoker(delegate()
                {
                    MessageBox.Show(ex.Message, "Error");
                }));
            }

            _retrievingJobs = false;
        }