コード例 #1
0
ファイル: AudioFolder.cs プロジェクト: seyed1411/ief
        internal void SavePlaylistNonEnglishLibrary(Dictionary <string, MusicPlaylist> _dictionary)
        {
            AudioFolder temp = new AudioFolder(this.location, this.title);

            foreach (var item in Enum.GetValues(typeof(Languages)))
            {
                if (_dictionary.ContainsKey(item.ToString()))
                {
                    string header   = item.ToString().Substring(0, 2);
                    string fileName = "index." + header + ".json";
                    if (DiskIO.IsFileExist(ContentLocation, fileName))
                    {
                        temp = DiskIO.DeserializeAudioFolderFromFile(ContentLocation, fileName);
                        temp.SetLocationTitle(this.location, this.title);
                        if (temp.HasPlaylistWithID(_dictionary[item.ToString()].id))
                        {
                            temp.RemovePlaylistWithID(_dictionary[item.ToString()].id);
                        }
                        temp.library.Add(_dictionary[item.ToString()]);
                        temp.SavePlaylistLibrary(fileName);
                    }
                    else
                    {
                        temp.library = new List <MusicPlaylist>();
                        temp.library.Add(_dictionary[item.ToString()]);
                        temp.SavePlaylistLibrary(fileName);
                    }
                }
            }
        }
コード例 #2
0
ファイル: DiskIO.cs プロジェクト: seyed1411/ief
        internal static AudioFolder DeserializeAudioFolderFromFile(string _path, string _name)
        {
            string      content = File.ReadAllText(_path + "\\" + _name);
            AudioFolder obj     = JsonConvert.DeserializeObject <AudioFolder>(content);

            return(obj);
        }
コード例 #3
0
ファイル: ProjectFolder.cs プロジェクト: seyed1411/ief
 public ProjectFolder(string _title, string _location)
 {
     this.title    = _title;
     this.location = _location;
     playlists     = new AudioFolder(ContentLocation, AUDIO_FOLDER_NAME);
     movies        = new VideoFolder(ContentLocation, VIDEO_FOLDER_NAME);
     articles      = new PDFFolder(ContentLocation, PDF_FOLDER_NAME);
     announces     = new VideoFolder(ContentLocation, ANNOUNC_FOLDER_NAME);
     questions     = new SurveyFolder(ContentLocation, SURVEY_FOLDER_NAME);
 }
コード例 #4
0
ファイル: AudioFolder.cs プロジェクト: seyed1411/ief
        internal FileCopier[] ExportFilesTo(string _contentLoc, string[] _languages)
        {
            string            newWorkArea    = _contentLoc + "\\" + title;
            List <FileCopier> allFilesToCopy = new List <FileCopier>();

            // create root folder
            DiskIO.CreateDirectory(newWorkArea);
            DiskIO.DeleteAllFiles(newWorkArea);
            // create each playlist folder
            foreach (MusicPlaylist p in this.library)
            {
                string playlistNewLocation = newWorkArea + "\\" + p.id;
                DiskIO.CreateDirectory(playlistNewLocation);
                // determine music files to copy
                foreach (MusicFile file in p.GetMusicFilesInfo())
                {
                    // add music file
                    allFilesToCopy.Add(new FileCopier(file.file, playlistNewLocation + "\\" + DiskIO.GetFileName(file.file)));
                    // change the file path to the new path for further library json saving
                    file.file = DiskIO.GetFileName(file.file);
                }
                // add playlist cover to copy
                if (p.cover != "")
                {
                    allFilesToCopy.Add(new FileCopier(p.cover, playlistNewLocation + "\\cover.jpg"));
                    // change the cover path to the new path for further library json saving
                    p.cover = "\\cover.jpg";
                }
                p.playlist = "\\index.m3u";
            }
            // save changed paths and music files into exported location
            this.SavePlaylistLibraryAtLocation(newWorkArea, "index.en.json");

            // copy all requested non-English langs
            foreach (string lang in _languages)
            {
                string abbriv = "index." + lang.Substring(0, 2).ToLower() + ".json";
                if (DiskIO.IsFileExist(ContentLocation, abbriv))
                {
                    AudioFolder temp = DiskIO.DeserializeAudioFolderFromFile(ContentLocation, abbriv);
                    foreach (MusicPlaylist x in temp.library)
                    {
                        x.playlist = "\\index.m3u";
                        if (x.cover != "")
                        {
                            x.cover = "\\cover.jpg";
                        }
                    }
                    DiskIO.SaveAsJSONFile(temp, newWorkArea, abbriv);
                }
            }
            return(allFilesToCopy.ToArray());
        }
コード例 #5
0
ファイル: AudioFolder.cs プロジェクト: seyed1411/ief
        internal static AudioFolder SerializeFromJSON(string _audioLocation, string _audioFolderName, string _fileName)
        {
            AudioFolder retVal = new AudioFolder(_audioLocation, _audioFolderName);

            if (DiskIO.IsFileExist(_audioLocation + "\\" + _audioFolderName, _fileName))
            {
                retVal = DiskIO.DeserializeAudioFolderFromFile(_audioLocation + "\\" + _audioFolderName, _fileName);
                foreach (MusicPlaylist pls in retVal.library)
                {
                    pls.LoadMusicFileInfos(_audioLocation + "\\" + _audioFolderName + "\\" + pls.id, "index.json");
                }
            }
            retVal.SetLocationTitle(_audioLocation, _audioFolderName);
            return(retVal);
        }
コード例 #6
0
ファイル: ProjectFolder.cs プロジェクト: seyed1411/ief
        public ProjectFolder(string _mcmFilePath)
        {
            string mcmContent = DiskIO.ReadTextFile(_mcmFilePath);

            string[] tempArr = mcmContent.Split(';');
            this.title    = tempArr[0];
            this.location = tempArr[1];

            playlists = new AudioFolder(ContentLocation, AUDIO_FOLDER_NAME);
            playlists = AudioFolder.SerializeFromJSON(ContentLocation, AUDIO_FOLDER_NAME, "index.en.json");
            movies    = new VideoFolder(ContentLocation, VIDEO_FOLDER_NAME);
            movies    = VideoFolder.SerializeFromJSON(ContentLocation, VIDEO_FOLDER_NAME, "index.en.json");
            announces = new VideoFolder(ContentLocation, ANNOUNC_FOLDER_NAME);
            announces = VideoFolder.SerializeFromJSON(ContentLocation, ANNOUNC_FOLDER_NAME, "index.en.json");
            articles  = new PDFFolder(ContentLocation, PDF_FOLDER_NAME);
            articles  = PDFFolder.SerializeFromJSON(ContentLocation, PDF_FOLDER_NAME, "index.en.json");
            questions = new SurveyFolder(ContentLocation, SURVEY_FOLDER_NAME);
            questions = SurveyFolder.SerializeFromJSON(ContentLocation, SURVEY_FOLDER_NAME, "index.en.json");
        }
コード例 #7
0
ファイル: AudioFolder.cs プロジェクト: seyed1411/ief
        internal void RemovePlaylistNonEnglishData(int _id)
        {
            AudioFolder temp = new AudioFolder(this.location, this.title);

            foreach (var item in Enum.GetValues(typeof(Languages)))
            {
                string header   = item.ToString().Substring(0, 2);
                string fileName = "index." + header + ".json";
                if (DiskIO.IsFileExist(ContentLocation, fileName))
                {
                    temp = DiskIO.DeserializeAudioFolderFromFile(ContentLocation, fileName);
                    temp.SetLocationTitle(this.location, this.title);
                    if (temp.HasPlaylistWithID(_id))
                    {
                        temp.RemovePlaylistWithID(_id);
                    }
                    DiskIO.SaveAsJSONFile(temp, this.ContentLocation, fileName);
                }
            }
        }
コード例 #8
0
ファイル: AudioFolder.cs プロジェクト: seyed1411/ief
        internal Dictionary <string, MusicPlaylist> ReadNonEnglishDataLibrary(int _id)
        {
            Dictionary <string, MusicPlaylist> retVal = new Dictionary <string, MusicPlaylist>();
            AudioFolder temp = new AudioFolder(this.location, this.title);

            foreach (var item in Enum.GetValues(typeof(Languages)))
            {
                string header   = item.ToString().Substring(0, 2);
                string fileName = "index." + header + ".json";
                if (DiskIO.IsFileExist(ContentLocation, fileName))
                {
                    temp = DiskIO.DeserializeAudioFolderFromFile(ContentLocation, fileName);
                    temp.SetLocationTitle(this.location, this.title);
                    if (temp.HasPlaylistWithID(_id))
                    {
                        retVal.Add(item.ToString(), temp.FindPlaylistWithID(_id));
                    }
                }
            }
            return(retVal);
        }