Exemplo n.º 1
0
        protected void ImportParticipant(EventPageBase ep, string[] participantFields, string[] keys)
        {
            string email = "";
            Hashtable fieldsHashtable = new Hashtable();
            if(participantFields.Count() == keys.Count())
            for (int i = 0; i < keys.Count(); i++)
            {
                if(!fieldsHashtable.ContainsKey(keys[i]))
                    fieldsHashtable.Add(keys[i].ToLower(), participantFields[i]);
            }

            if (fieldsHashtable.ContainsKey("email"))
                email = fieldsHashtable["email"].ToString();
            else
                return;
            if(string.IsNullOrEmpty(email))
                return;

            XForm xform = ep.RegistrationForm;

            XFormData xFormData = xform.CreateFormData();

            PopulateChildNodeRecursive(fieldsHashtable, xFormData.Data.ChildNodes);
           

            string xformstring = xFormData.Data.InnerXml;
            StatusLiteral.Text += "Adding participant: " + email+"<br/>";
            AttendRegistrationEngine.GenerateParticipation(ep.ContentLink, email, false, xformstring,
                "Imported participant from text");
        }
Exemplo n.º 2
0
 public static SessionBlock GenerateSession(EventPageBase EventPageBase, string name, DateTime start, DateTime end)
 {
     var contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>();
     SessionBlock newSession = contentRepository.GetDefault<SessionBlock>(GetOrCreateSessionFolder(EventPageBase.ContentLink).ContentLink);
     newSession.Start = start;
     newSession.End = end;
     newSession.NumberOfSeats = EventPageBase.EventDetails.NumberOfSeats;
     newSession.EventPageBase = EventPageBase.ContentLink.ToPageReference();
     IContent newSessionContent = newSession as IContent;
     newSessionContent.Name = name;
     contentRepository.Save(newSessionContent, EPiServer.DataAccess.SaveAction.Publish, EPiServer.Security.AccessLevel.NoAccess);
     return newSession;
 }
Exemplo n.º 3
0
        protected string GetProgressBar(EventPageBase eventPageBase)
        {
            if (eventPageBase.EventDetails.Cancelled == true)
                return "<div class='progress-bar progress-bar-danger' style='width:100%;'></div>";

          
            if (ConfirmedParticipants() == 0)
                return "<div class='progress-bar progress-bar-info' style='width:100%;'></div>";

            return
                string.Format("<div class='progress-bar progress-bar-success' style='width:{0}%;'><div class='pull-right'>{1}&nbsp;</span></div></div>", Math.Round(((double)(ParticipatedParticipants()) / (double)ExpectedParticipants() * 100)), ParticipatedParticipants());

        }
Exemplo n.º 4
0
 public EmailSender(EventPageBase EventPageBase, EmailTemplateBlock emailTemplate)
 {
     CurrentEvent = EventPageBase;
     CurrentParticipant = null;
     Email = EmailTemplate.Load(emailTemplate, CurrentEvent, null);
 }
Exemplo n.º 5
0
        protected static string GetPropertyValue(string objectName, string propertyName, EventPageBase CurrentEvent, IParticipant CurrentParticipant)
        {
            object value = null;

            if (0 == String.Compare("CurrentPage", objectName, true))
            {
                if (0 == String.Compare(propertyName, "PageLinkUrl", true))
                {
                    string linkUrl = CurrentEvent.LinkURL;
                    UrlBuilder ub = new UrlBuilder(linkUrl);

                    Global.UrlRewriteProvider.ConvertToExternal(ub, CurrentEvent.PageLink, System.Text.Encoding.UTF8);

                    value = ub.ToString();
                }
                else
                {
                    value = CurrentEvent.Property[propertyName];
                }
            }
            else if (0 == String.Compare("CurrentRegistration", objectName, true))
            {
                value = AttendRegistrationEngine.GetParticipantInfo(CurrentParticipant, propertyName);
            }


            if (null == value)
                return "";
            else
                return value.ToString();
        }
Exemplo n.º 6
0
        public static string PopulatePropertyValues(string template, EventPageBase EventPageBase, IParticipant participant)
        {
            if (template != null)
            {
                template = EmailTemplate.databindPattern.Replace(template, delegate(Match m)
                {

                    string value = GetPropertyValue(m.Groups[1].Value, m.Groups[2].Value, EventPageBase, participant);

                    if (!String.IsNullOrEmpty(value))
                        value = EmailTemplate.xmlSafe.Replace(value, new MatchEvaluator(XmlSafe));

                    return value;
                });
            }
            return template;
        }
Exemplo n.º 7
0
        protected string GetProgressBar(EventPageBase EventPageBase)
        {
            if (EventPageBase.EventDetails.Cancelled == true)
                return "<div class='progress-bar progress-bar-danger' style='width:100%;'></div>";

            int numberOfSeats =
                BVNetwork.Attend.Business.API.AttendRegistrationEngine.GetNumberOfSeats(EventPageBase.PageLink);
            int availableSeats = BVNetwork.Attend.Business.API.AttendRegistrationEngine.GetAvailableSeats(EventPageBase.PageLink);

            if (availableSeats == 0)
                return "<div class='progress-bar progress-bar-info' style='width:100%;'></div>";

            return
                string.Format("<div class='progress-bar' style='width:{0}%;'><div class='pull-right'>{1}&nbsp;</span></div>", Math.Round(((double)(numberOfSeats - availableSeats) / (double)numberOfSeats) * 100), numberOfSeats - availableSeats);

        }
        public static DateTime GetSendDate(ScheduledEmailBlock scheduledEmailBlock, EventPageBase EventPageBase)
        {
            DateTime dateToSend = DateTime.Now;
            bool subtract = false;
            if (scheduledEmailBlock.EmailSendOptions == SendOptions.Specific)
                return scheduledEmailBlock.SpecificDateScheduled;
            if (scheduledEmailBlock.EmailSendOptions == SendOptions.Relative)
            {
                switch (scheduledEmailBlock.ScheduledRelativeTo)
                {
                    case RelativeTo.AfterEventStart:
                        subtract = false;
                        dateToSend = EventPageBase.EventDetails.EventStart;
                        break;

                    case RelativeTo.BeforeEventStart:
                        subtract = true;
                        dateToSend = EventPageBase.EventDetails.EventStart;
                        break;

                    case RelativeTo.AfterStartPublish:
                        subtract = false;
                        dateToSend = EventPageBase.StartPublish;
                        break;

                    case RelativeTo.BeforeStartPublish:
                        subtract = true;
                        dateToSend = EventPageBase.StartPublish;
                        break;

                }
                int amount = scheduledEmailBlock.ScheduledRelativeAmount;
                if (subtract)
                    amount = amount * -1;

                switch (scheduledEmailBlock.ScheduledRelativeUnit)
                {
                    case RelativeUnit.Days:
                        dateToSend = dateToSend.AddDays(amount);
                        break;
                    case RelativeUnit.Hours:
                        dateToSend = dateToSend.AddHours(amount);
                        break;
                    case RelativeUnit.Minutes:
                        dateToSend = dateToSend.AddMinutes(amount);
                        break;
                    case RelativeUnit.Months:
                        dateToSend = dateToSend.AddMonths(amount);
                        break;
                }
                return dateToSend;
            }
            return DateTime.MaxValue;
        }
 public static IEnumerable<ScheduledEmailBlock> GetScheduledEmailsToSend(EventPageBase eventPageBase, DateTime plannedAfterDate, DateTime plannedBeforeDate)
 {
     var scheduledEmailBlocks = GetScheduledEmails(eventPageBase);
     var scheduledEmailBlocksToSend = new List<ScheduledEmailBlock>();
     scheduledEmailBlocksToSend.AddRange((from x in scheduledEmailBlocks where x.SendDateTime < plannedBeforeDate && x.SendDateTime > plannedAfterDate && x.DateSent < new DateTime(1801, 01, 01) select x));
     return scheduledEmailBlocksToSend;
 }
Exemplo n.º 10
0
        public static void PasteParticipantsMove(EventPageBase destination)
        {
            foreach (IParticipant participantBlock in GetOrCreateParticipantsClipboard())
            {
                var participant = (participantBlock as ParticipantBlock).CreateWritableClone() as ParticipantBlock;
                participant.EventPage = (destination as IContent).ContentLink.ToPageReference();
                ServiceLocator.Current.GetInstance<IContentRepository>()
                    .Save(participant as IContent, SaveAction.Publish);
                Log.ParticipantLog.AddLogText("Move", "Moved from " + participantBlock.EventPage.ID + " to " + destination.ContentLink.ID, participant);

                ServiceLocator.Current.GetInstance<IContentRepository>()
                    .Move((participantBlock as IContent).ContentLink, GetOrCreateParticipantsFolder(destination.ContentLink).ContentLink, AccessLevel.NoAccess, AccessLevel.NoAccess);
            }
        }
Exemplo n.º 11
0
        public static void PasteParticipantsCopy(EventPageBase destination)
        {
            ///TODO: Rewrite
            /*
            foreach (ParticipantBlock participantBlock in GetOrCreateParticipantsClipboard())
            {

                var newParticipant = ServiceLocator.Current.GetInstance<IContentRepository>()
                    .Copy((participantBlock as IContent).ContentLink, GetOrCreateParticipantsFolder(destination.ContentLink).ContentLink, AccessLevel.NoAccess, AccessLevel.NoAccess, true);
                var participant = ServiceLocator.Current.GetInstance<IContentRepository>().Get<ParticipantBlock>(newParticipant).CreateWritableClone() as ParticipantBlock;
                participant.Code = GenerateCode();
                participant.Comment = participant.Comment + "Copied from " + participantBlock.EventPageBase.ID;
                participant.EventPageBase = (destination as IContent).ContentLink.ToPageReference();
                Log.ParticipantLog.AddLogText("Copy", "Copied from " + participantBlock.EventPageBase.ID + " to " + destination.ContentLink.ID, participant);
                ServiceLocator.Current.GetInstance<IContentRepository>()
                    .Save(participant as IContent, SaveAction.Publish);
            }
            CopyParticipantsRemoveAll();*/
        }
Exemplo n.º 12
0
        public static void Create(Stream template, IParticipant registration, EventPageBase pageData, System.IO.Stream outputStream)
        {
            try
            {
                PdfReader pr = new PdfReader(template);
                PdfStamper ps = new PdfStamper(pr, outputStream);

                AcroFields fields = ps.AcroFields;

                foreach (string fieldName in fields.Fields.Keys)
                {
                    string objectName;
                    string propertyName;

                    Match m = databindPattern.Match(fieldName);

                    if (!m.Success)
                    {
                        objectName = "CurrentRegistration";
                        propertyName = fieldName;
                    }
                    else
                    {
                        objectName = m.Groups[1].Value;
                        propertyName = m.Groups[2].Value;
                    }

                    

                    if (0 == String.Compare("CurrentRegistration", objectName, true))
                    {
                        if(!string.IsNullOrEmpty(pageData.EventDetails[propertyName] as string))
                            fields.SetField(fieldName, pageData.EventDetails[propertyName] as string);
                        if (!string.IsNullOrEmpty(pageData[propertyName] as string))
                            fields.SetField(fieldName, pageData[propertyName] as string);
                        if (!string.IsNullOrEmpty(AttendRegistrationEngine.GetParticipantInfo(registration, propertyName) as string))
                            fields.SetField(fieldName, AttendRegistrationEngine.GetParticipantInfo(registration, propertyName) as string);
                    }
                    else if (0 == String.Compare(objectName, "CurrentPage", true))
                    {
                        
                        if (0 == String.Compare(propertyName, "PageLinkUrl", true))
                        {
                            string linkUrl = pageData.LinkURL;
                            UrlBuilder ub = new UrlBuilder(linkUrl);

                            Global.UrlRewriteProvider.ConvertToExternal(ub, pageData.PageLink, System.Text.Encoding.UTF8);
                            fields.SetField(fieldName, ub.ToString());
                        }
                        else
                        {
                            if (pageData.EventDetails.Property[propertyName] != null && !string.IsNullOrEmpty(pageData.EventDetails.Property[propertyName].ToString()))
                                fields.SetField(fieldName, pageData.EventDetails[propertyName] as string);
                            else
                                fields.SetField(fieldName, pageData.Property[propertyName].ToString());
                        }
                    }
                    else
                    {
                        // unrecognized ObjectName, simply set ""
                        fields.SetField(fieldName, "");
                    }
                }


                ps.FormFlattening = true;
                ps.Close();

            }
            catch (Exception)
            {
            }
        }
        public static int UpdateEvent(EventPageBase EventPageBase)
        {
            var scheduledEmails =
                Attend.Business.API.AttendScheduledEmailEngine.GetAllEmails(EventPageBase.ContentLink);
            int cnt = 0;
            if (!ContainsStatusMail(scheduledEmails, AttendStatus.Submitted))
            {
                cnt++;
                CreateScheduledEmail(EventPageBase, AttendStatus.Submitted, EventPageBase["SubmitMailTemplate"] as EmailTemplateBlock, EventPageBase["SubmitMailTemplateBlock"] as ContentReference, "Submit mail template");
            }

            if (!ContainsStatusMail(scheduledEmails, AttendStatus.Confirmed))
            {
                cnt++;
                CreateScheduledEmail(EventPageBase, AttendStatus.Confirmed, EventPageBase["ConfirmMailTemplate"] as EmailTemplateBlock, EventPageBase["ConfirmMailTemplateBlock"] as ContentReference, "Confirm mail template");
            }

            if (!ContainsStatusMail(scheduledEmails, AttendStatus.Cancelled))
            {
                cnt++;
                CreateScheduledEmail(EventPageBase, AttendStatus.Cancelled, EventPageBase["CancelMailTemplate"] as EmailTemplateBlock, EventPageBase["CancelMailTemplateBlock"] as ContentReference, "Cancel mail template");
            }

            return cnt;

        }
        public static void CreateScheduledEmail(EventPageBase EventPageBase, AttendStatus status, EmailTemplateBlock emailTemplate, ContentReference emailTemplateContentReference, string name)
        {
            ScheduledEmailBlock emailBlock =
                API.AttendScheduledEmailEngine.GenerateScheduledEmailBlock(EventPageBase.ContentLink).CreateWritableClone() as ScheduledEmailBlock;
            emailBlock.EmailSendOptions = SendOptions.Action;
            emailBlock.SendOnStatus = status;
            emailBlock.EmailTemplate.BCC = emailTemplate.BCC;
            emailBlock.EmailTemplate.CC = emailTemplate.CC;
            emailBlock.EmailTemplate.From = emailTemplate.From;
            emailBlock.EmailTemplate.To = emailTemplate.To;
            emailBlock.EmailTemplate.Subject = emailTemplate.Subject;
            emailBlock.EmailTemplate.MainBody = emailTemplate.MainBody;
            emailBlock.EmailTemplate.MainTextBody = emailTemplate.MainTextBody;

            emailBlock.EmailTemplateContentReference = emailTemplateContentReference;

            (emailBlock as IContent).Name = name;

            DataFactory.Instance.Save(emailBlock as IContent, SaveAction.Publish);

        }
Exemplo n.º 15
0
 public static SessionBlock GenerateSession(EventPageBase EventPageBase)
 {
     return GenerateSession(EventPageBase, "New Session", EventPageBase.EventDetails.EventStart, EventPageBase.EventDetails.EventEnd);
 }
Exemplo n.º 16
0
        protected IEnumerable<ScheduledEmailBlock> GetScheduledEmailBlocks(EventPageBase EventPageBase)
        {
            return AttendScheduledEmailEngine.GetScheduledEmailsToSend(EventPageBase);

        }
Exemplo n.º 17
0
 public static IEnumerable<ScheduledEmailBlock> GetScheduledEmails(EventPageBase EventPageBase)
 {
     return (from e in GetAllEmails(EventPageBase.ContentLink) where (e.EmailSendOptions == SendOptions.Specific || e.EmailSendOptions == SendOptions.Relative) select e);
 }
Exemplo n.º 18
0
 public static string GetAvailableSeatsText(EventPageBase EventPageBase)
 {
     int available = GetAvailableSeats(EventPageBase.ContentLink);
     if (available > 3 && !string.IsNullOrEmpty(EventPageBase.AvailableSeatsText.ManyAvailableSeats))
         return string.Format(EventPageBase.AvailableSeatsText.ManyAvailableSeats, available);
     if (available == 3)
         return EventPageBase.AvailableSeatsText.ThreeSeats;
     if (available == 2)
         return EventPageBase.AvailableSeatsText.TwoSeats;
     if (available == 1)
         return EventPageBase.AvailableSeatsText.OneSeat;
     return string.Empty;
 }
Exemplo n.º 19
0
 public static IEnumerable<ScheduledEmailBlock> GetScheduledEmailsToSend(EventPageBase eventPageBase)
 {
     return GetScheduledEmailsToSend(eventPageBase, DateTime.MinValue, DateTime.Now);
 }
 public static IEnumerable<ScheduledEmailBlock> GetScheduledEmailsToSend(EventPageBase EventPageBase)
 {
     var scheduledEmailBlocks = (from e in GetScheduledEmails(EventPageBase.ContentLink) where (e.EmailSendOptions == SendOptions.Specific || e.EmailSendOptions == SendOptions.Relative) select e);
     var scheduledEmailBlocksToSend = new List<ScheduledEmailBlock>();
     foreach (ScheduledEmailBlock scheduledEmailBlock in scheduledEmailBlocks)
     {
         if (GetSendDate(scheduledEmailBlock, EventPageBase) < DateTime.Now && scheduledEmailBlock.DateSent < new DateTime(1801, 01, 01))
             scheduledEmailBlocksToSend.Add(scheduledEmailBlock);
     }
     return scheduledEmailBlocksToSend;
 }
Exemplo n.º 21
0
        private void ExtractFieldNames(EventPageBase EventPageBase)
        {
            if (EventPageBase.RegistrationForm == null)
                return;

            XForm xform = XForm.CreateInstance(new Guid(EventPageBase.RegistrationForm.Id.ToString()));
            NameValueCollection formControls = xform.CreateFormData().GetValues();
            foreach (string data in formControls)
            {
                if (!FieldsList.Contains(data))
                    FieldsList.Add(data);
            }
        }
Exemplo n.º 22
0
 public static EmailTemplate Load(EmailTemplateBlock template, EventPageBase EventPageBase, IParticipant participant)
 {
     EmailTemplate email = new EmailTemplate();
     email.HtmlBody = PopulatePropertyValues(template.MainBody != null ? template.MainBody.ToString() : string.Empty, EventPageBase, participant);
     email.Body = PopulatePropertyValues(template.MainTextBody, EventPageBase, participant);
     email.To = PopulatePropertyValues(template.To, EventPageBase, participant);
     email.From = PopulatePropertyValues(template.From, EventPageBase, participant);
     email.Cc = PopulatePropertyValues(template.CC, EventPageBase, participant);
     email.Bcc = PopulatePropertyValues(template.BCC, EventPageBase, participant);
     email.Subject = PopulatePropertyValues(template.Subject, EventPageBase, participant);
     email.Participant = participant;
     email.SendAsSms = template.SendAsSms;
     return email;
 }