public void CheckJobStatus() { var client = BrightstarService.GetClient(Store.Source.ConnectionString); _transactionJob = client.GetJobInfo(Store.Location, _transactionJob.JobId); if (_transactionJob.JobPending) { ProgressText = "Job is currently queued for processing."; } if (_transactionJob.JobStarted) { ProgressText = "Job is running"; } if (_transactionJob.JobCompletedOk) { ProgressText = "Job completed successfully"; Messenger.Default.Send(new ShowDialogMessage( Strings.ExportCompletedDialogTitle, String.Format(Strings.ExportCompletedDialogMsg, Store.Location), MessageBoxImage.Information, MessageBoxButton.OK), "MainWindow"); } else if (_transactionJob.JobCompletedWithErrors) { ProgressText = String.IsNullOrEmpty(_transactionJob.StatusMessage) ? "Export job failed. No further details provided by the server." : String.Format("Export job failed. Server reports : '{0}'", _transactionJob.StatusMessage); Messenger.Default.Send(new ShowDialogMessage(Strings.ImportFailedDialogTitle, String.Format(Strings.ImportFailedDialogMsg, Store.Location), MessageBoxImage.Error, MessageBoxButton.OK), "MainWindow"); } else { _dispatcher.BeginInvoke(DispatcherPriority.SystemIdle, new TransactionViewModel.JobMonitorDelegate(this.CheckJobStatus)); } }
public ImportJobViewModel(string importFileName, IJobInfo importJobInfo, bool isLocalImport) { ImportFileName = importFileName; IsLocalImport = isLocalImport; _importJobInfo = importJobInfo; UpdateStatusProperties(); }
protected virtual void ProcessItem(IJobInfo job) { HandlePause(); lock (_currentProcessingItemLockerObject) { _currentlyProcessingItemCount++; } _processItemBehavior.ProcessSpecific(job); //Interlocked.Decrement(ref _taskCounter); //Interlocked.Decrement(ref ProcessInfo.ElementsInQueue); //Interlocked.Increment(ref ProcessInfo.Results); lock (_currentProcessingItemLockerObject) { Debug.WriteLine($"Thread {Thread.CurrentThread} changing counters"); _taskCounter--; _currentlyProcessingItemCount--; ProcessInfo.ElementsInQueue--; ProcessInfo.Results++; Debug.WriteLine($"Thread {Thread.CurrentThread} _currentlyProcessingItemCount = {_currentlyProcessingItemCount}"); } }
/// <summary> /// Appends an item to the end of the JobInfo Queue /// </summary> /// <param name="jobInfo">The JobInfo to add</param> public void Add(IJobInfo jobInfo) { string jobFile = Path.GetFullPath(jobInfo.InfFile); _logger.Debug("New JobInfo: " + jobFile); _logger.Debug("DocumentTitle: " + jobInfo.SourceFiles[0].DocumentTitle); _logger.Debug("ClientComputer: " + jobInfo.SourceFiles[0].ClientComputer); _logger.Debug("SessionId: " + jobInfo.SourceFiles[0].SessionId); _logger.Debug("PrinterName: " + jobInfo.SourceFiles[0].PrinterName); _logger.Debug("JobCounter: " + jobInfo.SourceFiles[0].JobCounter); _logger.Debug("JobId: " + jobInfo.SourceFiles[0].JobId); if (_jobFileSet.Contains(jobFile)) { return; } _logger.Debug("Added JobInfo: " + jobFile); JobInfos.Add(jobInfo); _jobFileSet.Add(jobFile); if (OnNewJobInfo != null) { OnNewJobInfo(null, new NewJobInfoEventArgs(jobInfo)); } }
public void CheckJobStatus() { var client = BrightstarService.GetClient(Store.Source.ConnectionString); _transactionJob = client.GetJobInfo(Store.Location, _transactionJob.JobId); if (_transactionJob.JobCompletedOk) { ValidationMessages.Clear(); ValidationMessages.Add(Strings.TransactionSuccess); } else if (_transactionJob.JobCompletedWithErrors) { ValidationMessages.Clear(); ValidationMessages.Add(Strings.TransactionFailed); ValidationMessages.Add(_transactionJob.ExtractJobErrorMessage(true)); Messenger.Default.Send( new ShowDialogMessage("Transaction failed", "Transaction failed with status: " + _transactionJob.StatusMessage, MessageBoxImage.Error, MessageBoxButton.OK), "MainWindow"); } else { _dispatcher.BeginInvoke(DispatcherPriority.SystemIdle, new JobMonitorDelegate(this.CheckJobStatus)); } }
/// <summary> /// Create a new GhostscriptJob instance /// </summary> /// <param name="jobInfo">JobInfo of the job to convert</param> /// <param name="profile">Profile that determines the conversion process</param> /// <param name="tempFolder"> /// TempFolderProvider that gives the full Temp path, i.e. C:\Users\Admin\Local /// Settings\Temp\clawPDF /// </param> /// <param name="jobTranslations">Translations needed for the job</param> /// <param name="fileWrap">Only for testing</param> /// <param name="directoryWrap">Only for testing</param> public GhostscriptJob(IJobInfo jobInfo, ConversionProfile profile, JobTranslations jobTranslations, ITempFolderProvider tempFolder, IFile fileWrap, IDirectory directoryWrap) : base(jobInfo, profile, jobTranslations, fileWrap, directoryWrap) { var gsVersion = new GhostscriptDiscovery().GetBestGhostscriptInstance(); if (gsVersion == null) { Logger.Error("No valid Ghostscript version found."); throw new InvalidOperationException("No valid Ghostscript version found."); } Logger.Debug("Ghostscript Version: " + gsVersion.Version + " loaded from " + gsVersion.DllPath); _ghostScript = new GhostScript(gsVersion); JobTempFolder = PathSafe.Combine(tempFolder.TempFolder, "Job_" + PathSafe.GetFileNameWithoutExtension(PathSafe.GetRandomFileName())); JobTempOutputFolder = PathSafe.Combine(JobTempFolder, "tempoutput"); DirectoryWrap.CreateDirectory(JobTempFolder); DirectoryWrap.CreateDirectory(JobTempOutputFolder); // Shorten the temp folder for GS compatibility //缩短临时文件夹以实现GS兼容性 JobTempFolder = JobTempFolder; }
public PrintJobViewModel(ApplicationSettings appSettings, IList <ConversionProfile> profiles, IJobInfoQueue jobInfoQueue, ConversionProfile preselectedProfile = null, IJobInfo jobInfo = null, TranslationHelper translationHelper = null) { _currentThreadDispatcher = Dispatcher.CurrentDispatcher; Profiles = profiles; _preselectedProfile = preselectedProfile; //must be set before ApplicationSettings because it is evaluated in the Set method of appsettings. ApplicationSettings = appSettings; _jobInfoQueue = jobInfoQueue; _jobInfoQueue.OnNewJobInfo += NewJobInfo; SaveCommand = new DelegateCommand(ExecuteSave); EmailCommand = new DelegateCommand(ExecuteMail); ManagePrintJobsCommand = new DelegateCommand(ExecuteManagePrintJobs); if (jobInfo != null) { JobInfo = jobInfo; } _translationHelper = translationHelper; }
/// <summary> /// Create a workflow based on the job and settings objects provided. This will create an AutoSave workflow if the /// job's printer has an AutoSave profile associated or the default profile uses AutoSave. /// Otherwise, an interactive workflow will be created. /// 基于提供的作业和设置对象创建工作流。如果作业的打印机关联了自动保存配置文件或默认配置文件使用自动保存, /// 则此操作将创建自动保存工作流。否则,将创建交互式工作流。 /// </summary> /// <param name="jobInfo">The jobinfo used for the decision</param> /// <param name="settings">The settings used for the decision</param> /// <returns>A ConversionWorkflow either for AutoSave or interactive use</returns> public static ConversionWorkflow CreateWorkflow(IJobInfo jobInfo, clawPDFSettings settings) { Logger.Trace("Creating Workflow"); var preselectedProfile = PreselectedProfile(jobInfo, settings).Copy(); Logger.Debug("Profile: {0} (GUID {1})", preselectedProfile.Name, preselectedProfile.Guid); var jobTranslations = new JobTranslations(); jobTranslations.EmailSignature = MailSignatureHelper.ComposeMailSignature(); var job = JobFactory.CreateJob(jobInfo, preselectedProfile, JobInfoQueue.Instance, jobTranslations); job.AutoCleanUp = true; if (preselectedProfile.AutoSave.Enabled) { Logger.Trace("Creating AutoSaveWorkflow"); return(new AutoSaveWorkflow(job, settings)); } Logger.Trace("Creating InteractiveWorkflow"); return(new InteractiveWorkflow(job, settings)); }
/// <summary> /// Determines the preselected profile for the printer that was used while creating the job /// </summary> /// <param name="jobInfo">The jobinfo used for the decision</param> /// <param name="settings">The settings used for the decision</param> /// <returns>The profile that is associated with the printer or the default profile</returns> private static ConversionProfile PreselectedProfile(IJobInfo jobInfo, clawPDFSettings settings) { foreach (var mapping in settings.ApplicationSettings.PrinterMappings) { if (mapping.PrinterName.Equals(jobInfo.SourceFiles[0].PrinterName, StringComparison.OrdinalIgnoreCase)) { var p = settings.GetProfileByGuid(mapping.ProfileGuid); if (p != null) { return(p); } break; } } var lastUsedProfile = settings.GetLastUsedProfile(); if (lastUsedProfile != null) { return(lastUsedProfile); } // try default profile var defaultProfile = SettingsHelper.GetDefaultProfile(settings.ConversionProfiles); if (defaultProfile != null) { return(defaultProfile); } // last resort: first profile from the list return(settings.ConversionProfiles[0]); }
private void StartExport() { var client = BrightstarService.GetClient(Store.Source.ConnectionString); _transactionJob = client.StartExport(Store.Location, ExportFileName); _dispatcher.BeginInvoke(DispatcherPriority.SystemIdle, new TransactionViewModel.JobMonitorDelegate(CheckJobStatus)); }
public void Create_Job_With_Ctor() { var TEST1 = "test1"; job = new JobInfo(TEST1, true, true, true, true, 1, TEST1, TEST1); Assert.AreEqual(TEST1, job.Name); Assert.AreEqual(TEST1, job.Schedule); Assert.AreEqual(1, job.RepetitionIntervalTime); Assert.IsTrue(job.Enabled); Assert.IsTrue(job.LogEnabled); Assert.IsTrue(job.Repeatable); Assert.IsTrue(job.StopOnError); var TEST2 = "test2"; job = new JobInfo(TEST2, false, false, false, false, 2, TEST2, TEST2); Assert.AreEqual(TEST2, job.Name); Assert.AreEqual(TEST2, job.Schedule); Assert.AreEqual(2, job.RepetitionIntervalTime); Assert.IsFalse(job.Enabled); Assert.IsFalse(job.LogEnabled); Assert.IsFalse(job.Repeatable); Assert.IsFalse(job.StopOnError); }
private void RaisePropertyChangedEvents(IJobInfo jobInfo) { RaisePropertyChanged("JobCount"); RaisePropertyChanged("PendingJobsText"); ManagePrintJobsCommand.RaiseCanExecuteChanged(); RaisePropertyChanged("CanManagePrintJobs"); }
public void CheckJobStatus() { var client = BrightstarService.GetClient(Store.Source.ConnectionString); _transactionJob = client.GetJobInfo(Store.Location, _transactionJob.JobId); if (_transactionJob.JobPending) { ProgressText = "Job is currently queued for processing."; } if (_transactionJob.JobStarted) { ProgressText = "Job is running"; } if (_transactionJob.JobCompletedOk) { ProgressText = "Job completed successfully"; Messenger.Default.Send(new ShowDialogMessage( Strings.ExportCompletedDialogTitle, String.Format(Strings.ExportCompletedDialogMsg, Store.Location), MessageBoxImage.Information, MessageBoxButton.OK), "MainWindow"); } else if (_transactionJob.JobCompletedWithErrors) { ProgressText = String.IsNullOrEmpty(_transactionJob.StatusMessage) ? "Export job failed. No further details provided by the server." : String.Format("Export job failed. Server reports : '{0}'", _transactionJob.StatusMessage); Messenger.Default.Send(new ShowDialogMessage(Strings.ImportFailedDialogTitle, String.Format(Strings.ImportFailedDialogMsg, Store.Location), MessageBoxImage.Error, MessageBoxButton.OK), "MainWindow"); } else { _dispatcher.BeginInvoke(DispatcherPriority.SystemIdle, new TransactionViewModel.JobMonitorDelegate(this.CheckJobStatus)); } }
public void JobInfoWithMultipleSourceFiles_AfterMerge_SourceFilesHaveCorrectOrder() { var sourceFiles = new List <SourceFileInfo>(); for (int i = 0; i < 8; i++) { sourceFiles.Add(FakeSourceFileInfo()); } IJobInfo jobInfo = new JobInfo(); for (int i = 0; i < 4; i++) { jobInfo.SourceFiles.Add(sourceFiles[i]); } IJobInfo jobInfoStub = MockRepository.GenerateStub <IJobInfo>(); jobInfoStub.Stub(x => x.SourceFiles).Return(sourceFiles.GetRange(4, 4)); jobInfo.Merge(jobInfoStub); for (int i = 0; i < 8; i++) { Assert.AreSame(sourceFiles[i], jobInfo.SourceFiles[i]); } }
/// <summary>添加记录</summary> /// <param name="param">实例<see cref="IJobInfo"/>详细信息</param> public void Insert(IJobInfo param) { ibatisMapper.Insert(StringHelper.ToProcedurePrefix(string.Format("{0}_Insert", tableName)), param); // 绑定关系 // BindRelation(param); }
public override void ProcessSpecific(IJobInfo job) { Console.WriteLine((job as StringJobInfo).Job); //load //extract links //extract data //export }
private void StartRemoteImport() { var client = BrightstarService.GetClient(Store.Source.ConnectionString); _transactionJob = client.StartImport(Store.Location, ImportFileName); _dispatcher.BeginInvoke(DispatcherPriority.SystemIdle, new TransactionViewModel.JobMonitorDelegate(CheckJobStatus)); }
private void MoveJob(IJobInfo jobInfo, int positionDifference) { var oldIndex = _jobInfos.IndexOf(jobInfo); _jobInfos.Move(oldIndex, oldIndex + positionDifference); JobInfos.MoveCurrentToPosition(oldIndex + positionDifference); }
public static string ExtractJobErrorMessage(this IJobInfo jobInfo, bool stopOnFirstDetailMessage = false) { if (jobInfo.ExceptionInfo != null) { return(jobInfo.StatusMessage + ": " + jobInfo.ExceptionInfo.ExtractExceptionMessages(stopOnFirstDetailMessage)); } return(jobInfo.StatusMessage); }
public XpsJob(IJobInfo jobInfo, ConversionProfile profile, JobTranslations jobTranslations) : base(jobInfo, profile, jobTranslations) { JobTempFolder = Path.Combine(Path.Combine(Path.GetTempPath(), "clawPDF\\Temp"), "Job_" + Path.GetFileNameWithoutExtension(Path.GetRandomFileName())); JobTempOutputFolder = Path.Combine(JobTempFolder, "tempoutput"); Directory.CreateDirectory(JobTempFolder); Directory.CreateDirectory(JobTempOutputFolder); }
protected void AssertJobSuccessful(IBrightstarService client,string storeName, IJobInfo job) { while (!(job.JobCompletedOk || job.JobCompletedWithErrors)) { Task.Delay(3).Wait(); job = client.GetJobInfo(storeName, job.JobId); } Assert.IsTrue(job.JobCompletedOk, "Job failed with message: {0} : {1}", job.StatusMessage, job.ExceptionInfo); }
public static void AssertJobCompletesSuccessfully(IBrightstarService client, string storeName, IJobInfo job) { while (!job.JobCompletedOk && !job.JobCompletedWithErrors) { Task.Delay(10).Wait(); job = client.GetJobInfo(storeName, job.JobId); } Assert.IsTrue(job.JobCompletedOk, "Expected job to complete successfully, but it failed with message '{0}' : {1}", job.StatusMessage, job.ExceptionInfo); }
public static IJob CreateJob(IJobInfo jobInfo, ConversionProfile conversionProfile, ITempFolderProvider tempFolder, JobTranslations jobTranslations) { if (jobInfo.JobType == JobType.XpsJob) { return(new XpsJob(jobInfo, conversionProfile, jobTranslations)); } return(new GhostscriptJob(jobInfo, conversionProfile, tempFolder, jobTranslations)); }
// ------------------------------------------------------- // 查询 // ------------------------------------------------------- #region 函数:FindOne(string id) /// <summary>查询某条记录</summary> /// <param name="id">标识</param> /// <returns>返回实例<see cref="IJobInfo"/>的详细信息</returns> public IJobInfo FindOne(string id) { Dictionary <string, object> args = new Dictionary <string, object>(); args.Add("Id", StringHelper.ToSafeSQL(id)); IJobInfo param = ibatisMapper.QueryForObject <IJobInfo>(StringHelper.ToProcedurePrefix(string.Format("{0}_FindOne", tableName)), args); return(param); }
private void MonitorJob(IJobInfo job) { while (!(job.JobCompletedOk || job.JobCompletedWithErrors)) { Console.WriteLine(job.StatusMessage); Thread.Sleep(3000); job = _client.GetJobInfo(_storeName, job.JobId); } Assert.IsTrue(job.JobCompletedOk, "Expected job to complete successfully"); }
private void MonitorJob(IJobInfo job) { while(!(job.JobCompletedOk || job.JobCompletedWithErrors)) { Console.WriteLine(job.StatusMessage); Thread.Sleep(3000); job = _client.GetJobInfo(_storeName, job.JobId); } Assert.IsTrue(job.JobCompletedOk, "Expected job to complete successfully"); }
private void AddJobInfo(IJobInfo jobInfo) { _jobInfos.Add(jobInfo); if (JobInfos.CurrentItem == null) { JobInfos.MoveCurrentToFirst(); } RaiseRefreshView(); }
public void JobInfo_WhenMergedWithOtherJobInfo_DeleteIsCalledOnSecondJob() { IJobInfo jobInfo = new JobInfo(); IJobInfo jobInfoStub = MockRepository.GenerateStub <IJobInfo>(); jobInfoStub.Stub(x => x.SourceFiles).Return(new List <SourceFileInfo>()); jobInfo.Merge(jobInfoStub); jobInfoStub.AssertWasCalled(x => x.Delete(false)); }
/// <summary> /// Use this ctor. Do not use default ctor. /// </summary> public Opportunity(Guid publisherId, object publisher, IJobInfo <TTarget, TProduct> jobInfo, string category) { Id = Guid.NewGuid(); //OpportunityId = Guid.NewGuid(); PublisherId = publisherId; Publisher = publisher; JobInfo = jobInfo; Category = category; //Information = information; }
/// <summary> /// Removes a JobInfo from the Queue /// </summary> /// <param name="jobInfo">The JobInfo to remove</param> /// <param name="deleteFiles">If true, the inf and source files will be deleted</param> /// <returns>true, if successful</returns> public bool Remove(IJobInfo jobInfo, bool deleteFiles) { _jobFileSet.Remove(jobInfo.InfFile); if (deleteFiles) { jobInfo.Delete(true); } return(JobInfos.Remove(jobInfo)); }
private void UpdateStats(RoutedEventArgs e) { var button = e.Source as Button; if (button != null) { _dispatcher = button.Dispatcher; var client = BrightstarService.GetClient(Store.Source.ConnectionString); _statsUpdateJob = client.UpdateStatistics(Store.Location); _dispatcher.BeginInvoke(DispatcherPriority.SystemIdle, new TransactionViewModel.JobMonitorDelegate(CheckJobStatus)); } }
public void SetUp() { _jobInfo = new JobInfo(); var sourceFileInfo = new SourceFileInfo(); sourceFileInfo.ClientComputer = "someComputer"; sourceFileInfo.JobCounter = 3; sourceFileInfo.JobId = 14; sourceFileInfo.PrinterName = "SomePrinter"; sourceFileInfo.SessionId = 121; _jobInfo.SourceFiles.Add(sourceFileInfo); var metadata = new Metadata(); metadata.PrintJobAuthor = "someAuthor"; metadata.PrintJobName = "somePrintJobName"; metadata.Author = "someAuthor"; metadata.Title = "someTitle"; _jobInfo.Metadata = metadata; _tokenReplacerFactory = new TokenReplacerFactory(); _fileUtil = new MockFileUtil(); _fileUtil.SetInstanceToMock(); _environment = MockRepository.GenerateStub <IEnvironment>(); _environment.Stub(e => e.UserName).Return("someUser"); _environment.Stub(e => e.MachineName).Return("someMachine"); var dateTime = MockRepository.GenerateStub <IDateTime>(); dateTime.Stub(dt => dt.Now).Return(new DateTimeWrap(2000, 1, 1, 1, 1, 1)); _job = MockRepository.GenerateStub <IJob>(); _job.Stub(j => j.JobInfo).Return(_jobInfo); _job.Stub(j => j.NumberOfCopies).Return(5); _job.Stub(j => j.NumberOfPages).Return(14); _job.OutputFiles = new List <string>() { "outputFile", "test" }; var path = MockRepository.GenerateStub <IPath>(); path.Stub(p => p.GetFullPath("outputFile")).Return("fullPath"); path.Stub(p => p.GetFileNameWithoutExtension("C:\\thedir\\thefile.txt")).Return("thefile"); path.Stub(p => p.GetDirectoryName("C:\\thedir\\thefile.txt")).Return("C:\\thedir"); path.Stub(p => p.GetFileName("")).IgnoreArguments().Return("file"); _tokenReplacerFactory = new TokenReplacerFactory(dateTime, _environment, path); }
private void UpdateStats(RoutedEventArgs e) { var button = e.Source as Button; if (button != null) { _dispatcher = button.Dispatcher; var client = BrightstarService.GetClient(Store.Source.ConnectionString); _statsUpdateJob = client.UpdateStatistics(Store.Location); _dispatcher.BeginInvoke(DispatcherPriority.SystemIdle, new TransactionViewModel.JobMonitorDelegate(CheckJobStatus)); } }
public void Create_Job_With_Default_Ctor() { job = new JobInfo(); Assert.IsFalse(job.Enabled); Assert.AreEqual(NONE, job.Name); Assert.AreEqual(NONE, job.Schedule); Assert.IsFalse(job.LogEnabled); Assert.IsTrue(job.Repeatable); Assert.IsTrue(job.StopOnError); Assert.AreEqual(0, job.RepetitionIntervalTime); }
public void JobInfo_WhenMergedWithOtherJobInfo_MergedJobContainsBothSourceFiles() { IJobInfo jobInfo = new JobInfo(); jobInfo.SourceFiles.Add(FakeSourceFileInfo()); IJobInfo jobInfoStub = MockRepository.GenerateStub <IJobInfo>(); jobInfoStub.Stub(x => x.SourceFiles).Return(new List <SourceFileInfo>(new[] { FakeSourceFileInfo() })); jobInfo.Merge(jobInfoStub); Assert.AreEqual(2, jobInfo.SourceFiles.Count); }
/// <summary> /// Merge this JobInfo with another /// </summary> /// <param name="jobInfo">The JobInfo to merge with. Its source files will be added at the end of the source file list</param> public void Merge(IJobInfo jobInfo) { if (jobInfo.JobType != JobType) { return; } foreach (var sourceFile in jobInfo.SourceFiles) { SourceFiles.Add(sourceFile); } jobInfo.Delete(false); }
public static IJobInfo WaitForJob(IJobInfo job, IBrightstarService client, string storeName) { var cycleCount = 0; while (!job.JobCompletedOk && !job.JobCompletedWithErrors && cycleCount < 100) { Thread.Sleep(500); cycleCount++; job = client.GetJobInfo(storeName, job.JobId); } if (!job.JobCompletedOk && !job.JobCompletedWithErrors) { Assert.Fail("Job did not complete in time."); } return job; }
public void Execute(RoutedEventArgs eventArgs) { ValidationMessages.Clear(); var executeButton = eventArgs.Source as Button; if (executeButton!= null) { _dispatcher = executeButton.Dispatcher; var client = BrightstarService.GetClient(Store.Source.ConnectionString); // Instead of blocking, start the job and a background thread to monitor it var expandedAddTriples = GetExpandedTriples(AddTriples); var expandedDeleteTriples = GetExpandedDeletePatterns(); _transactionJob = client.ExecuteTransaction(Store.Location, null, expandedDeleteTriples, expandedAddTriples, waitForCompletion:false); ValidationMessages.Add("Executing transaction. Please wait..."); _dispatcher.BeginInvoke(DispatcherPriority.Normal, new JobMonitorDelegate(this.CheckJobStatus)); } }
private void CheckJobStatus() { try { var client = BrightstarService.GetClient(Store.Source.ConnectionString); _statsUpdateJob = client.GetJobInfo(Store.Location, _statsUpdateJob.JobId); if (_statsUpdateJob.JobPending) { SummaryMessage = "Updated job is queued for processing."; } if (_statsUpdateJob.JobStarted) { SummaryMessage = String.IsNullOrEmpty(_statsUpdateJob.StatusMessage) ? "Job is running" : _statsUpdateJob.StatusMessage; } if (_statsUpdateJob.JobCompletedOk) { SummaryMessage = "Statistics updated completed."; Refresh(); } else if (_statsUpdateJob.JobCompletedWithErrors) { SummaryMessage = "Updated job failed."; } else { _dispatcher.BeginInvoke(DispatcherPriority.SystemIdle, new TransactionViewModel.JobMonitorDelegate(CheckJobStatus)); } } catch (Exception) { SummaryMessage = "Error retrieving job status information from the server."; } }
public void OnJobLoaded(IList<IFlawTypeName> flawTypes, IList<ILaneInfo> lanes, IList<ISeverityInfo> severityInfo, IJobInfo jobInfo) { #region 註解 /* * 1. 使用Model來存取介面取得之參數. * 2. 啟動並回復執行緒 */ #endregion //MessageBox.Show("OnJobLoaded"); //DebugTool.WriteLog("PxPTab.cs", "OnJobLoaded"); //PxPVariable.FlawTypeName.Clear(); //PxPVariable.FlawTypeName = flawTypes; //Clear Some relative data MapWindowVariable.Flaws.Clear(); MapWindowVariable.FlawPiece.Clear(); MapWindowVariable.FlawPieces.Clear(); GradeVariable.SplitPiecesContainer.Clear(); MapWindowVariable.CurrentPiece = 0; MapWindowVariable.MapWindowController.InitLabel(); PxPVariable.CurrentCutPosition = 0; //Reload Grade config useing mcs value SystemVariable.LoadGradeConfig(); //開啟歷史資料時重新計算 P/F PxPVariable.DoffNum = 0; PxPVariable.FailNum = 0; PxPVariable.PassNum = 0; foreach (var ft in PxPVariable.FlawTypeName) { ft.DoffNum = 0; ft.JobNum = 0; } //完整處理完tmpList在丟到PxPVariable.FlawTypeName List<FlawTypeNameExtend> tmpList = new List<FlawTypeNameExtend>(); tmpList.AddRange(PxPVariable.FlawTypeName); // 一開始Conf會載入儲存Config中所有的設定到PxPVariable.FlawTypeName //把flawTypes沒有的項目先從tmp移除 var DifferencesConfigList = PxPVariable.FlawTypeName.Where(x => !flawTypes.Any(x1 => x1.Name == x.Name && x1.FlawType == x.FlawType)); foreach (var r in DifferencesConfigList) { tmpList.Remove(r); } //差異比對 補上conf沒有 但是flawTypes有的 一樣的就跳過不處理 var DifferencesList = flawTypes.Where(x => !tmpList.Any(x1 => x1.Name == x.Name && x1.FlawType == x.FlawType )); foreach (var i in DifferencesList) { //Default FlawTypeNameExtend tmp = new FlawTypeNameExtend(); tmp.FlawType = i.FlawType; tmp.Name = i.Name; tmp.Display = true; foreach (var f in PxPVariable.FlawLegend) { if (f.Name.Trim() == tmp.Name.Trim()) { //tmp.Color = String.Format("#{0:X6}", Convert.ToString(f.Color, 16).PadRight(6,'0')); tmp.Color = String.Format("#{0:X2}{1:X2}{2:X2}", ColorTranslator.FromWin32((int)f.Color).R, ColorTranslator.FromWin32((int)f.Color).G, ColorTranslator.FromWin32((int)f.Color).B); //tmp.Color = String.Format("#{0:X6}", Reverse((f.Color).ToString("X6").PadRight(6, '0'))); break; } else { tmp.Color = "#000000"; } } tmp.Shape = Shape.Cone.ToGraphic(); tmpList.Add(tmp); } //var random = new Random(); //foreach (var i in flawTypes) //{ // FlawTypeNameExtend tmp = new FlawTypeNameExtend(); // foreach (var f in PxPVariable.FlawTypeName) // { // if (i.Name != f.Name) // { // //Default // tmp.FlawType = i.FlawType; // tmp.Name = i.Name; // tmp.Display = true; // //tmp.Color =String.Format("#{0:X6}", random.Next(0x1000000)); // //tmp.Shape = Shape.Cross.ToGraphic(); // tmp.Color = "#000000"; // tmp.Shape = Shape.Cone.ToGraphic(); // tmpList.Add(tmp); // } // } //} PxPVariable.FlawTypeName.Clear(); PxPVariable.FlawTypeName.AddRange(tmpList); PxPVariable.FlawTypeName.Sort(delegate(FlawTypeNameExtend f1, FlawTypeNameExtend f2) { return f1.FlawType.CompareTo(f2.FlawType); }); //Copy a temp for setup gridview display. Not save to global variable just for display. PxPVariable.TmpFlawTypeNameForSetup.Clear(); foreach (var ft in PxPVariable.FlawTypeName) { FlawTypeNameExtend tmp = new FlawTypeNameExtend(); tmp.FlawType = ft.FlawType; tmp.Name = ft.Name; tmp.Display = ft.Display; tmp.Count = ft.Count; tmp.Color = ft.Color; tmp.Shape = ft.Shape; PxPVariable.TmpFlawTypeNameForSetup.Add(tmp); } PxPVariable.JobInfo = jobInfo; PxPVariable.SeverityInfo = severityInfo; PxPThreadStatus.IsOnJobLoaded = true; //Disable MapSetup Button MapWindowVariable.MapWindowController.btnMapSetup.Enabled = true; MapWindowVariable.MapWindowController.SetJobInfo(); MapWindowVariable.MapWindowController.SetMapAxis(); MapWindowVariable.MapWindowController.bsFlawType.ResetBindings(false); MapWindowVariable.MapWindowController.InitSubPiece(); PxPThreadEvent.Set(); }
public void CheckJobStatus() { var client = BrightstarService.GetClient(Store.Source.ConnectionString); _transactionJob = client.GetJobInfo(Store.Location, _transactionJob.JobId); if (_transactionJob.JobCompletedOk) { ValidationMessages.Clear(); ValidationMessages.Add(Strings.TransactionSuccess); } else if (_transactionJob.JobCompletedWithErrors) { ValidationMessages.Clear(); ValidationMessages.Add(Strings.TransactionFailed); ValidationMessages.Add(_transactionJob.ExtractJobErrorMessage(true)); Messenger.Default.Send( new ShowDialogMessage("Transaction failed", "Transaction failed with status: " + _transactionJob.StatusMessage, MessageBoxImage.Error, MessageBoxButton.OK), "MainWindow"); } else { _dispatcher.BeginInvoke(DispatcherPriority.SystemIdle, new JobMonitorDelegate(this.CheckJobStatus)); } }
// Initial UI and local object public void InitJobInfo(IJobInfo jobInfo) { lblDateTimeValue.Text = DateTime.Now.ToShortDateString(); lblOrderNumberValue.Text = jobInfo.OrderNumber; lblOperatorValue.Text = jobInfo.OperatorName; lblJobIdValue.Text = jobInfo.JobID; lblMeterialTypeValue.Text = jobInfo.MaterialType; // update on cut lblDoffValue.Text = "0"; // Job 段號 初始為0 lblPassValue.Text = "0"; lblFailValue.Text = "0"; lblYieldValue.Text = "0%"; lblScoreValue.Text = "0"; lblNowPiece.Text = "---"; lblTotalPiece.Text = "---"; lblNowPiece.ForeColor = SystemColors.ControlDarkDark; btnPrevPiece.Enabled = false; btnNextPiece.Enabled = false; btnShowGoPage.Enabled = false; _jobDoffNum.Clear(); _doffResult.Clear(); if (JobHelper.IsOnpeHistory) { cmbFilterType.SelectedItem = "All"; } }
public ImportJobViewModel(string importFileName, IJobInfo importJobInfo, bool isLocalImport) { ImportFileName = importFileName; IsLocalImport = isLocalImport; _importJobInfo = importJobInfo; UpdateStatusProperties(); }
public void RefreshStatus(IBrightstarService client, string storeName) { _importJobInfo = client.GetJobInfo(storeName, _importJobInfo.JobId); UpdateStatusProperties(); }
private void LocalImportContinuation(MessageBoxResult dialogResult = MessageBoxResult.Yes) { try { if (dialogResult == MessageBoxResult.Yes) { var ext = MimeTypesHelper.GetTrueFileExtension(_importFileName); bool isGZipped = ext.EndsWith(MimeTypesHelper.DefaultGZipExtension); string lines; var fileTypeDefinition = MimeTypesHelper.GetDefinitionsByFileExtension(ext).FirstOrDefault(d => d.CanParseRdf); var rdfReader = fileTypeDefinition == null ? null : fileTypeDefinition.GetRdfParser(); if (rdfReader == null || rdfReader is NTriplesParser || rdfReader is NQuadsParser) { // We can't determine the file type, or it is NQuads or NTriples if (isGZipped) { using (var fileStream = new FileStream(_importFileName, FileMode.Open)) { var gZipStream = new GZipStream(fileStream, CompressionMode.Decompress); var reader = new StreamReader(gZipStream); lines = reader.ReadToEnd(); } } else { lines = File.ReadAllText(_importFileName); } } else { using (var textWriter = new StringWriter()) { try { var nQuadsFormatter = new NQuadsFormatter(); var writeThroughHandler = new WriteThroughHandler(nQuadsFormatter, textWriter); rdfReader.Load(writeThroughHandler, _importFileName); lines = textWriter.ToString(); } catch (Exception ex) { Messenger.Default.Send(new ShowDialogMessage( Strings.ParseErrorTitle, String.Format(Strings.ParseErrorDescription, _importFileName, ex.Message), MessageBoxImage.Error, MessageBoxButton.OK), "MainWindow"); return; } } } var client = BrightstarService.GetClient(Store.Source.ConnectionString); _transactionJob = client.ExecuteTransaction(Store.Location, String.Empty, String.Empty, lines, waitForCompletion:false); _dispatcher.BeginInvoke(DispatcherPriority.SystemIdle, new TransactionViewModel.JobMonitorDelegate(CheckJobStatus)); } } catch (OutOfMemoryException) { Messenger.Default.Send(new ShowDialogMessage(Strings.ParseErrorTitle, Strings.ImportFileTooLarge, MessageBoxImage.Error, MessageBoxButton.OK), "MainWindow"); } }
private void ReportCompletedJob(IJobInfo jobInfo) { var expectedCount = Int32.Parse(jobInfo.Label.Split('_').Last()); BenchmarkLogging.Info("EXPORT {0}, {1}", expectedCount, jobInfo.EndTime.Subtract(jobInfo.StartTime).TotalMilliseconds); var actualCount = CountLines("import" + Path.DirectorySeparatorChar + jobInfo.Label + ".nt"); if (expectedCount == actualCount) { BenchmarkLogging.Info("Validated expected number of triples exported in {0}.nt", jobInfo.Label); } else { BenchmarkLogging.Error("Exported triple count in file {0}.nt does not match the expected count. (Expected: {1}, Counted: {2})", jobInfo.Label, expectedCount, actualCount); } }
public void OnJobLoaded(IList<IFlawTypeName> flawTypes, IList<ILaneInfo> lanes, IList<ISeverityInfo> severityInfo, IJobInfo jobInfo) { JobHelper.FlawTypes = flawTypes; JobHelper.JobInfo = jobInfo; JobHelper.Lanes = lanes; JobHelper.SeverityInfo = severityInfo; //btnSetting.Enabled = true; chartControl.Series.Clear(); _flawData.Clear(); //InitialChart(); }
// (16) public void OnJobLoaded(IList<IFlawTypeName> flawTypes, IList<ILaneInfo> lanes, IList<ISeverityInfo> severityInfo, IJobInfo jobInfo) { // WriteHelper.Log("OnJobLoaded()"); // Reset to default. _cuts = new List<double>(); //_newCuts = new List<Cut>(); lblNowPage.Text = "---"; lblTotalPage.Text = "---"; btnNextFlawImages.Enabled = false; btnPrevFlawImages.Enabled = false; btnShowGoPage.Enabled = false; _nowPage = 0; _totalPage = 0; _dvFiliter = new DataView(); // save datas in global helper. JobHelper.FlawTypes = flawTypes; JobHelper.JobInfo = jobInfo; JobHelper.Lanes = lanes; JobHelper.SeverityInfo = severityInfo; //update dgvFlaw HeaderText + (Unit) NowUnit unitFlawListCD = _units.Find(x => x.ComponentName == "Flaw List CD"); dgvFlaw.Columns["CD"].HeaderText = dgvFlaw.Columns["CD"].Name + String.Format("({0})", unitFlawListCD.Symbol); NowUnit unitFlawListMD = _units.Find(x => x.ComponentName == "Flaw List MD"); dgvFlaw.Columns["MD"].HeaderText = dgvFlaw.Columns["MD"].Name + String.Format("({0})", unitFlawListMD.Symbol); NowUnit unitFlawListWidth = _units.Find(x => x.ComponentName == "Flaw List Width"); dgvFlaw.Columns["Width"].HeaderText = dgvFlaw.Columns["Width"].Name + String.Format("({0})", unitFlawListWidth.Symbol); NowUnit unitFlawListLength = _units.Find(x => x.ComponentName == "Flaw List Height"); dgvFlaw.Columns["Length"].HeaderText = dgvFlaw.Columns["Length"].Name + String.Format("({0})", unitFlawListLength.Symbol); NowUnit unitFlawListArea = _units.Find(x => x.ComponentName == "Flaw List Area"); dgvFlaw.Columns["Area"].HeaderText = dgvFlaw.Columns["Area"].Name + String.Format("({0})", unitFlawListArea.Symbol); // initialize datatable flaw format without data. _dtbFlaws = new DataTable("Flaws"); _dtbFlaws.Columns.Add("FlawID", typeof(int)); _dtbFlaws.Columns.Add("CD", typeof(double)); _dtbFlaws.Columns.Add("MD", typeof(double)); _dtbFlaws.Columns.Add("Area", typeof(string)); _dtbFlaws.Columns.Add("FlawClass", typeof(string)); _dtbFlaws.Columns.Add("FlawType", typeof(int)); _dtbFlaws.Columns.Add("Images", typeof(IList<IImageInfo>)); _dtbFlaws.Columns.Add("LeftEdge", typeof(double)); _dtbFlaws.Columns.Add("RightEdge", typeof(double)); _dtbFlaws.Columns.Add("Length", typeof(double)); _dtbFlaws.Columns.Add("Width", typeof(double)); _dtbFlaws.Columns.Add("Roll", typeof(int)); _dtbFlaws.Columns.Add("RollMD", typeof(double)); _dtbFlaws.Columns.Add("RightRollCD", typeof(double)); _dtbFlaws.Columns.Add("LeftRollCD", typeof(double)); _dtbFlaws.Columns.Add("DateTime", typeof(DateTime)); // other columns for deal grade and score. _dtbFlaws.Columns.Add("Priority", typeof(int)); _dtbFlaws.Columns.Add("PointScore", typeof(double)); _dtbFlaws.Columns.Add("SubPieceName", typeof(string)); // sort by default column ConfigHelper ch = new ConfigHelper(); _dtbFlaws.DefaultView.Sort = String.Format("{0} ASC", ch.GetSortByColumnName().Trim()); // set dgvFlaws datasource dgvFlaw.DataSource = _dtbFlaws; // Refresh TableLayoutPanel tlpFlawImages.Controls.Clear(); tlpFlawImages.ColumnStyles.Clear(); tlpFlawImages.ColumnCount = ch.GettlpFlawImagesColumns(); tlpFlawImages.RowCount = ch.GettlpFlawImagesRows(); int phdHeight = tlpFlawImages.Height / tlpFlawImages.RowCount; int phdrWidth = tlpFlawImages.Width / tlpFlawImages.ColumnCount; for (int i = 0; i < tlpFlawImages.RowCount; i++) { tlpFlawImages.RowStyles.Add(new RowStyle(SizeType.Percent, 50)); } for (int i = 0; i < tlpFlawImages.ColumnCount; i++) { tlpFlawImages.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50)); } // For MapWindow.cs //--------------------------------------------------------------------------- // Setting MapWindow _mp.InitJobInfo(jobInfo); _mp.InitFlawLegendGrid(); _mp.InitDatatableFlaws(ref _dtbFlaws); _mp.InitUnits(ref _units); _mp.InitCutList(ref _cuts); // UNDONE: New Cut List // _mp.InitCutList(ref _newCuts); _mp.InitFire(ref Fire); // Initial Flaw Chart FlawLegend NowUnit unitFlawMapCD = _units.Find(x => x.ComponentName == "Flaw Map CD"); double mapWidth = JobHelper.PxPInfo.Width * unitFlawMapCD.Conversion; double mapHeight = JobHelper.PxPInfo.Height * unitFlawMapCD.Conversion; _mp.InitChart(mapWidth, mapHeight); }