Exemple #1
0
        private bool ProcessDigestEventTargetList(INotificationEvent ne, IList <dynamic> payload)
        {
            bool          bResult      = false;
            int           itemCount    = 0;
            IDeliveryItem deliveryItem = EntityFactory.Create <IDeliveryItem>();

            deliveryItem.DeliverySystem = ne.DeliveryMethod;
            deliveryItem.Status         = DeliverySystems.DeliveryItemStatuses.ToBeProcessed;

            try
            {
                // Build Body
                foreach (dynamic item in payload)
                {
                    string body = null;
                    body = GenerateBody(item, ne.EmailTemplate);
                    deliveryItem.Body = String.Format("{0}{1}", deliveryItem.Body, body);
                    itemCount++;
                }

                // Build Subject
                deliveryItem.Subject = GenerateSubject(ne, itemCount);

                // Add Targets
                foreach (INotificationTarget target in ne.Targets)
                {
                    if (target.Target.Type == OwnerType.User)
                    {
                        IDeliveryItemTarget t = EntityFactory.Create <IDeliveryItemTarget>();
                        t.Type         = DeliverySystems.DeliveryItemTargetTypes.To;
                        t.Address      = target.Target.User.UserInfo.Email;
                        t.DeliveryItem = deliveryItem;
                        deliveryItem.DeliveryItemTargets.Add(t);
                    }
                    else
                    {
                        // Get 1st level of Team or Dept members
                        IList <string> emails = GetEmails(target.Target);

                        foreach (string email in emails)
                        {
                            IDeliveryItemTarget t = EntityFactory.Create <IDeliveryItemTarget>();
                            t.Type         = "TO";
                            t.Address      = email;
                            t.DeliveryItem = deliveryItem;
                            deliveryItem.DeliveryItemTargets.Add(t);
                        }
                    }
                }
                deliveryItem.Save();
                bResult = true;
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message);
            }
            return(bResult);
        }
        private void WeeklyForecastSummary(IBulletin bulletin)
        {
            DateTime        today = DateTime.UtcNow;
            ForecastSummary fs    = new ForecastSummary();

            Progress = 0;
            decimal counter = 0;

            using (var session = new SessionScopeWrapper())
            {
                IList <IForecast> forecasts = session.QueryOver <IForecast>()
                                              .Where(x => today >= x.BeginDate && today <= x.EndDate && x.Active == true)
                                              .List <IForecast>();

                foreach (IForecast f in forecasts)
                {
                    ForecastInfo fi = new ForecastInfo();
                    fi.ForecastName = f.Description;
                    fi.AssignedTo   = f.AssignedTo.UserInfo.NameLF;
                    fi.Amount       = Convert.ToDecimal(f.Amount);
                    fi.Pipeline     = (decimal)f.PeriodPipelineAmt("Avg");
                    fi.ClosedWon    = (decimal)f.PeriodClosedWonAmt();
                    fi.Quota        = GetQuotaAmtforUser(f.AssignedTo, today);

                    fs.forecasts.Add(fi);
                    Progress = (100M * ++counter / forecasts.Count) / 2;
                }
            }

            counter = 0;
            if (fs.forecasts.Count > 0)
            {
                string msgBody = BuildMessageBody(fs);
                string subject = "Weekly Forecast Summary";

                IDeliveryItem di = Sage.Platform.EntityFactory.Create <IDeliveryItem>();
                di.Body           = msgBody;
                di.Subject        = subject;
                di.DeliverySystem = bulletin.DeliverySystem;
                di.Status         = "To Be Processed";

                foreach (IBulletinSubscriber subscriber in bulletin.Subscribers)
                {
                    IDeliveryItemTarget target = EntityFactory.Create <IDeliveryItemTarget>();
                    target.DeliveryItem = di;
                    target.Address      = subscriber.Subscriber.UserInfo.Email;
                    target.Type         = "TO";
                    di.DeliveryItemTargets.Add(target);
                    di.Save();
                    Progress = 50M + (50M * ++counter / bulletin.Subscribers.Count);
                }
            }
        }
Exemple #3
0
        public void CreateDeliveryItem(string subject, string body, IDeliverySystem ds, IList <string> targets)
        {
            IDeliveryItem deliveryItem = EntityFactory.Create <IDeliveryItem>();

            deliveryItem.Subject        = subject;
            deliveryItem.Body           = body;
            deliveryItem.Status         = DeliverySystems.DeliveryItemStatuses.ToBeProcessed;
            deliveryItem.DeliverySystem = ds;

            foreach (string target in targets)
            {
                IDeliveryItemTarget t = EntityFactory.Create <IDeliveryItemTarget>();
                t.DeliveryItem = deliveryItem;
                t.Address      = target;
                t.Type         = DeliverySystems.DeliveryItemTargetTypes.To;
                deliveryItem.DeliveryItemTargets.Add(t);
            }
            deliveryItem.Save();
        }