Beispiel #1
0
        /// <summary>
        /// Method of menu option pageIndex (key:pageIndex). <args> expects param: operation:indexPageTableOperation;sourceFile:String;debug:Boolean;
        /// </summary>
        /// <param name="args"><seealso cref="aceOperationArgs"/> requered parameters:  operation:indexPageTableOperation;sourceFile:String;debug:Boolean;</param>
        /// <remarks>
        /// <para>It will propt for secondary command if not specified by parameters</para>
        /// <para>Performs management operations over page index data table</para>
        /// <para>Message if item disabled: (disabled)</para>
        /// </remarks>
        /// <seealso cref="aceOperationSetExecutorBase"/>
        public void aceOperation_runpageIndex(aceOperationArgs args)

        {
            indexPageTableOperation operation = args.Get <indexPageTableOperation>("operation");

            string sourceFile = args.Get <string>("sourceFile");
            bool   ok         = false;
            string sufix      = "";

            if (state.sampleList.Any())
            {
                sufix = " (Active sample: " + state.sampleList.Count + ")";
            }
            if (operation == indexPageTableOperation.none)
            {
                operation = aceTerminalInput.askForEnum <indexPageTableOperation>("Select indexPage operation to perform", indexPageTableOperation.none);
            }
            if (operation == indexPageTableOperation.loadReviewedTable)
            {
                if (!File.Exists(imbWEMManager.index.folder.pathFor(sourceFile)))
                {
                    var files = imbWEMManager.index.folder.findFiles("*.xlsx|*.csv", SearchOption.TopDirectoryOnly, true);
                    sourceFile = aceTerminalInput.askForOption("Select data table file for operation: " + operation.ToString() + "", files.First(), files, null).toStringSafe();
                }

                ok = File.Exists(imbWEMManager.index.folder.pathFor(sourceFile));
            }
            else
            {
                ok = aceTerminalInput.askYesNo("Are you sure to: " + operation.ToString() + "? " + sufix, false);
            }

            if (ok)
            {
                imbWEMManager.index.ExecuteIndexPageOperation(operation, sourceFile, state.sampleList, output);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Load index information from the external data table source
        /// </summary>
        /// <param name="operation">The operation.</param>
        /// <param name="sourceFile">The source file.</param>
        /// <param name="loger">The loger.</param>
        public void ExecuteIndexPageOperation(indexPageTableOperation operation, string sourceFile, List <string> domainsString = null, ILogBuilder loger = null)
        {
            List <indexPage> pages = new List <indexPage>();

            int i    = 0;
            int c    = 0;
            int imax = pages.Count / 20;

            List <indexDomain> domains = new List <indexDomain>();

            List <string> dList = new List <string>();

            if (domainsString != null)
            {
                foreach (string dm in domainsString)
                {
                    domainAnalysis da = new domainAnalysis(dm);
                    dList.Add(da.domainName);
                }
            }
            domainsString = dList;

            switch (operation)
            {
            default:
                break;

            case indexPageTableOperation.flushNotInSample:

                pages = pageIndexTable.GetList();

                imax = domainsString.Count / 10;

                // domains = domainIndexTable.GetDomains(indexDomainContentEnum.any);

                List <indexPage> newPages = new List <indexPage>();
                foreach (string dm in domainsString)
                {
                    newPages.AddRange((IEnumerable <indexPage>)pageIndexTable.GetPagesForDomain(dm));

                    if (i > imax)
                    {
                        i = 0;
                        loger.log("Selecting pages [" + ((double)c / (double)domainsString.Count).ToString("P2") + "]");
                    }
                    i++;
                    c++;
                }

                pageIndexTable.Clear();
                Save();



                imax = newPages.Count / 20;


                foreach (indexPage page in newPages)
                {
                    pageIndexTable.Add(page);

                    if (i > imax)
                    {
                        i = 0;
                        loger.log("Adding pages [" + ((double)c / (double)newPages.Count).ToString("P2") + "]");
                    }
                    i++;
                    c++;
                }

                domainIndexTable.Clear();

                Save();
                Recheck(loger);

                Publish(new aceAuthorNotation());

                break;

            case indexPageTableOperation.flushNotLoaded:
                pages = pageIndexTable.GetList();
                //domains = domainIndexTable.GetDomains(indexDomainContentEnum.any);

                foreach (indexPage page in pages)
                {
                    if (page.byteSize == 0)
                    {
                        pageIndexTable.Remove(page);
                    }

                    if (i > imax)
                    {
                        i = 0;
                        loger.log("Removing pages from index [" + ((double)c / (double)pages.Count).ToString("P2") + "]");
                    }
                    i++;
                    c++;
                }
                break;

            case indexPageTableOperation.loadReviewedTable:
                ApplyManualPageIndex(sourceFile, loger, true);
                break;
            }
        }