Beispiel #1
0
        /// <summary>
        /// Check if there have been and data changes.
        /// </summary>
        /// <param name="oldParameters">The original parameter values.</param>
        /// <returns>HasChanged if the data has changed; NotChanged otherwise.</returns>
        public DataState HasDataChanged(RunParameters oldParameters)
        {
            if (parameterSet == ParameterSet.Collector)
            {
                if (SelectedTuners.Count != oldParameters.SelectedTuners.Count)
                    return (DataState.Changed);

                foreach (int tuner in SelectedTuners)
                {
                    if (!oldParameters.SelectedTuners.Contains(tuner))
                        return (DataState.Changed);
                }
            }

            if (outputFileName != oldParameters.OutputFileName)
                return (DataState.Changed);
            if (wmcImportName != oldParameters.WMCImportName)
                return(DataState.Changed);
            if (maxService != oldParameters.MaxService)
                return(DataState.Changed);
            if (frequencyTimeout != oldParameters.FrequencyTimeout)
                return (DataState.Changed);
            if (lockTimeout != oldParameters.LockTimeout)
                return (DataState.Changed);
            if (repeats != oldParameters.Repeats)
                return (DataState.Changed);
            if (countryCode != oldParameters.CountryCode)
                return (DataState.Changed);
            if (region != oldParameters.Region)
                return (DataState.Changed);
            if (inputLanguage != oldParameters.InputLanguage)
                return (DataState.Changed);
            if (outputLanguage != oldParameters.OutputLanguage)
                return (DataState.Changed);
            if (timeZoneSet != oldParameters.TimeZoneSet)
                return (DataState.Changed);
            if (timeZone != oldParameters.TimeZone)
                return (DataState.Changed);
            if (nextTimeZone != oldParameters.NextTimeZone)
                return (DataState.Changed);
            if (nextTimeZoneChange != oldParameters.NextTimeZoneChange)
                return (DataState.Changed);

            if ((options == null && oldParameters.Options != null) || (options != null && oldParameters.Options == null))
                return (DataState.Changed);

            if (options != null)
            {
                if (options.Count != oldParameters.Options.Count)
                    return (DataState.Changed);

                foreach (string option in options)
                {
                    if (!oldParameters.Options.Contains(option))
                        return (DataState.Changed);
                }
            }

            if ((traceIDs == null && oldParameters.TraceIDs != null) || (traceIDs != null && oldParameters.TraceIDs == null))
                return (DataState.Changed);

            if (traceIDs != null)
            {
                if (traceIDs.Count != oldParameters.TraceIDs.Count)
                    return (DataState.Changed);

                foreach (string traceID in traceIDs)
                {
                    if (!oldParameters.TraceIDs.Contains(traceID))
                        return (DataState.Changed);
                }
            }

            if ((debugIDs == null && oldParameters.DebugIDs != null) || (debugIDs != null && oldParameters.DebugIDs == null))
                return (DataState.Changed);

            if (debugIDs != null)
            {
                if (debugIDs.Count != oldParameters.DebugIDs.Count)
                    return (DataState.Changed);

                foreach (string debugID in debugIDs)
                {
                    if (!oldParameters.DebugIDs.Contains(debugID))
                        return (DataState.Changed);
                }
            }

            if (tsFileName != oldParameters.TSFileName)
                return (DataState.Changed);
            if (channelBouquet != oldParameters.ChannelBouquet)
                return (DataState.Changed);
            if (channelRegion != oldParameters.ChannelRegion)
                return (DataState.Changed);
            if (diseqcIdentity != oldParameters.DiseqcIdentity)
                return (DataState.Changed);
            if (eitPid != oldParameters.EITPid)
                return (DataState.Changed);

            if ((mhw1Pids == null && oldParameters.MHW1Pids != null) || (mhw1Pids != null && oldParameters.MHW1Pids == null))
                return (DataState.Changed);

            if (mhw1Pids != null)
            {
                if (mhw1Pids.Length != oldParameters.MHW1Pids.Length)
                    return (DataState.Changed);

                foreach (int newPid in mhw1Pids)
                {
                    bool found = false;
                    foreach (int oldPid in oldParameters.MHW1Pids)
                    {
                        if (oldPid == newPid)
                            found = true;
                    }
                    if (!found)
                        return (DataState.Changed);
                }
            }

            if ((mhw2Pids == null && oldParameters.MHW2Pids != null) || (mhw2Pids != null && oldParameters.MHW2Pids == null))
                return (DataState.Changed);

            if (mhw2Pids != null)
            {
                if (mhw2Pids.Length != oldParameters.MHW2Pids.Length)
                    return (DataState.Changed);

                foreach (int newPid in mhw2Pids)
                {
                    bool found = false;
                    foreach (int oldPid in oldParameters.MHW2Pids)
                    {
                        if (oldPid == newPid)
                            found = true;
                    }
                    if (!found)
                        return (DataState.Changed);
                }
            }

            if (parameterSet == ParameterSet.Plugin)
            {
                if (pluginFrequency != null)
                {
                    if (pluginFrequency.GetType().FullName != oldParameters.pluginFrequency.GetType().FullName)
                        return (DataState.Changed);
                    else
                    {
                        if (pluginFrequency != null)
                        {
                            if (pluginFrequency.Provider.Name != oldParameters.pluginFrequency.Provider.Name)
                                return (DataState.Changed);
                            if (pluginFrequency.Frequency != oldParameters.pluginFrequency.Frequency)
                                return (DataState.Changed);
                            if (pluginFrequency.CollectionType != oldParameters.pluginFrequency.CollectionType)
                                return (DataState.Changed);
                        }
                    }
                }
            }
            else
            {
                if (originalStations.Count != TVStation.StationCollection.Count)
                    return (DataState.Changed);

                foreach (TVStation originalStation in originalStations)
                {
                    TVStation newStation = TVStation.FindStation(originalStation.OriginalNetworkID, originalStation.TransportStreamID, originalStation.ServiceID);
                    if (newStation == null)
                        return (DataState.Changed);
                    else
                    {
                        if (!originalStation.EqualTo(newStation))
                            return (DataState.Changed);
                    }
                }

                if (originalFrequencies.Count != TuningFrequency.FrequencyCollection.Count)
                    return (DataState.Changed);

                for (int index = 0; index < originalFrequencies.Count; index++)
                {
                    if (!originalFrequencies[index].EqualTo(TuningFrequency.FrequencyCollection[index]))
                        return (DataState.Changed);
                }
            }

            if (originalTimeOffsets.Count != TimeOffsetChannel.Channels.Count)
                return (DataState.Changed);

            foreach (TimeOffsetChannel oldOffset in originalTimeOffsets)
            {
                TimeOffsetChannel newOffset = TimeOffsetChannel.Channels[originalTimeOffsets.IndexOf(oldOffset)];

                if (oldOffset.SourceChannel.Name != newOffset.SourceChannel.Name ||
                    oldOffset.DestinationChannel.Name != newOffset.DestinationChannel.Name ||
                    oldOffset.Offset != newOffset.Offset)
                    return (DataState.Changed);
            }

            if ((originalFilters == null && ChannelFilterEntry.ChannelFilters != null) ||
                originalFilters != null && ChannelFilterEntry.ChannelFilters == null)
                return(DataState.Changed);

            if (originalFilters != null)
            {
                if (originalFilters.Count != ChannelFilterEntry.ChannelFilters.Count)
                    return(DataState.Changed);

                foreach (ChannelFilterEntry oldFilterEntry in originalFilters)
                {
                    ChannelFilterEntry newFilterEntry = ChannelFilterEntry.ChannelFilters[originalFilters.IndexOf(oldFilterEntry)];
                    if (oldFilterEntry.OriginalNetworkID != newFilterEntry.OriginalNetworkID ||
                        oldFilterEntry.TransportStreamID != newFilterEntry.TransportStreamID ||
                        oldFilterEntry.StartServiceID != newFilterEntry.StartServiceID ||
                        oldFilterEntry.EndServiceID != newFilterEntry.EndServiceID)
                        return(DataState.Changed);
                }
            }

            if (originalRepeatExclusions != null)
            {
                if (originalRepeatExclusions.Count != RepeatExclusion.Exclusions.Count)
                    return (DataState.Changed);

                foreach (RepeatExclusion oldRepeatExclusion in originalRepeatExclusions)
                {
                    RepeatExclusion newRepeatExclusion = RepeatExclusion.Exclusions[originalRepeatExclusions.IndexOf(oldRepeatExclusion)];
                    if (oldRepeatExclusion.Title != newRepeatExclusion.Title ||
                        oldRepeatExclusion.Description != newRepeatExclusion.Description)
                        return (DataState.Changed);
                }
            }

            if (originalPhrasesToIgnore != null)
            {
                if (originalPhrasesToIgnore.Count != RepeatExclusion.PhrasesToIgnore.Count)
                    return (DataState.Changed);

                foreach (string oldPhrase in originalPhrasesToIgnore)
                {
                    if (RepeatExclusion.PhrasesToIgnore[originalPhrasesToIgnore.IndexOf(oldPhrase)] != oldPhrase)
                        return (DataState.Changed);
                }
            }

            return (DataState.NotChanged);
        }
Beispiel #2
0
        /// <summary>
        /// Create a copy of this instance.
        /// </summary>
        /// <returns>A new instance with the same properties as the current instance.</returns>
        public RunParameters Clone()
        {
            RunParameters newParameters = new RunParameters(parameterSet);

            if (parameterSet == ParameterSet.Collector)
            {
                if (selectedTuners != null)
                {
                    newParameters.selectedTuners = new Collection<int>();
                    foreach (int tuner in selectedTuners)
                        newParameters.selectedTuners.Add(tuner);
                }
            }

            newParameters.outputFileName = outputFileName;
            newParameters.wmcImportName = wmcImportName;
            newParameters.frequencyTimeout = frequencyTimeout;
            newParameters.lockTimeout = lockTimeout;
            newParameters.repeats = repeats;
            newParameters.countryCode = countryCode;
            newParameters.region = region;
            newParameters.inputLanguage = inputLanguage;
            newParameters.outputLanguage = outputLanguage;
            newParameters.timeZone = timeZone;
            newParameters.nextTimeZone = nextTimeZone;
            newParameters.nextTimeZoneChange = nextTimeZoneChange;
            newParameters.timeZoneSet = timeZoneSet;

            if (options != null)
            {
                newParameters.options = new Collection<string>();
                foreach (string option in options)
                    newParameters.options.Add(option);
            }

            if (traceIDs != null)
            {
                newParameters.traceIDs = new Collection<string>();
                foreach (string traceID in traceIDs)
                    newParameters.traceIDs.Add(traceID);
            }

            if (debugIDs != null)
            {
                newParameters.debugIDs = new Collection<string>();
                foreach (string debugID in debugIDs)
                    newParameters.debugIDs.Add(debugID);
            }

            newParameters.tsFileName = tsFileName;
            newParameters.channelBouquet = channelBouquet;
            newParameters.channelRegion = channelRegion;
            newParameters.diseqcIdentity = diseqcIdentity;
            newParameters.eitPid = eitPid;

            if (mhw1Pids != null)
                newParameters.mhw1Pids = (int[])mhw1Pids.Clone();

            if (mhw2Pids != null)
                newParameters.mhw2Pids = (int[])mhw2Pids.Clone();

            if (parameterSet == ParameterSet.Plugin)
            {
                if (pluginFrequency != null)
                    newParameters.pluginFrequency = pluginFrequency.Clone();
            }
            else
            {
                originalStations = new Collection<TVStation>();
                foreach (TVStation station in TVStation.StationCollection)
                    originalStations.Add(station.Clone());

                originalFrequencies = new Collection<TuningFrequency>();
                foreach (TuningFrequency frequency in TuningFrequency.FrequencyCollection)
                    originalFrequencies.Add(frequency.Clone());
            }

            originalTimeOffsets = new Collection<TimeOffsetChannel>();

            foreach (TimeOffsetChannel oldOffset in TimeOffsetChannel.Channels)
            {
                TimeOffsetChannel newOffset = new TimeOffsetChannel(oldOffset.SourceChannel, oldOffset.DestinationChannel, oldOffset.Offset);
                originalTimeOffsets.Add(newOffset);
            }

            if (ChannelFilterEntry.ChannelFilters == null)
                originalFilters = null;
            else
            {
                originalFilters = new Collection<ChannelFilterEntry>();

                foreach (ChannelFilterEntry oldFilterEntry in ChannelFilterEntry.ChannelFilters)
                {
                    ChannelFilterEntry newFilterEntry = new ChannelFilterEntry(oldFilterEntry.OriginalNetworkID,
                        oldFilterEntry.TransportStreamID, oldFilterEntry.StartServiceID, oldFilterEntry.EndServiceID);

                    originalFilters.Add(newFilterEntry);
                }
            }

            if (RepeatExclusion.Exclusions == null)
                originalRepeatExclusions = null;
            else
            {
                originalRepeatExclusions = new Collection<RepeatExclusion>();

                foreach (RepeatExclusion oldRepeatExclusion in RepeatExclusion.Exclusions)
                {
                    RepeatExclusion newRepeatExclusion = new RepeatExclusion(oldRepeatExclusion.Title, oldRepeatExclusion.Description);
                    originalRepeatExclusions.Add(newRepeatExclusion);
                }
            }

            if (RepeatExclusion.PhrasesToIgnore == null)
                originalPhrasesToIgnore = null;
            else
            {
                originalPhrasesToIgnore = new Collection<string>();

                foreach (string oldPhrase in RepeatExclusion.PhrasesToIgnore)
                    originalPhrasesToIgnore.Add(oldPhrase);
            }

            newParameters.MaxService = maxService;

            return (newParameters);
        }