示例#1
0
        public void putIntoSafe()
        {
            int maxValue = attributes.Safe.Max - attributes.Safe.Actual;
            if (maxValue != 0 && attributes.Cash.Actual != 0)
            {
                int value = 0;
                if (attributes.Cash.Actual > maxValue) value = maxValue;
                else value = attributes.Cash.Actual;

                FormData formData = new FormData();
                formData.addValue("formo_safe_deposit", "safe_deposit");
                formData.addValue("safe_deposit_csrf", csrf);
                formData.addValue("deposit_value", new StringBuilder().Append(value).ToString());
                formData.addValue("safe_deposit_submit", "");

                int timeout = 0;

                do
                {
                    try
                    {
                        String responseContent = httpClient.SendHttpPostAndReturnResponseContent("http://parafia.biz/buildings/safe", formData);

                        updateRiseSafeCost(responseContent);

                        attributes = new Attributes.Attributes(responseContent);
                        timeout = 0;
                    }
                    catch (WebException we)
                    {
                        worker.printLog("[ERROR] Wystąpił błąd. putIntoSafe!!!");
                        worker.printLog("[ERROR] Treść błędu: " + we.Message);
                        worker.printLog("[ERROR] Ponawiam proces.");
                        timeout++;
                    }
                }
                while ((timeout != 0) && timeout < 5);
            }
        }
示例#2
0
        public bool login()
        {
            String responseContent = httpClient.SendHttpGetAndReturnResponseContent("http://parafia.biz/");
            csrf = HtmlUtils.GetStringValueByXPathExpression(responseContent, "//input[@name='login_csrf']");

            if (checkDependencies(responseContent, new String[] { "formo_login_form", "login_csrf", "user_name", "user_pass", "login_submit" }))
            {
                FormData formData = new FormData();
                formData.addValue("formo_login_form", "login_form");
                formData.addValue("login_csrf", csrf);
                formData.addValue("user_name", config.AccountUser);
                formData.addValue("user_pass", config.AccountPassword);
                formData.addValue("login_submit", "");

                int timeout = 0;
                do
                {
                    try
                    {
                        responseContent = httpClient.SendHttpPostAndReturnResponseContent("http://parafia.biz/", formData);
                        timeout = 0;
                    }
                    catch (WebException we)
                    {
                        worker.printLog("[ERROR] Wystąpił błąd. login!!!");
                        worker.printLog("[ERROR] Treść błędu: " + we.Message);
                        worker.printLog("[ERROR] Ponawiam proces.");
                        timeout++;
                    }
                }
                while ((timeout != 0) && timeout < 5);

                if (timeout == 0)
                {
                    String errorMessage = HtmlUtils.GetStringValueByXPathExpression(responseContent, "//div[@class='form-error']/text()");

                    if (!String.IsNullOrEmpty(errorMessage))
                    {
                        throw new LoginException(errorMessage);
                    }
                    else
                    {
                        attributes = new Attributes.Attributes(responseContent);
                        papacyParty = !checkPapacParty(responseContent);
                    }
                    return true;
                }
            }
            return false;
        }
示例#3
0
        public int buyRelic(String name)
        {
            String content = httpClient.SendHttpGetAndReturnResponseContent("http://parafia.biz/relics");

            attributes = new Attributes.Attributes(content);

            HtmlNodeCollection nodes = HtmlUtils.GetNodesCollectionByXPathExpression(content, "//ul[@class='relics-buy']/li/div[@class='info']");

            int relicsNo = -1;

            foreach (HtmlNode node in nodes)
            {
                String h3NodeText = HtmlUtils.GetStringValueByXPathExpression(node.InnerHtml, "//h3/text()");

                if (h3NodeText.ToLower().Equals(name.ToLower()))
                {
                    HtmlNode linkAndCostNode = HtmlUtils.GetSingleNodeByXPathExpression(node.InnerHtml, "//a[@class='button']");

                    if (linkAndCostNode != null)
                    {
                        String link = HtmlUtils.GetAttributeValueFromHtmlNode(linkAndCostNode, "href");
                        String costTxt = HtmlUtils.GetAttributeValueFromHtmlNode(linkAndCostNode, "title");

                        costTxt = MainUtils.removeAllNotNumberCharacters(costTxt).Replace(" ", "");

                        int cost = int.Parse(costTxt);

                        relicsNo = attributes.Cash.Actual / cost;

                        for (int i = 0; i < relicsNo; i++)
                        {
                            Thread thread = new Thread((ThreadStart)delegate
                            {
                                httpClient.SendHttpGetAndReturnResponseContent(link);
                            });
                            thread.Start();
                        }
                    }
                    else
                    {
                        relicsNo = 0;
                        break;
                    }
                }
            }

            return relicsNo;
        }
示例#4
0
 public void updateAttributes(String content)
 {
     attributes = new Attributes.Attributes(content);
 }
示例#5
0
 public void updateAttributes()
 {
     int timeout = 0;
     do
     {
         try
         {
             String content = httpClient.SendHttpGetAndReturnResponseContent("http://parafia.biz/start/dashboard");
             this.attributes = new Attributes.Attributes(content);
             timeout = 0;
         }
         catch (WebException we)
         {
             worker.printLog("[ERROR] Wystąpił błąd. updateAttributes!!!");
             worker.printLog("[ERROR] Treść błędu: " + we.Message);
             worker.printLog("[ERROR] Ponawiam proces.");
             timeout++;
         }
     }
     while ((timeout != 0) && timeout < 5);
 }
示例#6
0
        //[TestMethod]
        public void loginTest()
        {
            String responseContent = httpClient.SendHttpGetAndReturnResponseContent("http://parafia.biz/");
            String csrf = HtmlUtils.GetStringValueByXPathExpression(responseContent, "//input[@name='login_csrf']");

            FormData formData = new FormData();
            formData.addValue("formo_login_form", "login_form");
            formData.addValue("login_csrf", csrf);
            formData.addValue("user_name", user);
            formData.addValue("user_pass", passwd);
            formData.addValue("login_submit", "");

            responseContent = httpClient.SendHttpPostAndReturnResponseContent("http://parafia.biz/", formData);

            String errorMessage = HtmlUtils.GetStringValueByXPathExpression(responseContent, "//div[@class='form-error']/text()");

            if (!String.IsNullOrEmpty(errorMessage))
            {
                Assert.Fail();
            }
            else
            {
                Attributes att = new Attributes(responseContent);
            }
        }