Example #1
0
        public void CopyTo(AbstractSource outputSource)
        {
            outputSource.SetMetaData(this.MetaData);

            outputSource.SetProviderID(this.ProviderID);
            outputSource.SetSourceName(this.SourceName);
        }
Example #2
0
        /// <summary>
        /// Actual logic for checking for updates.
        /// This is usually run from separate threads by UpdateItems
        /// </summary>
        /// <param name="p"></param>
        /// <param name="s"></param>
        /// <param name="addedItems"></param>
        private void DoItemsCheck(IProvider p, AbstractSource s, List <IDataItem> addedItems)
        {
            try
            {
                DateTime start = DateTime.Now;

                var results = p.CheckForNewItems(s);

                if (results != null)
                {
                    results = dataStore.AddItems(results);
                    addedItems.AddRange(results);
                }

                DateTime end = DateTime.Now;

                TimeSpan ts = end - start;

                AddMessage(String.Format("Source: {0}, New Items: {1}, Total Time: {2}",
                                         s.GetDisplayName(),
                                         results == null ? 0 : results.Count,
                                         (int)ts.TotalSeconds + " seconds"));
            }
            catch (Exception e)
            {
                AddMessage(String.Format("Source: {0}, Error: {1}",
                                         s.GetDisplayName(), e.Message));
            }
        }
Example #3
0
        public AbstractSource AddSource(AbstractSource source)
        {
            if (sources.Contains(source))
            {
                throw new Exception("Source already exists.");
            }
            else if (source.ID != null)
            {
                throw new Exception("Source should not have ID");
            }
            else
            {
                try
                {
                    sources.Add(source);

                    DoInsertSource(source);

                    if (source.ID == null)
                    {
                        throw new Exception("Logic error, expected DataStore to set ID");
                    }
                }
                catch (Exception e)
                {
                    sources.RemoveAt(sources.Count - 1);
                    throw;
                }

                return(source);
            }
        }
Example #4
0
        public void RemoveSource(AbstractSource source)
        {
            bool removed = sources.Remove(source);

            if (removed)
            {
                RemoveFromDataStore(source);
            }
        }
Example #5
0
 public List <AbstractItem> CheckForNewItems(AbstractSource source)
 {
     if (this.providerId != source.ProviderID)
     {
         return(null); //throw new Exception(String.Format("Source is not supported by this provider."));
     }
     else
     {
         return(GetNewItems(source));
     }
 }
Example #6
0
 private bool IsEqual(AbstractSource that)
 {
     return(this.ProviderID == that.ProviderID &&
            this.SourceName == that.SourceName);
 }
Example #7
0
 public abstract void RemoveFromDataStore(AbstractSource source);
Example #8
0
 protected abstract void DoUpdateSource(AbstractSource source);
Example #9
0
 public void UpdateSource(AbstractSource source)
 {
     DoUpdateSource(source);
 }
Example #10
0
 /// <summary>
 /// Insert the Source into the actual data store.
 /// This function should set the ID on the source object
 /// </summary>
 /// <param name="source"></param>
 protected abstract void DoInsertSource(AbstractSource source);
Example #11
0
 public virtual AbstractSource CastSource(AbstractSource src)
 {
     return(src);
 }
Example #12
0
 public bool CanCheck(AbstractSource source)
 {
     return(source.ProviderID == this.providerId);
 }
Example #13
0
 protected abstract List <AbstractItem> GetNewItems(AbstractSource source);