コード例 #1
0
        /// <summary>
        ///     Allows you to generate an HTML representation of the current Address object.
        /// </summary>
        /// <returns>An HTML representation of the current Address object.</returns>
        public string ToHtmlString()
        {
            var sb = new StringBuilder();

            if (NickName.Trim().Length > 0)
            {
                sb.Append("<em>" + NickName + "</em><br />");
            }
            if (LastName.Length > 0 || FirstName.Length > 0)
            {
                sb.Append(FirstName);
                if (MiddleInitial.Trim().Length > 0)
                {
                    sb.Append(" " + MiddleInitial);
                }
                sb.Append(" " + LastName + "<br />");
                if (Company.Trim().Length > 0)
                {
                    sb.Append(Company + "<br />");
                }
            }

            sb.Append(GetLinesHtml());

            return(sb.ToString());
        }
コード例 #2
0
ファイル: Address.cs プロジェクト: wncoder/core
        /// <summary>
        ///     Returns a List-based representation of the address, including all of the common addres properties, as specified in
        ///     the parameters.
        /// </summary>
        /// <param name="appendNameAndCompany">It true, the full name and company name will be included in the list.</param>
        /// <param name="appendPhones">If true, the phone, fax, and website URL will be included in the list.</param>
        /// <returns>List - an array of the address information in the current object.</returns>
        public List <string> GetLines(bool appendNameAndCompany = true, bool appendPhones = true)
        {
            var lines = new List <string>();

            if (appendNameAndCompany)
            {
                lines.Add(
                    LastName +
                    (string.IsNullOrWhiteSpace(MiddleInitial) ? "" : " " + MiddleInitial.Trim()) +
                    (string.IsNullOrWhiteSpace(FirstName) ? "" : " " + FirstName.Trim())
                    );
                lines.Add(Company);
            }

            lines.Add(Line1);
            lines.Add(Line2);
            lines.Add(Line3);

            if (RegionData != null)
            {
                lines.Add(City + ", " + RegionData.Abbreviation + " " + _postalCode);
            }
            else
            {
                lines.Add(City + ", " + _postalCode);
            }

            if (CountryData != null && !string.IsNullOrEmpty(CountryData.DisplayName))
            {
                lines.Add(CountryData.DisplayName);
            }
            if (appendPhones)
            {
                lines.Add(Phone);

                if (!string.IsNullOrWhiteSpace(Fax))
                {
                    lines.Add("Fax: " + Fax);
                }

                lines.Add(WebSiteUrl);
            }

            // Remove emtpy lines
            var i = 0;

            while (i < lines.Count)
            {
                if (string.IsNullOrWhiteSpace(lines[i]))
                {
                    lines.RemoveAt(i);
                }
                else
                {
                    i++;
                }
            }

            return(lines);
        }
コード例 #3
0
 public void Authenticate(string Username, string Password)
 {
     try
     {
         this.DE = new DirectoryEntry(null, Username, Password, AuthenticationTypes.Secure);
         var sss = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
         DirectorySearcher deSearch = new DirectorySearcher(DE);
         deSearch.Filter = "(&(objectClass=user)(sAMAccountName=" + Username + "))";
         SearchResult result = deSearch.FindOne();
         if (result != null)
         {
             this.DE           = new DirectoryEntry(result.Path, Username, Password, AuthenticationTypes.Secure);
             IsAuthenticated   = true;
             FirstName         = GetProperty("givenName");
             MiddleInitial     = GetProperty("initials");
             LastName          = GetProperty("sn");
             UserPrincipalName = GetProperty("UserPrincipalName");
             EmployeeID        = int.Parse(GetProperty("employeeID"));
             //PostalAddress = GetProperty("PostalAddress");
             //MailingAddress = GetProperty("StreetAddress");
             //ResidentialAddress = GetProperty("HomePostalAddress");
             Title = GetProperty("Title");
             //HomePhone = GetProperty("HomePhone");
             //OfficePhone = GetProperty("TelephoneNumber");
             //Mobile = GetProperty("Mobile");
             //Fax = GetProperty("FacsimileTelephoneNumber");
             Email             = GetProperty("mail");
             Url               = GetProperty("Url");
             this.Username     = GetProperty("sAMAccountName");
             DistinguishedName = GetProperty("DistinguishedName");
             //Company = GetProperty("Company");
             Department  = GetProperty("Department");
             DisplayName = FirstName + ((MiddleInitial.Trim() != string.Empty) ? " " + MiddleInitial.Trim() + "." : string.Empty) + " " + LastName;
             Groups.Clear();
             for (int i = 0; i <= DE.Properties["memberOf"].Count - 1; i++)
             {
                 string s = GetProperty("memberOf", i);
                 if (s.IndexOf("OU=CPL Systems") != 0)
                 {
                     string[] x = s.Split(',')[0].Split('=');
                     Groups.Add(x[1]);
                 }
             }
             OU = DistinguishedName.Split(',')[1].Replace("OU=", "");
         }
     }
     catch
     {
         //Exception = ex;
         Clear();
     }
 }
コード例 #4
0
        /// <summary>
        ///     Allows you to compare another address object to determine if the two addresses are the same.
        /// </summary>
        /// <param name="a2">Another address object.</param>
        /// <returns>If true, the current address matches the address in the parameter.</returns>
        public bool IsEqualTo(Address a2)
        {
            if (a2 == null)
            {
                return(false);
            }

            var result = true;

            if (string.Compare(NickName.Trim(), a2.NickName.Trim(), true, CultureInfo.InvariantCulture) != 0)
            {
                result = false;
            }
            if (string.Compare(FirstName.Trim(), a2.FirstName.Trim(), true, CultureInfo.InvariantCulture) != 0)
            {
                result = false;
            }
            if (string.Compare(MiddleInitial.Trim(), a2.MiddleInitial.Trim(), true, CultureInfo.InvariantCulture) != 0)
            {
                result = false;
            }
            if (string.Compare(LastName.Trim(), a2.LastName.Trim(), true, CultureInfo.InvariantCulture) != 0)
            {
                result = false;
            }
            if (string.Compare(Company.Trim(), a2.Company.Trim(), true, CultureInfo.InvariantCulture) != 0)
            {
                result = false;
            }
            if (string.Compare(Line1.Trim(), a2.Line1.Trim(), true, CultureInfo.InvariantCulture) != 0)
            {
                result = false;
            }
            if (string.Compare(Line2.Trim(), a2.Line2.Trim(), true, CultureInfo.InvariantCulture) != 0)
            {
                result = false;
            }
            if (string.Compare(Line3.Trim(), a2.Line3.Trim(), true, CultureInfo.InvariantCulture) != 0)
            {
                result = false;
            }
            if (string.Compare(RegionBvin.Trim(), a2.RegionBvin.Trim(), true, CultureInfo.InvariantCulture) != 0)
            {
                result = false;
            }
            if (string.Compare(City.Trim(), a2.City.Trim(), true, CultureInfo.InvariantCulture) != 0)
            {
                result = false;
            }
            if (string.Compare(PostalCode.Trim(), a2.PostalCode.Trim(), true, CultureInfo.InvariantCulture) != 0)
            {
                result = false;
            }
            if (string.Compare(CountryBvin.Trim(), a2.CountryBvin.Trim(), true, CultureInfo.InvariantCulture) != 0)
            {
                result = false;
            }
            if (string.Compare(Phone.Trim(), a2.Phone.Trim(), true, CultureInfo.InvariantCulture) != 0)
            {
                result = false;
            }
            if (string.Compare(Fax.Trim(), a2.Fax.Trim(), true, CultureInfo.InvariantCulture) != 0)
            {
                result = false;
            }
            if (string.Compare(WebSiteUrl.Trim(), a2.WebSiteUrl.Trim(), true, CultureInfo.InvariantCulture) != 0)
            {
                result = false;
            }
            //if (this.Residential != a2.Residential) {
            //    result = false;
            //}

            return(result);
        }
コード例 #5
0
        public string ToHtmlString()
        {
            StringBuilder sb = new StringBuilder();

            if (NickName.Trim().Length > 0)
            {
                sb.Append("<em>" + NickName + "</em><br />");
            }
            if (LastName.Length > 0 || FirstName.Length > 0)
            {
                sb.Append(FirstName);
                if (MiddleInitial.Trim().Length > 0)
                {
                    sb.Append(" " + MiddleInitial);
                }
                sb.Append(" " + LastName + "<br />");
                if (Company.Trim().Length > 0)
                {
                    sb.Append(Company + "<br />");
                }
            }
            if (Line1.Length > 0)
            {
                sb.Append(Line1 + "<br />");
            }
            if (Line2.Trim().Length > 0)
            {
                sb.Append(Line2 + "<br />");
            }
            if (Line3.Trim().Length > 0)
            {
                sb.Append(Line3 + "<br />");
            }

            MerchantTribe.Web.Geography.Country c = MerchantTribe.Web.Geography.Country.FindByBvin(CountryBvin);
            MerchantTribe.Web.Geography.Region  r = c.Regions.Where(y => y.Abbreviation == RegionBvin).FirstOrDefault();

            if (r != null)
            {
                sb.Append(City + ", " + r.Abbreviation + " " + _PostalCode + "<br />");
            }
            else
            {
                if (RegionName.Trim().Length > 0)
                {
                    sb.Append(City + ", " + RegionName + " " + _PostalCode + "<br />");
                }
                else
                {
                    sb.Append(City + ", " + _PostalCode + "<br />");
                }
            }
            if (c != null)
            {
                sb.Append(c.DisplayName + "<br />");
            }

            if (Phone.Trim().Length > 0)
            {
                sb.Append(Phone + "<br />");
            }
            if (Fax.Trim().Length > 0)
            {
                sb.Append("Fax: " + Fax + "<br />");
            }
            if (WebSiteUrl.Trim().Length > 0)
            {
                sb.Append(WebSiteUrl + "<br />");
            }
            return(sb.ToString());
        }