protected void _btnAddJob_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(_cmbSourceFiles.Text))
            {
                return;
            }

            if (string.IsNullOrEmpty(_cmbConversionProfile.Text))
            {
                return;
            }

            MultimediaData multimediaData = new MultimediaData(_cmbSourceFiles.Text, _outputFilesUrl, File.ReadAllBytes(_cmbConversionProfile.SelectedItem.Value), _cmbConversionProfile.SelectedItem.Text);

            // Add new job.
            AddJobRequest AddJobRequest = new AddJobRequest();

            AddJobRequest.UserToken   = _hiddenFieldClientMetadata.Value;
            AddJobRequest.JobMetadata = MultimediaData.SerializeToString(multimediaData);
            AddJobRequest.JobType     = "Multimedia";
            AddJobResponse addJobResponse = _jobService.AddJob(AddJobRequest);

            GetJobInformationRequest getJobInfoRequest = new GetJobInformationRequest();

            getJobInfoRequest.ID = addJobResponse.Id;
            GetJobInformationResponse getJobInfoResponse = _jobService.GetJobInformation(getJobInfoRequest);

            AddJobToGridView(getJobInfoResponse.JobInformation);

            GetClientJobs();
        }
        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();
        }
        protected void _btnAddJob_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(_cmbSourceFiles.Text))
            {
                return;
            }

            OcrData ocrData = new OcrData(_cmbSourceFiles.Text, _outputFilesUrl, _cmbDocumentFormats.Text);

            // Add new job.
            AddJobRequest jobRequest = new AddJobRequest();

            jobRequest.JobType     = "OCR";
            jobRequest.UserToken   = _hiddenFieldClientMetadata.Value;
            jobRequest.JobMetadata = OcrData.SerializeToString(ocrData);
            AddJobResponse addJobResponse = _jobService.AddJob(jobRequest);

            GetJobInformationRequest getJobInfoRequest = new GetJobInformationRequest();

            getJobInfoRequest.ID = addJobResponse.Id;
            GetJobInformationResponse getJobInfoResponse = _jobService.GetJobInformation(getJobInfoRequest);

            AddJobToGridView(getJobInfoResponse.JobInformation);

            GetClientJobs();
        }
        protected void _btnMarkAsNew_Click(object sender, EventArgs e)
        {
            // Iterate through the Session variable, get the primary key and then change the selected jobs status to "New".
            if (Session["tblSelected"] != null)
            {
                DataTable tblSelected = (DataTable)Session["tblSelected"];
                for (int i = 0; i < tblSelected.Rows.Count; i++)
                {
                    for (int j = 0; j < _gridViewClientJobs.Rows.Count; j++)
                    {
                        Label lblJobID = (Label)_gridViewClientJobs.Rows[j].FindControl("_lblJobID");
                        if (lblJobID != null)
                        {
                            if (lblJobID.Text == tblSelected.Rows[i]["id"].ToString())
                            {
                                // Get current job information first.
                                GetJobInformationRequest getInfoRequest = new GetJobInformationRequest();
                                getInfoRequest.ID = tblSelected.Rows[i]["id"].ToString();
                                GetJobInformationResponse getJobInfoResponse = _jobService.GetJobInformation(getInfoRequest);
                                if (getJobInfoResponse.JobInformation != null && !string.IsNullOrEmpty(getJobInfoResponse.JobInformation.ID))
                                {
                                    ResetJobRequest resetJobRequest = new ResetJobRequest();
                                    resetJobRequest.ID = tblSelected.Rows[i]["id"].ToString();
                                    _jobService.ResetJob(resetJobRequest);
                                }
                                break;
                            }
                        }
                    }
                }

                GetClientJobs();
            }
            else
            {
                UpdateUIState();
            }
        }
示例#5
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;
        }