public static BOEventCollection GetEventsToProcess(int internalStatus, int numberOfEvents)
        {
            BOEventCollection a = new BOEventCollection();
            SqlConnection con = new SqlConnection(BOBase.GetConnectionString());

            con.Open();

            try
            {
                SqlCommand cmd = new SqlCommand("P_Event_GetEventsToProcess", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@InternalStatus", SqlDbType.Int).Value = internalStatus;
                cmd.Parameters.Add("@Events", SqlDbType.Int).Value = numberOfEvents;
                SqlDataReader rdr = cmd.ExecuteReader();

                try
                {
                    while (rdr.Read())
                    {
                        BOEvent businessObject = new BOEvent(rdr);
                        a.Add(businessObject);
                    }
                }
                finally
                {
                    rdr.Close();
                }
            }
            finally
            {
                con.Close();
            }
            return a;
        }
Пример #2
0
        public BOEventCollection GetNewEvents()
        {
            BOEventCollection events = new BOEventCollection();
            if (Name == "Dota 2")
            {
                // This code needs to be moved
                WebClient Client = new WebClient();
                string HTML = Client.DownloadString(this.Link);

                HtmlDocument document = new HtmlDocument();
                document.LoadHtml(HTML);
                List<HtmlNode> evs = document.DocumentNode.Descendants().Where(d => d.Name.Contains("tbody")).ToArray()[0].SelectNodes("tr").ToList();
                evs.AddRange(document.DocumentNode.Descendants().Where(d => d.Name.Contains("tbody")).ToArray()[1].SelectNodes("tr").ToList());
                evs.AddRange(document.DocumentNode.Descendants().Where(d => d.Name.Contains("tbody")).ToArray()[2].SelectNodes("tr").ToList());

                foreach (HtmlNode row in evs)
                {
                    bool onGoing = false;
                    var columns = row.SelectNodes("td");
                    string name = Regex.Match(columns[0].FirstChild.Attributes["href"].Value, "(tournament= ?)([-\\w\\d: ]+)").Groups[2].Value;
                    string link = "http://www.datdota.com/" + columns[0].FirstChild.Attributes["href"].Value.Replace(" ", "%20");

                    DateTime startDate;
                    string strStartDate = columns[1].InnerText;
                    DateTime.TryParse(strStartDate, out startDate);

                    DateTime endDate = new DateTime();
                    string strEndDate = columns[2].InnerText;
                    if (strEndDate == "TBD")
                        onGoing = true;
                    else
                        DateTime.TryParse(strEndDate, out endDate);

                    string location = columns[3].InnerText;
                    long prizepool = long.Parse(columns[4].InnerText);
                    BOEvent ev;
                    if (BOEvent.CheckExistingWebsiteURL(link))
                    {
                        ev = new BOEvent();
                        ev.InternalStatus = 0;
                    }
                    else
                    {
                        ev = BOEvent.GetByLink(link);
                    }
                    ev.URL = link;
                    ev.StartDate = startDate;
                    ev.EndDate = endDate;
                    ev.Name = name;
                    ev.Game = this;

                    if (onGoing)
                        ev.InternalStatus = 2;

                    ev.Save();
                    Console.WriteLine("Updated Event " + ev.Name);

                }
            }
            return events;
        }