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 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()); }
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); }