本文整理汇总了C#中Job.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Job.Dispose方法的具体用法?C# Job.Dispose怎么用?C# Job.Dispose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Job
的用法示例。
在下文中一共展示了Job.Dispose方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Print
public void Print(RecordSet records, ReportGenConfig config)
{
if (records == null | config == null)
{
throw new ArgumentNullException("打印参数或打印数据不能为空");
}
try
{
TECITLicense.Register();
}
catch (Exception ex)
{
throw new ReportGenLicenseException(ex);
}
Job job = default(Job);
JobDataRecordSet jobdata = default(JobDataRecordSet);
job = new Job();
jobdata = new JobDataRecordSet();
job.JobData = jobdata;
job.RepositoryName = config.Template;
job.PrinterName = config.Printer;
job.PrinterType = config.PrinterType;
job.NumberOfCopies = config.NumberOfCopies;
for (int i = 0; i <= records.Count - 1; i++)
{
Record rec = new Record();
foreach (KeyValuePair<string, string> ent in records[i])
{
rec.Data.Add(ent.Key, ent.Value);
}
jobdata.Records.Add(rec);
}
try
{
job.Print();
job.Dispose();
}
catch (TFORMerException ex)
{
if (ex.ErrorCode == 13)
{
throw new ReportTypeException(ex);
}
else { throw new ReportPrintException(ex); }
}
catch (Exception ex)
{
throw new ReportPrintException(ex);
}
finally {
if (job != null)
job.Dispose();
}
}
示例2: RemoveJobAndDispose
private void RemoveJobAndDispose(Job job, bool jobIsJob2)
{
try
{
bool job2TypeFound = false;
if (jobIsJob2)
{
job2TypeFound = JobManager.RemoveJob(job as Job2, this, true, false);
}
if (!job2TypeFound)
{
JobRepository.Remove(job);
}
job.Dispose();
}
catch (ArgumentException ex)
{
string message = PSRemotingErrorInvariants.FormatResourceString(
RemotingErrorIdStrings.CannotRemoveJob);
ArgumentException ex2 = new ArgumentException(message, ex);
WriteError(new ErrorRecord(ex2, "CannotRemoveJob", ErrorCategory.InvalidOperation, job));
}
}
示例3: Main
static void Main(string[] args)
{
MediaItem mediaItem;
if (args.Length == 0) {
System.Console.WriteLine("Usage: wmvocplus.exe <wmvfilename> <jpg filler to append> <seconds to display filler>");
return;
}
string wmvfilename = args[0];
string jpgfillername = args[1];
string outputfilename = wmvfilename.Substring(0, wmvfilename.Length -3 );
outputfilename += "oc.wmv";
string captionfilename = wmvfilename.Substring(0, wmvfilename.Length - 3);
captionfilename += ".smi";
int timeoptions = Convert.ToInt32(args[2]);
System.Console.WriteLine("wmvfilename:\t" + wmvfilename);
System.Console.WriteLine("jpgfillername:\t" + jpgfillername);
System.Console.WriteLine("timeoptions:\t" + timeoptions);
System.Console.WriteLine("output:\t" + outputfilename);
try
{
// sets file name to media item
mediaItem = new MediaItem(wmvfilename);
// challenge... these next three lines fix aspect ratio screen clipping that occurs when
// source is also wmv. ...unfortunately it also causes the captions not to burn into the video...
// mediaItem.OutputFormat.VideoProfile = new AdvancedVC1VideoProfile();
// mediaItem.OutputFormat.VideoProfile = mediaItem.SourceVideoProfile;
// mediaItem.OutputFormat.AudioProfile = mediaItem.SourceAudioProfile;
/*
mediaItem.OutputFormat.VideoProfile.AspectRatio = mediaItem.SourceVideoProfile.AspectRatio;
mediaItem.OutputFormat.VideoProfile = new AdvancedVC1VideoProfile();
mediaItem.OutputFormat.VideoProfile.Bitrate = new ConstantBitrate(200); // VariableConstrainedBitrate(200, 1500);
mediaItem.OutputFormat.VideoProfile.Streams[0].Size = new Size(320, 240);
mediaItem.OutputFormat.VideoProfile.Size = new Size(320, 240);
mediaItem.OutputFormat.VideoProfile.FrameRate = 30;
mediaItem.OutputFormat.VideoProfile.KeyFrameDistance = new TimeSpan(0, 0, 4); */
// audio on one didn't work out so this helped but blows up on others...
// mediaItem.OutputFormat.AudioProfile = new WmaAudioProfile();
// mediaItem.OutputFormat.AudioProfile.Bitrate = new ConstantBitrate(128); // VariableConstrainedBitrate(128, 192);
// mediaItem.OutputFormat.AudioProfile.Codec = AudioCodec.WmaProfessional;
// mediaItem.OutputFormat.AudioProfile.BitsPerSample = 24;
// captions
//mediaItem.Sources[0].CaptionFiles.Add(new CaptionFile(captionfilename));
// add trailer
mediaItem.Sources.Add(new Source(@""+jpgfillername+""));
mediaItem.Sources[1].Clips[0].EndTime = mediaItem.Sources[1].MediaFile.Duration + TimeSpan.FromSeconds(timeoptions);
}
catch (InvalidMediaFileException exp)
{
// Media file was invalid and it returns an error msg
Console.WriteLine(exp.ToString());
return;
}
// verifies encoding of file
Console.WriteLine("\nEncoding: {0}", wmvfilename );
// Create a job and the media item for the video we wish
// to encode.
Job job = new Job();
job.MediaItems.Add(mediaItem);
// Set up the progress callback function
job.EncodeProgress
+= new EventHandler<EncodeProgressEventArgs>(OnProgress);
// Set the output directory and encode.
job.OutputDirectory = Environment.CurrentDirectory;
job.DefaultMediaOutputFileName = outputfilename;
job.CreateSubfolder = false;
// encodes job
job.Encode();
job.Dispose();
}