Esempio n. 1
0
        private void _menuItemOpenConvertedFile_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow selectedJob in _dgvJobs.SelectedRows)
            {
                try
                {
                    if (selectedJob.Cells[JobProcessorConstants.Database.StatusColumn].Value != DBNull.Value &&
                        String.Compare((string)selectedJob.Cells[JobProcessorConstants.Database.StatusColumn].Value, JobStatus.Completed.ToString(), true) == 0)
                    {
                        string jobType     = selectedJob.Cells[JobProcessorConstants.Database.JobTypeColumn].Value != DBNull.Value ? (string)selectedJob.Cells[JobProcessorConstants.Database.JobTypeColumn].Value : String.Empty;
                        string jobMetadata = selectedJob.Cells[JobProcessorConstants.Database.JobMetadataColumn].Value != DBNull.Value ? (string)selectedJob.Cells[JobProcessorConstants.Database.JobMetadataColumn].Value : String.Empty;

                        if (String.Compare(jobType, "OCR", true) == 0)
                        {
                            StartProcess(OcrData.DeserializeFromString(jobMetadata).DocumentFileName);
                        }
                        else if (String.Compare(jobType, "Multimedia", true) == 0)
                        {
                            StartProcess(MultimediaData.DeserializeFromString(jobMetadata).TargetFile);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error");
                }
            }
        }
Esempio n. 2
0
        /***************************************************************************/
        /* This function will convert multimedia files based on the settings specified in MultimediaData.ConversionSettings*/
        /***************************************************************************/
        public override void OnJobReceived(string id, string clientMetadata, string jobMetadata, string jobType, int progressRate)
        {
            _jobId            = id;
            conversionAborted = false;
            AutoResetEvent finishedEvent = new AutoResetEvent(false);

            try
            {
                // Check if we have valid job information and job metadata
                if (String.IsNullOrEmpty(jobMetadata))
                {
                    SetFailureStatus(_jobId, (int)RasterExceptionCode.InvalidParameter, Leadtools.RasterException.GetCodeMessage(RasterExceptionCode.InvalidParameter), null);
                    return;
                }

                //Deserialize the jobMetadata so we can get the MultimediaData
                MultimediaData multimediaData = MultimediaData.DeserializeFromString(jobMetadata);
                _reportStatusInterval = progressRate * SECONDS_TO_MILLISECONDS_FACTOR;

                using (Timer updateStatusTimer = new Timer(new TimerCallback(UpdateStatusProc), multimediaData, 0, _reportStatusInterval))
                {
                    ConvertFile(multimediaData);
                }
            }
            catch (COMException ex)
            {
                SetFailureStatus(id, ex.ErrorCode, ex.Message, null);
            }
            catch (Exception ex)
            {
                SetFailureStatus(id, 0, ex.Message, null);
            }
            finally
            {
                finishedEvent.Close();
            }
        }
        private void BindGrid(int rowcount, JobServiceReference.JobInformation jobInformation)
        {
            if (jobInformation == null)
            {
                return;
            }

            //Only show multimedia jobs in this demo
            if (String.Compare(jobInformation.JobType, "Multimedia", true) != 0)
            {
                return;
            }

            MultimediaData multimediaData = MultimediaData.DeserializeFromString(jobInformation.Metadata.JobMetadata);
            string         inputFileName  = multimediaData.SourceFile.Length > 0 ? Path.GetFileName(multimediaData.SourceFile) : String.Empty;
            string         outputFileName = jobInformation.Status == JobStatus.Completed && multimediaData.TargetFile.Length > 0 ? Path.GetFileName(multimediaData.TargetFile) : String.Empty;

            DataColumn[] dataColums = new DataColumn[]
            {
                new DataColumn("Job ID", typeof(string)),
                new DataColumn("Status", typeof(string)),
                new DataColumn("Worker", typeof(string)),
                new DataColumn("Percentage", typeof(int)),
                new DataColumn("Added Data/Time", Nullable.GetUnderlyingType(typeof(Nullable <DateTime>))),
                new DataColumn("Completed Data/Time", Nullable.GetUnderlyingType(typeof(Nullable <DateTime>))),
                new DataColumn("Error ID", typeof(int)),
                new DataColumn("Error Message", typeof(string)),
                new DataColumn("Input File", typeof(string)),
                new DataColumn("Output File", typeof(string)),
                new DataColumn("Full Path", typeof(string)),
                new DataColumn("Target Format", typeof(string)),
            };

            DataTable dt = new DataTable();

            dt.Columns.AddRange(dataColums);

            DataRow dr;

            if (ViewState["CurrentData"] != null)
            {
                for (int i = 0; i < rowcount; i++)
                {
                    dt = (DataTable)ViewState["CurrentData"];
                    if (dt.Rows.Count > 0)
                    {
                        dr    = dt.NewRow();
                        dr[0] = dt.Rows[i][0].ToString();
                        dr[1] = dt.Rows[i][1].ToString();
                        dr[2] = dt.Rows[i][2].ToString();
                        dr[3] = dt.Rows[i][3].ToString();
                        if (dt.Rows[i][3] != null)
                        {
                            dr[4] = dt.Rows[i][4];
                        }
                        else
                        {
                            dr[4] = DBNull.Value;
                        }

                        if (dt.Rows[i][4] != null)
                        {
                            dr[5] = dt.Rows[i][5];
                        }
                        else
                        {
                            dr[5] = DBNull.Value;
                        }
                        dr[6]  = dt.Rows[i][6].ToString();
                        dr[7]  = dt.Rows[i][7].ToString();
                        dr[8]  = dt.Rows[i][8].ToString();
                        dr[9]  = dt.Rows[i][9].ToString();
                        dr[10] = dt.Rows[i][10].ToString();
                        dr[11] = dt.Rows[i][11].ToString();
                    }
                }
                if (jobInformation != null)
                {
                    dr    = dt.NewRow();
                    dr[0] = jobInformation.ID;
                    dr[1] = jobInformation.Status;
                    dr[2] = jobInformation.Worker;
                    dr[3] = jobInformation.Percentage;
                    if (jobInformation.AddedTime != null)
                    {
                        dr[4] = jobInformation.AddedTime;
                    }
                    else
                    {
                        dr[4] = DBNull.Value;
                    }

                    if (jobInformation.CompletedTime != null)
                    {
                        dr[5] = jobInformation.CompletedTime;
                    }
                    else
                    {
                        dr[5] = DBNull.Value;
                    }
                    dr[6]  = jobInformation.FailureInformation.FailedErrorID;
                    dr[7]  = jobInformation.FailureInformation.FailedMessage;
                    dr[8]  = inputFileName;
                    dr[9]  = outputFileName;
                    dr[10] = _outputFilesName + outputFileName;
                    dr[11] = multimediaData.ProfileName;
                    dt.Rows.Add(dr);
                }
            }
            else
            {
                if (jobInformation != null)
                {
                    dr    = dt.NewRow();
                    dr[0] = jobInformation.ID;
                    dr[1] = jobInformation.Status;
                    dr[2] = jobInformation.Worker;
                    dr[3] = jobInformation.Percentage;
                    if (jobInformation.AddedTime != null)
                    {
                        dr[4] = jobInformation.AddedTime;
                    }
                    else
                    {
                        dr[4] = DBNull.Value;
                    }

                    if (jobInformation.CompletedTime != null)
                    {
                        dr[5] = jobInformation.CompletedTime;
                    }
                    else
                    {
                        dr[5] = DBNull.Value;
                    }
                    dr[6]  = jobInformation.FailureInformation.FailedErrorID;
                    dr[7]  = jobInformation.FailureInformation.FailedMessage;
                    dr[8]  = inputFileName;
                    dr[9]  = outputFileName;
                    dr[10] = _outputFilesName + outputFileName;
                    dr[11] = multimediaData.ProfileName;
                    dt.Rows.Add(dr);
                }
            }

            // If ViewState has a data then use the value as the DataSource
            if (ViewState["CurrentData"] != null)
            {
                _gridViewClientJobs.DataSource = (DataTable)ViewState["CurrentData"];
                _gridViewClientJobs.DataBind();
            }
            else
            {
                // Bind GridView with the initial data associated in the DataTable
                _gridViewClientJobs.DataSource = dt;
                _gridViewClientJobs.DataBind();
            }
            // Store the DataTable in ViewState to retain the values
            ViewState["CurrentData"] = dt;
        }