Ejemplo n.º 1
0
        /// <summary>
        /// Fetch the contents of the current feed and store the items.
        /// </summary>
        public void FetchFeed()
        {
            try
            {
                ModuleLoader        moduleLoader = IoC.Resolve <ModuleLoader>();
                RemoteContentModule module       = moduleLoader.GetModuleFromSection(this._feed.Section) as RemoteContentModule;

                if (this._session == null)
                {
                    // Use in a different session, otherwise things go wrong because this method might
                    // run in a different thread.
                    ISessionFactory sessionFactory = IoC.Resolve <ISessionFactory>("nhibernate.factory");
                    using (ISession session = sessionFactory.OpenSession())
                    {
                        UpdateFeed(session, module, this._feed);
                        session.Close();
                    }
                }
                else
                {
                    UpdateFeed(this._session, module, this._feed);
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.Message, ex);
            }
        }
Ejemplo n.º 2
0
 private void UpdateFeed(ISession session, RemoteContentModule module, Feed feed)
 {
     using (ITransaction tx = session.BeginTransaction())
     {
         try
         {
             session.Lock(feed, LockMode.None);
             module.RefreshFeedContents(feed);
             session.Update(feed);
             tx.Commit();
         }
         catch
         {
             tx.Rollback();
             throw;
         }
     }
 }
Ejemplo n.º 3
0
 private void UpdateFeed(ISession session, RemoteContentModule module, Feed feed)
 {
     using (ITransaction tx = session.BeginTransaction())
     {
         try
         {
             session.Lock(feed, LockMode.None);
             module.RefreshFeedContents(feed);
             session.Update(feed);
             tx.Commit();
         }
         catch
         {
             tx.Rollback();
             throw;
         }
     }
 }