public bool OnClearSelectedWordParserAnalyses(object argument) { WfiWordform wf = CurrentWordform; if (wf == null) { MessageBox.Show(ParserUIStrings.ksSelectWordFirst); } else { if (CurrentWordformHvo > 0) { using (WfiWordformUi wfui = new WfiWordformUi(WfiWordform.CreateFromDBObject(m_cache, CurrentWordformHvo))) { if (m_cache.DatabaseAccessor.IsTransactionOpen()) m_cache.DatabaseAccessor.CommitTrans(); m_cache.DatabaseAccessor.BeginTrans(); DbOps.ExecuteStoredProc( m_cache, string.Format("EXEC RemoveParserApprovedAnalyses$ {0}", CurrentWordformHvo), null); m_cache.DatabaseAccessor.CommitTrans(); wfui.UpdateWordsToolDisplay(CurrentWordformHvo, false, false, true, true); } } } return true; //we handled this. }
private void m_updateTimer_Elapsed(object sender, EventArgs myEventArgs) { if (!InWordsAnalyses) { TraceVerboseLine("ParserListener:Timer not in Analyses tool - don't process timer message."); return; } TraceVerbose(" <<updateTimer,"); TraceVerbose(" TID="+System.Threading.Thread.CurrentThread.GetHashCode()+" "); if (m_busy) { TraceVerbose(" THE BUSY MEMBER IS ALREADY SET. STILL PROCESSING LAST TIMER MESSAGE."); TraceVerboseLine(" Done>>"); return; } int currentWordformHvo = CurrentWordformHvo; if (!m_busy && currentWordformHvo > 0) { m_busy = true; try { // SyncMsg.ksyncSimpleEdit is added to Sync$ table in ParseFiler for every wordform, // whether it was changed, or not. using (WfiWordformUi wfui = new WfiWordformUi(CurrentWordform)) { foreach (int id in SimpleEdits) { m_maxID = id; wfui.UpdateWordsToolDisplay(currentWordformHvo, false, false, true, true); } } // SyncMsg.ksyncFullRefresh is added to Sync$ table in ParseFiler for every wordform, // but only when its count of analyses was changed. foreach (int[] ints in FullRefreshes) { m_maxIDAnal = ints[0]; int wfID = ints[1]; // it is possible for this word form to no longer be valid. The parser thread could have // added this sync record before the main thread removed it. See LT-9618 if (m_cache.IsValidObject(wfID)) { using (WfiWordformUi wfui = new WfiWordformUi(WfiWordform.CreateFromDBObject(m_cache, wfID))) { wfui.UpdateWordsToolDisplay(wfui.Object.Hvo, false, false, true, (currentWordformHvo == wfID)); } } } } finally { m_busy = false; } } }
private static CmObjectUi MakeUi(FdoCache cache, int hvo, int clsid) { IFwMetaDataCache mdc = cache.DomainDataByFlid.MetaDataCache; // If we've encountered an object with this Clsid before, and this clsid isn't in // the switch below, the dictioanry will give us the appropriate clsid that IS in the // map, so the loop below will have only one iteration. Otherwise, we start the // search with the clsid of the object itself. int realClsid = m_subclasses.ContainsKey(clsid) ? m_subclasses[clsid] : clsid; // Each iteration investigates whether we have a CmObjectUi subclass that // corresponds to realClsid. If not, we move on to the base class of realClsid. // In this way, the CmObjectUi subclass we return is the one designed for the // closest base class of obj that has one. CmObjectUi result = null; while (result == null) { switch (realClsid) { // Todo: lots more useful cases. case WfiAnalysisTags.kClassId: result = new WfiAnalysisUi(); break; case PartOfSpeechTags.kClassId: result = new PartOfSpeechUi(); break; case CmPossibilityTags.kClassId: result = new CmPossibilityUi(); break; case CmObjectTags.kClassId: result = new CmObjectUi(); break; case LexPronunciationTags.kClassId: result = new LexPronunciationUi(); break; case LexSenseTags.kClassId: result = new LexSenseUi(); break; case LexEntryTags.kClassId: result = new LexEntryUi(); break; case MoMorphSynAnalysisTags.kClassId: result = new MoMorphSynAnalysisUi(); break; case MoStemMsaTags.kClassId: result = new MoStemMsaUi(); break; case MoDerivAffMsaTags.kClassId: result = new MoDerivAffMsaUi(); break; case MoInflAffMsaTags.kClassId: result = new MoInflAffMsaUi(); break; case MoAffixAllomorphTags.kClassId: case MoStemAllomorphTags.kClassId: result = new MoFormUi(); break; case ReversalIndexEntryTags.kClassId: result = new ReversalIndexEntryUi(); break; case WfiWordformTags.kClassId: result = new WfiWordformUi(); break; case WfiGlossTags.kClassId: result = new WfiGlossUi(); break; default: realClsid = mdc.GetBaseClsId(realClsid); // This isn't needed because CmObject.kClassId IS 0. // if (realClsid == 0) // { // // Somehow the class doesn't have CmObject in its inheritance path! // Debug.Assert(false); // // this may help make us more robust if this somehow happens. // realClsid = (uint)CmObject.kClassId; // } break; } } if (realClsid != clsid) m_subclasses[clsid] = realClsid; result.m_hvo = hvo; result.m_cache = cache; return result; }
protected override void ReallyDeleteUnderlyingObject() { // Gather original counts. var wf = (IWfiWordform) Object.Owner; int prePACount = wf.ParserCount; int preUACount = wf.UserCount; // we need to include resetting the wordform's checksum as part of the undo action // for deleting this analysis. using (var helper = new UndoableUnitOfWorkHelper( m_cache.ActionHandlerAccessor, FdoUiStrings.ksUndoDelete, FdoUiStrings.ksRedoDelete)) { base.ReallyDeleteUnderlyingObject(); // We need to fire off a notification about the deletion for several virtual fields. using (var wfui = new WfiWordformUi(wf)) { bool updateUserCountAndIcon = (preUACount != wf.UserCount); bool updateParserCountAndIcon = (prePACount != wf.ParserCount); wfui.UpdateWordsToolDisplay(wf.Hvo, updateUserCountAndIcon, updateUserCountAndIcon, updateParserCountAndIcon, updateParserCountAndIcon); } // Make sure it gets parsed the next time. wf.Checksum = 0; helper.RollBack = false; } }
/// <summary> /// Have the utility do what it does. /// </summary> public void Process() { Debug.Assert(m_dlg != null); FdoCache cache = (FdoCache)m_dlg.Mediator.PropertyTable.GetValue("cache"); List<int> wordformIds = DbOps.ReadIntsFromCommand( cache, "SELECT Id FROM WfiWordform", null); int curObjId = 0; if (m_dlg.Mediator != null) { Mediator mediator = m_dlg.Mediator; RecordClerk activeClerk = (RecordClerk)mediator.PropertyTable.GetValue("ActiveClerk"); if (activeClerk != null && activeClerk.Id == "concordanceWords" && activeClerk.CurrentObject != null) curObjId = activeClerk.CurrentObject.Hvo; } // Set up progress bar. m_dlg.ProgressBar.Minimum = 0; m_dlg.ProgressBar.Maximum = wordformIds.Count; m_dlg.ProgressBar.Step = 1; // stop parser if it's running. m_dlg.Mediator.SendMessage("StopParser", null); if (wordformIds.Count > 0) { if (cache.DatabaseAccessor.IsTransactionOpen()) cache.DatabaseAccessor.CommitTrans(); foreach (int wfId in wordformIds) { cache.DatabaseAccessor.BeginTrans(); DbOps.ExecuteStoredProc( cache, string.Format("EXEC RemoveParserApprovedAnalyses$ {0}",wfId), null); cache.DatabaseAccessor.CommitTrans(); using (WfiWordformUi wfui = new WfiWordformUi(WfiWordform.CreateFromDBObject(cache, wfId))) { wfui.UpdateWordsToolDisplay(curObjId, false, false, true, true); } m_dlg.ProgressBar.PerformStep(); } } else m_dlg.ProgressBar.PerformStep(); }
protected override void ReallyDeleteUnderlyingObject() { // Gather original counts. IWfiWordform wf = WfiWordform.CreateFromDBObject(m_cache, this.Object.OwnerHVO); int wfHvo = wf.Hvo; int prePACount = wf.ParserCount; int preUACount = wf.UserCount; base.ReallyDeleteUnderlyingObject(); // We need to fire off a notification about the deletion for several virtual fields. using (WfiWordformUi wfui = new WfiWordformUi(wf)) { bool updateUserCountAndIcon = (preUACount != wf.UserCount); bool updateParserCountAndIcon = (prePACount != wf.ParserCount); wfui.UpdateWordsToolDisplay(wf.Hvo, updateUserCountAndIcon, updateUserCountAndIcon, updateParserCountAndIcon, updateParserCountAndIcon); } // Make sure it gets parsed the next time. wf.Checksum = 0; }