Ejemplo n.º 1
0
        public static int AddRole(int seriesId, TvdbActor actor, string role)
        {
            var actorId = Add(actor);
            var roleId = RoleEntity.Add(actorId, null, null, role);
            RoleToSeriesEntity.Add(roleId, seriesId, actor.SortOrder);

            return roleId;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Extract a list of actors when the data has the format:
        /// <![CDATA[
        /// <?xml version="1.0" encoding="UTF-8" ?>
        /// <Actors>
        ///   <Actor>
        ///     <id>22017</id>
        ///     <Image>actors/22017.jpg</Image>
        ///     <Name>Zachary Levi</Name>
        ///     <Role>Chuck Bartowski</Role>
        ///     <SortOrder>0</SortOrder>
        ///   </Actor>
        /// </Actors>
        /// ]]>
        /// </summary>
        /// <param name="_data">data</param>
        /// <returns>List of actors</returns>
        internal List<TvdbActor> ExtractActors(String _data)
        {
            //Stopwatch watch = new Stopwatch();
              //watch.Start();

              XDocument xml = XDocument.Parse(_data);
              List<TvdbBanner> retList = new List<TvdbBanner>();
              var allActors = from episode in xml.Descendants("Actor")
                      select new
                      {

                        Id = episode.Element("id").Value,
                        Image = episode.Element("Image").Value,
                        Name = episode.Element("Name").Value,
                        Role = episode.Element("Role").Value,
                        SortOrder = episode.Element("SortOrder").Value
                      };
              List<TvdbActor> actorList = new List<TvdbActor>();
              foreach (var a in allActors)
              {
            TvdbActor actor = new TvdbActor();
            actor.Id = Util.Int32Parse(a.Id);
            actor.Name = a.Name;
            actor.Role = a.Role;
            actor.SortOrder = Util.Int32Parse(a.SortOrder);

            TvdbActorBanner banner = new TvdbActorBanner();
            banner.Id = actor.Id;
            banner.BannerPath = a.Image;
            actor.ActorImage = banner;
            if (actor.Id != -99)
            {
              actorList.Add(actor);
            }
              }
              //watch.Stop();
              //Log.Debug("Extracted " + actorList.Count + " actors in " + watch.ElapsedMilliseconds + " milliseconds");
              return actorList;
        }
Ejemplo n.º 3
0
 private void SetActorInfo(TvdbActor _actor)
 {
     txtActorId.Text = _actor.Id.ToString();
       txtActorName.Text = _actor.Name.ToString();
       txtActorRole.Text = _actor.Role.ToString();
       txtActorSortOrder.Text = _actor.SortOrder.ToString();
 }
Ejemplo n.º 4
0
        private bool ActorChanged(TvdbActor _actor1, TvdbActor _actor2)
        {
            if (_actor1 == null && _actor2 == null) return false;
              if (_actor1 == null || _actor2 == null) return true;

              bool actorChanged = false;
              //if (!_actor1.ActorImage.BannerPath.Equals(_actor2.BannerPath)) actorChanged = true;//shouldn't happen
              //if (_banner1.LastUpdated != _banner2.LastUpdated) bannerChanged = true;
              if (_actor1.Id != _actor2.Id) actorChanged = true;
              if (_actor1.Name != _actor2.Name) actorChanged = true;
              if (_actor1.Role != _actor2.Role) actorChanged = true;
              if (_actor1.SortOrder != _actor2.SortOrder) actorChanged = true;

              return actorChanged;
        }
Ejemplo n.º 5
0
        private void FillActorDetails(TvdbActor _before, TvdbActor _after, TvdbActor _current)
        {
            lvSeriesDetails.Items.Clear();

              //id
              lvSeriesDetails.Items.Add(CreateItem("Id", _before != null ? _before.Id.ToString() : "",
                                                 _after != null ? _after.Id.ToString() : "",
                                                 _current != null ? _current.Id.ToString() : ""));

              //Name
              lvSeriesDetails.Items.Add(CreateItem("Name", _before != null ? _before.Name.ToString() : "",
                                                 _after != null ? _after.Name.ToString() : "",
                                                 _current != null ? _current.Name.ToString() : ""));

              //Role
              lvSeriesDetails.Items.Add(CreateItem("Role", _before != null ? _before.Role.ToString() : "",
                                                 _after != null ? _after.Role.ToString() : "",
                                                 _current != null ? _current.Role.ToString() : ""));

              //SortOrder
              lvSeriesDetails.Items.Add(CreateItem("SortOrder", _before != null ? _before.SortOrder.ToString() : "",
                                                 _after != null ? _after.SortOrder.ToString() : "",
                                                 _current != null ? _current.SortOrder.ToString() : ""));

              //SortOrder
              lvSeriesDetails.Items.Add(CreateItem("Image", (_before != null && _before.ActorImage != null) ? _before.ActorImage.BannerPath.ToString() : "",
                                                 (_after != null && _after.ActorImage != null) ? _after.ActorImage.BannerPath.ToString() : "",
                                                 (_current != null && _current.ActorImage != null) ? _current.ActorImage.BannerPath.ToString() : ""));
        }
Ejemplo n.º 6
0
        private ItemState CheckActorChanged(TvdbActor _before, TvdbActor _after, TvdbActor _current)
        {
            if (_current != null)
              {
            if (_after != null)
            {//episode has been updated (_before != null) or added (_before == null)
              if (ActorChanged(_after, _current))
              {
            if (_before == null)
            {
              return ItemState.AddedAndInconsistent;
            }
            else
            {
              return ItemState.UpdatedAndInconsistent;
            }
              }
              else
              {
            if (_before == null)
            {//the item has been added correctly
              return ItemState.Added;
            }
            else
            {//the item has been updated correctly (after == current)
              if (ActorChanged(_before, _after))
              {
                return ItemState.UpdatedAndValueChanged;
              }
              else
              {
                return ItemState.Updated;
              }
            }
              }
            }

            //episode is available but hasn't been added to our cache yet
            if (_before == null && _after == null) return ItemState.AvailableButNotDownloaded;

            //we have no update for this item
            if (_after == null)
            {
              if (ActorChanged(_before, _current))
              {
            return ItemState.UnchangedAndInconsistent;
              }
              else
              {
            return ItemState.Unchanged;
              }
            }
              }

              if (_current == null)
              {//current version hasn't been loaded, we can't compare if the update was done correctly
            if (_before != null && _after != null)
            {//episode has been updated
              return ItemState.Updated;
            }
            else if (_before == null && _after != null)
            {//episode has been added
              return ItemState.Added;
            }
            else
            {
              return ItemState.Unchanged;
            }
              }
              return ItemState.Unchanged;
        }
Ejemplo n.º 7
0
 public static int AddRole(int seriesId, TvdbActor actor)
 {
     return AddRole(seriesId, actor, actor.Role);
 }
Ejemplo n.º 8
0
 public static int Add(TvdbActor actor)
 {
     return PersonEntity.AddOrUpdate(actor.Id, null, null, actor.Name);
 }