private void CreateDelayedAlert(Alert alert, AlertEventType eventType, SPItemEventProperties properties, AlertManager alertManager)
 {
     //, SPWeb web
     try
     {
         if (!alert.SendAsSingleMessage)
         {
             Notifications notificationSender = new Notifications();
             //Need to get the Alert instances
             MailTemplateUsageObject mtObject = alert.GetMailTemplateUsageObjectForEventType(eventType);
             //string subject = mtObject.Template.Subject;
             //string body = mtObject.Template.Body + "<br>" + "<br>" + FinalBody;
             string       subject      = notificationSender.ReplacePlaceHolders(mtObject.Template.Subject, properties.ListItem);
             string       body         = notificationSender.ReplacePlaceHolders(mtObject.Template.Body, properties.ListItem) + "<br>" + "<br>" + FinalBody;
             string       parentItemId = Convert.ToString(properties.ListItem.ID);
             DelayedAlert dAlert       = new DelayedAlert(subject, body, alert.Id, parentItemId, eventType);
             alertManager.AddDelayedAlert(dAlert);
         }
         else
         {
             Notifications           notificationSender = new Notifications();
             MailTemplateUsageObject mtObject           = alert.GetMailTemplateUsageObjectForEventType(eventType);
             string       subject      = properties.ListTitle;
             string       body         = notificationSender.ReplacePlaceHolders(mtObject.Template.Subject, properties.ListItem) + "<br>" + "<br>" + notificationSender.ReplacePlaceHolders(mtObject.Template.Body, properties.ListItem) + "<br>" + "<br>" + FinalBody;
             string       parentItemId = Convert.ToString(properties.ListItem.ID);
             DelayedAlert dAlert       = new DelayedAlert(subject, body, alert.Id, parentItemId, eventType);
             alertManager.AddDelayedAlert(dAlert);
         }
     }
     catch { }
 }
Exemplo n.º 2
0
 internal void ExecuteDelayedMessages(Alert alert)
 {
     try
     {
         SPQuery query = new SPQuery();
         query.Query = string.Format("<Where><Eq><FieldRef Name=\"{0}\" LookupId=\"TRUE\"/><Value Type=\"Lookup\">{1}</Value></Eq></Where>", "Alert", alert.Id);
         SPListItemCollection items = this.delayedAlertList.GetItems(query);
         if (items.Count > 0)
         {
             foreach (SPListItem item in items)
             {
                 try
                 {
                     try
                     {
                         if (alert.SendAsSingleMessage)
                         {
                             DelayedAlert  delayedAlert       = new DelayedAlert(item);
                             Notifications notificationSender = new Notifications();
                             SendDelayedMessage2(delayedAlert, alert, item);
                         }
                         else
                         {
                             DelayedAlert  delayedAlert       = new DelayedAlert(item);
                             Notifications notificationSender = new Notifications();
                             notificationSender.SendDelayedMessage(delayedAlert, alert, item);
                         }
                     }
                     catch
                     {
                     }
                     continue;
                 }
                 finally
                 {
                     try
                     {
                         //Delete the delayed alert after completion
                     }
                     catch { }
                 }
             }
             if (alert.SendAsSingleMessage)
             {
                 SendMail(smtpSName, toAddress, fromAddress, ccAddress, subject, body, null);
             }
         }
         else
         {
             //No delayed alert found in the Delayed alert list
         }
     }
     catch
     {  }
 }
Exemplo n.º 3
0
        internal void SendDelayedMessage(DelayedAlert delayedAlert, Alert alert, SPListItem item)
        {
            try
            {
                MailTemplateUsageObject mtObject = alert.GetMailTemplateUsageObjectForEventType(delayedAlert.AlertType);
                string toAddress   = GetRecipientEmailAddresses(alert.ToAddress, item);
                string ccAddress   = GetRecipientEmailAddresses(alert.CcAddress, item);
                string fromAddress = GetRecipientEmailAddresses(alert.FromAdderss, item);
                string subject     = delayedAlert.Subject;
                string body        = delayedAlert.Body;
                //string subject = ReplacePlaceHolders(mtObject.Template.Subject, item);
                //string body = ReplacePlaceHolders(mtObject.Template.Body, item);
                string smtpSName = GetSMTPServer(item);
                SendMail(smtpSName,
                         toAddress,
                         fromAddress,
                         ccAddress,
                         subject,
                         body,
                         null);
            }
            catch { }
            //try
            //{
            //    SPListItem item = null;
            //    using (SPSite site = new SPSite(this.siteCollectionURL))
            //    {
            //        site.CatchAccessDeniedException = false;
            //        try
            //        {
            //            using (SPWeb web = site.OpenWeb(alert.WebId))
            //            {
            //               // item = ScanningUtilities.GetItemFromList(web, alert.ListId, delayedAlert.Item.ID);
            //                //if (item == null)
            //                {
            //                    item = delayedAlert.Item;
            //                }

            //            }
            //        }
            //        catch
            //        {
            //            item = delayedAlert.Item;
            //        }

            //    }
            //}
            //catch
            //{
            //}
        }
Exemplo n.º 4
0
        internal void SendDelayedMessage(DelayedAlert delayedAlert, Alert alert, SPListItem item)
        {
            try
            {               
                MailTemplateUsageObject mtObject = alert.GetMailTemplateUsageObjectForEventType(delayedAlert.AlertType);
                string toAddress = GetRecipientEmailAddresses(alert.ToAddress, item);
                string ccAddress = GetRecipientEmailAddresses(alert.CcAddress, item);
                string fromAddress = GetRecipientEmailAddresses(alert.FromAdderss, item);
                string subject = delayedAlert.Subject;
                string body = delayedAlert.Body;
                //string subject = ReplacePlaceHolders(mtObject.Template.Subject, item);
                //string body = ReplacePlaceHolders(mtObject.Template.Body, item);
                string smtpSName = GetSMTPServer(item);
                SendMail(smtpSName,
                         toAddress,
                         fromAddress,
                         ccAddress,
                         subject,
                         body,
                         null);
            }
            catch { }
            //try
            //{
            //    SPListItem item = null;
            //    using (SPSite site = new SPSite(this.siteCollectionURL))
            //    {
            //        site.CatchAccessDeniedException = false;
            //        try
            //        {
            //            using (SPWeb web = site.OpenWeb(alert.WebId))
            //            {
            //               // item = ScanningUtilities.GetItemFromList(web, alert.ListId, delayedAlert.Item.ID);
            //                //if (item == null)
            //                {
            //                    item = delayedAlert.Item;
            //                }

            //            }
            //        }
            //        catch 
            //        {
            //            item = delayedAlert.Item;
            //        }

            //    }
            //}
            //catch 
            //{
            //}
        }
Exemplo n.º 5
0
 internal void AddDelayedAlert(DelayedAlert dAlert)
 {
     try
     {
         SPListItem item = delayedAlertList.AddItem();
         item[ListAndFieldNames.DelayedSubjectFieldName]     = dAlert.Subject;
         item[ListAndFieldNames.DelayedBodyFieldName]        = dAlert.Body;
         item[ListAndFieldNames.DelayedEventTypeFieldName]   = dAlert.AlertType;
         item[ListAndFieldNames.DelayedAlertLookupFieldName] = dAlert.ParentAlertID + ";#" + dAlert.ParentAlertID;
         item[ListAndFieldNames.DelayedParentItemID]         = dAlert.ParentItemID;
         item.Update();
     }
     catch { }
 }
Exemplo n.º 6
0
        public void SendDelayedMessage2(DelayedAlert delayedAlert, Alert alert, SPListItem item)
        {
            Notifications notificationSender = new Notifications();

            try
            {
                MailTemplateUsageObject mtObject = alert.GetMailTemplateUsageObjectForEventType(delayedAlert.AlertType);
                toAddress   = notificationSender.GetRecipientEmailAddresses(alert.ToAddress, item);
                ccAddress   = notificationSender.GetRecipientEmailAddresses(alert.CcAddress, item);
                fromAddress = notificationSender.GetRecipientEmailAddresses(alert.FromAdderss, item);
                subject     = delayedAlert.Subject;
                body       += delayedAlert.Body;
                smtpSName   = notificationSender.GetSMTPServer(item);
                //SendMail(smtpSName,
                //         toAddress,
                //         fromAddress,
                //         ccAddress,
                //         subject,
                //         body,
                //         null);
            }
            catch { }
        }
Exemplo n.º 7
0
 public void SendDelayedMessage2(DelayedAlert delayedAlert, Alert alert, SPListItem item)
 {
     
     Notifications notificationSender = new Notifications();
     try
     {
         
         MailTemplateUsageObject mtObject = alert.GetMailTemplateUsageObjectForEventType(delayedAlert.AlertType);
         toAddress = notificationSender.GetRecipientEmailAddresses(alert.ToAddress, item);
         ccAddress = notificationSender.GetRecipientEmailAddresses(alert.CcAddress, item);
         fromAddress = notificationSender.GetRecipientEmailAddresses(alert.FromAdderss, item);
         subject = delayedAlert.Subject;
         body += delayedAlert.Body;
         smtpSName = notificationSender.GetSMTPServer(item);
         //SendMail(smtpSName,
         //         toAddress,
         //         fromAddress,
         //         ccAddress,
         //         subject,
         //         body,
         //         null);
     }
     catch { }
 }
Exemplo n.º 8
0
 internal void ExecuteDelayedMessages(Alert alert)
 {
     try
     {
         SPQuery query = new SPQuery();
         query.Query  = string.Format("<Where><Eq><FieldRef Name=\"{0}\" LookupId=\"TRUE\"/><Value Type=\"Lookup\">{1}</Value></Eq></Where>", "Alert", alert.Id);
         SPListItemCollection items = this.delayedAlertList.GetItems(query);
         if (items.Count > 0)
         {
             foreach (SPListItem item in items)
             {
                 try
                 {
                     try
                     {
                         if (alert.SendAsSingleMessage)
                         {
                             DelayedAlert delayedAlert = new DelayedAlert(item);
                             Notifications notificationSender = new Notifications();
                             SendDelayedMessage2(delayedAlert, alert,item);                          
                         }
                         else
                         {
                             DelayedAlert delayedAlert = new DelayedAlert(item);
                             Notifications notificationSender = new Notifications();
                             notificationSender.SendDelayedMessage(delayedAlert, alert,item);                            
                         }
                     }
                     catch 
                     {
                     }
                     continue;
                 }
                 finally
                 {
                     try
                     {
                         //Delete the delayed alert after completion
                     }
                     catch { }
                 }
             }
             if (alert.SendAsSingleMessage)
             {
                 SendMail(smtpSName, toAddress, fromAddress,ccAddress,subject,body,null);
             }
         }
         else
         {
             //No delayed alert found in the Delayed alert list
         }
     }
     catch
     {  }
 }
Exemplo n.º 9
0
 internal void AddDelayedAlert(DelayedAlert dAlert)
 {
     try
     {
         SPListItem item = delayedAlertList.AddItem();
         item[ListAndFieldNames.DelayedSubjectFieldName] = dAlert.Subject;
         item[ListAndFieldNames.DelayedBodyFieldName] = dAlert.Body;
         item[ListAndFieldNames.DelayedEventTypeFieldName] = dAlert.AlertType;
         item[ListAndFieldNames.DelayedAlertLookupFieldName] = dAlert.ParentAlertID + ";#" + dAlert.ParentAlertID;
         item[ListAndFieldNames.DelayedParentItemID] = dAlert.ParentItemID;
         item.Update();
     }
     catch { }
 }
 private void CreateDelayedAlert(Alert alert, AlertEventType eventType, SPItemEventProperties properties, AlertManager alertManager)
 {
     //, SPWeb web
     try
     {
         if (!alert.SendAsSingleMessage)
         {
             Notifications notificationSender = new Notifications();
             //Need to get the Alert instances
             MailTemplateUsageObject mtObject = alert.GetMailTemplateUsageObjectForEventType(eventType);
             //string subject = mtObject.Template.Subject;
             //string body = mtObject.Template.Body + "<br>" + "<br>" + FinalBody;
             string subject = notificationSender.ReplacePlaceHolders(mtObject.Template.Subject, properties.ListItem);
             string body = notificationSender.ReplacePlaceHolders(mtObject.Template.Body, properties.ListItem) + "<br>" + "<br>" + FinalBody;
             string parentItemId = Convert.ToString(properties.ListItem.ID);
             DelayedAlert dAlert = new DelayedAlert(subject, body, alert.Id, parentItemId, eventType);
             alertManager.AddDelayedAlert(dAlert);
         }
         else
         {
             Notifications notificationSender = new Notifications();
             MailTemplateUsageObject mtObject = alert.GetMailTemplateUsageObjectForEventType(eventType);
             string subject = properties.ListTitle;
             string body = notificationSender.ReplacePlaceHolders(mtObject.Template.Subject, properties.ListItem) + "<br>" + "<br>" +notificationSender.ReplacePlaceHolders(mtObject.Template.Body,properties.ListItem) + "<br>" + "<br>" + FinalBody;
             string parentItemId = Convert.ToString(properties.ListItem.ID);
             DelayedAlert dAlert = new DelayedAlert(subject, body, alert.Id, parentItemId, eventType);
             alertManager.AddDelayedAlert(dAlert);
         }
     }
     catch { }
 }