Example #1
0
 public int UpdateAccountFeedItems(string ticket, int id)
 {
     using (SnCore.Data.Hibernate.Session.OpenConnection())
     {
         ISession session            = SnCore.Data.Hibernate.Session.Current;
         ManagedSecurityContext sec  = new ManagedSecurityContext(session, ticket);
         ManagedAccountFeed     feed = new ManagedAccountFeed(session, id);
         int count = feed.Update(sec);
         SnCore.Data.Hibernate.Session.Flush();
         return(count);
     }
 }
        public void RunSyndication(ISession session, ManagedSecurityContext sec)
        {
            IQuery query = session.CreateSQLQuery(
                "SELECT {AccountFeed.*} FROM AccountFeed" +
                " WHERE (NOT EXISTS ( SELECT AccountFeedItem_Id FROM AccountFeedItem item WHERE item.AccountFeed_Id = AccountFeed.AccountFeed_Id ))" +
                " OR ( AccountFeed.LastError NOT LIKE '' )" +
                " OR ( DATEDIFF(hour, AccountFeed.Updated, getutcdate()) > AccountFeed.UpdateFrequency )" +
                " ORDER BY AccountFeed.Updated ASC")
                           .AddEntity("AccountFeed", typeof(AccountFeed));

            IList <AccountFeed> list = query.List <AccountFeed>();

            foreach (AccountFeed feed in list)
            {
                if (IsStopping)
                {
                    break;
                }

                try
                {
                    ManagedAccountFeed m_feed = new ManagedAccountFeed(session, feed);
                    if (IsDebug)
                    {
                        EventLogManager.WriteEntry(string.Format("Syndication service updating {0} ({1}).",
                                                                 feed.Name, feed.Id), EventLogEntryType.Information);
                    }
                    m_feed.Update(sec);
                    m_feed.UpdateImages(sec);
                    m_feed.UpdateMedias(sec);
                }
                catch (ThreadAbortException)
                {
                    throw;
                }
                catch (Exception ex)
                {
                    feed.LastError = ex.Message;
                    session.Save(feed);
                }

                session.Flush();
                Thread.Sleep(1000 * InterruptInterval);
            }
        }
        public void RunSyndication(ISession session, ManagedSecurityContext sec)
        {
            IQuery query = session.CreateSQLQuery(
                "SELECT {AccountFeed.*} FROM AccountFeed" +
                " WHERE (NOT EXISTS ( SELECT AccountFeedItem_Id FROM AccountFeedItem item WHERE item.AccountFeed_Id = AccountFeed.AccountFeed_Id ))" +
                " OR ( AccountFeed.LastError NOT LIKE '' )" +
                " OR ( DATEDIFF(hour, AccountFeed.Updated, getutcdate()) > AccountFeed.UpdateFrequency )" +
                " ORDER BY AccountFeed.Updated ASC")
            .AddEntity("AccountFeed", typeof(AccountFeed));

            IList<AccountFeed> list = query.List<AccountFeed>();

            foreach(AccountFeed feed in list)
            {
                if (IsStopping)
                    break;

                try
                {
                    ManagedAccountFeed m_feed = new ManagedAccountFeed(session, feed);
                    if (IsDebug)
                    {
                        EventLogManager.WriteEntry(string.Format("Syndication service updating {0} ({1}).",
                            feed.Name, feed.Id), EventLogEntryType.Information);
                    }
                    m_feed.Update(sec);
                    m_feed.UpdateImages(sec);
                    m_feed.UpdateMedias(sec);
                }
                catch (ThreadAbortException)
                {
                    throw;
                }
                catch (Exception ex)
                {
                    feed.LastError = ex.Message;
                    session.Save(feed);
                }

                session.Flush();
                Thread.Sleep(1000 * InterruptInterval);
            }
        }
Example #4
0
 public int UpdateAccountFeedItems(string ticket, int id)
 {
     using (SnCore.Data.Hibernate.Session.OpenConnection())
     {
         ISession session = SnCore.Data.Hibernate.Session.Current;
         ManagedSecurityContext sec = new ManagedSecurityContext(session, ticket);
         ManagedAccountFeed feed = new ManagedAccountFeed(session, id);
         int count = feed.Update(sec);
         SnCore.Data.Hibernate.Session.Flush();
         return count;
     }
 }