/// <summary> /// start an ImvertorJob if possible. Else the job will be added to the waiting list /// </summary> /// <param name="imvertorJob">the job to start</param> private void startJob(EAImvertorJob imvertorJob) { if (this.canJobStart) { //create new backgroundWorker var imvertorJobBackgroundWorker = new BackgroundWorker(); //imvertorJobBackgroundWorker.WorkerSupportsCancellation = true; //TODO: implement cancellation imvertorJobBackgroundWorker.WorkerReportsProgress = true; imvertorJobBackgroundWorker.DoWork += imvertorBackground_DoWork; imvertorJobBackgroundWorker.ProgressChanged += imvertorBackground_ProgressChanged; imvertorJobBackgroundWorker.RunWorkerCompleted += imvertorBackgroundRunWorkerCompleted; //update gui this.imvertorControl.addJob(imvertorJob); //show the control this.model.showWindow(windowName); //start job in the background imvertorJobBackgroundWorker.RunWorkerAsync(imvertorJob); } else { //job cannot be started, we add it to the waiting jobs this.waitingjobs.Add(imvertorJob); } }
private void publish(UML.Classes.Kernel.Package selectedPackage, EAImvertorJobSettings jobSettings) { //somebody called the imvertor, we can show the control this._imvertorCalled = true; var imvertorJob = new EAImvertorJob(selectedPackage, jobSettings); this.startJob(imvertorJob); }
public void addJob(EAImvertorJob job) { this.jobs.Insert(0,job); var row = new ListViewItem(job.sourcePackage.name); row.SubItems.Add(job.status); row.Tag = job; this.imvertorJobGrid.Items.Insert(0,row); row.Selected = true; }
/// <summary> /// a package can be published if it's stereotype is present in the list of allowed stereotypes in the settings /// </summary> /// <param name="package">the package to publish</param> /// <returns>whether or not a package can be published</returns> private bool canBePublished(UML.Classes.Kernel.Package package) { return(package != null && (package.stereotypes.Any (x => this.settings.imvertorStereotypes.Any (y => y.Equals(x.name, StringComparison.InvariantCultureIgnoreCase))) || package.taggedValues.Any(x => "imvertor".Equals(x.name, StringComparison.InvariantCultureIgnoreCase) && "model".Equals(x.tagValue.ToString(), StringComparison.InvariantCultureIgnoreCase))) && EAImvertorJob.getProjectPackage(package) != null); }
public void addJob(EAImvertorJob job) { this.jobs.Insert(0, job); var row = new ListViewItem(job.sourcePackage.name); row.SubItems.Add(job.status); row.Tag = job; this.imvertorJobGrid.Items.Insert(0, row); row.Selected = true; }
public void refreshJobInfo(EAImvertorJob imvertorJob) { try { foreach (ListViewItem row in imvertorJobGrid.Items) { var currentJob = (EAImvertorJob)row.Tag; if (imvertorJob == null || currentJob.Equals(imvertorJob)) { string statusString = currentJob.status; if (!(currentJob.status.StartsWith("Finished") || currentJob.status.StartsWith("Error"))) { if (currentJob.timedOut) { statusString += " (Timed Out)"; } else if (currentJob.status.StartsWith("In Progress")) { if (currentJob.message.Length > 0) { statusString += string.Format(" ({0})", currentJob.message); } } else if (currentJob.tries > 0) { statusString += new string('.', currentJob.tries); } } else if (currentJob.status.StartsWith("Finished")) { if (currentJob.message.Length > 0) { statusString += string.Format(" ({0})", currentJob.message); } } else if (currentJob.status.StartsWith("Error")) { statusString += @" (See " + EAAddinFramework.Utilities.Logger.logFileName + " for more info)"; } row.SubItems[1].Text = statusString; } } setSelectedJobDetails(); this.enableDisable(); } catch (Exception) { //do nothing. TODO: figure out a thread safe way to refresh control } }
public void refreshJobInfo(EAImvertorJob imvertorJob) { try { foreach (ListViewItem row in imvertorJobGrid.Items) { var currentJob = (EAImvertorJob) row.Tag; if (imvertorJob == null || currentJob.Equals(imvertorJob) ) { string statusString = currentJob.status; if (!(currentJob.status.StartsWith("Finished") || currentJob.status.StartsWith("Error"))) { if (currentJob.timedOut) { statusString += " (Timed Out)"; } else if (currentJob.status.StartsWith("In Progress")) { if (currentJob.message.Length > 0) statusString += string.Format(" ({0})",currentJob.message); } else if (currentJob.tries > 0) { statusString += new string('.',currentJob.tries); } } else if (currentJob.status.StartsWith("Finished")) { if (currentJob.message.Length > 0) statusString += string.Format(" ({0})",currentJob.message); } else if (currentJob.status.StartsWith("Error")) { statusString += @" (See "+EAAddinFramework.Utilities.Logger.logFileName+" for more info)"; } row.SubItems[1].Text =statusString; } } setSelectedJobDetails(); this.enableDisable(); } catch(Exception) { //do nothing. TODO: figure out a thread safe way to refresh control } }
void imvertorBackground_ProgressChanged(object sender, ProgressChangedEventArgs e) { //if the current job is exporting we have to stop the other jobs from starting var currentJob = (EAImvertorJob)e.UserState; if (currentJob.status.StartsWith("Exporting")) { this.blockingJob = currentJob; this.canJobStart = false; } else { if (this.blockingJob == currentJob) { this.canJobStart = true; this.startNextJob(); } } this.imvertorControl.refreshJobInfo(currentJob); }
private void publish(UML.Classes.Kernel.Package selectedPackage, EAImvertorJobSettings jobSettings) { //somebody called the imvertor, we can show the control this._imvertorCalled = true; //create new backgroundWorker var imvertorJobBackgroundWorker = new BackgroundWorker(); //imvertorJobBackgroundWorker.WorkerSupportsCancellation = true; //TODO: implement cancellation imvertorJobBackgroundWorker.WorkerReportsProgress = true; imvertorJobBackgroundWorker.DoWork += imvertorBackground_DoWork; imvertorJobBackgroundWorker.ProgressChanged += imvertorBackground_ProgressChanged; imvertorJobBackgroundWorker.RunWorkerCompleted += imvertorBackgroundRunWorkerCompleted; var imvertorJob = new EAImvertorJob(selectedPackage, jobSettings); //update gui this.imvertorControl.addJob(imvertorJob); //show the control this.model.showWindow(windowName); //start job in the background imvertorJobBackgroundWorker.RunWorkerAsync(imvertorJob); }