public int GetAccountRssWatchItemsCount(string ticket, int id) { using (SnCore.Data.Hibernate.Session.OpenConnection()) { ISession session = SnCore.Data.Hibernate.Session.Current; ManagedSecurityContext sec = new ManagedSecurityContext(session, ticket); ManagedAccountRssWatch rsswatch = new ManagedAccountRssWatch(session, id); return(rsswatch.GetSubscriptionUpdatesCount(sec)); } }
public TransitRssChannelItems GetAccountRssWatchItems(string ticket, int id, ServiceQueryOptions options) { using (SnCore.Data.Hibernate.Session.OpenConnection()) { ISession session = SnCore.Data.Hibernate.Session.Current; ManagedSecurityContext sec = new ManagedSecurityContext(session, ticket); ManagedAccountRssWatch rsswatch = new ManagedAccountRssWatch(session, id); TransitRssChannelItems result = rsswatch.GetSubscriptionUpdates(sec); result.Items = WebServiceQueryOptions <TransitRssItem> .Apply(options, result.Items); return(result); } }
public void RunSubscriptions(ISession session, ManagedSecurityContext sec) { IEnumerable <AccountRssWatch> rsswatchs = session.CreateQuery( "FROM AccountRssWatch AccountRssWatch" + " WHERE AccountRssWatch.Enabled = 1" + " AND DATEDIFF(hour, AccountRssWatch.Sent, getutcdate()) > AccountRssWatch.UpdateFrequency" + " ORDER BY AccountRssWatch.Sent ASC") .Enumerable <AccountRssWatch>(); IEnumerator <AccountRssWatch> enumerator = rsswatchs.GetEnumerator(); while (enumerator.MoveNext() && !IsStopping) { AccountRssWatch rsswatch = enumerator.Current; rsswatch.LastError = string.Empty; DateTime utcnow = DateTime.UtcNow; try { ManagedAccountRssWatch m_rsswatch = new ManagedAccountRssWatch(session, rsswatch); if (m_rsswatch.HasSubscriptionUpdates(sec)) { ManagedAccount ma = new ManagedAccount(session, rsswatch.Account); ManagedSiteConnector.TrySendAccountEmailMessageUriAsAdmin( session, ma, string.Format("AccountRssWatchView.aspx?id={0}", m_rsswatch.Id)); } } catch (ThreadAbortException) { throw; } catch (Exception ex) { rsswatch.LastError = ex.Message; } finally { rsswatch.Sent = utcnow; session.Save(rsswatch); session.Flush(); } Thread.Sleep(1000 * InterruptInterval); } }
public void RunSubscriptions(ISession session, ManagedSecurityContext sec) { IEnumerable<AccountRssWatch> rsswatchs = session.CreateQuery( "FROM AccountRssWatch AccountRssWatch" + " WHERE AccountRssWatch.Enabled = 1" + " AND DATEDIFF(hour, AccountRssWatch.Sent, getutcdate()) > AccountRssWatch.UpdateFrequency" + " ORDER BY AccountRssWatch.Sent ASC") .Enumerable<AccountRssWatch>(); IEnumerator<AccountRssWatch> enumerator = rsswatchs.GetEnumerator(); while (enumerator.MoveNext() && ! IsStopping) { AccountRssWatch rsswatch = enumerator.Current; rsswatch.LastError = string.Empty; DateTime utcnow = DateTime.UtcNow; try { ManagedAccountRssWatch m_rsswatch = new ManagedAccountRssWatch(session, rsswatch); if (m_rsswatch.HasSubscriptionUpdates(sec)) { ManagedAccount ma = new ManagedAccount(session, rsswatch.Account); ManagedSiteConnector.TrySendAccountEmailMessageUriAsAdmin( session, ma, string.Format("AccountRssWatchView.aspx?id={0}", m_rsswatch.Id)); } } catch (ThreadAbortException) { throw; } catch (Exception ex) { rsswatch.LastError = ex.Message; } finally { rsswatch.Sent = utcnow; session.Save(rsswatch); session.Flush(); } Thread.Sleep(1000 * InterruptInterval); } }
public TransitRssChannelItems GetAccountRssWatchItems(string ticket, int id, ServiceQueryOptions options) { using (SnCore.Data.Hibernate.Session.OpenConnection()) { ISession session = SnCore.Data.Hibernate.Session.Current; ManagedSecurityContext sec = new ManagedSecurityContext(session, ticket); ManagedAccountRssWatch rsswatch = new ManagedAccountRssWatch(session, id); TransitRssChannelItems result = rsswatch.GetSubscriptionUpdates(sec); result.Items = WebServiceQueryOptions<TransitRssItem>.Apply(options, result.Items); return result; } }
public int GetAccountRssWatchItemsCount(string ticket, int id) { using (SnCore.Data.Hibernate.Session.OpenConnection()) { ISession session = SnCore.Data.Hibernate.Session.Current; ManagedSecurityContext sec = new ManagedSecurityContext(session, ticket); ManagedAccountRssWatch rsswatch = new ManagedAccountRssWatch(session, id); return rsswatch.GetSubscriptionUpdatesCount(sec); } }