{
DateTime now = DateTime.Now;
User user = new User();
Regex regex;
for (int i = 0; i < fields.Count; i++)
{
string field = fields[i].Groups[1].Value;
string value = fields[i].Groups[2].Value;
switch (field)
{
case "First Name:":
user.FirstName = value;
break;
case "Last Name:":
user.LastName = value;
break;
case "LSRP License Number:":
user.LPSRP = value;
break;
case "Company or Organization:":
user.Company = value;
break;
case "Title:":
user.Title = value;
break;
case "Web Address:":
regex = new Regex(REGWEBADDRESS, RegexOptions.Multiline);
user.WebAdress = regex.Match(value).Groups[1].Value;
user.WebAdress = user.WebAdress == "http://" ? "" : user.WebAdress;
break;
case "Phone Number:":
user.Phone = value;
break;
case "Address:":
user.AddressOne = value;
break;
case "Address 2:":
user.AddressTwo = value;
break;
case "City:":
user.City = value;
break;
case "State:":
user.State = value;
break;
case "Zip:":
user.Zip = value;
break;
case "Membership Type:":
user.MemberShip = value;
break;
}
}
pageSource = HttpUtility.HtmlDecode(pageSource);
regex = new Regex(REGEMAILNAME, RegexOptions.Multiline);
var email = regex.Match(pageSource).Groups[1].Value + "@";
regex = new Regex(REGEMAILSERVICE, RegexOptions.Multiline);
var tmp = regex.Match(pageSource);
email += tmp.Groups[1].Value + "." + tmp.Groups[2].Value;
email = email == "@." ? "" : email;
user.Email = email;
Console.WriteLine($"GetUser - {(DateTime.Now - now).TotalSeconds}");
return user;
}
Больше секунды на запись?
Обсуждают сегодня