private void SkuManagerMainForm_FormClosing(object sender, FormClosingEventArgs e) { if (_skuLoadWaitKey != null) { FrmWaitScreen.UpdateMessage((Guid)_skuLoadWaitKey, "Waiting for worker threads to finish/abort"); } AryaTools.Instance.Forms.SkuTabs.ForEach(tab => { tab.Value.AbortWorker = true; }); AryaTools.Instance.Forms.SkuTabs.ForEach( tab => { if (tab.Value.WorkerThread != null) { tab.Value.WorkerThread.Join(); } }); if (_skuLoadWaitKey != null) { FrmWaitScreen.HideMessage((Guid)_skuLoadWaitKey); _skuLoadWaitKey = null; } AryaTools.Instance.Forms.SkuTabs.Clear(); AryaTools.Instance.Forms.SkuForm.LoadQueue.Clear(); AryaTools.Instance.Forms.SkuLinksViewForm.Close(); AryaTools.Instance.Forms.SkuLinksViewForm.Dispose(); }
private void btnReplaceAll_Click(object sender, EventArgs e) { if (!ValidateInputParameters()) { return; } _findNext = false; int changeCount = 0; Guid waitKey = FrmWaitScreen.ShowMessage("Replace all"); while (DoFind()) { string originalValue = _parent.edgv.CurrentCell.Value.ToString(); _parent.CurrentChange.NewValues.Val = ddReplaceType.Text.Equals(FindTypeEntireValue) ? txtReplace.Text : Replace(_parent.edgv.CurrentCell.Value.ToString(), txtFind.Text, txtReplace.Text, rbMatchCase.Checked); _parent.SaveCurrentChangeAndGetNewChange(true); if (!_parent.edgv.CurrentCell.Value.ToString().Equals(originalValue)) { changeCount++; FrmWaitScreen.UpdateMessage(waitKey, string.Format("Replace all: {0} values updated", changeCount)); } } FrmWaitScreen.HideMessage(waitKey); AryaTools.Instance.SaveChangesIfNecessary(false, false); lblStatus.Text = string.Format("{0} values updated.", changeCount); ReselectSelection(); }
private void tmrMatch_Tick(object sender, EventArgs e) { if (_workerThread == null || !_workerThread.IsAlive) { tmrMatch.Stop(); MessageBox.Show(_currentStatus.Replace('|', '\n'), "Done!"); _currentStatus = string.Empty; var fi = new FileInfo(skuGapsFileName); if (fi.Exists) { AryaTools.Instance.Forms.BrowserForm.GotoUrl(fi.FullName); } } if (string.IsNullOrEmpty(_currentStatus)) { if (_waitkey != Guid.Empty) { FrmWaitScreen.HideMessage(_waitkey); _waitkey = Guid.Empty; } } else { if (_waitkey == Guid.Empty) { _waitkey = FrmWaitScreen.ShowMessage(_currentStatus); } else { FrmWaitScreen.UpdateMessage(_waitkey, _currentStatus); } } }
private void SaveChangesToDb() { var waitKey = FrmWaitScreen.ShowMessage("Waiting for workers to finish"); if (!Monitor.TryEnter(Instance.UpdateNodeWorkerSyncRoot, TimeSpan.FromSeconds(1))) // || //!Monitor.TryEnter(Instance.UpdateDefinitionWorkerSyncRoot, TimeSpan.FromSeconds(1)) || //!Monitor.TryEnter(Instance.UpdateEnrichmentsWorkerSyncRoot, TimeSpan.FromSeconds(1))) { Forms.TreeForm.taxonomyTree.AbortWorkers(); Monitor.Enter(Instance.UpdateNodeWorkerSyncRoot); //Monitor.Enter(Instance.UpdateDefinitionWorkerSyncRoot); //Monitor.Enter(Instance.UpdateEnrichmentsWorkerSyncRoot); } try { FrmWaitScreen.UpdateMessage(waitKey, "Saving"); SubmitAllChanges(); } finally { Monitor.Exit(Instance.UpdateNodeWorkerSyncRoot); //Monitor.Exit(Instance.UpdateDefinitionWorkerSyncRoot); //Monitor.Exit(Instance.UpdateEnrichmentsWorkerSyncRoot); Forms.TreeForm.taxonomyTree.TryStartWorkers(); } FrmWaitScreen.HideMessage(waitKey); }
// Public Methods (1) public void UpdateTitleAndStatus() { if (mainTabControl.TabPages.Count == 0) { Close(); return; } foreach (TabPage tab in mainTabControl.TabPages) { if (AryaTools.Instance.Forms.SkuTabs.ContainsKey(tab)) { AryaTools.Instance.Forms.SkuTabs[tab].ShortcutKeysEnabled = false; } } Text = @"SKU View"; if (mainTabControl.SelectedTab != null && AryaTools.Instance.Forms.SkuTabs.ContainsKey(mainTabControl.SelectedTab)) { Text += @" - " + mainTabControl.SelectedTab.Text; AryaTools.Instance.Forms.SkuTabs[mainTabControl.SelectedTab].ShortcutKeysEnabled = true; btnClose.Visible = mainTabControl.TabCount > 0; Rectangle rectangle = mainTabControl.GetTabRect(mainTabControl.SelectedIndex); btnClose.Location = rectangle.Location; } //Show wait screen if loading skus int tabsToLoad = AryaTools.Instance.Forms.SkuForm.LoadQueue.Count; if (tabsToLoad > 0) { if (_skuLoadWaitKey == null) { _skuLoadWaitKey = FrmWaitScreen.ShowMessage("Loading SKUs"); } else { FrmWaitScreen.UpdateMessage( (Guid)_skuLoadWaitKey, string.Format("Loading SKUs: {0} tab{1}", tabsToLoad, tabsToLoad > 1 ? "s" : "")); } } else { if (_skuLoadWaitKey != null) { FrmWaitScreen.HideMessage((Guid)_skuLoadWaitKey); _skuLoadWaitKey = null; } } }
private void UpdateEntities(Attribute newAtt, Guid waitkey) { //Update Entities //var eds = (from ei in Entities // join ed in AryaTools.Instance.InstanceData.Dc.EntityDatas on ei.ID equals ed.EntityID // where ed.AttributeID == Attribute.ID && ed.Active // select new {ed, ei}).ToList(); var eds = Entities.SelectMany( ei => ei.EntityDatas.Where(ed => ed != null && (ed.AttributeID == Attribute.ID && ed.Active)), (ei, ed) => new { ei, ed }).ToList(); var itemCount = eds.Count; var iCtr = 0; //DateTime.UtcNow is 20-30x faster than DateTime.Now as it skips local time conversion var lastUpdated = DateTime.UtcNow; foreach (var rec in eds) { var ed = rec.ed; ed.Active = false; rec.ei.EntityDatas.Add(new EntityData { Attribute = newAtt, Field1 = ed.Field1, Field2 = ed.Field2, Field3 = ed.Field3, Field4 = ed.Field4, //Field5orStatus = ed.Field5OrStatus, Value = ed.Value, Uom = ed.Uom }); ++iCtr; if (DateTime.UtcNow.Subtract(lastUpdated).TotalMilliseconds > 500) { FrmWaitScreen.UpdateMessage(waitkey, string.Format("Renaming attribute ({0} of {1} values)", iCtr, itemCount)); lastUpdated = DateTime.UtcNow; } } }
void ChangeTaxonomy(TaxonomyInfo currentTaxonomy, bool moveBlanks, Stack <EntityDataGridView.ChangeItem> undoHistory) { var waitkey = FrmWaitScreen.ShowMessage("Moving SKUs"); var newTaxonomy = NewValues.Tax; var changeId = Guid.NewGuid(); if (currentTaxonomy != null && !newTaxonomy.SchemaInfos.SelectMany(si => si.SchemaDatas).Any(sd => sd.Active) && currentTaxonomy.SchemaInfos.SelectMany(si => si.SchemaDatas).Any(sd => sd.Active)) { if (MessageBox.Show( @"The selected Destination node does not have an existing schema, do you wish it to be created from the Source Taxonomy?", @"Empty Schema", MessageBoxButtons.YesNo) == DialogResult.Yes) { FrmWaitScreen.UpdateMessage(waitkey, "Copying Schema"); var sourceSchemaDataList = currentTaxonomy.SchemaInfos.Where(si => si.SchemaData != null).Select(si => si.SchemaData).ToList(); CopySchema(sourceSchemaDataList, newTaxonomy); } } else if (currentTaxonomy != null && newTaxonomy.SchemaInfos.SelectMany(si => si.SchemaDatas).Any(sd => sd.Active) && currentTaxonomy.SchemaInfos.SelectMany(si => si.SchemaDatas).Any(sd => sd.Active)) { //Schema Append Process if (MessageBox.Show( string.Format("The selected destination node has an existing schema. Do you want to append additional schema attributes from the source node to the destination node? {0}{0}NOTE: Rank order of the appended schema attributes will be preserved and placed at the end of the existing schema.", Environment.NewLine), @"Append Schema", MessageBoxButtons.YesNo) == DialogResult.Yes) { FrmWaitScreen.UpdateMessage(waitkey, "Copying Schema"); var sourceAttributeList = currentTaxonomy.SchemaInfos.Where(si => si.SchemaData != null).Select( si => si.Attribute).Except ( newTaxonomy.SchemaInfos.Where(si => si.SchemaData != null).Select(si => si.Attribute) ).ToList(); var sourceSchemaDataList = currentTaxonomy.SchemaInfos.Where(si => sourceAttributeList.Contains(si.Attribute)).Select( si => si.SchemaData).ToList(); CopySchema(sourceSchemaDataList, newTaxonomy, true); } } int skuCount = 0; var resetTaxonomies = new List <TaxonomyInfo> { newTaxonomy }; var skus = GetSkus().Union(moveBlanks ? GetBlanks() : new List <Sku>()).ToList(); foreach (var sku in skus) { FrmWaitScreen.UpdateMessage(waitkey, string.Format("Moving SKUs ({0} of {1})", ++skuCount, skus.Count)); var currentSku = sku; // Make existing SkuInfos Inactive var oldSkuInfo = currentSku.SkuInfos.FirstOrDefault(si => si.Active); if (oldSkuInfo != null) { oldSkuInfo.Active = false; resetTaxonomies.Add(oldSkuInfo.TaxonomyInfo); } // Create a new SkuInfo var newSkuInfo = new SkuInfo { TaxonomyInfo = newTaxonomy }; currentSku.SkuInfos.Add(newSkuInfo); // Add these two to change history for Undo if (undoHistory != null) { undoHistory.Push(new EntityDataGridView.ChangeItem(oldSkuInfo, newSkuInfo, changeId)); } } resetTaxonomies.Distinct().ForEach(AryaTools.Instance.Forms.TreeForm.taxonomyTree.ResetSkuCount); FrmWaitScreen.HideMessage(waitkey); }