Exemplo n.º 1
0
        private void ExportSeries(string path, string separator, string newline)
        {
            try
            {
                IList items = SerieServices.Gets();

                for (int i = 0; i < items.Count; i++)
                {
                    SeriesSeason entity = items[i] as SeriesSeason;

                    CommonServices.GetChild(entity);
                    if (_isCancelationPending == true)
                    {
                        break;
                    }

                    StringBuilder row = new StringBuilder();
                    row.Append("Serie" + 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);
                        }

                        if (entity.MyRating != null)
                        {
                            row.Append(entity.MyRating + separator);
                        }
                        else
                        {
                            row.Append(string.Empty + 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(separator);
                        row.Append(separator);
                        row.Append(separator);
                        row.Append(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);
                        row.Append(entity.Season.ToString(CultureInfo.InvariantCulture) + separator);
                    }

                    File.AppendAllText(path, row + newline, Encoding.UTF8);

                    _intAddedItem++;
                    Current++;
                    items[i] = null;
                }
            }
            catch (Exception ex)
            {
                Util.LogException(ex);
                throw;
            }
        }
Exemplo n.º 2
0
        private void ExportSeries(Document doc)
        {
            try
            {
                WriteChapter(doc, "Series");
                IList items = SerieServices.Gets();

                PdfPTable mainTable = new PdfPTable(1);

                for (int i = 0; i < items.Count; i++)
                {
                    SeriesSeason entity = items[i] as SeriesSeason;

                    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.Season.ToString(CultureInfo.InvariantCulture), editorName);

                        DateTime releasedate = DateTime.MinValue;
                        if (entity.ReleaseDate != null)
                        {
                            releasedate = (DateTime)entity.ReleaseDate;
                        }

                        int rating = 0;
                        if (entity.MyRating != null)
                        {
                            rating = (int)entity.MyRating;
                        }

                        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, string.Empty, text);

                        table.AddCell(text);
                        table.SplitRows = false;

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