From 10662ab5e2c3724328bdc3611c708af2fe1ef2cb Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 30 Apr 2020 14:19:18 +0000 Subject: [PATCH] --- .../ProgressForm.Designer.cs | 19 ++++++ .../Plugins/AyaNova.Plugin.V8/ProgressForm.cs | 19 +++++- source/Plugins/AyaNova.Plugin.V8/V8.cs | 66 +++++++++++++------ 3 files changed, 82 insertions(+), 22 deletions(-) diff --git a/source/Plugins/AyaNova.Plugin.V8/ProgressForm.Designer.cs b/source/Plugins/AyaNova.Plugin.V8/ProgressForm.Designer.cs index 66117fb..bbaf35c 100644 --- a/source/Plugins/AyaNova.Plugin.V8/ProgressForm.Designer.cs +++ b/source/Plugins/AyaNova.Plugin.V8/ProgressForm.Designer.cs @@ -33,6 +33,7 @@ this.lblCurrent = new System.Windows.Forms.Label(); this.edCurrent = new System.Windows.Forms.TextBox(); this.edSubOp = new System.Windows.Forms.TextBox(); + this.btnCancel = new System.Windows.Forms.Button(); this.SuspendLayout(); // // edOut @@ -93,6 +94,22 @@ this.edSubOp.Size = new System.Drawing.Size(870, 22); this.edSubOp.TabIndex = 4; // + // btnCancel + // + this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnCancel.Enabled = false; + this.btnCancel.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnCancel.Location = new System.Drawing.Point(16, 603); + this.btnCancel.Margin = new System.Windows.Forms.Padding(2); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(82, 32); + this.btnCancel.TabIndex = 5; + this.btnCancel.Text = "Stop"; + this.btnCancel.UseVisualStyleBackColor = true; + this.btnCancel.Visible = false; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // // ProgressForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -100,6 +117,7 @@ this.CancelButton = this.btnClose; this.ClientSize = new System.Drawing.Size(870, 646); this.ControlBox = false; + this.Controls.Add(this.btnCancel); this.Controls.Add(this.edSubOp); this.Controls.Add(this.edCurrent); this.Controls.Add(this.lblCurrent); @@ -122,5 +140,6 @@ private System.Windows.Forms.Label lblCurrent; private System.Windows.Forms.TextBox edCurrent; private System.Windows.Forms.TextBox edSubOp; + private System.Windows.Forms.Button btnCancel; } } \ No newline at end of file diff --git a/source/Plugins/AyaNova.Plugin.V8/ProgressForm.cs b/source/Plugins/AyaNova.Plugin.V8/ProgressForm.cs index 64ef59f..97aefde 100644 --- a/source/Plugins/AyaNova.Plugin.V8/ProgressForm.cs +++ b/source/Plugins/AyaNova.Plugin.V8/ProgressForm.cs @@ -11,22 +11,29 @@ namespace AyaNova.PlugIn.V8 { public partial class ProgressForm : Form { + public bool KeepGoing { get; set; } public ProgressForm() { InitializeComponent(); + KeepGoing = true; } public void StartedImport() { - Cursor.Current = Cursors.WaitCursor; + //Cursor.Current = Cursors.WaitCursor; btnClose.Enabled = false; + btnCancel.Enabled = true; + btnCancel.Visible = true; + } public void FinishedImport() { - Cursor.Current = Cursors.Default; + //Cursor.Current = Cursors.Default; btnClose.Enabled = true; + btnCancel.Enabled = false; + btnCancel.Visible = false; } public void Append(string txt) @@ -58,5 +65,13 @@ namespace AyaNova.PlugIn.V8 { this.Close(); } + + private void btnCancel_Click(object sender, EventArgs e) + { + KeepGoing = false; + + } + + //eoc } } diff --git a/source/Plugins/AyaNova.Plugin.V8/V8.cs b/source/Plugins/AyaNova.Plugin.V8/V8.cs index 0ec0f39..adcb29a 100644 --- a/source/Plugins/AyaNova.Plugin.V8/V8.cs +++ b/source/Plugins/AyaNova.Plugin.V8/V8.cs @@ -213,22 +213,35 @@ namespace AyaNova.PlugIn.V8 //TAGS progress.Op("Compiling tags"); - ExportUnitModelCategories(progress); - ExportUnitServiceTypes(progress); - ExportWorkorderItemTypes(progress); - ExportRegions(progress); - ExportClientGroups(progress); - ExportWorkorderCategories(progress); - ExportPartCategories(progress); - ExportScheduleableUserGroups(progress); - ExportDispatchZones(progress); - ExportUserSkills(progress); - ExportUserCertifications(progress); + if (progress.KeepGoing) + ExportUnitModelCategories(progress); + if (progress.KeepGoing) + ExportUnitServiceTypes(progress); + if (progress.KeepGoing) + ExportWorkorderItemTypes(progress); + if (progress.KeepGoing) + ExportRegions(progress); + if (progress.KeepGoing) + ExportClientGroups(progress); + if (progress.KeepGoing) + ExportWorkorderCategories(progress); + if (progress.KeepGoing) + ExportPartCategories(progress); + if (progress.KeepGoing) + ExportScheduleableUserGroups(progress); + if (progress.KeepGoing) + ExportDispatchZones(progress); + if (progress.KeepGoing) + ExportUserSkills(progress); + if (progress.KeepGoing) + ExportUserCertifications(progress); progress.Op("Exporting objects"); //BIZ objects - await ExportUsers(progress); - await ExportLocales(progress); + if (progress.KeepGoing) + await ExportUsers(progress); + if (progress.KeepGoing) + await ExportLocales(progress); @@ -244,10 +257,19 @@ namespace AyaNova.PlugIn.V8 //NOTE: when get to PRIORITY, or WORKORDER STATUS be sure to add color code as per already done in USER export + if (progress.KeepGoing) + { + progress.Append("Export completed"); + progress.Op(""); - progress.Append("Export completed"); + goto End; + } + + progress.Append("Export cancelled before completing"); progress.Op(""); + End: + ; } catch (Exception ex) { @@ -327,6 +349,7 @@ namespace AyaNova.PlugIn.V8 foreach (UserPickList.UserPickListInfo i in pl) { + if (!progress.KeepGoing) return; List tags = new List(); tags.Add(ImportTag); @@ -417,6 +440,7 @@ namespace AyaNova.PlugIn.V8 //Because this is the User's we need to do the event log *after* they have all been posted as event log requires all user's id foreach (UserPickList.UserPickListInfo i in pl) { + if (!progress.KeepGoing) return; User c = User.GetItem(i.ID); var newId = Map[c.ID]; var creator = Map[c.Creator]; @@ -434,17 +458,18 @@ namespace AyaNova.PlugIn.V8 { //Skip stock locales already handled in Raven - List SkipLocales = new List(); - SkipLocales.Add("Deutsch"); - SkipLocales.Add("English"); - SkipLocales.Add("Español"); - SkipLocales.Add("Français"); + //List SkipLocales = new List(); + //SkipLocales.Add("Deutsch"); + //SkipLocales.Add("English"); + //SkipLocales.Add("Español"); + //SkipLocales.Add("Français"); LocaleList l = LocaleList.GetList(); progress.Append("Exporting " + l.Count.ToString() + " Locales"); foreach (LocaleList.LocaleListInfo i in l) { - if (!SkipLocales.Contains(i.Locale)) + if (!progress.KeepGoing) return; + if (i.Locale!="English") { LocalizedTextTable lt = LocalizedTextTable.Load(i.Locale); //todo: all locales except English default need to be dealt with @@ -714,6 +739,7 @@ namespace AyaNova.PlugIn.V8 //iterate the files foreach (AyaFileList.AyaFileListInfo i in fl) { + if (!progress.KeepGoing) return; var af = AyaFile.GetItem(i.LT_O_AyaFile.Value); if (af == null) continue;