public virtual void MapToEntity(IEpisodeModel model, ref IEpisode entity, int currentDepth = 1)
 {
     currentDepth++;
     // Assign Base properties
     NameableEntityMapper.MapToEntity(model, ref entity);
     // Episode Properties
     entity.HasStaffReview = model.HasStaffReview;
     entity.AirDate = model.AirDate;
     entity.EpisodeCode = model.EpisodeCode;
     entity.SeasonNumber = model.SeasonNumber;
     entity.EpisodeNumber = model.EpisodeNumber;
     // Related Objects
     entity.PrimaryImageFileId = model.PrimaryImageFileId;
     entity.PrimaryImageFile = (ImageFile)model.PrimaryImageFile?.MapToEntity();
     entity.SeriesId = model.SeriesId;
     entity.Series = (Series)model.Series?.MapToEntity();
     // Associated Objects
     entity.EpisodeAliases = model.EpisodeAliases?.Where(i => i.Active).Select(EpisodeAliasMapperExtensions.MapToEntity).ToList();
     entity.EpisodeCharacters = model.EpisodeCharacters?.Where(i => i.Active).Select(EpisodeCharacterMapperExtensions.MapToEntity).ToList();
     entity.EpisodeCharactersDied = model.EpisodeCharactersDied?.Where(i => i.Active).Select(EpisodeCharacterDiedMapperExtensions.MapToEntity).ToList();
     entity.EpisodeCharacterFirstAppearances = model.EpisodeCharacterFirstAppearances?.Where(i => i.Active).Select(EpisodeCharacterFirstAppearanceMapperExtensions.MapToEntity).ToList();
     entity.EpisodeConcepts = model.EpisodeConcepts?.Where(i => i.Active).Select(EpisodeConceptMapperExtensions.MapToEntity).ToList();
     entity.EpisodeConceptFirstAppearances = model.EpisodeConceptFirstAppearances?.Where(i => i.Active).Select(EpisodeConceptFirstAppearanceMapperExtensions.MapToEntity).ToList();
     entity.EpisodeLocations = model.EpisodeLocations?.Where(i => i.Active).Select(EpisodeLocationMapperExtensions.MapToEntity).ToList();
     entity.EpisodeLocationFirstAppearances = model.EpisodeLocationFirstAppearances?.Where(i => i.Active).Select(EpisodeLocationFirstAppearanceMapperExtensions.MapToEntity).ToList();
     entity.EpisodeObjects = model.EpisodeObjects?.Where(i => i.Active).Select(EpisodeObjectMapperExtensions.MapToEntity).ToList();
     entity.EpisodeObjectFirstAppearances = model.EpisodeObjectFirstAppearances?.Where(i => i.Active).Select(EpisodeObjectFirstAppearanceMapperExtensions.MapToEntity).ToList();
     entity.EpisodePeople = model.EpisodePeople?.Where(i => i.Active).Select(EpisodePersonMapperExtensions.MapToEntity).ToList();
     entity.EpisodeStoryArcs = model.EpisodeStoryArcs?.Where(i => i.Active).Select(EpisodeStoryArcMapperExtensions.MapToEntity).ToList();
     entity.EpisodeStoryArcFirstAppearances = model.EpisodeStoryArcFirstAppearances?.Where(i => i.Active).Select(EpisodeStoryArcFirstAppearanceMapperExtensions.MapToEntity).ToList();
     entity.EpisodeTeams = model.EpisodeTeams?.Where(i => i.Active).Select(EpisodeTeamMapperExtensions.MapToEntity).ToList();
     entity.EpisodeTeamFirstAppearances = model.EpisodeTeamFirstAppearances?.Where(i => i.Active).Select(EpisodeTeamFirstAppearanceMapperExtensions.MapToEntity).ToList();
 }
示例#2
0
 public IZone GetLocation(IEpisode ep, Random random)
 {
     switch ( ep.ActivityType )
     {
         case Activity.Market:
         case Activity.JointMarket:
         case Activity.IndividualOther:
         case Activity.JointOther:
             return this.GetLocationHomeBased( ep.ActivityType, ep.Owner.Household.HomeZone, random );
         case Activity.WorkBasedBusiness:
             {
                 var empZone = ep.Owner.EmploymentZone;
                 if ( empZone.ZoneNumber == this.TashaRuntime.ZoneSystem.RoamingZoneNumber )
                 {
                     return this.GetLocationHomeBased( Activity.WorkBasedBusiness, ep.Owner.Household.HomeZone, random );
                 }
                 else
                 {
                     return this.GetLocationWorkBased( empZone, ep.Owner, random );
                 }
             }
         case Activity.PrimaryWork:
         case Activity.SecondaryWork:
         case Activity.WorkAtHomeBusiness:
             return ( ep.Zone == null || ep.Zone.ZoneNumber == this.TashaRuntime.ZoneSystem.RoamingZoneNumber ) ? this.GetLocationHomeBased( ep, ep.Owner, random ) : ep.Zone;
         default:
             return ep.Zone;
     }
 }
示例#3
0
 public virtual void MapToEntity(IEpisodeModel model, ref IEpisode entity, int currentDepth = 1)
 {
     currentDepth++;
     // Assign Base properties
     NameableEntityMapper.MapToEntity(model, ref entity);
     // Episode Properties
     entity.HasStaffReview = model.HasStaffReview;
     entity.AirDate        = model.AirDate;
     entity.EpisodeCode    = model.EpisodeCode;
     entity.SeasonNumber   = model.SeasonNumber;
     entity.EpisodeNumber  = model.EpisodeNumber;
     // Related Objects
     entity.PrimaryImageFileId = model.PrimaryImageFileId;
     entity.PrimaryImageFile   = (ImageFile)model.PrimaryImageFile?.MapToEntity();
     entity.SeriesId           = model.SeriesId;
     entity.Series             = (Series)model.Series?.MapToEntity();
     // Associated Objects
     entity.EpisodeAliases                   = model.EpisodeAliases?.Where(i => i.Active).Select(EpisodeAliasMapperExtensions.MapToEntity).ToList();
     entity.EpisodeCharacters                = model.EpisodeCharacters?.Where(i => i.Active).Select(EpisodeCharacterMapperExtensions.MapToEntity).ToList();
     entity.EpisodeCharactersDied            = model.EpisodeCharactersDied?.Where(i => i.Active).Select(EpisodeCharacterDiedMapperExtensions.MapToEntity).ToList();
     entity.EpisodeCharacterFirstAppearances = model.EpisodeCharacterFirstAppearances?.Where(i => i.Active).Select(EpisodeCharacterFirstAppearanceMapperExtensions.MapToEntity).ToList();
     entity.EpisodeConcepts                  = model.EpisodeConcepts?.Where(i => i.Active).Select(EpisodeConceptMapperExtensions.MapToEntity).ToList();
     entity.EpisodeConceptFirstAppearances   = model.EpisodeConceptFirstAppearances?.Where(i => i.Active).Select(EpisodeConceptFirstAppearanceMapperExtensions.MapToEntity).ToList();
     entity.EpisodeLocations                 = model.EpisodeLocations?.Where(i => i.Active).Select(EpisodeLocationMapperExtensions.MapToEntity).ToList();
     entity.EpisodeLocationFirstAppearances  = model.EpisodeLocationFirstAppearances?.Where(i => i.Active).Select(EpisodeLocationFirstAppearanceMapperExtensions.MapToEntity).ToList();
     entity.EpisodeObjects                   = model.EpisodeObjects?.Where(i => i.Active).Select(EpisodeObjectMapperExtensions.MapToEntity).ToList();
     entity.EpisodeObjectFirstAppearances    = model.EpisodeObjectFirstAppearances?.Where(i => i.Active).Select(EpisodeObjectFirstAppearanceMapperExtensions.MapToEntity).ToList();
     entity.EpisodePeople    = model.EpisodePeople?.Where(i => i.Active).Select(EpisodePersonMapperExtensions.MapToEntity).ToList();
     entity.EpisodeStoryArcs = model.EpisodeStoryArcs?.Where(i => i.Active).Select(EpisodeStoryArcMapperExtensions.MapToEntity).ToList();
     entity.EpisodeStoryArcFirstAppearances = model.EpisodeStoryArcFirstAppearances?.Where(i => i.Active).Select(EpisodeStoryArcFirstAppearanceMapperExtensions.MapToEntity).ToList();
     entity.EpisodeTeams = model.EpisodeTeams?.Where(i => i.Active).Select(EpisodeTeamMapperExtensions.MapToEntity).ToList();
     entity.EpisodeTeamFirstAppearances = model.EpisodeTeamFirstAppearances?.Where(i => i.Active).Select(EpisodeTeamFirstAppearanceMapperExtensions.MapToEntity).ToList();
 }
示例#4
0
        public virtual IEpisodeModel MapToModel(IEpisode entity, int currentDepth = 1)
        {
            currentDepth++;
            var model = NameableEntityMapper.MapToModel <IEpisode, EpisodeModel>(entity);

            // Episode Properties
            model.HasStaffReview = entity.HasStaffReview;
            model.AirDate        = entity.AirDate;
            model.EpisodeCode    = entity.EpisodeCode;
            model.SeasonNumber   = entity.SeasonNumber;
            model.EpisodeNumber  = entity.EpisodeNumber;
            // Related Objects
            model.PrimaryImageFileId = entity.PrimaryImageFileId;
            model.PrimaryImageFile   = entity.PrimaryImageFile?.MapToModel();
            model.SeriesId           = entity.SeriesId;
            model.Series             = entity.Series?.MapToModel();
            // Associated Objects
            model.EpisodeAliases                   = entity.EpisodeAliases?.Where(i => i.Active).Select(EpisodeAliasMapperExtensions.MapToModelLite).ToList();
            model.EpisodeCharacters                = entity.EpisodeCharacters?.Where(i => i.Active).Select(EpisodeCharacterMapperExtensions.MapToModelLite).ToList();
            model.EpisodeCharactersDied            = entity.EpisodeCharactersDied?.Where(i => i.Active).Select(EpisodeCharacterDiedMapperExtensions.MapToModelLite).ToList();
            model.EpisodeCharacterFirstAppearances = entity.EpisodeCharacterFirstAppearances?.Where(i => i.Active).Select(EpisodeCharacterFirstAppearanceMapperExtensions.MapToModelLite).ToList();
            model.EpisodeConcepts                  = entity.EpisodeConcepts?.Where(i => i.Active).Select(EpisodeConceptMapperExtensions.MapToModelLite).ToList();
            model.EpisodeConceptFirstAppearances   = entity.EpisodeConceptFirstAppearances?.Where(i => i.Active).Select(EpisodeConceptFirstAppearanceMapperExtensions.MapToModelLite).ToList();
            model.EpisodeLocations                 = entity.EpisodeLocations?.Where(i => i.Active).Select(EpisodeLocationMapperExtensions.MapToModelLite).ToList();
            model.EpisodeLocationFirstAppearances  = entity.EpisodeLocationFirstAppearances?.Where(i => i.Active).Select(EpisodeLocationFirstAppearanceMapperExtensions.MapToModelLite).ToList();
            model.EpisodeObjects                   = entity.EpisodeObjects?.Where(i => i.Active).Select(EpisodeObjectMapperExtensions.MapToModelLite).ToList();
            model.EpisodeObjectFirstAppearances    = entity.EpisodeObjectFirstAppearances?.Where(i => i.Active).Select(EpisodeObjectFirstAppearanceMapperExtensions.MapToModelLite).ToList();
            model.EpisodePeople    = entity.EpisodePeople?.Where(i => i.Active).Select(EpisodePersonMapperExtensions.MapToModelLite).ToList();
            model.EpisodeStoryArcs = entity.EpisodeStoryArcs?.Where(i => i.Active).Select(EpisodeStoryArcMapperExtensions.MapToModelLite).ToList();
            model.EpisodeStoryArcFirstAppearances = entity.EpisodeStoryArcFirstAppearances?.Where(i => i.Active).Select(EpisodeStoryArcFirstAppearanceMapperExtensions.MapToModelLite).ToList();
            model.EpisodeTeams = entity.EpisodeTeams?.Where(i => i.Active).Select(EpisodeTeamMapperExtensions.MapToModelLite).ToList();
            model.EpisodeTeamFirstAppearances = entity.EpisodeTeamFirstAppearances?.Where(i => i.Active).Select(EpisodeTeamFirstAppearanceMapperExtensions.MapToModelLite).ToList();
            // Return Entity
            return(model);
        }
        /// <summary>
        /// Generate a string based on a formula. %r for Show name, %s for Season Number, %e for the overall episode
        /// number, %f for the episode number in the season, %p for the production number, %t for the title, and %d for the
        /// air date
        /// </summary>
        /// <param name="file">file to be renamed</param>
        /// <param name="episode">episode data to use to rename file</param>
        /// <param name="settings">options for renaming the file</param>
        /// <returns></returns>
        public Result Rename(IVideoFile file, IEpisode episode, bool isTest)
        {
            var newFilename = CreateFilename(episode);
            var newFilePath = string.Format("{0}\\{1}{2}", file.DirectoryPath, newFilename, file.FileExtension);

            if (!file.FullPath.Equals(newFilePath, StringComparison.CurrentCultureIgnoreCase) && !isTest)
            {
                var result = TryMoveFile(file.FullPath, newFilePath);

                if (result.Success)
                {
                    _episodeStore.UpdatePath(episode, newFilePath);
                }
                else
                {
                    return(result);
                }
            }
            else if (episode.VideoPath != newFilePath)
            {
                _episodeStore.UpdatePath(episode, file.FullPath);
            }

            return(Result.Successful);
        }
示例#6
0
        private string GetNewFileName(string mask, string showTitle, IEpisode ep, bool replaceSpaces)
        {
            string formatString = mask.Replace("%T", "{0}");

            formatString = formatString.Replace("%E", "{1}");
            formatString = formatString.Replace("%s", "{2}");
            formatString = formatString.Replace("%e", "{3}");
            formatString = formatString.Replace("%a", "{4}");
            formatString = formatString.Replace("%d", "{5}");
            formatString = formatString.Replace("%g", "{6}");
            string fileShowTitle = showTitle;

            if (replaceSpaces)
            {
                fileShowTitle = ReplaceSpaces(".", fileShowTitle);
            }
            string fileEpTitle = ep.Title;

            if (replaceSpaces)
            {
                fileEpTitle = ReplaceSpaces(".", fileEpTitle);
            }

            return(string.Format(formatString, fileShowTitle, fileEpTitle, ep.SeasonNumber, ep.EpisodeNumber, ep.File.Attributes, ep.AiringDateTime, ep.File.FileProducer));
        }
示例#7
0
        public IZone GetLocation(IEpisode ep, Random random)
        {
            switch (ep.ActivityType)
            {
            case Activity.Market:
            case Activity.JointMarket:
            case Activity.IndividualOther:
            case Activity.JointOther:
                return(this.GetLocationHomeBased(ep.ActivityType, ep.Owner.Household.HomeZone, random));

            case Activity.WorkBasedBusiness:
            {
                var empZone = ep.Owner.EmploymentZone;
                if (empZone.ZoneNumber == this.TashaRuntime.ZoneSystem.RoamingZoneNumber)
                {
                    return(this.GetLocationHomeBased(Activity.WorkBasedBusiness, ep.Owner.Household.HomeZone, random));
                }
                else
                {
                    return(this.GetLocationWorkBased(empZone, ep.Owner, random));
                }
            }

            case Activity.PrimaryWork:
            case Activity.SecondaryWork:
            case Activity.WorkAtHomeBusiness:
                return((ep.Zone == null || ep.Zone.ZoneNumber == this.TashaRuntime.ZoneSystem.RoamingZoneNumber) ? this.GetLocationHomeBased(ep, ep.Owner, random) : ep.Zone);

            default:
                return(ep.Zone);
            }
        }
示例#8
0
 protected bool Deactivate(IEpisode entity)
 {
     // Deactivate it
     EpisodesRepository.Deactivate(entity);
     // Try to Save Changes
     EpisodesRepository.SaveChanges();
     // Finished!
     return(true);
 }
示例#9
0
文件: Schedule.cs 项目: lunaxi7/XTMF
 private void IncreaseArraySize()
 {
     // if we don't have room create a new array of 2x the size
     IEpisode[] temp = new IEpisode[EpisodeCount * 2];
     // copy all of the old data
     Array.Copy(Episodes, temp, EpisodeCount);
     // and now use that larger array
     Episodes = temp;
 }
示例#10
0
 public void ApplyDataFromEpisode(IEpisode episode)
 {
     this.AbsoluteEpisodeNumber = episode.AbsoluteEpisodeNumber;
     this.AirDate       = episode.AirDate;
     this.EpisodeNumber = episode.EpisodeNumber;
     this.Id            = episode.Id;
     this.IsMonitored   = episode.IsMonitored;
     this.Name          = episode.Name;
     this.SeasonNumber  = episode.SeasonNumber;
     this.SeriesId      = episode.SeriesId;
 }
示例#11
0
 public PodcastEpisode(IEpisode episode)
 {
     Title           = episode.Title;
     Description     = episode.Description;
     Image           = episode.Image;
     Audio           = episode.Audio;
     AudioLength     = TimeSpan.FromSeconds(episode.AudioLengthSec);
     PublishDate     = episode.PubDateMs;
     ExplicitContent = episode.ExplicitContent;
     Id = episode.Id;
 }
示例#12
0
        public void SaveEpisode(IEpisode episode)
        {
            const string sql = @"
				INSERT INTO episode
					(title, season, episode_in_show, episode_in_season, airdate, show_id, created_at, updated_at)
				VALUES
					(@Title, @Season, @EpisodeInShow, @EpisodeInSeason, @AirDate, @ShowId, current_timestamp, current_timestamp)"                    ;

            using (var dbConnection = Database.CreateConnection())
            {
                dbConnection.Execute(sql, new { episode.Title, episode.Season, episode.EpisodeInShow, episode.EpisodeInSeason, episode.AirDate, episode.ShowId });
            }
        }
示例#13
0
 protected bool Remove(IEpisode entity)
 {
     if (entity == null)
     {
         return(true);
     }                                    // No entity found to remove, consider it passed
     // Remove it
     EpisodesRepository.Remove(entity);
     // Try to Save Changes
     EpisodesRepository.SaveChanges();
     // Finished!
     return(true);
 }
示例#14
0
        private void CreateOrUpdateEpisode(IShow show, IEpisode episode)
        {
            var existingEpisode = show.Episodes.SingleOrDefault(x => x.Season == episode.Season && x.EpisodeInSeason == episode.EpisodeInSeason);

            if (existingEpisode == null)
            {
                CreateEpisode(episode);
            }
            else if (ShouldUpdateEpisode(existingEpisode, episode))
            {
                UpdateEpisode(episode);
            }
        }
 public virtual bool AreEqual(IEpisodeModel model, IEpisode entity)
 {
     return NameableEntityMapper.AreEqual(model, entity)
         // Episode Properties
         && model.HasStaffReview == entity.HasStaffReview
         && model.AirDate == entity.AirDate
         && model.EpisodeCode == entity.EpisodeCode
         && model.SeasonNumber == entity.SeasonNumber
         && model.EpisodeNumber == entity.EpisodeNumber
         // Related Objects
         && model.PrimaryImageFileId == entity.PrimaryImageFileId
         && model.SeriesId == entity.SeriesId
         ;
 }
示例#16
0
 public virtual bool AreEqual(IEpisodeModel model, IEpisode entity)
 {
     return(NameableEntityMapper.AreEqual(model, entity)
            // Episode Properties
            && model.HasStaffReview == entity.HasStaffReview &&
            model.AirDate == entity.AirDate &&
            model.EpisodeCode == entity.EpisodeCode &&
            model.SeasonNumber == entity.SeasonNumber &&
            model.EpisodeNumber == entity.EpisodeNumber
            // Related Objects
            && model.PrimaryImageFileId == entity.PrimaryImageFileId &&
            model.SeriesId == entity.SeriesId
            );
 }
示例#17
0
        private static bool ShouldUpdateEpisode(IEpisode exisingEpisode, IEpisode newEpisode)
        {
            if (newEpisode.AirDate == default(DateTime) || newEpisode.AirDate == DateTime.MinValue || newEpisode.AirDate == DateTime.MaxValue)
            {
                return(false);
            }

            if (exisingEpisode.Title != newEpisode.Title || exisingEpisode.AirDate != newEpisode.AirDate)
            {
                return(true);
            }

            return(false);
        }
示例#18
0
        public virtual IEpisodeModel MapToModelListing(IEpisode entity, int currentDepth = 1)
        {
            currentDepth++;
            var model = NameableEntityMapper.MapToModelListing <IEpisode, EpisodeModel>(entity);

            // Episode Properties
            model.HasStaffReview = entity.HasStaffReview;
            model.AirDate        = entity.AirDate;
            model.EpisodeCode    = entity.EpisodeCode;
            model.SeasonNumber   = entity.SeasonNumber;
            model.EpisodeNumber  = entity.EpisodeNumber;
            // Related Objects
            model.PrimaryImageFileId = entity.PrimaryImageFileId;
            model.SeriesId           = entity.SeriesId;
            // Return Entity
            return(model);
        }
 /// <summary>
 /// we assume that the new episode has more up-to-date information
 /// but we dont want to lose any info that is not retrieved automatically
 /// such as file path so we will only merge what we safely can
 /// </summary>
 /// <param name="origEp">original episode</param>
 /// <param name="newEp">new episode</param>
 private void MergeEpisodes(Episode origEp, IEpisode newEp)
 {
     origEp.AiringDateTime = newEp.AiringDateTime;
     if (string.IsNullOrEmpty(origEp.Description))
     {
         origEp.Description = newEp.Description;
     }
     if (origEp.DetailsURI == null)
     {
         origEp.DetailsURI = newEp.DetailsURI;
     }
     if (origEp.File == null)
     {
         origEp.File = newEp.File;
     }
     origEp.Title = newEp.Title;
 }
示例#20
0
        public void UpdatePath(IEpisode episode, string path)
        {
            const string sql = @"
				UPDATE episode
				SET 
					path = @Path,
					updated_at = current_timestamp
				WHERE 
					show_id = @ShowId
					AND season = @Season
					AND episode_in_season = @EpisodeInSeason"                    ;

            using (var dbConnection = Database.CreateConnection())
            {
                dbConnection.Execute(sql, new { episode.ShowId, episode.Season, episode.EpisodeInSeason, path });
            }
        }
示例#21
0
        public void UpdateEpisode(IEpisode episode)
        {
            const string sql = @"
				UPDATE episode
				SET 
					title = @Title,
					airdate = @AirDate,
					updated_at = current_timestamp
				WHERE 
					show_id = @ShowId
					AND season = @Season
					AND episode_in_season = @EpisodeInSeason"                    ;

            using (var dbConnection = Database.CreateConnection())
            {
                dbConnection.Execute(sql, new { episode.ShowId, episode.Season, episode.EpisodeInSeason, episode.Title, episode.AirDate });
            }
        }
示例#22
0
        public IZone GetLocation(IEpisode ep, Random random)
        {
            switch (ep.ActivityType)
            {
            case Activity.Market:
            case Activity.JointMarket:
            case Activity.IndividualOther:
            case Activity.JointOther:
            case Activity.WorkAtHomeBusiness:
                return(GetLocationHomeBased(ep.ActivityType, ep.Owner.Household.HomeZone, random));

            case Activity.WorkBasedBusiness:
                return(GetLocationWorkBased(ep.Owner.EmploymentZone, ep.Owner, random));

            default:
                return(ep.Zone);
            }
        }
示例#23
0
        /// <summary>
        /// Get Episode Name/Title as specified by preference. if nothing found, the first available is returned
        /// </summary>
        /// <param name="episode">IEpisode object representing the episode to search the name for</param>
        /// <param name="langs">Arguments array taking in the TitleLanguages that should be search for.</param>
        /// <returns>string representing the episode name for the first language a name is found for</returns>
        private string GetEpNameByPref(IEpisode episode, params TitleLanguage[] langs)
        {
            //iterate over all passed TitleLanguages
            foreach (TitleLanguage lang in langs)
            {
                //set the title to the first found title whose language matches with the search one.
                //if none is found, title is null
                string title = episode.Titles.FirstOrDefault(s => s.Language == lang)?.Title;

                //return the found title if title is not null
                if (title != null)
                {
                    return(title);
                }
            }

            //no title for any given TitleLanguage found, return the first available.
            return(episode.Titles.First().Title);
        }
 private void MergeSeasons(ISeason origSeason, ISeason newSeason)
 {
     foreach (IEpisode newEp in newSeason.Episodes)
     {
         IEpisode originalEp = origSeason[newEp.EpisodeNumber];
         if (originalEp == null)
         {
             origSeason.Episodes.Add(newEp);
         }
         else if (originalEp is Episode)
         {
             MergeEpisodes((Episode)originalEp, newEp);
         }
         else
         {
             // FIXME: what to do here?
         }
     }
 }
示例#25
0
        private void btnRename_Click(object sender, EventArgs e)
        {
            List <MediaFile> oldFiles = new List <MediaFile>();
            List <string>    newNames = new List <string>();
            StringBuilder    msg      = new StringBuilder();
            string           mask     = drpFileMask.Text;

            if (string.IsNullOrEmpty(mask))
            {
                MessageBox.Show("Please select a file mask first: " + drpFileMask.SelectedText);
                return;
            }
            msg.Append("The Following Files will be renamed\n\n");
            foreach (DataGridViewRow row in grdEpisodes.Rows)
            {
                DataGridViewCheckBoxCell cell = (DataGridViewCheckBoxCell)row.Cells[0];
                if (cell.Value == cell.TrueValue)
                {
                    IEpisode ep = (IEpisode)row.DataBoundItem;

                    string newFileName = GetNewFileName(mask, title, ep, true);
                    string oldFilename = ep.File.FileName;
                    if (string.IsNullOrEmpty(Path.GetDirectoryName(newFileName)))
                    {
                        newFileName = Path.Combine(Path.GetDirectoryName(oldFilename), newFileName);
                    }
                    newNames.Add(newFileName);
                    oldFiles.Add(ep.File);
                    msg.Append(oldFilename + " will be renamed to " + newFileName + "\n");
                }
            }
            if (oldFiles.Count > 0 && DialogResult.OK == MessageBox.Show(msg.ToString(), "Confirm Rename", MessageBoxButtons.OKCancel))
            {
                for (int i = 0; i < oldFiles.Count; i++)
                {
                    File.Move(oldFiles[i].FileName, newNames[i]);
                    oldFiles[i].FileName = newNames[i];
                }
                Close();
            }
        }
        /// <summary>
        /// handles the event from the episode import dialog. we go through each of the MediaFileInfo
        /// objects and if there is no season object already, we add it. we then set the file info
        /// for the appropriate episode in the season
        /// </summary>
        /// <param name="selectedMediaItems"></param>
        private void importDialog_MediaItemsSelected(List <MediaFile> selectedMediaItems)
        {
            foreach (MediaFile mfi in selectedMediaItems)
            {
                int episodeNumber = mfi.EpisodeNumber;
                int seasonNumber  = mfi.SeasonNumber;

                ISeason seasonToAdd = showDetails[seasonNumber];
                if (seasonToAdd == null)
                {
                    seasonToAdd = AddSeason(seasonNumber);
                }

                if (seasonToAdd != null)
                {
                    IEpisode ep = seasonToAdd[episodeNumber];
                    if (ep != null)
                    {
                        //                        MessageBox.Show("Setting path for Episode " + ep.EpisodeNumber + ": " + ep.Title + " to " + mfi.FileName);
                        if (ep is Episode)
                        {
                            ((Episode)ep).File = mfi;
                        }
                    }
                    else
                    {
                        ep = new Episode(seasonNumber, episodeNumber, null, mfi.EpisodeTitle, null);
                        if (seasonToAdd is Season)
                        {
                            seasonToAdd.Episodes.Add(ep);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Unable to determine any details for season " + seasonNumber);
                }
            }
        }
示例#27
0
 private Time ComputeAvailableTime(IEpisode previous, IEpisode next)
 {
     return (next == null ? Time.EndOfDay : (next.StartTime + next.Duration - (MaximumEpisodeDurationCompression * next.OriginalDuration)))
         - (previous == null ? Time.StartOfDay : previous.EndTime - previous.Duration - (MaximumEpisodeDurationCompression * previous.OriginalDuration));
 }
示例#28
0
 public IZone GetLocationHomeBased(IEpisode episode, ITashaPerson person, Random random)
 {
     throw new NotImplementedException("This method is no longer supported for V4.0+");
 }
示例#29
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="e">The episode to find a zone for</param>
 /// <param name="person">The person to look at (their household)</param>
 /// <returns></returns>
 public IZone GetLocationHomeBased(IEpisode e, ITashaPerson person, Random random)
 {
     return GetLocationHomeBased( e.ActivityType, person.Household.HomeZone, random );
 }
示例#30
0
 public bool SetDownloaded(IEpisode episode)
 {
     return episode.SetDownloaded(this);
 }
示例#31
0
 public void SetWatched(IEpisode episode, int note = -1)
 {
     episode.SetWatched(this, note);
 }
示例#32
0
 internal IZone GetLocation(IZone previousZone, IEpisode ep, IZone nextZone, Time startTime, Time availableTime, float[] calculationSpace, Random random)
 {
     var total = CalculateLocationProbabilities(previousZone, ep, nextZone, startTime, availableTime, calculationSpace);
     if (total <= 0)
     {
         return null;
     }
     var pop = (float)random.NextDouble() * total;
     float current = 0.0f;
     for (int i = 0; i < calculationSpace.Length; i++)
     {
         current += calculationSpace[i];
         if (pop <= current)
         {
             return zones[i];
         }
     }
     for (int i = 0; i < calculationSpace.Length; i++)
     {
         if (calculationSpace[i] > 0)
         {
             return zones[i];
         }
     }
     return null;
 }
 public void Deactivate(IEpisode entity)
 {
     entity.Active = false;
     Update(entity);
 }
 public void Update(IEpisode entity)
 {
     Context.SetModified(entity);
 }
 public void Remove(IEpisode entity)
 {
     Context.Episodes.Remove((Episode)entity);
 }
示例#36
0
文件: Schedule.cs 项目: Cocotus/XTMF
 /// <summary>
 /// Checks to see if an episode can be inserted, and does if it can
 /// </summary>
 public abstract bool CheckEpisodeInsert(IEpisode episode, ref TimeWindow feasibleWindow);
示例#37
0
        private string GetNewFileName(string mask, string showTitle, IEpisode ep, bool replaceSpaces)
        {
            string formatString = mask.Replace("%T", "{0}");
            formatString = formatString.Replace("%E", "{1}");
            formatString = formatString.Replace("%s", "{2}");
            formatString = formatString.Replace("%e", "{3}");
            formatString = formatString.Replace("%a", "{4}");
            formatString = formatString.Replace("%d", "{5}");
            formatString = formatString.Replace("%g", "{6}");
            string fileShowTitle = showTitle;
            if (replaceSpaces)
            {
                fileShowTitle = ReplaceSpaces(".",fileShowTitle);
            }
            string fileEpTitle = ep.Title;
            if (replaceSpaces)
            {
                fileEpTitle = ReplaceSpaces(".", fileEpTitle);
            }

            return string.Format(formatString, fileShowTitle, fileEpTitle, ep.SeasonNumber, ep.EpisodeNumber, ep.File.Attributes, ep.AiringDateTime, ep.File.FileProducer);
        }
示例#38
0
 public float[] GetLocationProbabilities(IEpisode ep)
 {
     throw new NotImplementedException();
 }
示例#39
0
 internal IZone GetLocation(IZone previousZone, IEpisode ep, IZone nextZone, Time startTime, Time availableTime, float[] calculationSpace, Random random)
 {
     var p = zoneSystem.GetFlatIndex(previousZone.ZoneNumber);
     var n = zoneSystem.GetFlatIndex(nextZone.ZoneNumber);
     var size = zones.Length;
     int index = GetTimePeriod(startTime);
     var rowTimes = Parent.TimePeriods[index].RowTravelTimes;
     var columnTimes = Parent.TimePeriods[index].ColumnTravelTimes;
     var from = From[index];
     var available = availableTime.ToMinutes();
     var to = To[index];
     var pIndex = FlatZoneToPDCubeLookup[p];
     var nIndex = FlatZoneToPDCubeLookup[n];
     var data = PDCube[pIndex][nIndex];
     int previousIndexOffset = p * size;
     int nextSizeOffset = n * size;
     float total = 0.0f;
     if(VectorHelper.IsHardwareAccelerated)
     {
         Vector<float> availableTimeV = new Vector<float>(available);
         Vector<float> totalV = Vector<float>.Zero;
         if(nIndex == pIndex)
         {
             for(int i = 0; i < calculationSpace.Length; i++)
             {
                 var odUtility = 1.0f;
                 var pdindex = data[FlatZoneToPDCubeLookup[i]];
                 if(pdindex >= 0)
                 {
                     odUtility = (pIndex == FlatZoneToPDCubeLookup[i]) ? ODConstants[pdindex].ExpConstant * expSamePD : ODConstants[pdindex].ExpConstant;
                 }
                 else
                 {
                     odUtility = (pIndex == FlatZoneToPDCubeLookup[i]) ? expSamePD : 1.0f;
                 }
                 calculationSpace[i] = odUtility;
             }
         }
         else
         {
             for(int i = 0; i < calculationSpace.Length; i++)
             {
                 var pdindex = data[FlatZoneToPDCubeLookup[i]];
                 calculationSpace[i] = pdindex >= 0 ? ODConstants[pdindex].ExpConstant : 1f;
             }
         }
         for(int i = 0; i <= calculationSpace.Length - Vector<float>.Count; i += Vector<float>.Count)
         {
             Vector<int> zeroMask = Vector.LessThanOrEqual(new Vector<float>(rowTimes, previousIndexOffset + i)
                 + new Vector<float>(rowTimes, previousIndexOffset + i), availableTimeV);
             Vector<float> calcV = new Vector<float>(calculationSpace, i);
             calcV = Vector.AsVectorSingle(Vector.BitwiseAnd(Vector.AsVectorInt32(calcV), zeroMask))
                 * new Vector<float>(to, previousIndexOffset + i)
                 * new Vector<float>(nextSizeOffset + i);
             calcV.CopyTo(calculationSpace, i);
             totalV += calcV;
         }
         float remainderTotal = 0.0f;
         for(int i = calculationSpace.Length - (calculationSpace.Length % Vector<float>.Count); i < calculationSpace.Length; i++)
         {
             if(rowTimes[previousIndexOffset + i] + columnTimes[nextSizeOffset + i] <= available)
             {
                 remainderTotal += (calculationSpace[i] = to[previousIndexOffset + i] * from[nextSizeOffset + i] * calculationSpace[i]);
             }
             else
             {
                 calculationSpace[i] = 0;
             }
         }
         total += remainderTotal + Vector.Dot(totalV, Vector<float>.One);
     }
     else
     {
         unsafe
         {
             fixed (float* pRowTimes = &rowTimes[0])
             fixed (float* pColumnTimes = &columnTimes[0])
             fixed (float* pTo = &to[0])
             fixed (float* pFrom = &from[0])
             fixed (int* pData = &data[0])
             {
                 if(nIndex == pIndex)
                 {
                     for(int i = 0; i < calculationSpace.Length; i++)
                     {
                         if(pRowTimes[previousIndexOffset + i] + pColumnTimes[nextSizeOffset + i] <= available)
                         {
                             var odUtility = 1.0f;
                             var pdindex = pData[FlatZoneToPDCubeLookup[i]];
                             if(pdindex >= 0)
                             {
                                 odUtility = (pIndex == FlatZoneToPDCubeLookup[i]) ? ODConstants[pdindex].ExpConstant * expSamePD : ODConstants[pdindex].ExpConstant;
                             }
                             else
                             {
                                 odUtility = (pIndex == FlatZoneToPDCubeLookup[i]) ? expSamePD : 1.0f;
                             }
                             total += calculationSpace[i] = pTo[previousIndexOffset + i] * pFrom[nextSizeOffset + i] * odUtility;
                         }
                         else
                         {
                             calculationSpace[i] = 0;
                         }
                     }
                 }
                 else
                 {
                     for(int i = 0; i < calculationSpace.Length; i++)
                     {
                         if(pRowTimes[previousIndexOffset + i] + pColumnTimes[nextSizeOffset + i] <= available)
                         {
                             var odUtility = 1.0f;
                             var pdindex = pData[FlatZoneToPDCubeLookup[i]];
                             if(pdindex >= 0)
                             {
                                 odUtility = ODConstants[pdindex].ExpConstant;
                             }
                             total += calculationSpace[i] = pTo[previousIndexOffset + i] * pFrom[nextSizeOffset + i] * odUtility;
                         }
                         else
                         {
                             calculationSpace[i] = 0;
                         }
                     }
                 }
             }
         }
     }
     if(total <= 0)
     {
         return null;
     }
     var pop = (float)random.NextDouble() * total;
     float current = 0.0f;
     for(int i = 0; i < calculationSpace.Length; i++)
     {
         current += calculationSpace[i];
         if(pop <= current)
         {
             return zones[i];
         }
     }
     for(int i = 0; i < calculationSpace.Length; i++)
     {
         if(calculationSpace[i] > 0)
         {
             return zones[i];
         }
     }
     return null;
 }
 public void Add(IEpisode entity)
 {
     Context.Episodes.Add((Episode)entity);
 }
示例#41
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="e">The episode to find a zone for</param>
 /// <param name="person">The person to look at (their household)</param>
 /// <returns></returns>
 public IZone GetLocationHomeBased(IEpisode e, ITashaPerson person, Random random)
 {
     return(GetLocationHomeBased(e.ActivityType, person.Household.HomeZone, random));
 }
示例#42
0
 public static void MapToEntity(this IEpisodeModel model, ref IEpisode entity, int currentDepth = 1)
 {
     Mapper.MapToEntity(model, ref entity, currentDepth);
 }
示例#43
0
 internal float[] GetLocationProbabilities(IZone previousZone, IEpisode ep, IZone nextZone, Time startTime, Time availableTime, float[] calculationSpace)
 {
     var total = CalculateLocationProbabilities(previousZone, ep, nextZone, startTime, availableTime, calculationSpace);
     if (total <= 0.0f)
     {
         return calculationSpace;
     }
     if (VectorHelper.IsHardwareAccelerated)
     {
         VectorHelper.Multiply(calculationSpace, 0, calculationSpace, 0, 1.0f / total, calculationSpace.Length);
     }
     else
     {
         var ratio = 1.0f / total;
         for (int i = 0; i < calculationSpace.Length; i++)
         {
             calculationSpace[i] *= ratio;
         }
     }
     return calculationSpace;
 }
示例#44
0
 public static IEpisodeModel MapToModelListing(this IEpisode entity, int currentDepth = 1)
 {
     return(Mapper.MapToModelListing(entity, currentDepth));
 }
示例#45
0
 public float[] GetLocationProbabilities(IEpisode ep)
 {
     var episodes = ep.ContainingSchedule.Episodes;
     var startTime = ep.StartTime;
     int i = 0;
     for (; i < episodes.Length; i++)
     {
         if (episodes[i] == null) break;
         if (startTime < episodes[i].StartTime)
         {
             return GetLocationProbabilities(ep, (i == 0 ? null : episodes[i - 1]), episodes[i], startTime);
         }
     }
     return GetLocationProbabilities(ep, (i > 0 ? episodes[i - 1] : null), null, startTime);
 }
示例#46
0
 public bool HasWatched(IEpisode episode)
 {
     return HasWatched(episode.UrlShow, episode.Season, episode.Number);
 }
示例#47
0
 public void SetMark(IEpisode episode, int mark)
 {
     episode.SetMark(this, mark);
 }
示例#48
0
 public override bool CheckEpisodeInsert(IEpisode episode, ref TimeWindow feasibleWindow)
 {
     throw new NotImplementedException();
 }
示例#49
0
 public static bool AreEqual(this IEpisodeModel model, IEpisode entity)
 {
     return(Mapper.AreEqual(model, entity));
 }
示例#50
0
 //Uppdaterar textfältet med avsnittsdetaljer
 private void UpdateEpisodeDetails(IEpisode episode)
 {
     lbEpisodeDetails.Text      = episode.Name;
     txtEpisodeDescription.Text = episode.Description;
 }
示例#51
0
文件: Schedule.cs 项目: lunaxi7/XTMF
 /// <summary>
 /// Checks to see if an episode can be inserted, and does if it can
 /// </summary>
 public abstract bool CheckEpisodeInsert(IEpisode episode, ref TimeWindow feasibleWindow);
示例#52
0
 public override bool CheckEpisodeInsert(IEpisode episode, ref TimeWindow feasibleWindow)
 {
     throw new NotImplementedException();
 }
示例#53
0
 public IZone GetLocation(IEpisode ep, Random random)
 {
     var episodes = ep.ContainingSchedule.Episodes;
     var startTime = ep.StartTime;
     int i = 0;
     for(; i < episodes.Length; i++)
     {
         if(episodes[i] == null) break;
         if(startTime < episodes[i].StartTime)
         {
             return GetLocation(ep, random, (i == 0 ? null : episodes[i - 1]), episodes[i], startTime);
         }
     }
     return GetLocation(ep, random, (i > 0 ? episodes[i - 1] : null), null, startTime);
 }
 protected bool Deactivate(IEpisode entity)
 {
     // Deactivate it
     EpisodesRepository.Deactivate(entity);
     // Try to Save Changes
     EpisodesRepository.SaveChanges();
     // Finished!
     return true;
 }
示例#55
0
 private static IZone GetZone(IEpisode otherEpisode, IEpisode inserting)
 {
     return otherEpisode == null ? inserting.Owner.Household.HomeZone : otherEpisode.Zone;
 }
 protected bool Remove(IEpisode entity)
 {
     if (entity == null) { return true; } // No entity found to remove, consider it passed
     // Remove it
     EpisodesRepository.Remove(entity);
     // Try to Save Changes
     EpisodesRepository.SaveChanges();
     // Finished!
     return true;
 }
示例#57
0
 private IZone GetLocation(IEpisode ep, Random random, IEpisode previous, IEpisode next, Time startTime)
 {
     var previousZone = GetZone(previous, ep);
     var nextZone = GetZone(next, ep);
     var calculationSpace = CalculationSpace;
     if(calculationSpace == null)
     {
         CalculationSpace = calculationSpace = new float[Root.ZoneSystem.ZoneArray.Count];
     }
     Time availableTime = ComputeAvailableTime(previous, next);
     switch(ep.ActivityType)
     {
         case Activity.Market:
         case Activity.JointMarket:
             return MarketModel.GetLocation(previousZone, ep, nextZone, startTime, availableTime, calculationSpace, random);
         case Activity.JointOther:
         case Activity.IndividualOther:
             return OtherModel.GetLocation(previousZone, ep, nextZone, startTime, availableTime, calculationSpace, random);
         case Activity.WorkBasedBusiness:
         case Activity.SecondaryWork:
             return WorkBasedBusinessModel.GetLocation(previousZone, ep, nextZone, startTime, availableTime, calculationSpace, random);
     }
     // if it isn't something that we understand just accept its previous zone
     return ep.Zone;
 }
示例#58
0
            /// <summary>
            /// 
            /// </summary>
            /// <param name="previousZone"></param>
            /// <param name="ep"></param>
            /// <param name="nextZone"></param>
            /// <param name="startTime"></param>
            /// <param name="availableTime"></param>
            /// <param name="calculationSpace"></param>
            /// <returns>The sum of the calculation space</returns>
            private float CalculateLocationProbabilities(IZone previousZone, IEpisode ep, IZone nextZone, Time startTime, Time availableTime, float[] calculationSpace)
            {
                var p = zoneSystem.GetFlatIndex(previousZone.ZoneNumber);
                var n = zoneSystem.GetFlatIndex(nextZone.ZoneNumber);
                var size = zones.Length;
                int index = GetTimePeriod(startTime);
                var rowTimes = Parent.TimePeriods[index].RowTravelTimes;
                var columnTimes = Parent.TimePeriods[index].ColumnTravelTimes;
                var from = From[index];
                var available = availableTime.ToMinutes();
                var to = To[index];
                var pIndex = FlatZoneToPDCubeLookup[p];
                var nIndex = FlatZoneToPDCubeLookup[n];
                var data = PDCube[index][pIndex][nIndex];
                int previousIndexOffset = p * size;
                int nextIndexOffset = n * size;
                float total = 0.0f;
                if (Vector.IsHardwareAccelerated)
                {
                    Vector<float> availableTimeV = new Vector<float>(available);
                    Vector<float> totalV = Vector<float>.Zero;
                    int i = 0;
                    if (nIndex == pIndex)
                    {
                        for (i = 0; i < calculationSpace.Length; i++)
                        {
                            var odUtility = 1.0f;
                            var pdindex = data[FlatZoneToPDCubeLookup[i]];
                            if (pdindex >= 0)
                            {
                                odUtility = (pIndex == FlatZoneToPDCubeLookup[i]) ? TimePeriod[index].ODConstants[pdindex].ExpConstant * TimePeriod[index].expSamePD
                                    : TimePeriod[index].ODConstants[pdindex].ExpConstant;
                            }
                            else
                            {
                                odUtility = (pIndex == FlatZoneToPDCubeLookup[i]) ? TimePeriod[index].expSamePD : 1.0f;
                            }
                            calculationSpace[i] = odUtility;
                        }
                    }
                    else
                    {
                        for (i = 0; i < calculationSpace.Length; i++)
                        {
                            var pdindex = data[FlatZoneToPDCubeLookup[i]];
                            calculationSpace[i] = pdindex >= 0 ? TimePeriod[index].ODConstants[pdindex].ExpConstant : 1f;
                        }
                    }

                    for (i = 0; i <= calculationSpace.Length - Vector<float>.Count; i += Vector<float>.Count)
                    {
                        var timeTo = new Vector<float>(rowTimes, previousIndexOffset + i);
                        var timeFrom = new Vector<float>(columnTimes, nextIndexOffset + i);
                        var utilityTo = new Vector<float>(to, previousIndexOffset + i);
                        var utilityFrom = new Vector<float>(from, nextIndexOffset + i);
                        Vector<float> calcV = new Vector<float>(calculationSpace, i);
                        Vector<int> zeroMask = Vector.LessThanOrEqual(timeTo + timeFrom, availableTimeV);
                        calcV = Vector.AsVectorSingle(Vector.BitwiseAnd(Vector.AsVectorInt32(calcV), zeroMask))
                            * utilityTo * utilityFrom;
                        calcV.CopyTo(calculationSpace, i);
                        totalV += calcV;
                    }
                    float remainderTotal = 0.0f;
                    for (; i < calculationSpace.Length; i++)
                    {
                        if (rowTimes[previousIndexOffset + i] + columnTimes[nextIndexOffset + i] <= available)
                        {
                            remainderTotal += (calculationSpace[i] = to[previousIndexOffset + i] * from[nextIndexOffset + i] * calculationSpace[i]);
                        }
                        else
                        {
                            calculationSpace[i] = 0;
                        }
                    }
                    total += remainderTotal + Vector.Dot(totalV, Vector<float>.One);
                }
                else
                {
                    unsafe
                    {
                        fixed (float* pRowTimes = &rowTimes[0])
                        fixed (float* pColumnTimes = &columnTimes[0])
                        fixed (float* pTo = &to[0])
                        fixed (float* pFrom = &from[0])
                        fixed (int* pData = &data[0])
                        {
                            if (nIndex == pIndex)
                            {
                                for (int i = 0; i < calculationSpace.Length; i++)
                                {
                                    if (pRowTimes[previousIndexOffset + i] + pColumnTimes[nextIndexOffset + i] <= available)
                                    {
                                        var odUtility = 1.0f;
                                        var pdindex = pData[FlatZoneToPDCubeLookup[i]];
                                        if (pdindex >= 0)
                                        {
                                            odUtility = (pIndex == FlatZoneToPDCubeLookup[i]) ?
                                                TimePeriod[index].ODConstants[pdindex].ExpConstant * TimePeriod[index].expSamePD
                                                : TimePeriod[index].ODConstants[pdindex].ExpConstant;
                                        }
                                        else
                                        {
                                            odUtility = (pIndex == FlatZoneToPDCubeLookup[i]) ? TimePeriod[index].expSamePD : 1.0f;
                                        }
                                        total += calculationSpace[i] = pTo[previousIndexOffset + i] * pFrom[nextIndexOffset + i] * odUtility;
                                    }
                                    else
                                    {
                                        calculationSpace[i] = 0;
                                    }
                                }
                            }
                            else
                            {
                                for (int i = 0; i < calculationSpace.Length; i++)
                                {
                                    if (pRowTimes[previousIndexOffset + i] + pColumnTimes[nextIndexOffset + i] <= available)
                                    {
                                        var odUtility = 1.0f;
                                        var pdindex = pData[FlatZoneToPDCubeLookup[i]];
                                        if (pdindex >= 0)
                                        {
                                            odUtility = TimePeriod[index].ODConstants[pdindex].ExpConstant;
                                        }
                                        total += calculationSpace[i] = pTo[previousIndexOffset + i] * pFrom[nextIndexOffset + i] * odUtility;
                                    }
                                    else
                                    {
                                        calculationSpace[i] = 0;
                                    }
                                }
                            }
                        }
                    }
                }
                return total;
            }
 /// <summary>
 /// we assume that the new episode has more up-to-date information
 /// but we dont want to lose any info that is not retrieved automatically
 /// such as file path so we will only merge what we safely can
 /// </summary>
 /// <param name="origEp">original episode</param>
 /// <param name="newEp">new episode</param>
 private void MergeEpisodes(Episode origEp, IEpisode newEp)
 {
     origEp.AiringDateTime = newEp.AiringDateTime;
     if (string.IsNullOrEmpty(origEp.Description))
         origEp.Description = newEp.Description;
     if (origEp.DetailsURI == null )
         origEp.DetailsURI = newEp.DetailsURI;
     if (origEp.File == null)
         origEp.File = newEp.File;
     origEp.Title = newEp.Title;
 }
示例#60
0
 public IZone GetLocation(IEpisode ep, Random random)
 {
     switch ( ep.ActivityType )
     {
         case Activity.Market:
         case Activity.JointMarket:
         case Activity.IndividualOther:
         case Activity.JointOther:
         case Activity.WorkAtHomeBusiness:
             return GetLocationHomeBased( ep.ActivityType, ep.Owner.Household.HomeZone, random );
         case Activity.WorkBasedBusiness:
             return GetLocationWorkBased( ep.Owner.EmploymentZone, ep.Owner, random );
         default:
             return ep.Zone;
     }
 }