private void ExportMovies(string path, string separator, string newline) { try { IList items = MovieServices.Gets(); for (int i = 0; i < items.Count; i++) { Movie entity = items[i] as Movie; CommonServices.GetChild(entity); if (_isCancelationPending == true) { break; } StringBuilder row = new StringBuilder(); row.Append("Movie" + separator); if (entity != null) { row.Append(entity.Title + separator); if (entity.Publisher != null) { row.Append(entity.Publisher.Name + separator); } else { row.Append(string.Empty + separator); } if (entity.ReleaseDate != null) { row.Append(entity.ReleaseDate.Value.ToShortDateString() + separator); } else { row.Append(string.Empty + separator); } row.Append(MovieServices.CalculateMovieRating(entity) + separator); //FIX 2.8.9.0 string description = string.Empty; if (entity.Comments != null) { description = entity.Description.Replace(separator, " "); } row.Append(description + separator); StringBuilder types = new StringBuilder(); foreach (Genre item in entity.Genres) { if (types.Length == 0) { if (item != null) { types.Append(item.DisplayName); } } else if (item != null) { types.Append("," + item.DisplayName); } } row.Append(types + separator); row.Append(entity.AddedDate.ToShortDateString() + separator); if (entity.Media != null) { row.Append(entity.Media.Name + separator); } else { row.Append(string.Empty + separator); } row.Append(entity.FilePath + separator); row.Append(entity.FileName + separator); row.Append(separator); row.Append(separator); row.Append(entity.OriginalTitle + separator); types = new StringBuilder(); foreach (Artist item in entity.Artists) { if (types.Length == 0) { types.Append(item.FulleName); } else { types.Append("," + item.FulleName); } } row.Append(types + separator); } File.AppendAllText(path, row + newline, Encoding.UTF8); _intAddedItem++; Current++; items[i] = null; } } catch (Exception ex) { Util.LogException(ex); throw; } }
private void ExportMovies(Document doc) { try { WriteChapter(doc, "Movies"); IList items = MovieServices.Gets(); PdfPTable mainTable = new PdfPTable(1); for (int i = 0; i < items.Count; i++) { Movie entity = items[i] as Movie; CommonServices.GetChild(entity); if (_isCancelationPending == true) { break; } if (entity != null) { Ressource cover = entity.Ressources.FirstOrDefault(x => x.IsDefault == true); byte[] image = null; if (cover != null) { image = cover.Value; } PdfPTable table = WriteCover(image, entity.Title); string editorName = string.Empty; if (entity.Publisher != null) { editorName = entity.Publisher.Name; } PdfPTable text = WriteFirstRow(entity.Title, entity.OriginalTitle, editorName); DateTime releasedate = DateTime.MinValue; if (entity.ReleaseDate != null) { releasedate = (DateTime)entity.ReleaseDate; } double?rating = MovieServices.CalculateMovieRating(entity); WriteSecondRow(releasedate, rating, text); WriteDescription(entity.Description, text); StringBuilder types = new StringBuilder(); foreach (Genre item in entity.Genres) { if (types.Length == 0) { if (item != null) { types.Append(item.DisplayName); } } else if (item != null) { types.Append("," + item.DisplayName); } } WriteTypeRow(types.ToString(), entity.AddedDate.ToShortDateString(), text); types = new StringBuilder(); foreach (Artist item in entity.Artists) { if (types.Length == 0) { types.Append(item.FulleName); } else { types.Append("," + item.FulleName); } } WriteCast(types.ToString(), text); string media = string.Empty; if (entity.Media != null) { media = entity.Media.Name; } WriteMediaInfo(media, entity.FilePath, entity.FileName, text); table.AddCell(text); PdfPCell cell = new PdfPCell(table); cell.Border = 0; cell.BorderColor = iTextSharp.text.BaseColor.WHITE; mainTable.AddCell(cell); } _intAddedItem++; Current++; items[i] = null; } doc.Add(mainTable); doc.NewPage(); } catch (Exception ex) { Util.LogException(ex); throw; } }