示例#1
0
        public override void Delete(ManagedSecurityContext sec)
        {
            ManagedAccountGroup m_group = new ManagedAccountGroup(Session, mInstance.AccountGroup);

            m_group.Leave(mInstance.Account.Id, sec);
            // delete group subscription
            AccountRssWatch watch = GetGroupRssWatch();

            if (watch != null)
            {
                Session.Delete(watch);
            }
            base.Delete(sec);
        }
示例#2
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);
            }
        }