internal void SaveArticlesNonEnglishData(Dictionary <string, ArticleFile> _dictionary) { PDFFolder temp = new PDFFolder(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.DeserializePDFFolderFromFile(ContentLocation, fileName); temp.SetLocationTitle(this.location, this.title); if (temp.HasArticleWithID(_dictionary[item.ToString()].id)) { temp.RemoveArticleWithID(_dictionary[item.ToString()].id); } temp.library.Add(_dictionary[item.ToString()]); temp.SaveArticleLibrary(fileName); } else { temp.library = new List <ArticleFile>(); temp.library.Add(_dictionary[item.ToString()]); temp.SaveArticleLibrary(fileName); } } } }
internal static PDFFolder DeserializePDFFolderFromFile(string _path, string _name) { string content = File.ReadAllText(_path + "\\" + _name); PDFFolder obj = JsonConvert.DeserializeObject <PDFFolder>(content); return(obj); }
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); }
internal static PDFFolder SerializeFromJSON(string _pdfLocation, string _pdfFolderName, string _fileName) { PDFFolder retVal = new PDFFolder(_pdfLocation, _pdfFolderName); if (DiskIO.IsFileExist(_pdfLocation + "\\" + _pdfFolderName, _fileName)) { retVal = DiskIO.DeserializePDFFolderFromFile(_pdfLocation + "\\" + _pdfFolderName, _fileName); } retVal.SetLocationTitle(_pdfLocation, _pdfFolderName); return(retVal); }
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); foreach (ArticleFile p in this.library) { // create each pdf folder string pdfNewLocation = newWorkArea + "\\" + p.id; DiskIO.CreateDirectory(pdfNewLocation); // add pdf files to copy allFilesToCopy.Add(new FileCopier(p.file, pdfNewLocation + "\\" + DiskIO.GetFileName(p.file))); // change the file path to the new path for further library json saving p.file = DiskIO.GetFileName(p.file); if (!string.IsNullOrEmpty(p.cover)) { // add video cover to copy allFilesToCopy.Add(new FileCopier(p.cover, pdfNewLocation + "\\cover.jpg")); // change the cover path to the new path for further library json saving p.cover = "\\cover.jpg"; } } // save changed paths and music files into exported location this.SaveArticleLibraryAtLocation(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)) { PDFFolder temp = DiskIO.DeserializePDFFolderFromFile(ContentLocation, abbriv); foreach (ArticleFile p in temp.library) { p.file = DiskIO.GetFileName(p.file); if (!string.IsNullOrEmpty(p.cover)) { p.cover = "\\cover.jpg"; } } DiskIO.SaveAsJSONFile(temp, newWorkArea, abbriv); } } return(allFilesToCopy.ToArray()); }
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"); }
internal void RemoveArticleNonEnglishData(int _id) { PDFFolder temp = new PDFFolder(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.DeserializePDFFolderFromFile(ContentLocation, fileName); temp.SetLocationTitle(this.location, this.title); if (temp.HasArticleWithID(_id)) { temp.RemoveArticleWithID(_id); } DiskIO.SaveAsJSONFile(temp, this.ContentLocation, fileName); } } }
internal Dictionary <string, ArticleFile> ReadNonEnglishDataLibrary(int _id) { Dictionary <string, ArticleFile> retVal = new Dictionary <string, ArticleFile>(); PDFFolder temp = new PDFFolder(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.DeserializePDFFolderFromFile(ContentLocation, fileName); temp.SetLocationTitle(this.location, this.title); if (temp.HasArticleWithID(_id)) { retVal.Add(item.ToString(), temp.FindArticleWithID(_id)); } } } return(retVal); }