Beispiel #1
0
        static void Main(string[] args)
        {
            const string ApiKey = "9f2df9da";
            string       MovieName;

            Console.WriteLine("ПОИСК ФИЛЬМОВ");
            Console.Write("Введите название фильма (на англ. языке): ");
            MovieName = Console.ReadLine();

            string url = "http://www.omdbapi.com/?t=" + MovieName.Trim() + "&apikey=" + ApiKey;

            using (WebClient wc = new WebClient())
            {
                var json = wc.DownloadString(url);
                var oJS  = new JavaScriptSerializer();
                var obj  = new Movie();
                obj = oJS.Deserialize <Movie>(json);

                if (obj.Response == "True")
                {
                    obj.Print();
                }
                else
                {
                    Console.Write("Фильм не найден :(");
                }
            }

            Console.ReadLine();
        }
Beispiel #2
0
 private void ClearForm()
 {
     _movieRecord = null;
     MovieName.Focus();
     MovieName.Text = "";
     Year.Value     = Year.Maximum;
     Format.Text    = "";
 }
Beispiel #3
0
 void OpenMovie(MovieName type)
 {
     switch (type)
     {
     case MovieName.NvagaxmbiErexanery:
         VideoPlayer.PlayYoutubeVideo("ZMASACAmQV4");
         break;
     }
 }
Beispiel #4
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (MovieName != null ? MovieName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Episode != null ? Episode.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Year.GetHashCode();
         return(hashCode);
     }
 }
Beispiel #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="SeatX"></param>
        /// <param name="SeatY"></param>
        /// <param name="Time"></param>
        /// <param name="MovieName"></param>
        /// <param name="TheatherHall"></param>
        /// <returns></returns>
        private string createTicketID()
        {
            //Takes the first 3 letters of the movie and makes them all caps
            string MovieNameShort = MovieName.Substring(0, 3).ToUpper();

            //Create the movie unique id
            string MovieTicketData = (Time.ToString("mm")) + (Time.ToString("HH")) + (Time.ToString("dd")) +
                                     (Time.ToString("MM")) + (Time.ToString("yyyy")) + MovieNameShort + X + Y + TheatherHall;

            return(MovieTicketData);
        }
Beispiel #6
0
        private void buttonAddMovie_Click(object sender, RoutedEventArgs e)
        {
            string name     = MovieName.Text;
            int    year     = Convert.ToInt32(ReleaseYear.Text);
            double length   = Convert.ToDouble(MovieLength.Text);
            Movie  newMovie = new MovieList.Movie(name, year, length);

            movieList.Add(newMovie);
            MovieName.Clear();
            ReleaseYear.Clear();
            MovieLength.Clear();
        }
    void OpenMovie(MovieName type)
    {
        switch (type)
        {
        case MovieName.Azizyanner:
            VideoPlayer.PlayYoutubeVideo("9aHlFdot3kI");
            break;

        case MovieName.HinArqaner:
            VideoPlayer.PlayYoutubeVideo("NX9I3HuYu3k");
            break;
        }
    }
Beispiel #8
0
        private void addMovie_Click(object sender, EventArgs e)
        {
            if (DirectorBox.Text == "" || ProducerBox.Text == "" || ComposerBox.Text == "" || MovieName.Text == "" || MovieGenre.Text == "")
            {
                MovieStatus.Text      = "Missing Inputs";
                MovieStatus.ForeColor = System.Drawing.Color.Red;
                MovieStatus.Show();
                return;
            }
            int           DirectorID = Convert.ToInt32(((ComboboxItem)DirectorBox.SelectedItem).Key);
            int           ProducerID = Convert.ToInt32(((ComboboxItem)ProducerBox.SelectedItem).Key);
            int           ComposerID = Convert.ToInt32(((ComboboxItem)ComposerBox.SelectedItem).Key);
            String        conString  = @"Data Source=SHERIF\SQLEXPRESS;Initial Catalog=PopCornia;Persist Security Info=True;User ID=sa;Password=123456";
            SqlConnection connection = new SqlConnection(conString);

            connection.Open();
            SqlCommand query = new SqlCommand();

            query.CommandText = "INSERT INTO Movies(Name, Year, Genre, Director_ID, Producer_ID, Composer_ID) VALUES ('" +
                                MovieName.Text + "', '" +
                                MovieDate.Value + "', '" +
                                MovieGenre.Text + "', '" +
                                DirectorID + "', '" +
                                ProducerID + "', '" +
                                ComposerID +
                                "');";
            query.Connection  = connection;
            query.CommandType = CommandType.Text;
            try
            {
                query.ExecuteNonQuery();
                MovieStatus.Text      = "Added!";
                MovieStatus.ForeColor = System.Drawing.Color.LimeGreen;
                MovieStatus.Show();
                MovieName.Clear();
                MovieGenre.SelectedIndex  = -1;
                DirectorBox.SelectedIndex = -1;
                ProducerBox.SelectedIndex = -1;
                ComposerBox.SelectedIndex = -1;
                updateDropLists(1);
                addMovie.Enabled = false;
            }
            catch (Exception x)
            {
                MovieStatus.Text      = "Invalid IDs";
                MovieStatus.ForeColor = System.Drawing.Color.Red;
                MovieStatus.Show();
                MovieName.Clear();
                addMovie.Enabled = false;
            }
        }
Beispiel #9
0
        private static bool _TryParseMove(string name, out NiceName result, string releaserText, string resolutionText)
        {
            Match match = null;

            foreach (var regex in movieclear)
            {
                match = regex.Match(name);
                if (match.Success)
                {
                    break;
                }
            }

            if (match == null || !match.Success)
            {
                result = null;
                return(false);
            }

            var nicename = string.Empty;
            var year     = 0;

            if (!string.IsNullOrEmpty(match.Groups["title"].Value))
            {
                nicename = match.Groups["title"].Value;
            }
            else
            {
                Trace.WriteLine(name);
                Trace.WriteLine("ERROR PARSING " + match.Groups["title"].Value);
            }

            if (!string.IsNullOrEmpty(match.Groups["year"].Value))
            {
                year = int.Parse(match.Groups["year"].Value);
            }
            else
            {
                Trace.WriteLine(name);
                Trace.WriteLine("ERROR PARSING " + match.Groups["year"].Value);
            }

            result = new MovieName {
                Name       = cleanstr.Replace(nicename.StemNameBase(), ""),
                Year       = year,
                Resolution = resolutionText,
                Releaser   = releaserText
            };
            return(true);
        }
Beispiel #10
0
        public override void Format(ScriptWriter sw, IScriptFormatterContext formatterContext, IServices services)
        {
            var formatter = sw.Format(formatterContext, services);

            foreach (String name in MovieName.PossibleNames(_movieId))
            {
                formatter.CommentLine(name);
            }

            formatter
            .StaticType(nameof(IMovieService))
            .Method(nameof(IMovieService.PrepareToPlay))
            .Argument("movieId", _movieId)
            .Argument("flag", _flag)
            .Comment(nameof(MOVIEREADY));
        }
Beispiel #11
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (MovieId.Length != 0)
            {
                hash ^= MovieId.GetHashCode();
            }
            if (MovieName.Length != 0)
            {
                hash ^= MovieName.GetHashCode();
            }
            if (MoviePrice.Length != 0)
            {
                hash ^= MoviePrice.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Beispiel #12
0
 public override int GetHashCode() => MovieName.GetHashCode() ^ ShowingDate.GetHashCode() ^ CinemaId.GetHashCode();
Beispiel #13
0
 /// <summary>
 /// </summary>
 public void CleanupAndClose()
 {
     MovieName.Clear();
     _currentId = null;
     ToggleFlyout(1);
 }
Beispiel #14
0
        /// <summary>
        /// I may move this to a utility that strictly maps movies versus this generic "fuzzy" logic.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            bool result    = false;
            bool contains  = false;
            var  compareTo = obj as IMovie;

            if (compareTo != null)
            {
                if (Id != 0 && Id == compareTo.Id)
                {
                    result = true;
                }
                else if (Identifier != null && compareTo.Identifier != null)
                {
                    // The Identifier will trump all other equalities if they are set.
                    result = Identifier == compareTo.Identifier;

                    if (result && Day.HasValue && compareTo.Day.HasValue)
                    {
                        // If both days have values then they HAVE TO MATCH.

                        result = Day.Value == compareTo.Day.Value;
                    }
                }
                else
                {
                    // Make all the tests case insensitive.

                    var movieName     = MovieName.ToLower().Replace(" ", string.Empty);
                    var testMovieName = compareTo.MovieName.ToLower().Replace(" ", string.Empty);

                    result = movieName.Equals(testMovieName);

                    if (!result)
                    {
                        // Not an exact match so try starts with (limited contains)

                        result   = movieName.StartsWith(testMovieName) || testMovieName.StartsWith(movieName);
                        contains = result;
                    }

                    if (!result)
                    {
                        // Not an exact match so try ends with (limited contains)

                        result   = movieName.EndsWith(testMovieName) || testMovieName.EndsWith(movieName);
                        contains = result;
                    }

                    if (!result)
                    {
                        // Not an exact match so try "contains"

                        result   = movieName.IndexOf(testMovieName) > 1 || testMovieName.IndexOf(movieName) > 1;
                        contains = result;
                    }

                    if (result)
                    {
                        // Fail if there is a lot of noise.

                        if (movieName.Length > testMovieName.Length * 2 || testMovieName.Length > movieName.Length * 2)
                        {
                            // Try  to remove some of the noise.

                            var thisYear = $" {DateTime.Now.Year}";

                            movieName     = movieName.Replace(thisYear, string.Empty);
                            testMovieName = testMovieName.Replace(thisYear, string.Empty);

                            if (movieName.Length > testMovieName.Length * 2 || testMovieName.Length > movieName.Length * 2)
                            {
                                result = false;
                            }

                            if (contains)
                            {
                                var tokens1 = MovieName.Split();
                                var tokens2 = compareTo.MovieName.Split();
                                var index   = 0;

                                if (tokens1.Length == 1 || tokens2.Length == 1)
                                {
                                    // If either are a single word then the first words need to match exactly.  This may need to progress to other words.

                                    result = tokens1[0].ToLower().Equals(tokens2[0].ToLower());
                                }

                                // Basically just "starts with".

                                else if (tokens1.Length >= tokens2.Length)
                                {
                                    result = true;

                                    foreach (var token in tokens2)
                                    {
                                        if (token.ToLower() != tokens1[index++].ToLower())
                                        {
                                            result = false;
                                            break;
                                        }
                                    }
                                }
                                else if (tokens2.Length > tokens1.Length)
                                {
                                    result = true;

                                    foreach (var token in tokens1)
                                    {
                                        if (token.ToLower() != tokens2[index++].ToLower())
                                        {
                                            result = false;
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }

                    if (!result)
                    {
                        // Try to compare the names without the word "the"

                        result = movieName.Replace("the ", string.Empty).Replace(" the", string.Empty).Equals(testMovieName.Replace("the ", string.Empty).Replace(" the", string.Empty));
                    }

                    if (result && Day.HasValue && compareTo.Day.HasValue)
                    {
                        // If both days have values then they HAVE TO MATCH.

                        result = Day.Value == compareTo.Day.Value;
                    }
                }
            }

            return(result);
        }