public static SessionInCinema CreateSession(SessionResponse KinoafishaResponse)
        {
            SessionInCinema session = new SessionInCinema();
            session.CinemaName = KinoafishaResponse.k_name;
            session.CinemaURL = "http://kinoafisha.ua" + KinoafishaResponse.k_url;
            session.Halls = new List<Hall>();
            Hall hall = new Hall();
            hall.Name = KinoafishaResponse.h_name;
            hall.In3D = (KinoafishaResponse.h_is3d == "1");
            hall.Sessions = ParseSessions(KinoafishaResponse.sessions);
            foreach (SimpleSession hallSession in hall.Sessions)
            {
                hallSession.In3DText = hall.In3D ? "3D" : "";
            }
            session.Halls.Add(hall);
            session.Timesheet = "";
            foreach (SimpleSession hallSession in hall.Sessions)
            {
                session.Timesheet += hallSession.Time + " ";
            }
            session.Timesheet.Remove(session.Timesheet.Length - 1, 1);

            var request = WebRequest.CreateHttp(session.CinemaURL);
            request.Method = "GET";
            request.BeginGetResponse(result =>
            {
                HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(result);
                Stream streamResponse = response.GetResponseStream();
                StreamReader streamRead = new StreamReader(streamResponse);
                String responseContent = streamRead.ReadToEnd();
                ParseCinemaHTMLPage(session,responseContent);
            }, null);
            return session;
        }
 public static void AppendResponceToSession(SessionInCinema cinemaSession, SessionResponse KinoafishaResponse)
 {
     Hall hall = new Hall();
     hall.Name = KinoafishaResponse.h_name;
     hall.In3D = (KinoafishaResponse.h_is3d == "1");
     hall.Sessions = ParseSessions(KinoafishaResponse.sessions);
     foreach (SimpleSession session in hall.Sessions)
     {
         session.In3DText = hall.In3D ? "3D" : "";
     }
     cinemaSession.Halls.Add(hall);
     cinemaSession.Timesheet += "; ";
     foreach (SimpleSession session in hall.Sessions)
     {
         cinemaSession.Timesheet += session.Time + " ";
     }
     cinemaSession.Timesheet.Remove(cinemaSession.Timesheet.Length - 1, 1);
 }
        private static void ParseCinemaHTMLPage(SessionInCinema session, string html)
        {
            /*string logoURL = html.Replace("<link rel=\"image_src\" type=\"\" href=\"", "\0").Split('\0')[1];
            logoURL = logoURL.Substring(0,logoURL.IndexOf("\" />"));
            DownloadLogo(logoURL);*/
            if (html.IndexOf("Телефон: <span>") != -1)
            {
                string phone = html.Replace("Телефон: <span>", "\0").Split('\0')[1];
                phone = phone.Substring(0, phone.IndexOf("</span>"));
                int openScopeIdx = -1;
                for (int i = 0; i < 10 && openScopeIdx == - 1; i++)
                {
                    openScopeIdx = phone.IndexOf(i.ToString()[0]);
                }
                if (openScopeIdx == -1)
                {
                    openScopeIdx = phone.IndexOf('(');
                }

                if (openScopeIdx != -1)
                {
                    phone = phone.Substring(openScopeIdx, phone.Length - openScopeIdx);
                }

                phone = phone.Replace(";", ",");
                if (phone.IndexOf(',') != -1)
                {
                    string[] candidats = phone.Split(',');
                    phone = "";
                    foreach (string candidat in candidats)
                    {
                        if (candidat.IndexOf("бро") != -1 && candidat.IndexOf("кас") != -1)
                        {
                            phone = candidat;
                        }
                    }
                    if (phone == "")
                    {
                        phone = candidats[0];
                    }
                }
                for (int i = 0; i < phone.Length; i++)
                {
                    if (phone[i] < '0' || phone[i] > '9')
                    {
                        phone = phone.Remove(i, 1);
                        i--;
                    }
                }
                session.CinemaPhone = phone;
            }
            else
            {
                session.CinemaPhone = "";
            }

            if (html.IndexOf("<p>Адрес кинотеатра: <a class=\"on-map\" href=\"#yamaps\">") != -1)
            {
                string adress = html.Replace("<p>Адрес кинотеатра: <a class=\"on-map\" href=\"#yamaps\">", "\0").Split('\0')[1];
                adress = adress.Substring(0, adress.IndexOf("</a></p>"));
                session.CinemaAdress = adress;
            }
            else
            {
                session.CinemaAdress = "";
            }
        }