public ParticipantMailPayload(ParticipantMailType mailType, Membership membership, Person actingPerson)
        {
            Strings = new SerializableDictionary <MailPayloadString, string>();

            switch (mailType)
            {
            case ParticipantMailType.MemberAddedWelcome:
                Strings[MailPayloadString.ActingPerson]     = actingPerson.Name;
                Strings[MailPayloadString.MembershipExpiry] = membership.Expires.ToLongDateString();
                Strings[MailPayloadString.OrganizationName] = membership.Organization.Name;
                Strings[MailPayloadString.Regularship]      =
                    Participant.Localized(membership.Organization.RegularLabel, TitleVariant.Ship);

                BodyTemplate =
                    App_GlobalResources.Logic_Communications_Transmission_DefaultCommTemplates
                    .ParticipantManualAddWelcome_Body;

                SubjectTemplate =
                    App_GlobalResources.Logic_Communications_Transmission_DefaultCommTemplates
                    .ParticipantManualAddWelcome_Subject;

                break;

            default:
                throw new NotImplementedException("Unknown mailType: " + mailType.ToString());
            }
        }
Exemple #2
0
        protected void ButtonSubmit_Click(object sender, EventArgs e)
        {
            DateTime dateOfBirth = new DateTime(1800, 1, 1);  // null equivalent

            if (this.TextDateOfBirth.Text.Length > 0)
            {
                dateOfBirth = DateTime.Parse(this.TextDateOfBirth.Text);
            }

            string street = this.TextStreet1.Text;

            if (!string.IsNullOrEmpty(this.TextStreet2.Text))
            {
                street += "|" + this.TextStreet2.Text;
            }

            Person newPerson = Person.Create(this.TextName.Text, this.TextMail.Text, string.Empty, this.TextPhone.Text,
                                             street, this.TextPostal.Text, this.TextCity.Text, this.DropCountries.SelectedValue, dateOfBirth,
                                             (PersonGender)Enum.Parse(typeof(PersonGender), this.DropGenders.SelectedValue));

            DateTime            participationExpiry = Constants.DateTimeHigh;
            ParticipantMailType welcomeMailType     = ParticipantMailType.ParticipantAddedWelcome_NoExpiry;

            int participationDurationMonths = Int32.Parse(CurrentOrganization.Parameters.ParticipationDuration);

            if (participationDurationMonths < 1000)
            {
                participationExpiry = DateTime.Today.AddMonths(participationDurationMonths);
                welcomeMailType     = ParticipantMailType.ParticipantAddedWelcome;
            }

            Participation newParticipation = Participation.Create(newPerson, CurrentOrganization, participationExpiry);

            OutboundComm.CreateParticipantMail(welcomeMailType, newParticipation, CurrentUser);

            newPerson.LastLogonOrganizationId = CurrentOrganization.Identity;

            SwarmopsLogEntry logEntry = SwarmopsLog.CreateEntry(newPerson,
                                                                new Swarmops.Logic.Support.LogEntries.PersonAddedLogEntry(newParticipation, CurrentUser));

            logEntry.CreateAffectedObject(newParticipation);
            logEntry.CreateAffectedObject(CurrentUser);

            // Clear form and make way for next person

            this.TextName.Text             = string.Empty;
            this.TextStreet1.Text          = string.Empty;
            this.TextStreet2.Text          = string.Empty;
            this.TextMail.Text             = string.Empty;
            this.TextPhone.Text            = string.Empty;
            this.TextPostal.Text           = string.Empty;
            this.TextCity.Text             = string.Empty;
            this.TextDateOfBirth.Text      = string.Empty;
            this.DropGenders.SelectedValue = "Unknown";

            this.TextName.Focus();
            this.LiteralLoadAlert.Text = Resources.Pages.Swarm.AddPerson_PersonSuccessfullyRegistered;
        }
Exemple #3
0
        public static OutboundComm CreateParticipantMail(ParticipantMailType mailType, Participation participation,
                                                         Person actingPerson)
        {
            List <Person> recipients = People.FromSingle(participation.Person);

            OutboundComm comm = OutboundComm.Create(null, null, participation.Organization,
                                                    null /* resolver */, null /*recipientdata*/,
                                                    CommTransmitterClass.CommsTransmitterMail,
                                                    new PayloadEnvelope(new ParticipantMailPayload(mailType, participation, actingPerson)).ToXml(),
                                                    OutboundCommPriority.Low);

            foreach (Person person in recipients)
            {
                comm.AddRecipient(person);
            }

            comm.Resolved = true;

            return(comm);
        }
Exemple #4
0
        public static OutboundComm CreateMembershipLetter(ParticipantMailType mailType, Membership membership,
                                                          Person actingPerson)
        {
            List <Person> recipients = People.FromSingle(membership.Person);

            OutboundComm comm = OutboundComm.Create(null, null, membership.Organization,
                                                    CommResolverClass.Unknown, null,
                                                    CommTransmitterClass.CommsTransmitterMail,
                                                    new PayloadEnvelope(new ParticipantMailPayload(mailType, membership, actingPerson)).ToXml(),
                                                    OutboundCommPriority.Low);

            foreach (Person person in recipients)
            {
                comm.AddRecipient(person);
            }

            comm.Resolved = true;

            return(comm);
        }
        public ParticipantMailPayload(ParticipantMailType mailType, Participation participation, Person actingPerson)
        {
            Strings = new SerializableDictionary <MailPayloadString, string>();

            switch (mailType)
            {
            case ParticipantMailType.ParticipantAddedWelcome:
            case ParticipantMailType.ParticipantAddedWelcome_NoExpiry:
                Strings[MailPayloadString.ActingPerson]     = actingPerson.Name;
                Strings[MailPayloadString.MembershipExpiry] = participation.Expires.ToLongDateString();
                Strings[MailPayloadString.OrganizationName] = participation.Organization.Name;
                Strings[MailPayloadString.Regularship]      =
                    Participant.Localized(participation.Organization.RegularLabel, TitleVariant.Ship);
                Strings[MailPayloadString.ExternalUrl] = SystemSettings.ExternalUrl;

                if (mailType == ParticipantMailType.ParticipantAddedWelcome)
                {
                    BodyTemplate =
                        Resources.Logic_Communications_Transmission_DefaultCommTemplates
                        .ParticipantManualAddWelcome_Body;
                }
                else
                {
                    BodyTemplate =
                        Resources.Logic_Communications_Transmission_DefaultCommTemplates
                        .ParticipantManualAddWelcome_NoExpiry_Body;
                }

                SubjectTemplate =
                    Resources.Logic_Communications_Transmission_DefaultCommTemplates
                    .ParticipantManualAddWelcome_Subject;

                break;

            default:
                throw new NotImplementedException("Unknown mailType: " + mailType.ToString());
            }
        }