예제 #1
0
        private void ParseUnparsedParagraphs()
        {
            ConcDecorator concDecorator = ConcDecorator;

            IStTxtPara[] needsParsing = concDecorator.InterestingTexts.SelectMany(txt => txt.ParagraphsOS).Cast <IStTxtPara>().Where(para => !para.ParseIsCurrent).ToArray();
            if (needsParsing.Length > 0)
            {
                NonUndoableUnitOfWorkHelper.DoSomehow(m_cache.ActionHandlerAccessor,
                                                      () =>
                {
                    foreach (IStTxtPara para in needsParsing)
                    {
                        ParagraphParser.ParseParagraph(para);
                    }
                });
            }
        }
예제 #2
0
        void DeleteUnusedEntriesAndSenses(LcmCache cache, ProgressBar progressBar)
        {
            ConcDecorator cd = new ConcDecorator(cache.DomainDataByFlid as ISilDataAccessManaged, null, cache.ServiceLocator);

            cd.SetMediator(m_dlg.Mediator, m_dlg.PropTable);             // This lets the ConcDecorator use the interesting list of texts.
            var entries = cache.ServiceLocator.GetInstance <ILexEntryRepository>().AllInstances().ToArray();

            progressBar.Minimum = 0;
            progressBar.Maximum = entries.Length;
            progressBar.Step    = 1;
            List <ILexEntry> entriesToDel = new List <ILexEntry>();

            foreach (var entry in entries)
            {
                int count = 0;
                progressBar.PerformStep();
                List <IMoForm> forms = new List <IMoForm>();
                if (entry.LexemeFormOA != null)
                {
                    forms.Add(entry.LexemeFormOA);
                }
                forms.AddRange(entry.AlternateFormsOS);
                foreach (IMoForm mfo in forms)
                {
                    foreach (ICmObject cmo in mfo.ReferringObjects)
                    {
                        if (cmo is IWfiMorphBundle)
                        {
                            count += cd.get_VecSize(cmo.Owner.Hvo, ConcDecorator.kflidWaOccurrences);
                            if (count > 0)
                            {
                                break;
                            }
                        }
                    }
                    if (count > 0)
                    {
                        break;
                    }
                }
                if (count == 0)
                {
                    entriesToDel.Add(entry);
                }
            }
            // Warn if entries are to be deleted. We'll assume a specific warning for senses is not critical.
            if (entriesToDel.Count > 0)
            {
                string       dlgTxt = String.Format(LexEdStrings.ksDeleteEntrySenseConfirmText, entriesToDel.Count);
                DialogResult result = MessageBox.Show(dlgTxt, LexEdStrings.ksDeleteEntrySenseConfirmTitle,
                                                      MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                {
                    if (result == DialogResult.No)
                    {
                        return;
                    }
                }
            }

            progressBar.Value   = 1;
            progressBar.Maximum = entriesToDel.Count;
            foreach (var entry in entriesToDel)
            {
                progressBar.PerformStep();
                cache.DomainDataByFlid.DeleteObj(entry.Hvo);
            }

            var senses = cache.ServiceLocator.GetInstance <ILexSenseRepository>().AllInstances().ToArray();

            progressBar.Value   = 1;
            progressBar.Maximum = senses.Length;
            foreach (var sense in senses)
            {
                progressBar.PerformStep();
                int count = 0;
                foreach (ICmObject cmo in sense.ReferringObjects)
                {
                    if (cmo is IWfiMorphBundle)
                    {
                        count += cd.get_VecSize(cmo.Owner.Hvo, ConcDecorator.kflidWaOccurrences);
                        if (count > 0)
                        {
                            break;
                        }
                    }
                }
                if (count == 0)
                {
                    cache.DomainDataByFlid.DeleteObj(sense.Hvo);
                }
            }
        }