コード例 #1
0
        void WorkCharacterSheet(UrlQueueItem item)
        {
            Console.WriteLine("[CS]Working on: " + item.url);
            XmlDocument data = new XmlDocument();
            string server = "", cn = "";
            string[] tok = item.url.Split(new string[] { "&", "&" }, StringSplitOptions.RemoveEmptyEntries);
            if (tok.Length > 1)
            {
                server = tok[0].Substring(2);
                cn = tok[1].Substring(3);
            }

            if (!Directory.Exists("./Armory/" + server))
            {
                Console.WriteLine("[CS] Directory Created: ./Armory/" + server + "/");
                Directory.CreateDirectory("./Armory/" + server);
            }
            string FN ="./Armory/" + server + "/" + cn + ".xml";
            lock (myLock)
            {
                try
                {
                    Console.WriteLine(api_CharacterSheet + item.url);
                    string url = baseUrl + api_CharacterSheet + item.url + "&rhtml=n";
                    Console.WriteLine(url);
                    string xml = client.DownloadString(url);
                    //Console.WriteLine(xml);
                    data.LoadXml(xml);

                    data.Save(FN);
                    //Console.WriteLine(data.OuterXml);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Character sheet req: Exception:");
                    if (e.Message.Contains("503")) _503 = true;
                    Console.WriteLine(e.Message);
                    if (e.InnerException != null)
                        Console.WriteLine(e.InnerException.Message);
                    try
                    {
                        string dq = client.DownloadString("http://overlordsofjustice.com/DequeueCharacterSheet.aspx?k=L0ngnubby&r=" + server + "&cn=" + cn);
                        Console.WriteLine("[CS]" + dq);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("[CS] Exception:");
                        Console.WriteLine(ex.Message);
                        if (ex.InnerException != null)
                            Console.WriteLine(ex.InnerException.Message);
                    }
                }
                //No char info tag
                //characterInfo errCode="noCharacter"
                bool noCharacter = false;
                try
                {
                    XmlNodeList xList = data.GetElementsByTagName("characterInfo");
                    foreach (XmlNode xNode in xList)
                    {
                        try
                        {
                            if (xNode.Attributes["errCode"] != null)
                            {
                                noCharacter = true;
                                break;
                            }
                        }
                        catch { }
                    }
                }
                catch { }
                if (noCharacter)
                {
                    string dq = client.DownloadString("http://overlordsofjustice.com/DequeueCharacterSheet.aspx?k=L0ngnubby&r=" + server + "&cn=" + cn);
                    Console.WriteLine("[CS] " + dq);
                }
                else
                {
                    client.UploadFile(new Uri("http://overlordsofjustice.com/PostCharacterSheet.aspx?k=L0ngnubby&r=" + server + "&cn=" + cn), "POST", FN);
                    File.Delete(FN);
                }
                //TODO: Upload the xml to ooj.com
                //client.UploadFileAsync
            }
        }
コード例 #2
0
 void RequestQueue(int count)
 {
     Console.WriteLine("Requesting 10 more items to work on.");
     lock (myLock)
     {
         string page = "";
         page = client.DownloadString("http://overlordsofjustice.com/RequestQueue.aspx?n=10");
         string[] tok = page.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries), tok2;
         UrlQueueItem qi;
         ReqType rType;
         foreach (string s in tok)
         {
             tok2 = s.Split(new char[]{'|'},StringSplitOptions.RemoveEmptyEntries);
             if (tok2.Length > 1)
             {
                 switch (tok2[0])
                 {
                     case "characterSheet":
                         rType = ReqType.CHARACTER_SHEET;
                         break;
                     default:
                         rType = ReqType.UNKNOWN;
                         break;
                 }
                 if (rType != ReqType.UNKNOWN)
                 {
                     qi = new UrlQueueItem(rType, tok2[1]);
                     UrlQueue.Enqueue(qi);
                     Console.WriteLine("Queueing: " + s);
                 }
             }
         }
     }
 }