Exemplo n.º 1
0
    private void GetAllUsers()
    {
        MembershipCollection users = Membership.GetAllUsers();

        gvUser.DataSource();
        gvUser.DataBind();
    }
Exemplo n.º 2
0
 public ConstituentInfo(DataSet tessResults)
 {
     DataTableCollection tables = tessResults.Tables;
     if (tables.Contains("Addresses") && tables["Addresses"].Rows.Count > 0)
     {
         Addresses = new AddressCollection(tables["Addresses"]);
     }
     if (tables.Contains("ConstituentAttribute")
             && tables["ConstituentAttribute"].Rows.Count > 0)
     {
         Attributes = new ConstituentAttributeCollection(tables["ConstituentAttribute"]);
     }
     if (tables.Contains("EmailAddresses") && tables["EmailAddresses"].Rows.Count > 0)
     {
         EmailAddresses = new EmailAddressCollection(tables["EmailAddresses"]);
     }
     if (tables.Contains("Associations") && tables["Associations"].Rows.Count > 0)
     {
         Associations = new AssociationCollection(tables["Associations"]);
     }
     if (tables.Contains("Constituency") && tables["Constituency"].Rows.Count > 0)
     {
         Constituencies = new ConstituencyCollection(tables["Constituency"]);
     }
     if (tables.Contains("ConstituentHeader") && tables["ConstituentHeader"].Rows.Count > 0)
     {
         Header = new ConstituentHeader(tables["ConstituentHeader"]);
     }
     if (tables.Contains("Contribution") && tables["Contribution"].Rows.Count > 0)
     {
         Contributions = new ContributionRecordCollection(tables["Contribution"]);
     }
     if (tables.Contains("Interests") && tables["Interests"].Rows.Count > 0)
     {
         Interests = new InterestCollection(tables["Interests"]);
     }
     if (tables.Contains("Memberships") && tables["Memberships"].Rows.Count > 0)
     {
         Memberships = new MembershipCollection(tables["Memberships"]);
     }
     if (tables.Contains("Phones") && tables["Phones"].Rows.Count > 0)
     {
         PhoneNumbers = new PhoneNumberCollection(tables["Phones"]);
     }
     if (tables.Contains("ProgramListings") && tables["ProgramListings"].Rows.Count > 0)
     {
         ProgramListings = new ProgramListingCollection(tables["ProgramListings"]);
     }
     if (tables.Contains("Rankings") && tables["Rankings"].Rows.Count > 0)
     {
         Rankings = new RankCollection(tables["Rankings"]);
     }
 }
 public MembershipEntity GetMember(string uName, string password)
 {
     MembershipCollection memberships = new MembershipCollection();
     PredicateExpression filter = new PredicateExpression();
     filter.AddWithAnd(MembershipFields.UserName == uName);
     filter.AddWithAnd(MembershipFields.Password == Business.Encryption.SHA1Encryption.EncryptMessage(password));
     filter.AddWithAnd(MembershipFields.Status == true);
     memberships.GetMulti(filter);
     if (memberships.Count > 0)
         return memberships.FirstOrDefault();
     else
         return null;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Returns a silo address.
        /// </summary>
        /// <param name="membershipData">
        /// The membership data.
        /// </param>
        /// <param name="useProxyPort">
        /// The use proxy port.
        /// </param>
        /// <returns>
        /// The <see cref="SiloAddress"/>.
        /// </returns>
        public static SiloAddress ReturnSiloAddress(MembershipCollection membershipData, bool useProxyPort = false)
        {
            // Todo: Move this method to it's own class so it can be shared a bit more elogantly
            int port = membershipData.Port;

            if (useProxyPort)
            {
                port = membershipData.ProxyPort;
            }

            int    generation  = membershipData.Generation;
            string address     = membershipData.Address;
            var    siloAddress = SiloAddress.New(new IPEndPoint(IPAddress.Parse(address), port), generation);

            return(siloAddress);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Parses the MembershipData to a MembershipEntry
        /// </summary>
        /// <param name="membershipData">
        /// The membership data.
        /// </param>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        internal async Task <Tuple <MembershipEntry, string> > Parse(MembershipCollection membershipData)
        {
            // TODO: This is a bit of hack way to check in the current version if there's membership data or not, but if there's a start time, there's member.
            DateTime?       startTime = membershipData.StartTime;
            MembershipEntry entry     = null;

            if (startTime.HasValue)
            {
                entry = new MembershipEntry
                {
                    SiloAddress = ReturnSiloAddress(membershipData),

                    // SiloName = TryGetSiloName(record),
                    HostName     = membershipData.HostName,
                    Status       = (SiloStatus)membershipData.Status,
                    ProxyPort    = membershipData.ProxyPort,
                    StartTime    = startTime.Value,
                    IAmAliveTime = membershipData.IAmAliveTime,
                    SiloName     = membershipData.HostName
                };

                string suspectingSilos = membershipData.SuspectTimes;
                if (!string.IsNullOrWhiteSpace(suspectingSilos))
                {
                    entry.SuspectTimes = new List <Tuple <SiloAddress, DateTime> >();
                    entry.SuspectTimes.AddRange(
                        suspectingSilos.Split('|').Select(
                            s =>
                    {
                        var split = s.Split(',');
                        return(new Tuple <SiloAddress, DateTime>(
                                   SiloAddress.FromParsableString(split[0].Trim()),
                                   LogFormatter.ParseDate(split[1].Trim())));
                    }));
                }
            }

            BsonDocument membershipVersionDocument =
                await
                this.FindDocumentAsync(
                    MembershipVersionCollectionName,
                    MembershipVersionKeyName,
                    membershipData.DeploymentId);

            return(Tuple.Create(entry, membershipVersionDocument["Version"].AsInt32.ToString()));
        }
        public MembershipEntity GetMember(string uName, string password)
        {
            MembershipCollection memberships = new MembershipCollection();
            PredicateExpression  filter      = new PredicateExpression();

            filter.AddWithAnd(MembershipFields.UserName == uName);
            filter.AddWithAnd(MembershipFields.Password == Business.Encryption.SHA1Encryption.EncryptMessage(password));
            filter.AddWithAnd(MembershipFields.Status == true);
            memberships.GetMulti(filter);
            if (memberships.Count > 0)
            {
                return(memberships.FirstOrDefault());
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Return gateway uri.
 /// </summary>
 /// <param name="record">
 /// The record.
 /// </param>
 /// <returns>
 /// The <see cref="Uri"/>.
 /// </returns>
 internal static Uri ReturnGatewayUri(MembershipCollection record)
 {
     return(MongoMembershipRepository.ReturnSiloAddress(record, true).ToGatewayUri());
 }
Exemplo n.º 8
0
        /// <summary>
        /// Insert a membership as well as update the version
        /// </summary>
        /// <param name="deploymentId">
        /// The deployment id.
        /// </param>
        /// <param name="entry">
        /// The entry.
        /// </param>
        /// <param name="tableVersion">
        /// The table version.
        /// </param>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        /// <exception cref="Exception">
        /// </exception>
        public async Task <bool> InsertMembershipRow(
            string deploymentId,
            MembershipEntry entry,
            TableVersion tableVersion)
        {
            string address = ReturnAddress(entry.SiloAddress.Endpoint.Address);

            var collection = await ReturnCollection();

            var membershipDocument =
                collection.AsQueryable()
                .FirstOrDefault(
                    m =>
                    m.DeploymentId == deploymentId && m.Address == address &&
                    m.Port == entry.SiloAddress.Endpoint.Port && m.Generation == entry.SiloAddress.Generation);

            if (membershipDocument == null)
            {
                // Todo: Handle as transaction

                if (await UpdateVersion(deploymentId, Convert.ToInt32(tableVersion.VersionEtag), tableVersion.Version))
                {
                    MembershipCollection document = new MembershipCollection
                    {
                        DeploymentId = deploymentId,
                        Address      = address,
                        Port         = entry.SiloAddress.Endpoint.Port,
                        Generation   = entry.SiloAddress.Generation,
                        HostName     = entry.HostName,
                        Status       = (int)entry.Status,
                        ProxyPort    = entry.ProxyPort,
                        StartTime    = entry.StartTime,
                        IAmAliveTime = entry.IAmAliveTime
                    };

                    if (entry.SuspectTimes == null || entry.SuspectTimes.Count == 0)
                    {
                        document.SuspectTimes = string.Empty;
                    }
                    else
                    {
                        document.SuspectTimes = ReturnStringFromSuspectTimes(entry);
                    }

                    if (!collection.AsQueryable().Any(
                            r => r.DeploymentId == document.DeploymentId &&
                            r.Address == document.Address &&
                            r.Port == document.Port &&
                            r.Generation == document.Generation &&
                            r.HostName == document.HostName &&
                            r.Status == document.Status &&
                            r.ProxyPort == document.ProxyPort &&
                            r.StartTime == document.StartTime &&
                            r.IAmAliveTime == document.IAmAliveTime))
                    {
                        await collection.InsertOneAsync(document);
                    }
                    else
                    {
                        return(false);
                    }

                    return(true);
                }

                return(false);
            }

            return(false);
        }