当前位置: 首页>>代码示例>>C#>>正文


C# DotNetWikiBot.Site类代码示例

本文整理汇总了C#中DotNetWikiBot.Site的典型用法代码示例。如果您正苦于以下问题:C# Site类的具体用法?C# Site怎么用?C# Site使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Site类属于DotNetWikiBot命名空间,在下文中一共展示了Site类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReplacementJob

 public ReplacementJob(Site site,
                       IDictionary<string, string> replacements,
                       IDictionary<Regex, string> regexReplacements,
                       GeneralExtensions.Placeholder placeholders)
     : base(site)
 {
     Replacements = replacements;
     RegexReplacements = regexReplacements;
     Placeholders = placeholders;
 }
开发者ID:knabbi,项目名称:GW2WBot,代码行数:10,代码来源:ReplacementJob.cs

示例2: Main

        static void Main(string[] args)
        {
            foreach (var line in File.ReadLines("config.txt"))
            {
                var indexOfSep = line.IndexOf('=');
                var key = line.Substring(0,indexOfSep).Trim();
                var val = line.Substring(indexOfSep + 1).Trim();

                if (key == "user") User = val;
                if (key == "pass") Pass = val;
                if (key == "apiAuthentication") ApiAuthentication = val;
            }

            if (string.IsNullOrEmpty(User) || string.IsNullOrEmpty(Pass) || string.IsNullOrEmpty(ApiAuthentication))
            {
                Console.WriteLine("Incomplete config");
                return;
            }

            var statusApi = new StatusApi();
            statusApi.SetStatus(false);

            var s = new Site("http://wiki-de.guildwars2.com/wiki/", User, Pass);

            if (args.Contains("-generatePagelist") || !File.Exists("pagelist.txt"))
            {
                Console.WriteLine("Generating pagelist...");
                var pagelist = new PageList(s);
                pagelist.FillFromCategoryTree("Guild Wars 2");
                pagelist.SaveTitlesToFile("pagelist.txt");
            }

            try
            {
                Run(s);
            }
            finally
            {
                statusApi.SetStatus(false);
            }
        }
开发者ID:knabbi,项目名称:GW2WBot,代码行数:41,代码来源:Program.cs

示例3: AngebotSubpageToMainarticleJob

 public AngebotSubpageToMainarticleJob(Site site)
     : base(site)
 {
 }
开发者ID:knabbi,项目名称:GW2WBot,代码行数:4,代码来源:AngebotSubpageToMainarticleJob.cs

示例4: Page

 /// <summary>This constructor creates Page object without title using most recently
 /// created Site object.</summary>
 /// <returns>Returns Page object.</returns>
 public Page()
 {
     this.site = Bot.GetMostRecentSiteObject();
 }
开发者ID:KernelFreeze,项目名称:inteliBOT,代码行数:7,代码来源:DotNetWikiBot.cs

示例5: DoStuff

        public static void DoStuff()
        {
            string username = "";
            string password = "";

            Console.WriteLine("Enter wiki username: ");
            username = Console.ReadLine();
            Console.WriteLine("Enter wiki password: ");
            password = Console.ReadLine();
            password = password.Trim();

            newWiki = new Site(WIKI_URL, username, password);
            string[,] toPort = 
            {
                //{"MissionEditorCompatibility", "Mission Editor game compatibility"},
                //{"MissionEditorStartPage", "Mission Editor"},
                //{"MissionEditorWINE", "Mission Editor in WINE"},
                //{"FactoryOrdersTutorial", "Mission Editor Factory Orders Tutorial"},
                //{"MissionEditorTutorial", "Mission Editor Tutorial"},
                //{"MissionEditorCutsceneTutorial", "Mission Editor Cutscenes Tutorial"}
            };
            for (int i=0; i<toPort.GetLength(0); i++)
            {
                ConvertPage(toPort[i, 0], toPort[i, 1], true);
            }

            string[] toReformat =
            {
                //"Mission Editor Cutscenes Tutorial"
            };
            for (int i = 0; i < toReformat.GetLength(0); i++)
            {
                ReformatPage(toReformat[i]);
            }
        }
开发者ID:DeinFreund,项目名称:Zero-K-Infrastructure,代码行数:35,代码来源:WikiPortingMW.cs

示例6: Page

 /// <summary>This constructor creates Page object with specified title. Site object
 /// with default properties is created internally and logged in. Constructing
 /// new Site object is too slow, don't use this constructor needlessly.</summary>
 /// <param name="title">Page title as string.</param>
 /// <returns>Returns Page object.</returns>
 public Page(string title)
 {
     this.site = new Site();
     this.title = title;
 }
开发者ID:wikigit,项目名称:Picasa-Review-Bot,代码行数:10,代码来源:DotNetWikiBot.cs

示例7: PageList

 /// <summary>This constructor creates empty PageList object with specified
 /// Site object.</summary>
 /// <param name="site">Site object, it must be constructed beforehand.</param>
 /// <returns>Returns the PageList object.</returns>
 public PageList(Site site)
 {
     this.site = site;
 }
开发者ID:wikigit,项目名称:Picasa-Review-Bot,代码行数:8,代码来源:DotNetWikiBot.cs

示例8: AufgestiegenerSchmuckJob

 public AufgestiegenerSchmuckJob(Site site)
     : base(site)
 {
 }
开发者ID:knabbi,项目名称:GW2WBot,代码行数:4,代码来源:AufgestiegenerSchmuckJob.cs

示例9: RemoveUeberfluessigeParameter

 public RemoveUeberfluessigeParameter(Site site)
     : base(site)
 {
 }
开发者ID:knabbi,项目名称:GW2WBot,代码行数:4,代码来源:RemoveUeberfluessigeParameter.cs

示例10: Login

        private void Login()
        {
            this.Hide();
            loginForm = new FormLogin();
            if (loginForm.ShowDialog(this) != System.Windows.Forms.DialogResult.OK)
            {
                Application.Exit();
                return;
            }

            loadingDialog = new LoadingDialog();
            loadingDialog.Message = "Logging in...";
            loadingDialog.Show(this);
            this.Enabled = false;
            Thread loginThread = new Thread(new ThreadStart(delegate()
            {
                try
                {
                    errorMessage = null;
                    site = new Site("http://en.wikipedia.org", loginForm.Username, loginForm.Password);
                }
                catch (WikiBotException ex)
                {
                    if (ex.Message.Contains("Login failed"))
                    {
                        errorMessage = "Login failed. Check your username and password and try again.";
                    }
                    else
                    {
                        errorMessage = "Encountered error: " + ex.Message;
                    }
                }
                this.Invoke(new MethodInvoker(CompleteLogin));
            }));
            loginThread.Start();
        }
开发者ID:wikigit,项目名称:Persondata-o-matic,代码行数:36,代码来源:FormMain.cs

示例11: LoadPages

        void LoadPages()
        {
            //site = new Site("http://localhost/index.php/", "ZenithBot", "Bot");
            site = new Site("http://en.wikipedia.org/", "HNCluster", "csce470");
            Invoke(CheckSiteLoaded);

            pageList = new PageList(site);
            //pageList.FillFromFile(@"ComputerScienceWikipediaPagesList");
            pageList.FillAndLoadFromXMLDump(@"Wikipedia-ComputerScience.xml");

            wikiCollection.LoadFromPageList(pageList);
            Invoke(IncrementPagesLoadedByVal, wikiCollection.wikiPages.Count);
            pagesLoaded += wikiCollection.wikiPages.Count;

            if (InvokeRequired)
            {
                Invoke(UpdateText);
            }
            else
            {
                UpdateTextMethod();
            }

            Invoke(CheckTitlesLoaded);
            wikiCollection.ExtractTokens();
            Invoke(CheckTokenized);
            if (InvokeRequired)
            {
                Invoke(UpdateText);
            }
            else
            {
                UpdateTextMethod();
            }
            /*
            int num = 100;

            for (int i = 0; i < pageList.pages.Count; ++i)
            {
                if (i + num < pageList.pages.Count)
                {
                    Parallel.For(i, i + num, n =>
                    {
                        pageList.pages[n].Load();
                    });
                    i += num - 1;
                    pagesLoaded += num;
                    Invoke(IncrementPagesLoadedByVal, num);
                }
                else
                {
                    Parallel.For(i, pageList.pages.Count, n =>
                    {
                        pageList.pages[n].Load();
                    });
                    i += num - 1;
                    pagesLoaded += pageList.pages.Count - i;
                    Invoke(IncrementPagesLoadedByVal, pageList.pages.Count - i);
                }

            }*/
            /*
            foreach (Page page in pageList)
            {
                page.Load();
                if (numericUpDown1.Value == 0)
                {
                    Invoke(AddPageText, new object[] { pageList[0] });
                }
                pagesLoaded += 1;
                Invoke(IncrementPagesLoaded);
                //Application.DoEvents();
            }*/
        }
开发者ID:ZenithWest,项目名称:Wikipedia-Clustering,代码行数:74,代码来源:Form1.cs

示例12: FixParameterfehlerJob

 public FixParameterfehlerJob(Site site)
     : base(site)
 {
 }
开发者ID:knabbi,项目名称:GW2WBot,代码行数:4,代码来源:FixParameterfehlerJob.cs

示例13: DoStuff

        public static void DoStuff()
        {
            string username = "";
            string password = "";

            Console.WriteLine("Enter wiki username: ");
            username = Console.ReadLine();
            Console.WriteLine("Enter wiki password: ");
            password = Console.ReadLine();
            password = password.Trim();

            newWiki = new Site(WIKI_URL, username, password);

            int count = 0;  // increment this when we actually create a page
            var files = new System.Collections.Generic.List<string>(Directory.GetFiles(@"G:\zkwiki\output\markup"));
            files = files.Shuffle();
            foreach (string path in files)
            {
                string unitname = Path.GetFileNameWithoutExtension(path);
                unitname = unitname.Replace("&#47;", "/");
                var page = new Page(newWiki, unitname);
                page.Load();
                if (page.Exists())
                {
                    // do nothing
                }
                else
                {
                    var text = File.ReadAllText(path);
                    Console.WriteLine("-- Making page {0} --", unitname);
                    page.Save(text, "Created page from unitguide builder export", false);
                    count++;
                    //if (count >= 20) break;
                }
            }

            string[,] toPort = 
            {
                //{"MissionEditorCompatibility", "Mission Editor game compatibility"},
                //{"MissionEditorStartPage", "Mission Editor"},
                //{"MissionEditorWINE", "Mission Editor in WINE"},
                //{"FactoryOrdersTutorial", "Mission Editor Factory Orders Tutorial"},
                //{"MissionEditorTutorial", "Mission Editor Tutorial"},
                //{"MissionEditorCutsceneTutorial", "Mission Editor Cutscenes Tutorial"}
            };
            for (int i=0; i<toPort.GetLength(0); i++)
            {
                ConvertPage(toPort[i, 0], toPort[i, 1], false);
            }

            string[] toReformat =
            {
                //"Mission Editor Cutscenes Tutorial"
            };
            for (int i = 0; i < toReformat.GetLength(0); i++)
            {
                ReformatPage(toReformat[i]);
            }
        }
开发者ID:GoogleFrog,项目名称:Zero-K-Infrastructure,代码行数:59,代码来源:WikiPortingMW.cs

示例14: Main

        static void Main(string[] args)
        {
            Site site = new Site("http://commons.wikimedia.org", args[0], args[1]);
            while (true)
            {
                PageList list = new PageList(site);
                list.FillAllFromCategory("Category:Rotate270");
                foreach (Page page in list)
                {
                    if (!page.title.ToLower().EndsWith(".jpg")) continue;
                    page.Load();
                    if (!page.text.Contains("{{rotate"))
                    {
                        page.text = "{{rotate|270}}\n" + page.text;
                        page.Save("Add {{rotate|270}} tag since it's in Category:Rotate270", /*isMinorEdit*/false);
                    }
                }

                list = new PageList(site);
                list.FillAllFromCategory("Category:Images requiring rotation");
                foreach (Page page in list)
                {
                    Regex regex = new Regex(@"\{\{Rotate\|nobot=true\|reason='''Reason''': corrupt JPEG file.\|([^}]*)\}\}", RegexOptions.IgnoreCase);
                    page.Load();
                    Match m = regex.Match(page.text);
                    if (m.Success)
                    {
                        page.text = regex.Replace(page.text, "{{Rotate|" + m.Groups[1].Value + "}}");
                        page.Save("Undo mistagging by [[User:Rotatebot]], JPEG should not be corrupt", /*isMinorEdit*/false);
                    }
                }

                list = new PageList(site);
                list.FillAllFromCategory("Category:Images requiring rotation by bot");
                try
                {
                    foreach (Page page in list)
                    {
                        if (!page.title.ToLower().EndsWith(".jpg")) continue;
                        page.Load();
                        MatchCollection matches = new Regex(@"\{\{rotate\|([0-9]+)\}\}", RegexOptions.IgnoreCase).Matches(page.text);
                        if (matches.Count == 0)
                        {
                            matches = new Regex(@"\{\{rotate\|degree=([0-9]+)\}\}", RegexOptions.IgnoreCase).Matches(page.text);
                            if (matches.Count == 0)
                            {
                                matches = new Regex(@"\{\{rotate\|([0-9]+)\|[^}]*\}\}", RegexOptions.IgnoreCase).Matches(page.text);
                                if (matches.Count == 0)
                                {
                                    continue;
                                }
                            }
                        }
                        if (matches.Count > 1)
                        {
                            while (matches.Count > 1)
                            {
                                page.text = page.text.Remove(matches[0].Index, matches[0].Length);
                                matches = new Regex(@"\{\{rotate\|([0-9]+)\}\}", RegexOptions.IgnoreCase).Matches(page.text);
                                if (matches.Count == 0)
                                {
                                    matches = new Regex(@"\{\{rotate\|degree=([0-9]+)\}\}", RegexOptions.IgnoreCase).Matches(page.text);
                                    if (matches.Count == 0)
                                    {
                                        matches = new Regex(@"\{\{rotate\|([0-9]+)\|[^}]*\}\}", RegexOptions.IgnoreCase).Matches(page.text);
                                    }
                                }
                            }
                            page.Save("Remove redundant rotate tags", /*isMinorEdit*/false);
                        }

                        Match m = matches[0];
                        int degrees = int.Parse(m.Groups[1].Value);
                        page.DownloadImage("tempin.jpg");
                        File.Delete("tempout.jpg");
                        ProcessStartInfo info = new ProcessStartInfo(@"..\..\jpegtran.exe", "-rotate " + degrees + " tempin.jpg tempout.jpg");
                        info.CreateNoWindow = true;
                        info.UseShellExecute = false;
                        Process p = Process.Start(info);
                        p.WaitForExit();
                        if (File.Exists("tempout.jpg"))
                        {
                            page.UploadImage("tempout.jpg", "Losslessly rotate by " + degrees + " degrees per request using jpegtran", "", "", "");
                            page.Load();
                            page.text = page.text.Replace(m.Value + "\n", "");
                            page.text = page.text.Replace(m.Value, "");
                            page.text = page.text.Replace("[[Category:Rotate270]]\n", "");
                            page.text = page.text.Replace("[[Category:Rotate270]]", "");
                            page.Save("Done with rotation by " + degrees + " degrees, removing tag", /*isMinorEdit*/false);
                        }
                    }
                    System.Threading.Thread.Sleep(new TimeSpan(0, 2, 0));
                }
                catch (Exception e)
                {
                    Console.WriteLine("Caught exception: " + e.Message + e.StackTrace);
                }
            }
        }
开发者ID:wikigit,项目名称:DotNetRotateBot,代码行数:99,代码来源:Program.cs

示例15: Load

        public override void Load()
        {
            try
            {
                ch = core.getChannel(RequestLabs.RequestCh);
                if (ch == null)
                {
                    Log("CRITICAL: the bot isn't in " + RequestLabs.RequestCh + " unloading requests", true);
                    return;
                }
                RequestCache.Load();
                notifications = new Thread(Run);
                notifications.Start();
                Site wikitech = new Site("https://wikitech.wikimedia.org", "wmib", "");
                while (true)
                {
                    try
                    {
                        List<string> shell = new List<string>();
                        List<string> tooldata = new List<string>();
                        PageList requests = new PageList(wikitech);
                        requests.FillAllFromCategory("Shell Access Requests");
                        foreach (Page page in requests)
                        {
                            string title = page.title.Replace("Shell Request/", "");
                            if (RequestCache.Contains(title))
                            {
                                continue;
                            }
                            page.Load();
                            if (!Matches(page.text))
                            {
                                RequestCache.Insert(title);
                                lock (Shell)
                                {
                                    // this one was already processed
                                    RequestLabs previous = Contains(title);
                                    if (previous != null)
                                    {
                                        Shell.Remove(previous);
                                    }
                                }
                                continue;
                            }
                            else
                            {
                                if (!shell.Contains(title))
                                {
                                    shell.Add(title);
                                }
                                lock (Shell)
                                {
                                    if (Contains(title) == null)
                                    {
                                        Shell.Add(new RequestLabs(title));
                                    }
                                }
                            }
                        }

                        requests = new PageList(wikitech);
                        requests.FillAllFromCategory("Tools_Access_Requests");
                        foreach (Page page in requests)
                        {
                            string title = page.title.Replace("Nova Resource:Tools/Access Request/", "");
                            if (RequestCache.ContainsLabs(title))
                            {
                                continue;
                            }
                            page.Load();
                            if (!(Matches(page.text)))
                            {
                                RequestCache.InsertLabs(title);
                                lock (Tools)
                                {
                                    // this one was already processed
                                    RequestLabs previous = ContainsLabs(title);
                                    if (previous != null)
                                    {
                                        Tools.Remove(previous);
                                    }
                                }
                                continue;
                            }
                            else
                            {
                                if (!tooldata.Contains(title))
                                {
                                    tooldata.Add(title);
                                }
                                lock (Tools)
                                {
                                    if (ContainsLabs(title) == null)
                                    {
                                        Tools.Add(new RequestLabs(title));
                                    }
                                }
                            }
                        }
                        Thread.Sleep(60000);
//.........这里部分代码省略.........
开发者ID:Krenair,项目名称:wikimedia-bot,代码行数:101,代码来源:Request.cs


注:本文中的DotNetWikiBot.Site类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。