Exemplo n.º 1
0
        public void Post(OrganizeEpisode request)
        {
            var dicNewProviderIds = new ProviderIdDictionary();

            if (request.NewSeriesProviderIds != null)
            {
                dicNewProviderIds = request.NewSeriesProviderIds;
            }

            // Don't await this
            var task = InternalFileOrganizationService.PerformOrganization(new EpisodeFileOrganizationRequest
            {
                EndingEpisodeNumber  = request.EndingEpisodeNumber,
                EpisodeNumber        = request.EpisodeNumber,
                RememberCorrection   = request.RememberCorrection,
                ResultId             = request.Id,
                SeasonNumber         = request.SeasonNumber,
                SeriesId             = request.SeriesId,
                NewSeriesName        = request.NewSeriesName,
                NewSeriesYear        = request.NewSeriesYear,
                NewSeriesProviderIds = dicNewProviderIds,
                TargetFolder         = request.TargetFolder
            });

            // Async processing (close dialog early instead of waiting until the file has been copied)
            // Wait 2s for exceptions that may occur to have them forwarded to the client for immediate error display
            task.Wait(2000);
        }
Exemplo n.º 2
0
        public void Post(OrganizeMovie request)
        {
            var dicNewProviderIds = new ProviderIdDictionary();

            if (request.NewMovieProviderIds != null)
            {
                dicNewProviderIds = request.NewMovieProviderIds;
            }

            // Don't await this
            InternalFileOrganizationService.PerformOrganization(new MovieFileOrganizationRequest
            {
                ResultId            = request.Id,
                MovieId             = request.MovieId,
                NewMovieName        = request.NewMovieName,
                NewMovieYear        = request.NewMovieYear,
                NewMovieProviderIds = dicNewProviderIds,
                TargetFolder        = request.TargetFolder
            });
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the persons from XML node.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns>IEnumerable{PersonInfo}.</returns>
        private async Task <PersonInfo> GetPersonFromXmlNode(XmlReader reader)
        {
            var name      = string.Empty;
            var type      = PersonType.Actor; // If type is not specified assume actor
            var role      = string.Empty;
            int?sortOrder = null;

            var providerIds = new ProviderIdDictionary();

            await reader.MoveToContentAsync().ConfigureAwait(false);

            await reader.ReadAsync().ConfigureAwait(false);

            // Loop through each element
            while (!reader.EOF && reader.ReadState == ReadState.Interactive)
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    var readerName = reader.Name ?? string.Empty;

                    switch (readerName)
                    {
                    case "name":
                        name = await reader.ReadElementContentAsStringAsync().ConfigureAwait(false) ?? string.Empty;

                        break;

                    case "type":
                        if (Enum.TryParse(await reader.ReadElementContentAsStringAsync().ConfigureAwait(false) ?? string.Empty, true, out PersonType personType))
                        {
                            type = personType;
                        }
                        break;

                    case "role":
                    {
                        var val = await reader.ReadElementContentAsStringAsync().ConfigureAwait(false);

                        if (!string.IsNullOrWhiteSpace(val))
                        {
                            role = val;
                        }
                        break;
                    }

                    case "sortorder":
                    {
                        var val = await reader.ReadElementContentAsStringAsync().ConfigureAwait(false);

                        if (!string.IsNullOrEmpty(val))
                        {
                            int intVal;
                            if (int.TryParse(val, NumberStyles.Integer, CultureInfo.InvariantCulture, out intVal))
                            {
                                sortOrder = intVal;
                            }
                        }
                        break;
                    }

                    default:

                        if (readerName.EndsWith("id", StringComparison.OrdinalIgnoreCase))
                        {
                            var val = await reader.ReadElementContentAsStringAsync().ConfigureAwait(false);

                            readerName = readerName.Substring(0, readerName.Length - 2);
                            if (readerName.Length > 0)
                            {
                                if (!string.IsNullOrWhiteSpace(val))
                                {
                                    providerIds[readerName] = val;
                                }
                            }
                        }
                        else
                        {
                            await reader.SkipAsync().ConfigureAwait(false);
                        }
                        break;
                    }
                }
                else
                {
                    await reader.ReadAsync().ConfigureAwait(false);
                }
            }

            return(new PersonInfo
            {
                Name = name.Trim(),
                Role = role,
                Type = type,
                ProviderIds = providerIds
            });
        }