/// <summary> /// Given a long URL, returns a Bitlink. /// </summary> /// <param name="longURL">a long URL to be shortened (example: http://betaworks.com\/).</param> /// <param name="domain">the short domain to use; either bit.ly, j.mp, or bitly.com or a custom short domain. The default for this parameter is the short domain selected by each user in their bitly account settings. Passing a specific domain via this parameter will override the default settings.</param> /// <param name="format">json, xml, txt. Default: json.</param> /// <returns></returns> public string Shorten(string longURL, string domain = "bit.ly", string format = "json") { try { var request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create("https://api-ssl.bitly.com/v3/shorten"); string bitlyToken = System.Configuration.ConfigurationManager.AppSettings["BitlyToken"].ToString(); string postData = "access_token=" + bitlyToken + "&longUrl=" + longURL + "&domain" + domain + "&format=" + format; var data = System.Text.Encoding.ASCII.GetBytes(postData); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = data.Length; using (var stream = request.GetRequestStream()) { stream.Write(data, 0, data.Length); } var response = (System.Net.HttpWebResponse)request.GetResponse(); var responseString = new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd(); return(responseString.Replace("\n", "")); } catch (System.Exception ex) { return(""); } }
private static string GetQuery(string tableName, string queryName) { string resource = String.Format("CSV2Core_MySQL.Support.SQL.{0}.sql", queryName); string query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(resource)).ReadToEnd(); return(query.Replace("$$TABLENAME$$", tableName)); }
public static EmailResponse SendCommissionsEmail(int AgentId) { var model = Trawick.Data.Models.AgentRepo.Agent_CommissionEmailAndKey(AgentId); if (model != null) { string body = new System.IO.StreamReader(System.Web.HttpContext.Current.Server.MapPath("~/CommissionsEmail.html")).ReadToEnd(); body = body.Replace("%agent_key%", model.GUIDStr); var args = new EmailArgs() { EmailTo = model.commEmail, EmaillCC = "[email protected],[email protected],[email protected]", EmailSubject = "Commission Reports for Previous Month", IsHtml = true, EmailBody = body }; var Mailer = Trawick.Common.Email.EmailFactory.GetEmailFactory(); return(Mailer.SendMail(args)); } return(new EmailResponse() { Message = "Error Sending Commission Email" }); }
// Loads the RemoteMethod.ts content. private String ReadRemoteMethod() { string remoteMethod = new System.IO.StreamReader(this.GetType().Assembly.GetManifestResourceStream(FILENAME_REMOTE_METHOD)).ReadToEnd(); remoteMethod = remoteMethod.Replace("\r\n", "\r\n\t"); return(remoteMethod); }
public ActionResult StratisWeb() { string sPostData = new System.IO.StreamReader(this.HttpContext.Request.Body).ReadToEnd(); sPostData = sPostData.Replace("post=", ""); if (sPostData == string.Empty) { // This is the initial call during page load string style = ""; USGDFramework.Data d = new USGDFramework.Data(); string sURL1 = this.HttpContext.Request.QueryString.ToString(); string sMenu = d.GetTopLevelMenu(sURL1); if (sys.Theme == null) sys.Theme = "Biblepay"; string sDomain = this.HttpContext.Request.Scheme + "://" + this.HttpContext.Request.Host + "/StratisWeb/"; string sTheme = sDomain + "css/" + sys.Theme + ".css"; string sCss = " <link rel=stylesheet href='" + sDomain + "css/jquery-ui.css'> " + "<link rel=stylesheet href='" + sTheme + "'>"; // Dynamic Top banner string sSiteURL = this.HttpContext.Request.QueryString.ToString(); string sSiteBanner = "Biblepay Wallet"; string sBanner = GetBanner(sDomain, sSiteBanner); string sJQuery= "<script src='" + sDomain + "Scripts/jquery-1.12.4.js'></script>"; sJQuery += "<script src='" + sDomain + "Scripts/jquery-ui.js'></script>"; //sJQuery += "<script src='" + sDomain + "Scripts/jquery.uploadify.js'></script>"; sJQuery += "<script src='" + sDomain + "Scripts/Core.js'></script>"; sJQuery += "<script src='" + sDomain + "Scripts/jquery.contextMenu.js'></script>"; //sJQuery += "<script src='" + sDomain + "Scripts/featherlight.js'></script>"; //sJQuery += "<script src='" + sDomain + "Scripts/featherlight.gallery.js'></script>"; string sOut = "<html><head>" + style + sJQuery + sCss + " </head><body onload=formload();>" + sBanner + "<table><tr valign=top><td width=10%>" + sMenu + "</td><td width=2%> </td><td width=86%>" + "<div name=divbreadcrumb></div><div name=1>" +"<div name=2><div name=3></div></div></div></td><td width=2%> </td></tr></table></body></html>"; ContentResult c = new ContentResult(); c.Content = sOut; c.ContentType = "html"; return c; } ContentResult c1 = new ContentResult(); string s1 = u.HandleRequest(sPostData, sys); c1.Content = s1; return c1; }
public static string[][] ReadTable(string path) { string readed = new System.IO.StreamReader(path, System.Text.Encoding.Default).ReadToEnd(); readed = readed.Replace("\r\n", "|"); string[] strArray = readed.Split(new char[] { '|' }); string[][] result = new string[strArray.Length][]; for (int i = 0; i < strArray.Length; i++) { result[i] = strArray[i].Split(' '); } return(result); }
public void SendMailToParticipatedUser(DataTable particaipateduserTable) { try { RegisteredVolunteerRepository registeredVolunteerRepository = new RegisteredVolunteerRepository(); foreach (DataRow row in particaipateduserTable.Rows) { string body = ""; string subject = ""; if (!row.IsNull("Employee ID") && !row.IsNull("Event ID")) { RegisteredVolunteer registeredVolunteer = registeredVolunteerRepository.GetRegisteredVolunteerByAssociateID(row["Employee ID"].ToString()); Event outreachEvent = eventRepository.FindEvent(row["Event ID"].ToString()); if (registeredVolunteer != null && outreachEvent != null) { string Creds = outreachEvent.EventId + "\n" + registeredVolunteer.EmployeeID + "\n" + ConstantValues.Participated; string encrypt = AESCrypt.EncryptString(Creds); string url = ConfigurationManager.AppSettings["URL"].ToString() + "Feedback?FeedbackValue=" + encrypt + ""; subject = "Feedback for {0} Dated {1}"; subject = string.Format(subject, outreachEvent.EventName, outreachEvent.EventDate.Value.ToShortDateString()); body = new System.IO.StreamReader(HttpContext.Current.Server.MapPath("~/MailTemplate/Participate_Mail.html")).ReadToEnd(); body = body.Replace("{UserName}", string.IsNullOrEmpty(registeredVolunteer.EmployeeName) ? "-" : registeredVolunteer.EmployeeName) .Replace("{EventName}", string.IsNullOrEmpty(outreachEvent.EventName) ? "-" : outreachEvent.EventName) .Replace("{EventDate}", string.IsNullOrEmpty(outreachEvent.EventDate.Value.ToShortDateString()) ? "-" : outreachEvent.EventDate.Value.ToShortDateString()) .Replace("{Url}", string.IsNullOrEmpty(url) ? "-" : url); SendMail(subject, body, ConfigurationManager.AppSettings["CommonMail"].ToString()); } } } } catch (Exception ex) { ExceptionLogger logger = new ExceptionLogger() { ControllerName = "OutreachMail", ActionrName = "SendMailToParticipatedUser", ExceptionMessage = ex.Message, ExceptionStackTrace = ex.StackTrace, LogDateTime = DateTime.Now }; ExceptionRepository exceptionRepository = new ExceptionRepository(); exceptionRepository.AddException(logger); } }
void Get_Login() { if (IsLogin) { return; } stt1.Visible = true; stt1.Text = "Đang kiểm tra tài khoản..."; Application.DoEvents(); var request = (HttpWebRequest)WebRequest.Create(host + "/taikhoan/login"); request.CookieContainer = cookieContainer; var postData = "username="******"&password="******"POST"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = data.Length; using (var stream = request.GetRequestStream()) { stream.Write(data, 0, data.Length); } var response = (HttpWebResponse)request.GetResponse(); if (response.StatusCode == HttpStatusCode.OK) { var responseString = new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd(); string json = responseString.Replace("\n", "").Replace("\t", "").Replace("\"", "'").Replace(" ", " ").Replace(" ", " ").Replace(" ", " "); if (FuncHelp.CutFromTo(json, "'user_type':'", "'") == "1") { stt1.Visible = false; IsLogin = true; } else { MessageBox.Show("Tài khoản đăng nhập hoặc Mật khẩu không chính xác!!!"); IsStop = true; stt1.Text = ""; } } }
private void ToxnetHSDBButton_Click_1(object sender, EventArgs e) { string uriString = "https://toxgate.nlm.nih.gov/cgi-bin/sis/search2"; System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uriString); request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uriString); string postData = "queryxxx=" + m_casNo; postData += "&chemsyn=1"; postData += "&database=hsdb"; postData += "&Stemming=1"; postData += "&and=1"; postData += "&second_search=1"; postData += "&gateway=1"; var data = Encoding.ASCII.GetBytes(postData); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = data.Length; using (var stream = request.GetRequestStream()) { stream.Write(data, 0, data.Length); } System.Net.WebResponse response = (System.Net.HttpWebResponse)request.GetResponse(); string responseString = new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd(); string s1 = responseString.Replace("<br>", ""); var XMLReader = new System.Xml.XmlTextReader(new System.IO.StringReader(s1)); System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(QueryResult)); if (serializer.CanDeserialize(XMLReader)) { // Synonyms means more than one name for the same chemical/CAS Number. QueryResult result = (QueryResult)serializer.Deserialize(XMLReader); uriString = "https://toxgate.nlm.nih.gov/cgi-bin/sis/search2/f?" + result.TemporaryFile; string[] ids = result.Id.Split(' '); System.Diagnostics.Process.Start("http://toxgate.nlm.nih.gov/cgi-bin/sis/search2/r?dbs+hsdb:@term+@DOCNO+" + ids[0]); } }
void GetToxData(string compoundName, string casNo) { // http://toxnet.nlm.nih.gov/cgi-bin/sis/search2/f?./temp/~oiB60G:1 string uriString = "https://toxgate.nlm.nih.gov/cgi-bin/sis/search2"; System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uriString); request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uriString); string postData = "queryxxx=" + casNo; postData += "&chemsyn=1"; postData += "&database=hsdb"; postData += "&Stemming=1"; postData += "&and=1"; postData += "&second_search=1"; postData += "&gateway=1"; var data = Encoding.ASCII.GetBytes(postData); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = data.Length; using (var stream = request.GetRequestStream()) { stream.Write(data, 0, data.Length); } System.Net.WebResponse response = (System.Net.HttpWebResponse)request.GetResponse(); string responseString = new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd(); string s1 = responseString.Replace("<br>", ""); System.Xml.XmlDocument document = new System.Xml.XmlDocument(); document.Load(new System.IO.StringReader(s1)); string tempFileName = document.FirstChild["TemporaryFile"].InnerText; uriString = "https://toxgate.nlm.nih.gov/cgi-bin/sis/search2/f?" + tempFileName; // EcoTox request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uriString + ":1:etxv"); response = (System.Net.HttpWebResponse)request.GetResponse(); string ecoToxResposne = new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd(); string pattern = "LC50; Species:\\s*(?<1>[^\\n]*)\\s*[,;] Conditions:\\s*(?<2>[^\\n]*)\\s*[,;] Concentration:\\s*(?<3>\\S+)\\s*(?<4>\\S+)\\s*for\\s*(?<5>[^\\n]*)\\s*<br><code><NOINDEX>\\s*(?<6>[^\\n]*)\\s*</NOINDEX>"; System.Text.RegularExpressions.MatchCollection matchColl = System.Text.RegularExpressions.Regex.Matches(ecoToxResposne, pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled, TimeSpan.FromSeconds(1)); double lc50 = 1000000.0; System.Text.RegularExpressions.Match lc50Match = null; foreach (System.Text.RegularExpressions.Match match in matchColl) { string lc50STR = match.Groups[3].Value; lc50STR = lc50STR.Replace(">", ""); lc50STR = lc50STR.Replace("<", ""); double conc = Convert.ToDouble(lc50STR); string unit = match.Groups[4].Value; if (string.Compare(unit, "mg/l", true) == 0) { if (conc < lc50) { lc50 = conc; lc50Match = match; } } else if (string.Compare(unit, "ug/l", true) == 0) { { if (conc / 1000 < lc50) lc50 = conc / 1000; lc50Match = match; } } } string lc50Value = string.Empty; string lc50Reference = string.Empty; if (lc50Match != null) { lc50Value = lc50Match.Groups[3].Value; lc50Reference = "Species: " + lc50Match.Groups[1].Value + "; Conditions: " + lc50Match.Groups[2].Value + "; Time: " + lc50Match.Groups[5].Value + "; Reference: " + lc50Match.Groups[6].Value; } //pattern = "EC50; Species:\\s*(?<1>[^\\n]*)\\s*[,;] Conditions:\\s*(?<2>[^\\n]*)\\s*[,;] Concentration:\\s*(?<3>[^\\n]*)\\s*for\\s*(?<4>[^\\n]*)\\s*[,;] Effect: \\s*(?<5>[^\\n]*)\\s*<br><code><NOINDEX>\\s*(?<6>[^\\n]*)\\s*</NOINDEX>"; //matchColl = System.Text.RegularExpressions.Regex.Matches(ecoToxResposne, pattern, // System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled, // TimeSpan.FromSeconds(1)); // NonHuman Tox request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uriString + ":1:ntxv"); response = (System.Net.HttpWebResponse)request.GetResponse(); string nonHumanToxResposne = new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd(); pattern = "LD50\\s*(?<1>\\S+)\\s*oral\\s*[(>)\\s*]\\s*(?<2>\\S+)\\s*(?<3>\\S+)\\s*<br><code><NOINDEX>\\s*(?<4>[^\\n]*)\\s*</NOINDEX>"; matchColl = System.Text.RegularExpressions.Regex.Matches(nonHumanToxResposne, pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled, TimeSpan.FromSeconds(1)); double ld50Oral = 1000000.0; System.Text.RegularExpressions.Match ld50OralMatch = null; foreach (System.Text.RegularExpressions.Match match in matchColl) { string ld50STR = match.Groups[2].Value; ld50STR = ld50STR.Replace(">", ""); ld50STR = ld50STR.Replace("<", ""); double conc = 0; if (!double.TryParse(ld50STR, out conc)) { string[] values = ld50STR.Split('-'); double.TryParse(values[0], out conc); } string unit = match.Groups[3].Value; if (string.Compare(unit, "mg/kg", true) == 0) { if (conc < ld50Oral) { ld50Oral = conc; ld50OralMatch = match; } } else if (string.Compare(unit, "g/kg", true) == 0) { { if (conc * 1000 < ld50Oral) ld50Oral = conc * 1000; ld50OralMatch = match; } } } string ld50OralSpecies = string.Empty; string ld50OralValue = string.Empty; string ld50OralReference = string.Empty; if (ld50OralMatch != null) { ld50OralSpecies = ld50OralMatch.Groups[1].Value; ld50OralValue = ld50Oral.ToString(); ld50OralReference = ld50OralMatch.Groups[4].Value; } double ld50Dermal = 1000000.0; System.Text.RegularExpressions.Match ld50DermalMatch = null; string[] dermalSynomoyms = { "dermal", "percutaneous", "sc", "skin" }; foreach (string synonym in dermalSynomoyms) { pattern = "LD50\\s*(?<1>\\S+)\\s*" + synonym + "\\s*[(>)\\s*]\\s*(?<2>\\S+)\\s*(?<3>\\S+)\\s*<br><code><NOINDEX>\\s*(?<4>[^\\n]*)\\s*</NOINDEX>"; matchColl = System.Text.RegularExpressions.Regex.Matches(nonHumanToxResposne, pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled, TimeSpan.FromSeconds(1)); foreach (System.Text.RegularExpressions.Match match in matchColl) { string ld50STR = match.Groups[2].Value; ld50STR = ld50STR.Replace(">", ""); ld50STR = ld50STR.Replace("<", ""); double conc = Convert.ToDouble(ld50STR); string unit = match.Groups[3].Value; if (string.Compare(unit, "mg/kg", true) == 0) { if (conc < ld50Dermal) { ld50Dermal = conc; ld50DermalMatch = match; } } else if (string.Compare(unit, "g/kg", true) == 0) { { if (conc * 1000 < ld50Dermal) ld50Dermal = conc * 1000; ld50DermalMatch = match; } } } } pattern = "LD50\\s*(?<1>\\w*)\\s*[(>)\\s*]\\s*(?<2>\\S+)\\s*(?<3>\\S+)\\s*dermal[.\\s+]\\s*\\s*<br><code><NOINDEX>\\s*(?<4>[^\\n]*)\\s*</NOINDEX>"; matchColl = System.Text.RegularExpressions.Regex.Matches(nonHumanToxResposne, pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled, TimeSpan.FromSeconds(1)); foreach (System.Text.RegularExpressions.Match match in matchColl) { string ld50STR = match.Groups[2].Value; ld50STR = ld50STR.Replace(">", ""); ld50STR = ld50STR.Replace("<", ""); double conc = Convert.ToDouble(ld50STR); string unit = match.Groups[3].Value; if (string.Compare(unit, "mg/l", true) == 0) { if (conc < ld50Dermal) { ld50Dermal = conc; ld50DermalMatch = match; } } else if (string.Compare(unit, "ug/l", true) == 0) { { if (conc / 1000 < ld50Dermal) ld50Dermal = conc / 1000; ld50DermalMatch = match; } } } string ld50DermalSpecies = string.Empty; string ld50DermalValue = string.Empty; string ld50DermalReference = string.Empty; if (ld50DermalMatch != null) { ld50DermalSpecies = ld50DermalMatch.Groups[1].Value; ld50DermalValue = ld50Dermal.ToString(); ld50DermalReference = ld50DermalMatch.Groups[4].Value; } }
void GetTOXNETInformation(string compoundName, string casNo) { // http://toxnet.nlm.nih.gov/cgi-bin/sis/search2/f?./temp/~oiB60G:1 string uriString = "https://toxgate.nlm.nih.gov/cgi-bin/sis/search2"; System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uriString); string postData = "queryxxx=" + casNo; postData += "&chemsyn=1"; postData += "&database=hsdb"; postData += "&Stemming=1"; postData += "&and=1"; postData += "&second_search=1"; postData += "&gateway=1"; var data = Encoding.ASCII.GetBytes(postData); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = data.Length; using (var stream = request.GetRequestStream()) { stream.Write(data, 0, data.Length); } System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse(); string responseString = new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd(); string s1 = responseString.Replace("<br>", ""); System.Xml.XmlDocument document = new System.Xml.XmlDocument(); document.Load(new System.IO.StringReader(s1)); string tempFileName = document.FirstChild["TemporaryFile"].InnerText; uriString = "http://toxnet.nlm.nih.gov/cgi-bin/sis/search2/f?" + tempFileName; //// Whole Document m_hsdbDocumentURL = "http://toxgate.nlm.nih.gov/cgi-bin/sis/search2/r?dbs+hsdb:@term+@DOCNO+" + document.FirstChild["Id"].InnerText.Split(' ')[0]; // Molecular Formula request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uriString + ":1:mf"); response = (System.Net.HttpWebResponse)request.GetResponse(); string mfResposne = new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd(); string pattern = "Molecular Formula:</h3>\n<br>\n\\s*(?<1>\\S+)\\s*<br><code><NOINDEX>(?<2>[^\\n]*)</NOINDEX>"; System.Text.RegularExpressions.Match m = System.Text.RegularExpressions.Regex.Match(mfResposne, pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled, TimeSpan.FromSeconds(1)); this.m_molecularFormula = m.Groups[1].Value; this.m_molecularFormulareference = m.Groups[2].Value; // AutoIgnition temperature request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uriString + ":1:auto"); response = (System.Net.HttpWebResponse)request.GetResponse(); string autoResposne = new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd(); pattern = "Autoignition Temperature:</h3>\n<br>\n\\s*(?<1>\\S+)\\s*Deg\\s*(?<2>\\S+)\\s*\\((?<4>\\S+)\\s*deg\\s*(?<5>\\S+)\\s*\\)<br><code><NOINDEX>(?<3>[^\\n]*)</NOINDEX>"; m = System.Text.RegularExpressions.Regex.Match(autoResposne, pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled, TimeSpan.FromSeconds(1)); if (m.Groups.Count == 1) { pattern = "Autoignition Temperature:</h3>\n<br>\n\\s*(?<1>\\S+)\\s*Deg\\s*(?<2>\\S+)\\s*<br><code><NOINDEX>(?<3>[^\\n]*)</NOINDEX>"; m = System.Text.RegularExpressions.Regex.Match(autoResposne, pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled, TimeSpan.FromSeconds(1)); } // Chemical Properties request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uriString + ":1:cpp"); response = (System.Net.HttpWebResponse)request.GetResponse(); string propertiesResposne = new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd(); // Chemical Properties request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uriString + ":1:ph"); response = (System.Net.HttpWebResponse)request.GetResponse(); propertiesResposne = new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd(); pattern = "pH:\\s*(?<1>\\S+)\\s*(?<2>[^\\n]*)\\s*<NOINDEX>(?<3>[^\\n]*)</NOINDEX>"; m = System.Text.RegularExpressions.Regex.Match(propertiesResposne, pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled, TimeSpan.FromSeconds(1)); string m_pH = m.Groups[1].Value; string m_pHAdditional = m.Groups[2].Value; string m_pHReference = m.Groups[3].Value; // heat of vaporization: pattern = "Heat of Vaporization:</h3>\\s*<br>\\s*Latent:\\s*(?<1>\\S+)\\s*(?<2>\\S+)\\s*(?<4>[^\\n]*)<br><code><NOINDEX>(?<3>[^\\n]*)</NOINDEX>"; m = System.Text.RegularExpressions.Regex.Match(propertiesResposne, pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled, TimeSpan.FromSeconds(1)); if (m.Groups.Count == 1) { pattern = "Heat of Vaporization:</h3>\\s*<br>\\s*Enthalpy of vaporization:\\s*(?<1>\\S+)\\s*(?<2>\\S+)\\s*(?<4>[^\\n]*)<br><code><NOINDEX>(?<3>[^\\n]*)</NOINDEX>"; m = System.Text.RegularExpressions.Regex.Match(propertiesResposne, pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled, TimeSpan.FromSeconds(1)); } if (m.Groups.Count == 1) { pattern = "Heat of Vaporization:</h3>\\s*<br>\\s*(?<1>\\S+)\\s*(?<2>\\S+)\\s*(?<4>[^\\n]*)<br><code><NOINDEX>(?<3>[^\\n]*)</NOINDEX>"; m = System.Text.RegularExpressions.Regex.Match(propertiesResposne, pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled, TimeSpan.FromSeconds(1)); } m_HeatOfVaporization = m.Groups[1].Value; m_HeatOfVaporizationUnit = m.Groups[2].Value; if (m_HeatOfVaporizationUnit.ToLower() == "kj/g") { m_HeatOfVaporization = (Convert.ToDouble(m_HeatOfVaporization) * 1000).ToString(); m_HeatOfVaporizationUnit = "kJ/kg"; } if (m_HeatOfVaporizationUnit.ToLower() == "btu/lb") { m_HeatOfVaporization = (Convert.ToDouble(m_HeatOfVaporization) * 2.32599999962).ToString(); m_HeatOfVaporizationUnit = "kJ/kg"; } if (m_HeatOfVaporizationUnit.ToLower() == "g-cal/g") { m_HeatOfVaporization = (Convert.ToDouble(m_HeatOfVaporization) * 4.184 * 1000).ToString(); m_HeatOfVaporizationUnit = "kJ/kg"; } if (m_HeatOfVaporizationUnit.ToLower() == "kcal/mole") { m_HeatOfVaporization = (Convert.ToDouble(m_HeatOfVaporization) * 4.184).ToString(); m_HeatOfVaporizationUnit = "kJ/kg"; } if (m_HeatOfVaporizationUnit.ToLower() == "kj/mole" || m_HeatOfVaporizationUnit.ToLower() == "kj/mol") { m_HeatOfVaporization = (Convert.ToDouble(m_HeatOfVaporization) * 1000).ToString(); m_HeatOfVaporizationUnit = "kJ/kg"; } if (m_HeatOfVaporizationUnit.ToLower() == "gcal/gmole") { m_HeatOfVaporization = (Convert.ToDouble(m_HeatOfVaporization) * 4.184).ToString(); m_HeatOfVaporizationUnit = "kJ/kg"; } m_heatOfVaporizationReference = m.Groups[3].Value; if (m_casNo == "64-19-7") { m_HeatOfVaporization = "1219055.6"; m_HeatOfVaporizationUnit = "kJ/kg"; m_heatOfVaporizationReference = "[Haynes, W.M. (ed.). CRC Handbook of Chemistry and Physics. 94th Edition. CRC Press LLC, Boca Raton: FL 2013-2014, p. 6-132] **PEER REVIEWED** "; } // heat of combustion: pattern = "Heat of Combustion:</h3>\\s*<br>\\s*(?<1>\\S+)\\s*(?<2>\\S+)\\s*<br><code><NOINDEX>(?<3>[^\\n]*)</NOINDEX>"; m = System.Text.RegularExpressions.Regex.Match(propertiesResposne, pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled, TimeSpan.FromSeconds(1)); if (m.Groups.Count == 1) { pattern = "Heat of Combustion:</h3>\\s*<br>\\s*(?<1>\\S+)\\s*(?<2>\\S+)\\s*(?<3>[^\\n]*)\\s*<br><code><NOINDEX>(?<3>[^\\n]*)</NOINDEX>"; m = System.Text.RegularExpressions.Regex.Match(propertiesResposne, pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled, TimeSpan.FromSeconds(1)); } m_HeatOfCombustion = m.Groups[1].Value; m_HeatOfCombustionUnit = m.Groups[2].Value; if (m_HeatOfCombustionUnit.ToLower() == "kj/g") { m_HeatOfCombustion = (Convert.ToDouble(m_HeatOfCombustion) * 1000).ToString(); m_HeatOfCombustionUnit = "kJ/kg"; } if (m_HeatOfCombustionUnit.ToLower() == "btu/lb") { m_HeatOfCombustion = (Convert.ToDouble(m_HeatOfCombustion) * 2.32599999962).ToString(); m_HeatOfCombustionUnit = "kJ/kg"; } if (m_HeatOfCombustionUnit.ToLower() == "j/kmol") { m_HeatOfCombustion = (Convert.ToDouble(m_HeatOfCombustion) * 1000 * 1000).ToString(); m_HeatOfCombustionUnit = "kJ/kg"; } if (m_HeatOfCombustionUnit.ToLower() == "kj/mole" || m_HeatOfCombustionUnit.ToLower() == "kj/mol") { m_HeatOfCombustion = (Convert.ToDouble(m_HeatOfCombustion) * 1000).ToString(); m_HeatOfCombustionUnit = "kJ/kg"; } if (m_HeatOfCombustionUnit.ToLower() == "kj/kg") { m_HeatOfCombustion = (Convert.ToDouble(m_HeatOfCombustion) * 1000).ToString(); m_HeatOfCombustionUnit = "kJ/kg"; } m_HeatOfCombustionReference = m.Groups[3].Value; // Flash Point: if (string.IsNullOrEmpty(flashPtValue)) { // Chemical Properties pattern = "Flash Point:</h3>\\s*<br>\\s*(?<1>\\S+)\\s*deg\\s*(?<2>\\S+),\\s*(?<5>\\S+)\\s*deg\\s*(?<6>\\S+)\\s*(?<4>[^\\n]*)\\s*<br><code><NOINDEX>(?<3>[^\\n]*)</NOINDEX>"; m = System.Text.RegularExpressions.Regex.Match(propertiesResposne, pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled, TimeSpan.FromSeconds(1)); if (m.Groups.Count == 1) { pattern = "Flash Point:</h3>\\s*<br>\\s*(?<1>\\S+)\\s*deg\\s*(?<2>\\S+)\\s*(?<4>[^\\n]*)\\s*<br><code><NOINDEX>(?<3>[^\\n]*)</NOINDEX>"; m = System.Text.RegularExpressions.Regex.Match(propertiesResposne, pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled, TimeSpan.FromSeconds(1)); } if (m.Groups[2].Value == "C") { flashPtValue = m.Groups[1].Value; flashPtUnit = m.Groups[2].Value; } else if (m.Groups[4].Value == "F") { flashPtValue = ((Convert.ToDouble(m.Groups[1].Value) - 32) * 5 / 9).ToString(); flashPtUnit = "C"; } flashPtReference = m.Groups[3].Value; } // Vapor Pressure: if (string.IsNullOrEmpty(vaporPress)) { pattern = "Vapor Pressure:</h3>\\s*<br>\\s*(?<1>\\S+)\\s*(?<2>[^\"']*) at (?<3>\\S+) deg (?<4>\\S+)\\s*(?<5>[^\\n]*)\\s*<br><code><NOINDEX>(?<3>[^\\n]*)</NOINDEX>"; m = System.Text.RegularExpressions.Regex.Match(propertiesResposne, pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled, TimeSpan.FromSeconds(1)); vaporPress = m.Groups[1].Value.ToLower(); if (vaporPress.Contains("x")) { vaporPress = vaporPress.Replace("x10", "x"); string[] splits = vaporPress.Split('x'); vaporPress = (Convert.ToDouble(splits[0]) * Math.Pow(10, Convert.ToDouble(splits[1]))).ToString(); } vaporPressUnit = m.Groups[2].Value; vaporPressTemp = m.Groups[3].Value; vaporPressTempUnit = m.Groups[4].Value; } // boilingPoint: if (string.IsNullOrEmpty(bpValue)) { pattern = "Boiling Point:</h3>\\s*<br>\\s*(?<1>\\S+) deg (?<2>\\S+)<br><code><NOINDEX>(?<3>[^\\n]*)</NOINDEX>"; m = System.Text.RegularExpressions.Regex.Match(propertiesResposne, pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled, TimeSpan.FromSeconds(1)); if (m.Groups.Count == 1) { pattern = "Boiling Point:</h3>\\s*<br>\\s*(?<1>\\S+) deg (?<2>\\S+)\\s*(?<4>[^\\n]*)<br><code><NOINDEX>(?<3>[^\\n]*)</NOINDEX>"; m = System.Text.RegularExpressions.Regex.Match(propertiesResposne, pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled, TimeSpan.FromSeconds(1)); } bpValue = m.Groups[1].Value; bpUnit = m.Groups[2].Value; bpReference = m.Groups[3].Value; } // meltingPoint: if (string.IsNullOrEmpty(mpValue)) { pattern = "Melting Point:</h3>\\s*<br>\\s*(?<1>\\S+)\\s*deg\\s*(?<2>\\S+)\\s*(?<4>[^\\n]*)\\s*<br><code><NOINDEX>(?<3>[^\\n]*)</NOINDEX>"; m = System.Text.RegularExpressions.Regex.Match(propertiesResposne, pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled, TimeSpan.FromSeconds(1)); mpValue = m.Groups[1].Value; mpUnit = m.Groups[2].Value; mpReference = m.Groups[3].Value; } // density: if (string.IsNullOrEmpty(densityValue) || string.IsNullOrEmpty(relativeDensityValue)) { pattern = "Density/Specific Gravity:</h3>\\s*<br>\\s*Gas:\\s*(?<1>\\S+)\\s*(?<2>[^\"']*)\\s*at\\s*(?<4>[^\\n]*)\\s*<br><code><NOINDEX>(?<4>[^\\n]*)</NOINDEX>"; m = System.Text.RegularExpressions.Regex.Match(propertiesResposne, pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled, TimeSpan.FromSeconds(1)); if (m.Groups.Count == 1) { pattern = "Density/Specific Gravity:</h3>\\s*<br>\\s*Absolute density:\\s*(?<1>\\S+)\\s*(?<2>[^\"']*)\\s*at\\s*(?<4>[^\\n]*)\\s*<br><code><NOINDEX>(?<4>[^\\n]*)</NOINDEX>"; m = System.Text.RegularExpressions.Regex.Match(propertiesResposne, pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled, TimeSpan.FromSeconds(1)); } if (m.Groups.Count == 1) { pattern = "Density/Specific Gravity:</h3>\\s*<br>\\s*(?<1>\\S+)\\s*(?<2>[^\"']*)\\s*at\\s*(?<4>[^\\n]*)\\s*<br><code><NOINDEX>(?<4>[^\\n]*)</NOINDEX>"; m = System.Text.RegularExpressions.Regex.Match(propertiesResposne, pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled, TimeSpan.FromSeconds(1)); } densityValue = m.Groups[1].Value; densityUnit = m.Groups[2].Value; densityTemperature = m.Groups[3].Value; densityTemperatureUnit = m.Groups[4].Value; densityReference = m.Groups[5].Value; } // Chemical safety request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uriString + ":1:csha"); response = (System.Net.HttpWebResponse)request.GetResponse(); System.IO.StringReader safetyReader = new System.IO.StringReader(new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd()); if (string.IsNullOrEmpty(nfpaFire)) { // NFPA: request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uriString + ":1:nfpa"); response = (System.Net.HttpWebResponse)request.GetResponse(); string nfpaResponseString = safetyReader.ReadToEnd(); int index = nfpaResponseString.IndexOf("Health: "); if (index > 0) { nfpaHealth = nfpaResponseString.Substring(index + 8, 1); } index = nfpaResponseString.IndexOf("Flammability: "); if (index > 0) { nfpaFire = nfpaResponseString.Substring(index + 14, 1); } index = nfpaResponseString.IndexOf("Reactivity: "); if (index > 0) { nfpaReactivity = nfpaResponseString.Substring(index + 12, 1); } if (index > 0) { index = nfpaResponseString.IndexOf("instability: "); if (index == -1) { nfpaReactivity = nfpaResponseString.Substring(index + 13, 1); } } } }