Ejemplo n.º 1
0
        private void cmdBrowseFile_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                OpenFileDialog objDialog = new OpenFileDialog();
                objDialog.InitialDirectory = Environment.SpecialFolder.MyComputer.ToString();

                if (objDialog.ShowDialog() == true)
                {
                    if (string.IsNullOrEmpty(objDialog.FileName) == false)
                    {
                        txtFileName.Text    = objDialog.SafeFileName;
                        _objEntity.FileName = objDialog.SafeFileName;

                        if (string.IsNullOrWhiteSpace(txtFilePath.Text))
                        {
                            txtFilePath.Text    = objDialog.FileName.Replace(objDialog.SafeFileName, "");
                            _objEntity.FilePath = txtFilePath.Text;
                        }

                        MovieServices.Fill(MediaInfoService.getInfo(objDialog.FileName, _objEntity.Id), _objEntity);
                        MovieUpdate parent = Util.TryFindParent <MovieUpdate>(this);
                        parent.Bind();
                    }
                }
            }
            catch (Exception ex)
            {
                Util.LogException(ex);
                new MessageBoxYesNo(ex.Message, false, true).ShowDialog();
            }
        }
Ejemplo n.º 2
0
        private void AddMovies(string strTitle, string strFileName, string strFilePath)
        {
            try
            {
                Movie objMovie = new Movie();
                objMovie.Title      = strTitle;
                objMovie.Ressources = new List <Ressource>();
                objMovie.Artists    = new List <Artist>();
                objMovie.Audios     = new List <Audio>();
                objMovie.Subtitles  = new List <Language>();
                objMovie.Genres     = new List <Genre>();
                objMovie.Links      = new List <Links>();
                objMovie.AddedDate  = DateTime.Now;
                #region File

                objMovie.FileName = strFileName;
                objMovie.FilePath = strFilePath;

                #endregion
                objMovie.Media = MediaServices.Get(_strMediaName.Trim(), _mediaType, _path,
                                                   _cleanTitle, _entityType, _patternType, _useSubFolder, _bGetImage, _bParseNfo, true);
                #region Cover
                if (_bGetImage == true)
                {
                    RessourcesServices.AddImage(Util.GetLocalImage(objMovie.FilePath, objMovie.FileName, _bFile), objMovie, true);
                }
                #endregion
                if (string.IsNullOrEmpty(objMovie.Title) == false)
                {
                    bool bExist = false;
                    if (Dal.GetInstance.GetMovies(objMovie.Media.Name, objMovie.FilePath, objMovie.FileName) != null)
                    {
                        bExist = true;
                    }

                    if (bExist == false)
                    {
                        #region MediaInfo
                        FileInfo file = new FileInfo(Path.Combine(strFilePath, strFileName));
                        if (file.Attributes == FileAttributes.Directory)
                        {
                            DirectoryInfo objFolder = new DirectoryInfo(file.FullName);
                            if (objFolder.Exists == true)
                            {
                                FileInfo[] lstFile = objFolder.GetFiles("*.mkv", SearchOption.TopDirectoryOnly);

                                if (!lstFile.Any())
                                {
                                    lstFile = objFolder.GetFiles("*.avi", SearchOption.TopDirectoryOnly);
                                }

                                if (!lstFile.Any())
                                {
                                    lstFile = objFolder.GetFiles("*.divx ", SearchOption.TopDirectoryOnly);
                                }

                                if (lstFile.Any())
                                {
                                    MovieServices.Fill(MediaInfoService.getInfo(lstFile[0].FullName, objMovie.Id), objMovie);
                                }
                            }
                        }
                        else if (file.Attributes == FileAttributes.Normal)
                        {
                            MovieServices.Fill(MediaInfoService.getInfo(file.FullName, objMovie.Id), objMovie);
                        }

                        #endregion
                        #region ParseNfo

                        if (_bParseNfo == true)
                        {
                            string errorMessage;
                            MovieServices.ParseNfo(objMovie, out errorMessage);
                        }
                        #endregion
                        Dal.GetInstance.AddMovie(objMovie);
                        _intAddedItem++;
                    }
                    else
                    {
                        _intNotAddedItem++;
                    }
                }
            }
            catch (Exception exception)
            {
                Util.LogException(exception, strTitle);
            }
        }