Пример #1
0
        public static async Task <String> indexTextAsync(String name, bool onlyDelete)
        {
            String url = getUrl(name);

            {
                foreach (Page p in App.Auto.Select <Page>("from Page where url==?", url))
                {
                    engine.indexTextNoTran(App.Auto, commitCount, p.id, p.content.ToString(), true);
                    engine.indexTextNoTran(App.Auto, commitCount, p.rankUpId(), p.rankUpDescription(), true);
                    App.Auto.Delete("Page", p.id);
                }
            }
            if (onlyDelete)
            {
                return("deleted");
            }
            {
                Page p = await Page.GetAsync(url);

                if (p == null)
                {
                    return("temporarily unreachable");
                }
                else
                {
                    p.id = App.Auto.NewId();
                    App.Auto.Insert("Page", p);
                    engine.indexTextNoTran(App.Auto, commitCount, p.id, p.content.ToString(), false);
                    engine.indexTextNoTran(App.Auto, commitCount, p.rankUpId(), p.rankUpDescription(), false);

                    return(p.url);
                }
            }
        }
Пример #2
0
        public static async Task <String> indexTextAsync(String name, bool onlyDelete)
        {
            String url = getUrl(name);

            using (var box = App.Auto.Cube())
            {
                PageLock pl = box["PageLock", url].Select <PageLock>();
                if (pl == null)
                {
                    pl = new PageLock {
                        url = url, time = DateTime.Now
                    };
                }
                else if ((DateTime.Now - pl.time).TotalSeconds > 120)
                {
                    pl.time = DateTime.Now;
                }
                else
                {
                    return("Running");
                }
                box["PageLock"].Replace(pl);
                if (box.Commit() != CommitResult.OK)
                {
                    return("Running");
                }
            }
            try
            {
                foreach (Page p in App.Auto.Select <Page>("from Page where url==?", url))
                {
                    engine.indexTextNoTran(App.Auto, commitCount, p.id, p.content.ToString(), true);
                    engine.indexTextNoTran(App.Auto, commitCount, p.rankUpId(), p.rankUpDescription(), true);
                    App.Auto.Delete("Page", p.id);
                }

                if (onlyDelete)
                {
                    return("deleted");
                }
                {
                    Page p = await Page.GetAsync(url);

                    if (p == null)
                    {
                        return("temporarily unreachable");
                    }
                    else
                    {
                        p.id = App.Auto.NewId();
                        App.Auto.Insert("Page", p);
                        engine.indexTextNoTran(App.Auto, commitCount, p.id, p.content.ToString(), false);
                        engine.indexTextNoTran(App.Auto, commitCount, p.rankUpId(), p.rankUpDescription(), false);

                        return(p.url);
                    }
                }
            }
            finally
            {
                App.Auto.Delete("PageLock", url);
            }
        }