Esempio n. 1
0
        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.
        }
Esempio n. 2
0
        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;
                }
            }
        }
Esempio n. 3
0
        /// <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();
            }
        }