当前位置: 首页>>代码示例>>C#>>正文


C# People.Add方法代码示例

本文整理汇总了C#中People.Add方法的典型用法代码示例。如果您正苦于以下问题:C# People.Add方法的具体用法?C# People.Add怎么用?C# People.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在People的用法示例。


在下文中一共展示了People.Add方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ApplySubscription

        static private People ApplySubscription (People input, int feedId)
        {
            People output = new People();

            foreach (Person person in input)
            {
                if (person.IsSubscribing(feedId))
                {
                    output.Add(person);
                }
            }

            return output;
        }
开发者ID:SwarmCorp,项目名称:Swarmops,代码行数:14,代码来源:MailResolver.cs

示例2: ButtonSearch_Click

    protected void ButtonSearch_Click (object sender, EventArgs e)
    {
        // If a member number is present, use only that as search criteria.

        People searchResults = null;

        string searchMemberNumber = this.TextMemberNumber.Text.Trim();

        if (searchMemberNumber.Length > 0)
        {
            // Lots of things here that will throw on invalid arguments
            Regex re = new Regex(@"[\s,;]+");
            string[] numbers = re.Replace(searchMemberNumber, ";").Split(';');
            searchResults = new People();
            foreach (string pers in numbers)
            {
                try
                {
                    string persID = pers;
                    if (searchMemberNumber.Trim().ToUpper().StartsWith("PP"))
                    {
                        //Hexcoded number
                        char[] mnr = persID.Substring(2).ToCharArray();
                        Array.Reverse(mnr);
                        persID = new string(mnr);
                        int num = (System.Int32.Parse(searchMemberNumber, System.Globalization.NumberStyles.AllowHexSpecifier));
                        persID = num.ToString();
                    }
                    int personId = Convert.ToInt32(persID);
                    Person person = Person.FromIdentity(personId);
                    searchResults.Add(person);
                }
                catch (Exception)
                { }
            }

            if (numbers.Length > 1)
            {
                PersonList.GridView.PageSize = numbers.Length;
                PersonList.ShowStreet = true;
            }
        }
        else
        {
            People nameResult = People.FromNamePattern(TextNamePattern.Text);
            People emailResult = People.FromEmailPattern(TextEmailPattern.Text);
            People cityResult = People.FromCityPattern(TextCityPattern.Text);
            People pcResult = People.FromPostalCodePattern(TextPostalCodePattern.Text);

            if (nameResult != null || emailResult != null)
            {
                searchResults = People.LogicalAnd(nameResult, emailResult);
            }
            if (searchResults != null || cityResult != null)
            {
                searchResults = People.LogicalAnd(searchResults, cityResult);
            }
            if (searchResults != null || pcResult != null)
            {
                searchResults = People.LogicalAnd(searchResults, pcResult);
            }

            string inputDateText = textPersonalNumber.Text.Trim();
            if (inputDateText != "")
            {
                int inpLen = inputDateText.Length;
                int yLen = 2;

                string[] formats2 = new string[] { "yy", "yyMM", "yyMMdd", "yyyy", "yyyyMM", "yyyyMMdd", "yyyy", "yyyy-MM", "yyyy-MM-dd", "yy", "yy-MM", "yy-MM-dd" };
                string[] formats4 = new string[] { "yyyy", "yyyyMM", "yyyyMMdd", "yy", "yyMM", "yyMMdd", "yyyy", "yyyy-MM", "yyyy-MM-dd", "yy", "yy-MM", "yy-MM-dd" };
                string[] formats;

                DateTime parsedDate = DateTime.MinValue;
                DateTime endDate = DateTime.MaxValue;

                if (inputDateText.StartsWith("19")
                    || inputDateText.StartsWith("20"))
                {
                    formats = formats4;
                    yLen = 4;
                }
                else
                    formats = formats2;
                string[] datesSplit = (textPersonalNumber.Text + "--").Split(new string[] { "--" }, StringSplitOptions.None);

                DateTime.TryParseExact(datesSplit[0].Trim(), formats, CultureInfo.InvariantCulture, DateTimeStyles.None, out parsedDate);
                if (parsedDate != DateTime.MinValue)
                {
                    if (datesSplit[1] != "")
                    {
                        DateTime.TryParseExact(datesSplit[1].Trim(), formats, CultureInfo.InvariantCulture, DateTimeStyles.None, out endDate);
                        inpLen = datesSplit[1].Trim().Length;
                        bool dash = textPersonalNumber.Text.Contains("-");
                        if (inpLen == yLen)
                        {
                            endDate = endDate.AddYears(1);
                        }
                        else if (inpLen == yLen + 2 || (dash && inpLen == yLen + 3))
                        {
                            endDate = endDate.AddMonths(1);
//.........这里部分代码省略.........
开发者ID:SwarmCorp,项目名称:Swarmops,代码行数:101,代码来源:Search.aspx.cs

示例3: NewOnExecuted

 // Event handlers for menu items.
 void NewOnExecuted(object sender, ExecutedRoutedEventArgs args)
 {
     people = new People();
     people.Add(new Person());
     InitializeNewPeopleObject();
 }
开发者ID:gawallsibya,项目名称:BIT_MFC-CShap-DotNet,代码行数:7,代码来源:DataEntryWithNavigation.cs

示例4: FilterPeopleToMatchAuthority

        public static People FilterPeopleToMatchAuthority (People people, Authority authority, int gracePeriod)
        {
            // First: If sysadmin, return the whole list uncensored.

            if (IsSystemAdministrator(authority))
            {
                return people;
            }

            SwarmDb databaseRead = SwarmDb.GetDatabaseForReading();

            if (gracePeriod == -1)
                gracePeriod = Membership.GracePeriod;

            Dictionary<int, List<BasicMembership>> membershipTable = databaseRead.GetMembershipsForPeople(people.Identities, gracePeriod);
            Dictionary<int, int> geographyTable = databaseRead.GetPeopleGeographies(people.Identities);

            var clearedPeople = new Dictionary<int, Person>();


            // Clear by organization roles 
            bool CanSeeNonMembers = authority.HasPermission(Permission.CanSeeNonMembers,Organization.PPSEid,-1,Flag.AnyGeographyExactOrganization);

            foreach (BasicPersonRole role in authority.OrganizationPersonRoles)
            {
                Dictionary<int, BasicOrganization> clearedOrganizations =
                    OrganizationCache.GetOrganizationHashtable(role.OrganizationId);

                foreach (Person person in people)
                {
                    // Is the organization cleared in this officer's role for this to-be-viewed member?

                    if (membershipTable.ContainsKey(person.Identity))
                    {
                        foreach (BasicMembership membership in membershipTable[person.Identity])
                        {
                            if (clearedOrganizations.ContainsKey(membership.OrganizationId)
                                && authority.HasPermission(Permission.CanSeePeople, membership.OrganizationId, person.GeographyId, Flag.Default))
                            {
                                if (membership.Active
                                    || (membership.Expires > DateTime.Now.AddDays(-gracePeriod)
                                        && membership.Expires.AddDays(1) > membership.DateTerminated
                                        && authority.HasPermission(Permission.CanSeeExpiredDuringGracePeriod, membership.OrganizationId, person.GeographyId, Flag.Default)))
                                {
                                    clearedPeople[person.Identity] = person;
                                    break;
                                }
                            }
                        }
                    }
                    else if (CanSeeNonMembers)
                    { //person isn't member anywhere
                        clearedPeople[person.Identity] = person;
                    }
                }
            }


            // Clear by node roles:
            //
            // For each node role, check if each member is in a cleared geography AND a cleared organization.
            // If so, permit view of this member. (A person in a branch of a geographical area for organizations X and Z
            // should see only people of those organizations only on those nodes.)


            foreach (BasicPersonRole role in authority.LocalPersonRoles)
            {
                Dictionary<int, BasicGeography> clearedGeographies = GeographyCache.GetGeographyHashtable(role.GeographyId);
                Dictionary<int, BasicOrganization> clearedOrganizations = OrganizationCache.GetOrganizationHashtable(role.OrganizationId);

                foreach (Person person in people)
                {

                    // Is the node AND the organization cleared in this officer's role for this to-be-viewed member?

                    if (membershipTable.ContainsKey(person.Identity))
                    {
                        foreach (BasicMembership membership in membershipTable[person.Identity])
                        {
                            int organizationClear = 0;
                            int geographyClear = 0;
                            if (clearedOrganizations.ContainsKey(membership.OrganizationId))
                            {
                                organizationClear = membership.OrganizationId;

                                if (clearedGeographies.ContainsKey(geographyTable[person.Identity]))
                                {
                                    geographyClear = geographyTable[person.Identity];
                                }

                                if (organizationClear > 0
                                    && geographyClear > 0
                                    && authority.HasPermission(Permission.CanSeePeople, organizationClear, geographyClear, Flag.Default))
                                {
                                    if (membership.Active
                                        || (membership.Expires > DateTime.Now.AddDays(-gracePeriod)
                                            && membership.Expires.AddDays(1) > membership.DateTerminated
                                            && authority.HasPermission(Permission.CanSeeExpiredDuringGracePeriod, membership.OrganizationId, person.GeographyId, Flag.Default)))
                                    {
                                        clearedPeople[person.Identity] = person;
//.........这里部分代码省略.........
开发者ID:SwarmCorp,项目名称:Swarmops,代码行数:101,代码来源:Authorization.cs

示例5: GetPeopleByLoginToken

        /// <summary>
        /// Get all person IDs that match a certain login token.
        /// </summary>
        /// <param name="loginToken">The login token to look for.</param>
        /// <returns>An array of person IDs.</returns>
        private static People GetPeopleByLoginToken (string loginToken)
        {
            People result = new People();

            SwarmDb database = SwarmDb.GetDatabaseForReading();

            // First, is the login token numeric? If so, add it as is and is a valid person.

            if (LogicServices.IsNumber(loginToken))
            {
                try
                {
                    int personId = Int32.Parse(loginToken);
                    Person person = Person.FromIdentity(personId);

                    // If we get here without exception, the login token is a valid person Id

                    result.Add(person);
                }
                catch (Exception)
                {
                    // Do nothing. In particular, do not add the person Id as a candidate.
                }
            }

            // Second, is the login token ten digits? If so, look for the person with this personal number.
            // This is specific to the Swedish PP.

            string cleanedNumber = LogicServices.CleanNumber(loginToken);

            if (cleanedNumber.Length == 10)
            {
                int[] personIds = database.GetObjectsByOptionalData(ObjectType.Person,
                                                                    ObjectOptionalDataType.PersonalNumber,
                                                                    cleanedNumber);

                foreach (int personId in personIds)
                {
                    result.Add(Person.FromIdentity(personId));
                }
            }

            // Third, look for a matching name. Expand the login token so that "R Falkv" will match "Rickard Falkvinge".
            // Only do this if the login token, excessive whitespace removed, is five characters or more.

            result = People.LogicalOr(result, People.FromNamePattern(loginToken));

            // Fourth, look for a matching email. Only do an exact match here.

            if (loginToken.Contains("@"))
            {
                result = People.LogicalOr(result, People.FromEmailPattern(loginToken));
            }

            return result;
        }
开发者ID:SwarmCorp,项目名称:Swarmops,代码行数:61,代码来源:Authentication.cs

示例6: GetLeadsVicesAndAdmins

    /* Fix for Ticket #64 - Vice på distrikt- och valkretsnivå bör kunna assigna användare 
     * som är tilldelade Lead, för att avlasta varandra och undvika flaskhalsar. */
    protected People GetLeadsVicesAndAdmins ()
    {
        People result = new People();

        foreach (BasicPersonRole role in _authority.LocalPersonRoles)
        {
            if (role.Type == RoleType.LocalLead || role.Type == RoleType.LocalDeputy)
            {
                People localPeople = new People();

                RoleLookup allRoles = RoleLookup.FromGeographyAndOrganization(role.GeographyId, role.OrganizationId);

                Roles leadRoles = allRoles[RoleType.LocalLead];
                Roles viceRoles = allRoles[RoleType.LocalDeputy];
                Roles adminRoles = allRoles[RoleType.LocalAdmin];

                foreach (PersonRole localRole in leadRoles)
                {
                    localPeople.Add(localRole.Person);
                }

                foreach (PersonRole localRole in viceRoles)
                {
                    localPeople.Add(localRole.Person);
                }

                foreach (PersonRole localRole in adminRoles)
                {
                    localPeople.Add(localRole.Person);
                }

                result = result.LogicalOr(localPeople);
            }
        }

        return result;
    }
开发者ID:SwarmCorp,项目名称:Swarmops,代码行数:39,代码来源:ListVolunteers.aspx.cs

示例7: GetDirectReports

    protected People GetDirectReports ()
    {
        People result = new People();

        foreach (BasicPersonRole role in _authority.LocalPersonRoles)
        {
            if (role.Type == RoleType.LocalLead || role.Type == RoleType.LocalDeputy || role.Type == RoleType.LocalAdmin)
            {
                Geographies geographies = Geography.FromIdentity(role.GeographyId).Children;

                // HACK: Compensate for current bad tree structure

                if (role.GeographyId == 34)
                { //Lägg till Skåne till Södra
                    geographies = geographies.LogicalOr(Geography.FromIdentity(36).Children);
                }

                if (role.GeographyId == 32)
                { //Lägg till Västra Götaland till Västra
                    geographies = geographies.LogicalOr(Geography.FromIdentity(355).Children);
                }

                foreach (Geography geography in geographies)
                {
                    People localLead = new People();
                    RoleLookup allRoles = RoleLookup.FromGeographyAndOrganization(geography.Identity,
                                                                                  role.OrganizationId);

                    Roles leadRoles = allRoles[RoleType.LocalLead];

                    foreach (PersonRole leadRole in leadRoles)
                    {
                        localLead.Add(leadRole.Person);
                    }

                    result = result.LogicalOr(localLead);
                }
            }
        }

        return result;
    }
开发者ID:SwarmCorp,项目名称:Swarmops,代码行数:42,代码来源:ListVolunteers.aspx.cs

示例8: ProcessLocalDonationReceived

        private static void ProcessLocalDonationReceived (BasicPWEvent newPwEvent)
        {
            Organization organization = Organization.FromIdentity(newPwEvent.OrganizationId);
            Geography geography = Geography.FromIdentity(newPwEvent.GeographyId);
            FinancialAccount account = FinancialAccount.FromIdentity(Int32.Parse(newPwEvent.ParameterText));
            FinancialTransaction transaction = FinancialTransaction.FromIdentity(newPwEvent.ParameterInt);
            CultureInfo culture = new CultureInfo(organization.DefaultCountry.Culture);

            DateTime today = DateTime.Today;
            Int64 amount = transaction.Rows[0].AmountCents;  // just pick any transaction row, it'll have the amount
            Int64 budget = -(account.GetBudgetCents(DateTime.Today.Year));
            Int64 curBalance = account.GetDeltaCents(new DateTime(today.Year, 1, 1), new DateTime(today.Year, 12, 31));

            Int64 fundsAvailable = budget - curBalance;

            if (amount < 0)
            {
                amount = -amount;  // though possibly in the negative so let's make sure it's positive
            }

            // Assemble notification body

            string body =
                "Local donation received for " + organization.Name + ", " + geography.Name + ":\r\n\r\n";

            body += amount.ToString("N2", culture) + " received on " +
                    transaction.DateTime.ToString("yyyy-MMM-dd") + ".\r\n\r\n";

            body += "Total funds available in the local budget: " + (fundsAvailable/100.0).ToString("N2", culture) + ".\r\n";

            // Determine who to send to (local leads and vices, plus Rick for debugging)

            People concernedPeople = new People();

            RoleLookup lookup = RoleLookup.FromGeographyAndOrganization(geography, organization);

            Roles leadRoles = lookup[RoleType.LocalLead];
            Roles viceRoles = lookup[RoleType.LocalDeputy];

            if (leadRoles.Count > 0)
            {
                concernedPeople.Add(leadRoles[0].Person);  // should only be one lead
            }
            foreach (PersonRole role in viceRoles)
            {
                concernedPeople.Add(role.Person);
            }

            // add Rick

            concernedPeople.Add(Person.FromIdentity(1));

            new MailTransmitter(Strings.MailSenderNameFinancial, Strings.MailSenderAddress,
                               "Local donation received: [" + amount.ToString("N2", culture) + "]",
                               body, concernedPeople, true).Send();
        }
开发者ID:SwarmCorp,项目名称:Swarmops,代码行数:56,代码来源:EventProcessor.cs

示例9: ProcessParleyCancelled

        internal static void ProcessParleyCancelled (BasicPWEvent newPwEvent)
        {
            Parley parley = Parley.FromIdentity(newPwEvent.ParameterInt);
            Person actingPerson = Person.FromIdentity(newPwEvent.ActingPersonId);

            string body = "Regrettably, conference #" + parley.Identity + " (" + parley.Name +
                          "), organized by " + parley.Organization.Name + " and scheduled for " + parley.StartDate.ToString("yyyy-MM-dd") + ", has been cancelled. You were one of the attending people.\r\n\r\n";

            body +=
                "If you have received an invoice for your participation in this conference, you will receive a credit invoice shortly. If you have received an invoice and already paid your attendance fee, that fee will be reimbursed shortly as part of the crediting process. " +
                "You will get separate notices as this happens.\r\n\r\n" +

                "We apologize deeply for the inconvenience.\r\n";


            ParleyAttendees attendees = parley.Attendees;

            People concernedPeople = new People();

            foreach (ParleyAttendee attendee in attendees)
            {
                concernedPeople.Add(attendee.Person);
            }

            new MailTransmitter(Strings.MailSenderNameFinancial, "[email protected]",   // HACK - must use organization's address and name
                                           "Conference CANCELLED: " + parley.Name,
                                           body, concernedPeople, false).Send();

            foreach (ParleyAttendee attendee in attendees)
            {
                if (attendee.Invoiced && attendee.OutboundInvoiceId > 0)
                {
                    if (attendee.Invoice.CreditInvoice == null)
                    {
                        attendee.Invoice.Credit(actingPerson);
                    }
                }
            }

            parley.CancelBudget();
            parley.CloseBudget(actingPerson);
            parley.Open = false;
        }
开发者ID:SwarmCorp,项目名称:Swarmops,代码行数:43,代码来源:EventProcessor.cs


注:本文中的People.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。