예제 #1
0
        /// <summary>
        /// Get the alerts changed after last sync
        /// </summary>
        /// <param name="since"></param>
        /// <returns></returns>
        internal Dictionary <int, Alert> GetAlertsChangesSince(DateTime since)
        {
            Dictionary <int, Alert> modifiedAlerts = new Dictionary <int, Alert>();

            try
            {
                if (since < alertList.Created || since < DateTime.UtcNow.AddDays(-60))
                {
                    //By default, the change log retains data for 60 days. You can configure the retention period by setting the ChangeLogRetentionPeriod property.
                    since = alertList.Created;

                    //since = DateTime.UtcNow.AddDays(-30);
                }

                //SPChangeToken startToken = new SPChangeToken(SPChangeCollection.CollectionScope.List, list.ID, DateTime.UtcNow);

                //SPChangeToken endToken = new SPChangeToken(SPChangeCollection.CollectionScope.List,list.ID, new DateTime(2008, 10, 18));



                SPChangeToken token = new SPChangeToken(SPChangeCollection.CollectionScope.List, this.alertList.ID, since.ToUniversalTime());
                //Dictionary<int,Alert> modifiedAlerts = new Dictionary<int,Alert>();
                foreach (SPChange change in alertList.GetChanges(token))
                {
                    if (!(change is SPChangeItem))
                    {
                        continue;
                    }
                    SPChangeItem item = change as SPChangeItem;
                    if (!modifiedAlerts.ContainsKey(item.Id))
                    {
                        Alert alert = null;
                        //if(item.ChangeType  != 3)
                        try
                        {
                            alert = new Alert(alertList.GetItemById(item.Id), new MailTemplateManager(alertList.ParentWeb));
                        }
                        catch
                        {
                            //item has been deleted
                        }

                        //if (alert != null && !alert.ImmidiateAlways)
                        //{
                        //    alert = null;
                        //}

                        modifiedAlerts.Add(item.Id, alert);
                    }
                    //Check if the alert is not immediate and all the stuff which are not eligible for timer based alerts
                }
            }
            catch { }
            return(modifiedAlerts);
        }
예제 #2
0
 protected virtual bool ShouldNotify(SPChangeItem change)
 {
     return(true);
 }
예제 #3
0
 protected override bool ShouldNotify(SPChangeItem change)
 {
     return(monitoredLists.Contains(change.ListId));
 }
예제 #4
0
 protected override bool ShouldNotify(SPChangeItem change)
 {
     return(change.ListId == listId);
 }