コード例 #1
0
 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));
     }
 }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
 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;
     }
 }
コード例 #6
0
 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);
     }
 }