Esempio n. 1
0
        private void PopulateRepeater()
        {
            Participations participations = CurrentUser.GetMemberships();

            List <OrganizationParameters> availableOrganizations = new List <OrganizationParameters>();

            foreach (Participation membership in participations)
            {
                if (membership.OrganizationId == 1 && !PilotInstallationIds.IsPilot(PilotInstallationIds.PiratePartySE))
                {
                    // sandbox. Ignore.
                    continue;
                }

                OrganizationParameters newOrganization = new OrganizationParameters();
                newOrganization.LogoUrl          = "/Images/Flags/txl-64px.png";
                newOrganization.OrganizationId   = membership.OrganizationId;
                newOrganization.OrganizationName = membership.Organization.Name;

                availableOrganizations.Add(newOrganization);
            }

            OrganizationCount = availableOrganizations.Count;

            this.RepeaterOrganizations.DataSource = availableOrganizations;
            this.RepeaterOrganizations.DataBind();
        }
        public async Task <IActionResult> Edit(int id, [Bind("IdParticipation,IdYearOfContest,IdParticipant,IdSong,IdNomination,Place")] Participations participations)
        {
            if (id != participations.IdParticipation)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(participations);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ParticipationsExists(participations.IdParticipation))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdNomination"]    = new SelectList(_context.Nominations, "IdNomination", "NominationName", participations.IdNomination);
            ViewData["IdParticipant"]   = new SelectList(_context.Participants, "IdParticipant", "ParticipantName", participations.IdParticipant);
            ViewData["IdSong"]          = new SelectList(_context.Songs, "IdSong", "SongName", participations.IdSong);
            ViewData["IdYearOfContest"] = new SelectList(_context.Years, "IdYearOfContest", "YearOfContest", participations.IdYearOfContest);
            return(View(participations));
        }
Esempio n. 3
0
        internal static void RemindExpiries(DateTime dateExpiry)
        {
            Organizations orgs = Organizations.GetAll();

            foreach (Organization org in orgs)
            {
                Participations participations = Participations.GetExpiring(org, dateExpiry);

                // Mail each expiring member

                foreach (Participation membership in participations)
                {
                    try
                    {
                        SendReminderMail(membership);

                        /*PWLog.Write (PWLogItem.Person, membership.PersonId,
                         *  PWLogAction.MembershipRenewReminder,
                         *  "Mail was sent to " + membership.Person.Mail +
                         *  " reminding to renew membership in " + membership.Organization.Name + ".", string.Empty);*/
                    }
                    catch (Exception ex)
                    {
                        ExceptionMail.Send(
                            new Exception("Failed to create reminder mail for person " + membership.PersonId, ex));
                    }
                }
            }
        }
Esempio n. 4
0
        public async Task <HttpResponseMessage> CreateNewParticipationAsync(Participations participation)
        {
            var         json         = JsonConvert.SerializeObject(participation);
            var         checkUserUrl = BASEADDRESS + "Participations";
            HttpContent httpContent  = new StringContent(json, Encoding.UTF8, "application/json");

            return(await _client.PostAsync(new Uri(checkUserUrl), httpContent));
        }
Esempio n. 5
0
 public void AddParticipation(string competition, string number)
 {
     if (Participations.Count(c => c.Competition == competition) == 0)
     {
         Participations.Add(new Participant()
         {
             Competition = competition, Number = number, Couple = this
         });
     }
 }
Esempio n. 6
0
        // This function should basically not be called. Any time it is called means a security
        // risk.

        public static string ExportMemberList(int organizationIdRoot, DateTime membersAfter, DateTime membersBefore)
        {
            Organizations orgs   = Organization.FromIdentity(organizationIdRoot).ThisAndBelow();
            StringBuilder result = new StringBuilder();

            result.Append(
                String.Format("All members joining tree of " + orgs[0].Name + " between " +
                              membersAfter.ToString("yyyy-MMM-dd") + " and " + membersBefore.ToString("yyyy-MMM-dd") +
                              "\r\n\r\n"));

            membersAfter  = membersAfter.Date;
            membersBefore = membersBefore.AddDays(1).Date;

            foreach (Organization org in orgs)
            {
                if (org.AcceptsMembers)
                {
                    Participations participations = org.GetMemberships();

                    string orgSummary = org.Name + "\r\n";

                    // Iterate over membership roster and filter by date

                    List <int> relevantPersonIds = new List <int>();
                    foreach (Participation membership in participations)
                    {
                        if (membership.MemberSince > membersAfter && membership.MemberSince < membersBefore)
                        {
                            relevantPersonIds.Add(membership.PersonId);
                        }
                    }

                    People listMembers = People.FromIdentities(relevantPersonIds.ToArray());

                    List <string> csvResultList = new List <string>();

                    foreach (Person person in listMembers)
                    {
                        csvResultList.Add(
                            String.Format("{0},{1},{2},{3:yyyy-MMM-dd},{4}",
                                          person.Name, person.Street, person.PostalCodeAndCity, person.Birthdate,
                                          person.IsMale ? "Male" : "Female"));
                    }

                    string[] csvResults = csvResultList.ToArray();
                    Array.Sort(csvResults);

                    orgSummary += String.Join("\r\n", csvResults) + "\r\n\r\n";

                    result.Append(orgSummary);
                }
            }

            return(result.ToString());
        }
Esempio n. 7
0
 public CalendarEvent GetAsICal()
 {
     return(new CalendarEvent()
     {
         Start = new CalDateTime(Start),
         End = new CalDateTime(End),
         Summary = Name,
         Attendees = Participations.Select(p => new Attendee()
         {
             CommonName = p.User.Username, Value = new Uri($"mailto:{p.User.Email}")
         }).ToList(),
         Description = Description
     });
 }
        public async Task <IActionResult> Create([Bind("IdParticipation,IdYearOfContest,IdParticipant,IdSong,IdNomination,Place")] Participations participations)
        {
            if (ModelState.IsValid)
            {
                _context.Add(participations);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdParticipant"]   = new SelectList(_context.Participants, "IdParticipant", "ParticipantName", participations.IdParticipant);
            ViewData["IdSong"]          = new SelectList(_context.Songs, "IdSong", "SongName", participations.IdSong);
            ViewData["IdYearOfContest"] = new SelectList(_context.Years, "IdYearOfContest", "YearOfContest", participations.IdYearOfContest);
            ViewData["IdNomination"]    = new SelectList(_context.Nominations, "IdNomination", "NominationName", participations.IdNomination);
            return(View(participations));
        }
        /// <summary>
        /// This method is called whenever an actor is activated.
        /// An actor is activated the first time any of its methods are invoked.
        /// </summary>
        protected override async Task OnActivateAsync()
        {
            ActorEventSource.Current.ActorMessage(this, "Actor activated.");

            ConditionalValue <Participations> state = await this.StateManager.TryGetStateAsync <Participations>(ActorStateKeyName);

            if (!state.HasValue)
            {
                var participations = new Participations()
                {
                    Records = new List <ParticipationMonthYear>()
                    {
                        CreateMonthYear(DateTimeOffset.UtcNow.Month, DateTimeOffset.UtcNow.Year)
                    }
                };

                await this.StateManager.TryAddStateAsync(ActorStateKeyName, participations);
            }
        }
Esempio n. 10
0
        private void PopulateRepeater()
        {
            Participations participations = CurrentUser.GetParticipations();

            List <OrganizationParameters> availableOrganizations = new List <OrganizationParameters>();

            foreach (Participation membership in participations)
            {
                if (membership.OrganizationId == 1 && !PilotInstallationIds.IsPilot(PilotInstallationIds.PiratePartySE))
                {
                    // sandbox. Ignore.
                    continue;
                }

                Organization           organization = membership.Organization;
                OrganizationParameters newOrganizationParameters = new OrganizationParameters();

                string logoUrl = "/Images/Other/blank-logo-640x360.png";

                Document logoLandscape = organization.LogoLandscape;

                try
                {
                    if (logoLandscape != null)
                    {
                        newOrganizationParameters.LogoImage = logoLandscape.Image.GetBase64(64, 36);
                    }
                }
                catch (Exception)
                {
                    newOrganizationParameters.LogoImage = "/Images/Flags/txl-64px.png";
                }
                newOrganizationParameters.OrganizationId   = membership.OrganizationId;
                newOrganizationParameters.OrganizationName = membership.Organization.Name;

                availableOrganizations.Add(newOrganizationParameters);
            }

            OrganizationCount = availableOrganizations.Count;

            this.RepeaterOrganizations.DataSource = availableOrganizations;
            this.RepeaterOrganizations.DataBind();
        }
Esempio n. 11
0
        private void QRScanResult()
        {
            IsAnalyzing = false;
            IsScanning  = false;

            Device.BeginInvokeOnMainThread(async() =>
            {
                Participations participation            = new Participations();
                participation.UserId                    = _user.UserId;
                participation.EventId                   = Int32.Parse(Result.Text);
                HttpResponseMessage httpResponseMessage = await _repository.CreateNewParticipationAsync(participation);
                switch (httpResponseMessage.StatusCode)
                {
                case System.Net.HttpStatusCode.OK:
                    Events myEvent = JsonConvert.DeserializeObject <Events>(await httpResponseMessage.Content.ReadAsStringAsync());

                    Device.BeginInvokeOnMainThread(() =>
                    {
                        App.Current.MainPage.DisplayAlert("You are registrated!", "Thank you to participate to: " + myEvent.Description, "OK");
                    });
                    break;

                case System.Net.HttpStatusCode.NotFound:
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        App.Current.MainPage.DisplayAlert("Event was not found!", "Please try again", "OK");
                    });
                    break;

                default:
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        App.Current.MainPage.DisplayAlert("Something went wrong!", "Please try again", "OK");
                    });
                    break;
                }
                ResetScanner();
            });
        }
Esempio n. 12
0
        public People FilterPeople(People rawList, AccessAspect aspect = AccessAspect.Participation)
        {
            if (aspect != AccessAspect.Participation && aspect != AccessAspect.PersonalData)
            {
                throw new ArgumentException(@"AccessAspect needs to reflect visibility of people data", "aspect");
            }

            // Three cases:

            // 1) the current Position has system-level access.
            // 2) the current Position has org-level, but not system-level, access.
            // 3) the current Position has org-and-geo-level access.

            Dictionary <int, bool> orgLookup = new Dictionary <int, bool>();
            Dictionary <int, bool> geoLookup = new Dictionary <int, bool>();

            People result = new People();

            // Org lookup will always be needed. Geo lookup may be needed for case 3.

            Organizations orgStructure = this.Organization.ThisAndBelow();

            int[] orgIds = orgStructure.Identities;
            foreach (int orgId in orgIds)
            {
                orgLookup[orgId] = true;
            }
            orgLookup[Organization.Identity] = true;

            Dictionary <int, List <BasicParticipation> > membershipLookup = null;

            if (HasSystemAccess(AccessType.Read) || HasAccess(new Access(Organization, aspect, AccessType.Read)))
            {
                // cases 1 and 2: systemwide access, return everybody at or under the current Organization,
                // or org-wide read access (at least) to participant/personal data at current Organization

                // Optimization: Get all memberships in advance, without instantiating logic objects
                membershipLookup = Participations.GetParticipationsForPeople(rawList.Identities, 0);

                foreach (Person person in rawList)
                {
                    // For each person, we must test the list of active memberships to see if one of
                    // them is visible to this Authority - if it's a membership in an org at or below the
                    // Authority object's organization

                    if (membershipLookup.ContainsKey(person.Identity))
                    {
                        List <BasicParticipation> list = membershipLookup[person.Identity];

                        foreach (BasicParticipation basicMembership in list)
                        {
                            if (orgLookup.ContainsKey(basicMembership.OrganizationId))
                            {
                                // hit - this person has an active membership that makes them visible to this Authority
                                result.Add(person);
                                break;
                            }
                        }
                    }
                }

                return(result);
            }

            // Case 3: Same as above but also check for Geography (in an AND pattern).

            if (this.Position == null)
            {
                // No access at all. That was an easy case!

                return(new People()); // return empty list
            }

            if (this.Position.Geography == null)
            {
                // Org-level position, but one that doesn't have access to personal data, apparently.

                return(new People()); // empty list again
            }

            if (!HasAccess(new Access(this.Organization, Position.Geography, aspect, AccessType.Read)))
            {
                // No people access for active position. Also a reasonably easy case.

                return(new People()); // also return empty list
            }

            Geographies geoStructure = this.Position.Geography.ThisAndBelow();

            int[] geoIds = geoStructure.Identities;
            foreach (int geoId in geoIds)
            {
                geoLookup[geoId] = true;
            }
            geoLookup[Position.GeographyId] = true;

            // Optimization: Get all memberships in advance, without instantiating logic objects
            Dictionary <int, List <BasicParticipation> > personLookup =
                Participations.GetParticipationsForPeople(rawList.Identities, 0);

            foreach (Person person in rawList)
            {
                // For each person, we must test the list of active memberships to see if one of
                // them is visible to this Authority - if it's a membership in an org at or below the
                // Authority object's organization - and also test the person's Geography against
                // the list (lookup) of visible Geographies. We do Geographies first, because that test is
                // much cheaper.

                if (geoLookup[person.GeographyId])
                {
                    // Geography hit. Test Membership / Organization.

                    List <BasicParticipation> list = personLookup[person.Identity];

                    foreach (BasicParticipation basicMembership in list)
                    {
                        if (orgLookup.ContainsKey(basicMembership.OrganizationId))
                        {
                            // Organization hit - this person has an active membership that makes them visible to this Authority

                            result.Add(person);
                        }
                    }
                }
            }

            return(result);
        }
Esempio n. 13
0
 public static Participation[] SelectStatic(Participations participations)
 {
     return(participations.ToArray());
 }
Esempio n. 14
0
 public static Participation[] Select(int personId)
 {
     return
         (Participations.FromArray(SwarmDb.GetDatabaseForReading().GetParticipations(Person.FromIdentity(personId)))
          .ToArray());
 }
Esempio n. 15
0
 public Participations GetMemberships(bool includeTerminated)
 {
     return(Participations.ForOrganization(this, includeTerminated));
 }
Esempio n. 16
0
        public static GeographyStatistics GeneratePresent(int[] memberCountForOrganizations)
        {
            Dictionary <int, int> voterCounts = SwarmDb.GetDatabaseForReading().GetGeographyVoterCounts();
            GeographyStatistics   result      = new GeographyStatistics();

            // Step 1 - tally the leaf nodes

            foreach (int geographyId in voterCounts.Keys)
            {
                GeographyDataPoint dataPoint = new GeographyDataPoint
                {
                    GeographyName = Geography.FromIdentity(geographyId).Name,
                    GeographyId   = geographyId,
                    VoterCount    = voterCounts[geographyId]
                };

                result[geographyId] = dataPoint;
            }


            // Step 2 - add the member counts to the individual requested geo nodes

            foreach (int orgId in memberCountForOrganizations)
            {
                People members =
                    People.FromMemberships(
                        Participations.ForOrganizations(Organization.FromIdentity(orgId).ThisAndBelow()));

                foreach (Person person in members)
                {
                    Geography geography = person.Geography;

                    // If we don't have this key, it's because it's too far down. Move up the tree until we're at least
                    // at municipal level.

                    while (geography.Identity != 1 && !result.ContainsKey(geography.Identity))
                    {
                        geography = geography.Parent;
                    }

                    // Add the data, unless we hit the roof in the last op.

                    if (geography.Identity != 1)
                    {
                        int birthYearBracket = (person.Birthdate.Year - 1900) / 5;

                        if (birthYearBracket >= 0 && birthYearBracket < 30)
                        {
                            result[geography.Identity].OrganizationData[orgId - 1].BirthYearBracketMemberCounts[
                                birthYearBracket]++;
                        }

                        if (person.IsFemale)
                        {
                            result[geography.Identity].OrganizationData[orgId - 1].FemaleMemberCount++;
                        }
                        else if (person.IsMale)
                        {
                            result[geography.Identity].OrganizationData[orgId - 1].MaleMemberCount++;
                        }
                    }
                }
            }

            // TODO: Activist count as a new step


            // Step 3 - add up the totals for every intermediate node (expensive!)

            Geographies allGeographies = Geography.Root.ThisAndBelow();

            foreach (Geography geography in allGeographies)
            {
                Geographies localTree  = geography.ThisAndBelow();
                int         voterCount = 0;
                GeographyOrganizationDataPoint[] tempOrgData = new GeographyOrganizationDataPoint[2]; // HACK
                tempOrgData[0] = new GeographyOrganizationDataPoint();
                tempOrgData[1] = new GeographyOrganizationDataPoint();

                foreach (Geography localNode in localTree)
                {
                    // Increment our temp values for every geo node below the one we're currently processing.

                    if (!result.ContainsKey(localNode.Identity))
                    {
                        continue;
                    }

                    voterCount += result[localNode.Identity].VoterCount;

                    for (int orgIndex = 0; orgIndex < 2; orgIndex++)
                    {
                        for (int ageBracketIndex = 0; ageBracketIndex < 30; ageBracketIndex++)
                        {
                            tempOrgData[orgIndex].BirthYearBracketMemberCounts[ageBracketIndex] +=
                                result[localNode.Identity].OrganizationData[orgIndex].BirthYearBracketMemberCounts[
                                    ageBracketIndex];
                        }

                        tempOrgData[orgIndex].ActivistCount +=
                            result[localNode.Identity].OrganizationData[orgIndex].ActivistCount;
                        tempOrgData[orgIndex].FemaleMemberCount +=
                            result[localNode.Identity].OrganizationData[orgIndex].FemaleMemberCount;
                        tempOrgData[orgIndex].MaleMemberCount +=
                            result[localNode.Identity].OrganizationData[orgIndex].MaleMemberCount;
                    }
                }

                if (!result.ContainsKey(geography.Identity))
                {
                    result[geography.Identity] = new GeographyDataPoint
                    {
                        GeographyId   = geography.Identity,
                        GeographyName = geography.Name
                    };
                }

                // Save our temp values to the processed node.

                result[geography.Identity].VoterCount = voterCount;

                for (int orgIndex = 0; orgIndex < 2; orgIndex++)
                {
                    for (int ageBracketIndex = 0; ageBracketIndex < 30; ageBracketIndex++)
                    {
                        result[geography.Identity].OrganizationData[orgIndex].BirthYearBracketMemberCounts[
                            ageBracketIndex] =
                            tempOrgData[orgIndex].BirthYearBracketMemberCounts[ageBracketIndex];
                    }

                    result[geography.Identity].OrganizationData[orgIndex].ActivistCount =
                        tempOrgData[orgIndex].ActivistCount;
                    result[geography.Identity].OrganizationData[orgIndex].FemaleMemberCount =
                        tempOrgData[orgIndex].FemaleMemberCount;
                    result[geography.Identity].OrganizationData[orgIndex].MaleMemberCount =
                        tempOrgData[orgIndex].MaleMemberCount;
                }
            }


            // Step 4 - collect

            return(result);
        }
Esempio n. 17
0
        public static Person RequestNewPasswordProcess(string eMail, string URL)
        {
            int personID = 0;

            int.TryParse(eMail, out personID);
            Person authenticatedUser = null;
            People candidatePeople   = null;

            if (personID == 0)
            {
                BasicPerson[] people =
                    SwarmDb.GetDatabaseForReading().GetPeopleFromEmailPattern(eMail.ToLower().Replace("%", "").Trim());
                candidatePeople = People.FromArray(people);

                // if multiple people share same e-mail, suppose the last one registered is the one to change.
                foreach (Person p in candidatePeople)
                {
                    if (authenticatedUser == null || authenticatedUser.PersonId < p.PersonId)
                    {
                        authenticatedUser = p;
                    }
                }
            }
            else
            {
                candidatePeople = People.FromIdentities(new[] { personID });
                if (candidatePeople.Count > 0)
                {
                    authenticatedUser = candidatePeople[0];
                }
            }

            if (authenticatedUser == null)
            {
                return(null);
            }

            string passwordTicket = CreateWeakSecret(EmailVerificationTicketLength);

            foreach (Person p in candidatePeople)
            {
                string encodedPasswordTicket = GenerateNewPasswordHash(p, passwordTicket);
                p.ResetPasswordTicket = encodedPasswordTicket + ";" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            }

            //TODO: Localize
            string mailbody = "";

            App_LocalResources.Authentication.Culture = CultureInfo.InvariantCulture;

            if (candidatePeople.Count == 1)
            {
                App_LocalResources.Authentication.Culture =
                    CultureInfo.GetCultureInfo(authenticatedUser.PreferredCulture);

                mailbody  = App_LocalResources.Authentication.RequestNewPassword_Mail_Preamble;
                mailbody += App_LocalResources.Authentication.RequestNewPassword_Mail_ClickOneLink;
                mailbody += "\r\n" + String.Format(URL, authenticatedUser.PersonId, passwordTicket);
            }
            else
            {
                string linksTot = "";
                foreach (Person p in candidatePeople)
                {
                    string links           = "";
                    int    membershipCount = 0;
                    if (App_LocalResources.Authentication.Culture == CultureInfo.InvariantCulture)
                    {
                        App_LocalResources.Authentication.Culture = CultureInfo.GetCultureInfo(p.PreferredCulture);
                    }

                    links += "\r\n\r\n";
                    links += "#" + p.PersonId;
                    links += " [Member of:";
                    Participations msList = p.GetParticipations();
                    foreach (Participation ms in msList)
                    {
                        ++membershipCount;
                        links += " (" + ms.Organization.Name + "," + ms.MemberSince.ToString("yyyy-MM-dd") + ")";
                    }
                    links += "] ";
                    links += "\r\n" + String.Format(URL, p.PersonId, passwordTicket);
                    if (membershipCount > 0)
                    {
                        linksTot += links;
                    }
                }

                mailbody  = App_LocalResources.Authentication.RequestNewPassword_Mail_Preamble;
                mailbody += App_LocalResources.Authentication.RequestNewPassword_Mail_ClickOneOfLinks;
                mailbody += "\r\n" + linksTot;
            }

            mailbody += App_LocalResources.Authentication.RequestNewPassword_Mail_Ending;

            authenticatedUser.SendNotice(App_LocalResources.Authentication.RequestNewPassword_Mail_Subject, mailbody, 1);
            return(authenticatedUser);
        }
Esempio n. 18
0
        /// <summary>
        ///     Returns one authenticated user from login token and password.
        /// </summary>
        /// <param name="loginToken">The login token provided.</param>
        /// <param name="password">The password provided.</param>
        /// <returns>Exactly one authenticated user, if successful.</returns>
        /// <exception cref="UnauthorizedAccessException">
        ///     This function will throw an UnauthorizedAccessException if the user
        ///     cannot be authenticated using the supplied credentials.
        /// </exception>
        public static Person Authenticate(string loginToken, string password)
        {
            // Get the list of people that match the login token.

            People candidatePeople   = GetPeopleByLoginToken(loginToken);
            Person authenticatedUser = null;

            // For every person in the list, test the supplied password against the current and legacy hash schemes.

            foreach (Person candidate in candidatePeople)
            {
                // Check that the candidate has at least one valid membership.

                bool hasActiveMemberships = false;

                Participations participations = candidate.GetParticipations();

                foreach (Participation membership in participations)
                {
                    if (membership.Active)
                    {
                        hasActiveMemberships = true;
                        break;
                    }
                }

                // If no active memberships, do not authenticate against this candidate.

                if (!hasActiveMemberships)
                {
                    continue;
                }

                // Check the credentials.

                bool goodCredentials = false;

                if (CheckPassword(candidate, password))
                {
                    goodCredentials = true;
                }
                else if (PilotInstallationIds.IsPilot(PilotInstallationIds.PiratePartySE))
                {
                    // If the most recent password hash mechanism fails, try legacy hashes IF on pilot installation

                    string[] legacyHashes = GenerateLegacyPasswordHashes(candidate, password);

                    foreach (string legacyHash in legacyHashes)
                    {
                        if (legacyHash == candidate.PasswordHash)
                        {
                            goodCredentials = true;
                        }
                    }
                }

                // Now we've iterated over the possible password hashes for the candidate. Were the credentials good?

                if (goodCredentials)
                {
                    // We have a set of good credentials. As a security mechanism, make sure that we haven't approved another
                    // user already using these credentials. In theory, the chances of this happening with SHA-1 hashes is less
                    // than astronomical, but anyway.

                    if (authenticatedUser != null)
                    {
                        // We have a double credentials hit. This becomes a serious security concern.
                        // TODO: Alert operator about this, it's a serious condition.

                        throw new UnauthorizedAccessException("Double credentials hit");
                    }

                    // The current candidate has good credentials:

                    authenticatedUser = candidate;
                }
            }

            // If a user came through as authenticated, return him/her. Otherwise, sod off.

            if (authenticatedUser != null)
            {
                return(authenticatedUser);
            }

            throw new UnauthorizedAccessException();
        }
Esempio n. 19
0
        public static void Run()
        {
            MeetingElections polls = MeetingElections.GetAll();

            foreach (MeetingElection poll in polls)
            {
                Console.Write("Looking at poll #" + poll.Identity + "...");

                if (DateTime.Now > poll.VotingCloses)
                {
                    Console.Write(" after closedatetime " + poll.VotingCloses.ToString("yyyy-MM-dd HH:mm") + "...");

                    // Poll should be CLOSED, definitely CLOSED.

                    if (poll.VotingOpen)
                    {
                        Console.WriteLine(" CLOSING.");

                        poll.VotingOpen = false; // Closes poll
                        poll.Creator.SendNotice("Poll Closed: " + poll.Name, string.Empty, poll.OrganizationId);
                        Person.FromIdentity(1)
                        .SendNotice("Poll Closed: " + poll.Name, string.Empty, poll.OrganizationId);

                        ReportPollResults(poll, false);
                    }
                    else
                    {
                        Console.WriteLine(" no action.");
                    }
                }
                else if (DateTime.Now > poll.VotingOpens)
                {
                    try
                    {
                        // Poll should be OPEN.

                        Console.Write("after opendatetime " + poll.VotingOpens.ToString("yyyy-MM-dd HH:mm") + "...");

                        if (!poll.VotingOpen)
                        {
                            Console.WriteLine("OPENING for " + poll.Organization.Name + ":");

                            // Populate voters, then open for voting

                            Organizations orgTree = poll.Organization.ThisAndBelow();

                            Participations participations = Participations.ForOrganizations(orgTree);

                            Dictionary <int, bool> dupeCheck = new Dictionary <int, bool>();

                            int count = 0;

                            foreach (Participation membership in participations)
                            {
                                Console.Write("\r - voters: {0:D6}/{1:D6} (person #{2:D6})...", ++count,
                                              participations.Count, membership.PersonId);

                                if (!membership.Active)
                                {
                                    continue; // paranoid programming
                                }

                                if (!membership.Organization.IsOrInherits(poll.Organization))
                                {
                                    continue; // more paranoid programming
                                }

                                if (!dupeCheck.ContainsKey(membership.PersonId))
                                {
                                    if (membership.Person.GeographyId == 0)
                                    {
                                        // It's a trap!

                                        Console.Write(" GEOGRAPHY ZERO, ignoring\r\n");
                                    }
                                    else
                                    {
                                        Geography geo = membership.Person.Geography;

                                        if (geo.Inherits(Geography.FromIdentity(poll.GeographyId)) || geo.Identity == poll.GeographyId)
                                        {
                                            poll.AddVoter(membership.Person);
                                            dupeCheck[membership.PersonId] = true;
                                        }
                                    }
                                }
                            }

                            Console.WriteLine(" done.");
                            Console.Write(" - opening poll...");

                            poll.VotingOpen = true;

                            Console.WriteLine(" done.");
                            Console.Write("Sending notices... ");

                            string body = "Electoral roll for poll \"" + poll.Name + "\" primed. " +
                                          dupeCheck.Count + " people can vote. The vote is now OPEN.";

                            string subject = "Poll Open: " + poll.Name;

                            poll.Creator.SendNotice(subject, body, poll.OrganizationId);
                            Person.FromIdentity(1).SendNotice(subject, body, poll.OrganizationId);

                            Console.WriteLine(" done.");
                        }
                        else
                        {
                            Console.WriteLine(" already open, no action.");

                            // Report intermediate results to owner

                            ReportPollResults(poll, true);
                        }
                    }
                    catch (Exception exception)
                    {
                        Console.WriteLine(exception.ToString());

                        throw exception;
                    }
                }
            }
        }
Esempio n. 20
0
 public int GetMemberCount()
 {
     return(Participations.GetParticipantCountForOrganization(this));
 }
Esempio n. 21
0
    public List <ListPerson> GetData(string sortBy)
    {
        List <ListPerson> retval = new List <ListPerson>();

        if (this.listedPersons != null)
        {
            People ppl = People.FromIdentities(this.listedPersons);
            Dictionary <int, List <BasicParticipation> > membershipTable =
                Participations.GetParticipationsForPeople(ppl, Participation.GracePeriod);
            Participations participationsToLoad = new Participations();
            foreach (Person p in ppl)
            {
                if (membershipTable.ContainsKey(p.Identity))
                {
                    foreach (BasicParticipation bm in membershipTable[p.Identity])
                    {
                        if (bm.OrganizationId == this.selectedOrgId)
                        {
                            Participation ms = Participation.FromBasic(bm);
                            participationsToLoad.Add(ms);
                        }
                    }
                }
            }
            Participation.LoadPaymentStatuses(participationsToLoad);

            Dictionary <int, Participation> memberships = new Dictionary <int, Participation>();
            foreach (Participation ms in participationsToLoad)
            {
                memberships[ms.Identity] = ms;
            }

            foreach (Person p in ppl)
            {
                ListPerson lp = new ListPerson(p);
                if (membershipTable.ContainsKey(p.Identity))
                {
                    foreach (BasicParticipation bm in membershipTable[p.Identity])
                    {
                        if (bm.OrganizationId == this.selectedOrgId)
                        {
                            Participation ms = memberships[bm.MembershipId];
                            lp.JoinedDate   = ms.MemberSince;
                            lp.ExpiresDate  = ms.Expires;
                            lp.MembershipId = ms.Identity;
                            retval.Add(lp);
                        }
                    }
                }
            }
        }

        PropertyInfo pi = typeof(ListPerson).GetProperty(sortBy);

        if (pi != null)
        {
            MemberInfo[] miA = pi.PropertyType.GetMember("CompareTo", MemberTypes.Method,
                                                         BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);
            if (miA.Length > 0)
            {
                MethodInfo mi = (MethodInfo)miA[0];
                retval.Sort(
                    delegate(ListPerson p1, ListPerson p2)
                {
                    return(Convert.ToInt32(mi.Invoke(pi.GetValue(p1, null), new[] { pi.GetValue(p2, null) })));
                });
            }
        }
        return(retval);
    }
Esempio n. 22
0
        public static void RemindExpiriesMail()
        {
            // Get expiring

            Console.WriteLine("Inside RemindExpiriesMail()");

            Organizations orgs = Organizations.GetAll();

            Dictionary <int, bool>   personLookup = new Dictionary <int, bool>();
            Dictionary <string, int> dateLookup   = new Dictionary <string, int>();

            DateTime      lowerBound      = DateTime.Today;
            DateTime      upperBound      = lowerBound.AddDays(31);
            List <string> failedReminders = new List <string>();

            int weekDayInteger = (int)DateTime.Today.DayOfWeek;

            foreach (Organization org in orgs)
            {
                Participations participations = Participations.GetExpiring(org, lowerBound, upperBound);

                foreach (Participation membership in participations)
                {
                    if (membership.OrganizationId % 7 != weekDayInteger)
                    {
                        continue;
                    }

                    try
                    {
                        Console.Write("Reminding " + membership.Person.Canonical + " about " +
                                      membership.Organization.Name + ".");
                        SendReminderMail(membership);
                        Console.Write(".");

                        /*PWLog.Write (PWLogItem.Person, membership.PersonId,
                         *  PWLogAction.MembershipRenewReminder,
                         *  "Mail was sent to " + membership.Person.Mail +
                         *  " reminding to renew membership in " + membership.Organization.Name + ".", string.Empty);*/

                        Console.Write(".");

                        string dateString = membership.Expires.ToString("yyyy-MM-dd");
                        if (!dateLookup.ContainsKey(dateString))
                        {
                            dateLookup[dateString] = 0;
                        }
                        dateLookup[dateString]++;

                        Console.WriteLine(" done.");
                    }
                    catch (Exception x)
                    {
                        string logText = "FAILED sending mail to " + membership.Person.Mail +
                                         " for reminder of pending renewal in " + membership.Organization.Name + ".";
                        failedReminders.Add(membership.Person.Canonical);

                        /*PWLog.Write (PWLogItem.Person, membership.PersonId,
                         *  PWLogAction.MembershipRenewReminder,
                         *  logText, string.Empty);*/
                        ExceptionMail.Send(new Exception(logText, x));
                    }
                }
            }

            string notifyBody = String.Format("Sending renewal reminders to {0} people:\r\n\r\n", personLookup.Count);

            Console.WriteLine("Sending renewal reminders to {0} people", personLookup.Count);

            List <string> dateSummary = new List <string>();
            int           total       = 0;

            foreach (string dateString in dateLookup.Keys)
            {
                dateSummary.Add(string.Format("{0}: {1,5}", dateString, dateLookup[dateString]));
                total += dateLookup[dateString];
            }

            dateSummary.Sort();

            foreach (string dateString in dateSummary)
            {
                notifyBody += dateString + "\r\n";
                Console.WriteLine(dateString);
            }

            notifyBody += string.Format("Total sent: {0,5}\r\n\r\n", total);
            Console.WriteLine("Total sent: {0,5}\r\n\r\n", total);

            notifyBody += "FAILED reminders:\r\n";
            Console.WriteLine("FAILED reminders:");

            foreach (string failed in failedReminders)
            {
                notifyBody += failed + "\r\n";
                Console.WriteLine(failed);
            }

            if (failedReminders.Count == 0)
            {
                notifyBody += "none.\r\n";
                Console.WriteLine("none.");
            }

            /* no. just no. we should do a global search for "FromIdentity(1)"
             * Person.FromIdentity(1).SendOfficerNotice("Reminders sent today", notifyBody, 1);  */
        }
        public async Task <IActionResult> Import(IFormFile fileExcel)
        {
            if (ModelState.IsValid)
            {
                if (fileExcel != null)
                {
                    using (var stream = new FileStream(fileExcel.FileName, FileMode.Create))
                    {
                        await fileExcel.CopyToAsync(stream);

                        using (XLWorkbook workBook = new XLWorkbook(stream, XLEventTracking.Disabled))
                        {
                            foreach (IXLWorksheet worksheet in workBook.Worksheets)
                            {
                                ParticipantTypes newtype;
                                var t = (from type in _context.ParticipantTypes where type.ParticipantType.Contains(worksheet.Name) select type).ToList();
                                if (t.Count > 0)
                                {
                                    newtype = t[0];
                                }

                                else
                                {
                                    newtype = new ParticipantTypes();
                                    newtype.ParticipantType = worksheet.Name;
                                    _context.ParticipantTypes.Add(newtype);
                                }
                                //перегляд усіх рядків
                                foreach (IXLRow row in worksheet.RowsUsed().Skip(1))
                                {
                                    try
                                    {
                                        //участник
                                        Participants participant = new Participants();
                                        var          p           = (from part in _context.Participants where part.ParticipantName == row.Cell(1).Value.ToString() select part).ToList();
                                        if (p.Count > 0)
                                        {
                                            participant = p[0];
                                        }
                                        else
                                        {
                                            participant.ParticipantName = row.Cell(1).Value.ToString();
                                            participant.ParticipantDate = Convert.ToDateTime(row.Cell(2).Value.ToString());
                                            participant.Biography       = row.Cell(3).Value.ToString();

                                            //участник -> город
                                            Cities newcity;
                                            var    c = (from city in _context.Cities where city.CityName.Contains(row.Cell(4).Value.ToString()) select city).ToList();
                                            if (c.Count > 0)
                                            {
                                                newcity = c[0];
                                            }
                                            else
                                            {
                                                newcity             = new Cities();
                                                newcity.CityName    = row.Cell(4).Value.ToString();
                                                newcity.Description = "Imported from file.";
                                                _context.Cities.Add(newcity);
                                            }

                                            participant.IdRepresentedCityNavigation = newcity;
                                            participant.IdParticipantTypeNavigation = newtype;
                                            _context.Participants.Add(participant);
                                        }

                                        //участие
                                        Participations participation = new Participations();
                                        var            pt            = (from parts in _context.Participations where parts.IdParticipantNavigation.ParticipantName == row.Cell(1).Value.ToString() select parts).ToList();
                                        if (pt.Count > 0)
                                        {
                                            participation = pt[0];
                                        }
                                        else
                                        {
                                            //песня
                                            Songs song = new Songs();
                                            var   s    = (from songs in _context.Songs where song.SongName == row.Cell(5).Value.ToString() select songs).ToList();
                                            if (s.Count > 0)
                                            {
                                                song = s[0];
                                            }
                                            else
                                            {
                                                song.SongName = row.Cell(5).Value.ToString();
                                                string   myString = row.Cell(6).Value.ToString();
                                                double   d        = double.Parse(myString);
                                                DateTime dt       = DateTime.FromOADate(d);
                                                song.Duration = new TimeSpan(dt.Hour, dt.Minute, dt.Second);
                                                _context.Songs.Add(song);
                                            }

                                            //участие -> год
                                            Years newyear;
                                            var   y = (from year in _context.Years where year.YearOfContest == int.Parse(row.Cell(7).Value.ToString()) select year).ToList();
                                            if (y.Count > 0)
                                            {
                                                newyear = y[0];
                                            }
                                            else
                                            {
                                                newyear = new Years();
                                                newyear.YearOfContest = Convert.ToInt32(row.Cell(7).Value);
                                                newyear.Slogan        = "Slogan";
                                                newyear.Stage         = "Stage";
                                                foreach (var city in _context.Cities)
                                                {
                                                    if (city.CityName == "POLIGON")
                                                    {
                                                        newyear.IdHostCityNavigation = city;
                                                        break;
                                                    }
                                                }
                                                _context.Years.Add(newyear);
                                            }

                                            //участие -> номинация
                                            Nominations newnomination;
                                            var         n = (from nomination in _context.Nominations where nomination.NominationName.Contains(row.Cell(8).Value.ToString()) select nomination).ToList();
                                            if (n.Count > 0)
                                            {
                                                newnomination = n[0];
                                            }
                                            else
                                            {
                                                newnomination = new Nominations();
                                                newnomination.NominationName = row.Cell(8).Value.ToString();
                                                _context.Nominations.Add(newnomination);
                                            }


                                            participation.IdParticipantNavigation   = participant;
                                            participation.IdSongNavigation          = song;
                                            participation.IdYearOfContestNavigation = newyear;
                                            participation.IdNominationNavigation    = newnomination;
                                            participation.Place = Convert.ToInt32(row.Cell(9).Value);

                                            _context.Participations.Add(participation);
                                        }
                                    }
                                    catch
                                    {
                                        RedirectToAction("ErrorOpen", "Home");
                                    }
                                }
                            }
                        }
                    }
                }

                await _context.SaveChangesAsync();
            }
            return(RedirectToAction(nameof(Index)));
        }
Esempio n. 24
0
        public static Person RequestActivistSignoffProcess(string eMail, string URL)
        {
            int personID = 0;

            int.TryParse(eMail, out personID);
            Person authenticatedUser = null;
            People candidatePeople   = null;
            bool   personIsActivist  = false;

            if (personID == 0)
            {
                BasicPerson[] people =
                    SwarmDb.GetDatabaseForReading().GetPeopleFromEmailPattern(eMail.ToLower().Replace("%", "").Trim());
                candidatePeople = People.FromArray(people);

                // if multiple people share same e-mail, suppose the last one registered is the one to change.
                foreach (Person p in candidatePeople)
                {
                    if (authenticatedUser == null || authenticatedUser.PersonId < p.PersonId && p.IsActivist)
                    {
                        authenticatedUser = p;
                    }
                }
            }
            else
            {
                candidatePeople = People.FromIdentities(new[] { personID });
                if (candidatePeople.Count > 0)
                {
                    authenticatedUser = candidatePeople[0];
                }
            }

            if (authenticatedUser == null)
            {
                return(null);
            }


            //TODO: Localize
            string mailbody = "";

            App_LocalResources.Authentication.Culture = CultureInfo.InvariantCulture;


            if (candidatePeople.Count == 1 && candidatePeople[0].IsActivist)
            {
                personIsActivist = true;
                Person p = candidatePeople[0];
                if (App_LocalResources.Authentication.Culture == CultureInfo.InvariantCulture)
                {
                    App_LocalResources.Authentication.Culture = CultureInfo.GetCultureInfo(p.PreferredCulture);
                }


                string encodedPasswordTicket =
                    SHA1.Hash(p.Identity.ToString(CultureInfo.InvariantCulture)).Replace(" ", "").Substring(0, 4) +
                    p.Identity;

                mailbody  = App_LocalResources.Authentication.RequestActivistSignoff_Mail_Preamble;
                mailbody += App_LocalResources.Authentication.RequestActivistSignoff_Mail_ClickOneLink;


                mailbody += "\r\n" + String.Format(URL, encodedPasswordTicket);
            }
            else
            {
                string links = "";
                foreach (Person p in candidatePeople)
                {
                    Participations msList = p.GetParticipations();
                    if (msList.Count == 0 && p.IsActivist)
                    {
                        personIsActivist = true;
                        if (App_LocalResources.Authentication.Culture == CultureInfo.InvariantCulture)
                        {
                            App_LocalResources.Authentication.Culture = CultureInfo.GetCultureInfo(p.PreferredCulture);
                        }


                        string encodedPasswordTicket =
                            GenerateNewPasswordHash(p, p.Identity.ToString()).Replace(" ", "").Substring(0, 4) +
                            p.Identity;
                        links += "\r\n\r\n";
                        links += "#" + p.PersonId;

                        links += "\r\n" + String.Format(URL, encodedPasswordTicket);
                    }
                }

                mailbody  = App_LocalResources.Authentication.RequestActivistSignoff_Mail_Preamble;
                mailbody += App_LocalResources.Authentication.RequestActivistSignoff_Mail_ClickOneOfLinks;
                mailbody += links;
            }

            mailbody += App_LocalResources.Authentication.RequestActivistSignoff_Mail_Ending;

            if (personIsActivist)
            {
                authenticatedUser.SendNotice(App_LocalResources.Authentication.RequestActivistSignoff_Mail_Subject,
                                             mailbody, 1);
            }
            return(authenticatedUser);
        }
Esempio n. 25
0
        // This should run daily, suggested right after midnight.

        public static void ChurnExpiredMembers()
        {
            Organizations organizations = Organizations.GetAll();

            foreach (Organization organization in organizations)
            {
                Participations participations = Participations.GetExpired(organization);
                // Mail each expiring member

                foreach (Participation membership in participations)
                {
                    //only remove expired memberships
                    if (membership.Expires > DateTime.Now.Date)
                    {
                        continue;
                    }

                    Person person = membership.Person;

                    // TODO: Check for positions that expire with membership


                    // Mail

                    Participations personParticipations   = person.GetParticipations();
                    Participations participationsToDelete = new Participations();
                    foreach (Participation personMembership in personParticipations)
                    {
                        if (personMembership.Expires <= DateTime.Now.Date)
                        {
                            participationsToDelete.Add(personMembership);
                        }
                    }


                    ExpiredMail expiredmail    = new ExpiredMail();
                    string      membershipsIds = "";

                    if (participationsToDelete.Count > 1)
                    {
                        foreach (Participation personMembership in participationsToDelete)
                        {
                            membershipsIds += "," + personMembership.MembershipId;
                        }
                        membershipsIds = membershipsIds.Substring(1);
                        string expiredMemberships = "";
                        foreach (Participation personMembership in participationsToDelete)
                        {
                            if (personMembership.OrganizationId != organization.Identity)
                            {
                                expiredMemberships += ", " + personMembership.Organization.Name;
                            }
                        }
                        expiredMemberships      += ".  ";
                        expiredmail.pMemberships = expiredMemberships.Substring(2).Trim();
                    }

                    //TODO: URL for renewal, recieving end of this is NOT yet implemented...
                    // intended to recreate the memberships in MID
                    string tokenBase = person.PasswordHash + "-" + membership.Expires.Year;
                    string stdLink   = "https://pirateweb.net/Pages/Public/SE/People/MemberRenew.aspx?MemberId=" +
                                       person.Identity +
                                       "&SecHash=" + SHA1.Hash(tokenBase).Replace(" ", "").Substring(0, 8) +
                                       "&MID=" + membershipsIds;

                    expiredmail.pStdRenewLink = stdLink;
                    expiredmail.pOrgName      = organization.MailPrefixInherited;

                    person.SendNotice(expiredmail, organization.Identity);

                    person.DeleteSubscriptionData();

                    string orgIdString = string.Empty;

                    foreach (Participation personMembership in participationsToDelete)
                    {
                        if (personMembership.Active)
                        {
                            orgIdString += " " + personMembership.OrganizationId;

                            personMembership.Terminate(EventSource.PirateBot, null, "Member churned in housekeeping.");
                        }
                    }
                }
            }
        }
Esempio n. 26
0
        public static void NotifyBouncingEmails()
        {
            Regex regex = new Regex(@"(?<email>[a-z_0-9\.\+\-]+\@[a-z_0-9\.\-]+)",
                                    RegexOptions.Compiled | RegexOptions.IgnoreCase);

            string  SMSBouncingEmail = ("" + Persistence.Key["SMSBouncingEmail"]).ToUpper().Trim();
            Regex   reIsNo           = new Regex(@"(NO)|(N)|(NEJ)", RegexOptions.IgnoreCase);
            Boolean dontSendSMS      = reIsNo.IsMatch(SMSBouncingEmail);
            Boolean holdSMS          = SMSBouncingEmail == "HOLD";
            int     lastCaseHandled  = 0;

            if (PhoneMessageTransmitter.CheckServiceStatus() == false)
            {
                dontSendSMS = true;
            }

            SupportCase[] cases = null;
            while (lastCaseHandled == 0 || (cases != null && cases.Length > 0))
            {
                cases = GetUndeliverableCases(lastCaseHandled, 100);

                if (cases.Length == 0) // very very important bugfix
                {
                    break;
                }

                foreach (SupportCase @case in cases)
                {
                    lastCaseHandled = @case.Identity;
                    bool attemptRecovery = true;

                    if (@case.Title.ToLower().Contains("ditt medlemskap har"))
                    {
                        // "Ditt medlemskap har gått ut"

                        attemptRecovery = false;
                    }

                    if (@case.Title.ToLower().Contains("press"))
                    {
                        // Press release

                        attemptRecovery = false;
                    }

                    if (attemptRecovery)
                    {
                        string body = GetFirstEventText(@case.Identity);

                        // Strip the mail header

                        int bodySeparator = body.IndexOf("\r\n\r\n");

                        if (bodySeparator > 0)
                        {
                            body = body.Substring(bodySeparator + 4);
                        }
                        else
                        {
                            body = string.Empty;
                        }

                        Match match = regex.Match(body);
                        if (match.Success)
                        {
                            string email  = match.Groups["email"].Value;
                            People people = People.FromMail(email);

                            if (people.Count > 2)
                            {
                                CloseWithComment(@case.Identity,
                                                 "Bounced message closed. More than one person matches the email address. Both marked unreachable.");

                                foreach (Person person in people)
                                {
                                    person.MailUnreachable = true;
                                }
                            }

                            else if (people.Count < 1)
                            {
                                CloseWithComment(@case.Identity,
                                                 "Bounced message closed. No person in the database matches the email address.");
                            }

                            else
                            {
                                // When we get here, there is exactly one person matching in the database

                                Person person = people[0];

                                bool hasActiveMemberships = false;

                                Participations participations = person.GetParticipations();

                                foreach (Participation membership in participations)
                                {
                                    if (membership.Active)
                                    {
                                        hasActiveMemberships = true;
                                    }
                                }

                                if (hasActiveMemberships)
                                {
                                    // Attempt to contact by SMS.
                                    if (!holdSMS)
                                    {
                                        if (person.Phone.Trim().Length > 2)
                                        {
                                            if (dontSendSMS)
                                            {
                                                CloseWithComment(@case.Identity,
                                                                 "The person at phone# " + person.Phone + ", " + person.Name +
                                                                 " (#" + person.Identity +
                                                                 "), was not contacted due to that SMS notification is currently turned off. Bounced message closed.");
                                            }
                                            else
                                            {
                                                try
                                                {
                                                    person.SendPhoneMessage(
                                                        "Piratpartiet: den mailadress vi har till dig (" +
                                                        person.Mail +
                                                        ") studsar. Kontakta [email protected] med ny adress.");
                                                    CloseWithComment(@case.Identity,
                                                                     "Successfully notified the member at phone# " + person.Phone +
                                                                     ", " + person.Name + " (#" + person.Identity +
                                                                     "), about the bounced email using an SMS message. Case closed.");
                                                }
                                                catch (Exception)
                                                {
                                                    CloseWithComment(@case.Identity,
                                                                     "The person at phone# " + person.Phone + ", " + person.Name +
                                                                     " (#" + person.Identity +
                                                                     "), could not be reached over SMS. This member has been marked unreachable. Bounced message closed.");
                                                    person.MailUnreachable = true;
                                                }
                                            }
                                        }
                                        else
                                        {
                                            CloseWithComment(@case.Identity,
                                                             person.Name + " (#" + person.Identity +
                                                             ") does not have a listed phone number. This member has been marked unreachable. Bounced message closed.");
                                            person.MailUnreachable = true;
                                        }
                                    }
                                }
                                else
                                {
                                    CloseWithComment(@case.Identity,
                                                     "The person at phone# " + person.Phone + ", " + person.Name + " (#" +
                                                     person.Identity +
                                                     ") has no active memberships. Bounced message closed.");
                                }
                            }
                        }
                        else
                        {
                            CloseWithComment(@case.Identity,
                                             "Bounced message closed. No email address could be located.");
                        }
                    }
                    else
                    {
                        CloseWithComment(@case.Identity, "Bounced message closed without attempt of recovery.");
                    }
                }
            }
        }