protected void Page_Load(object sender, EventArgs e) { DataSet dstemp = Peerfx_DB.SPs.ViewErrorsLastone().GetDataSet(); string strEventTime = "Time"; if (dstemp.Tables[0].Rows[0]["EventTime"] != DBNull.Value) { strEventTime = dstemp.Tables[0].Rows[0]["EventTime"].ToString(); } string strRequestURL = "URL"; if (dstemp.Tables[0].Rows[0]["RequestURL"] != DBNull.Value) { strRequestURL = dstemp.Tables[0].Rows[0]["RequestURL"].ToString(); } string strDetails = "Details"; if (dstemp.Tables[0].Rows[0]["Details"] != DBNull.Value) { strDetails = dstemp.Tables[0].Rows[0]["Details"].ToString(); } string thebody = System.IO.File.ReadAllText(HttpContext.Current.Server.MapPath("/Emails/ErrorEmail.txt")); thebody = thebody.Replace("TIMEERROR", strEventTime); thebody = thebody.Replace("URLERROR", strRequestURL); thebody = thebody.Replace("DETAILSERROR", strDetails); string Toemail = System.Configuration.ConfigurationSettings.AppSettings.Get("ErrorToEmail").ToString(); SendGrid sg = new SendGrid(); sg.SimpleEmail("Lorne", "Passportfx Error", Toemail, "*****@*****.**", thebody, "Passportfx Error"); }
private string Web_Request(Hashtable hstemp) { string url = ConfigurationSettings.AppSettings["Mixpanelurl"]; HttpWebResponse webResponse; string request = JsonConvert.SerializeObject(hstemp); request = sitetemp.EncodeTo64(request).ToString(); url += request; // Create request object HttpWebRequest webRequest = WebRequest.Create(url) as HttpWebRequest; webRequest.ContentType = "application/x-www-form-urlencoded"; webRequest.MediaType = "application/x-www-form-urlencoded"; webRequest.Method = "GET"; string responseString = ""; try { // Get the response from the request object and verify the status webResponse = webRequest.GetResponse() as HttpWebResponse; if (!webRequest.HaveResponse) { throw new Exception(); } if (webResponse.StatusCode != HttpStatusCode.OK && webResponse.StatusCode != HttpStatusCode.Accepted) { throw new Exception(); } // Read the response string StreamReader reader = new StreamReader(webResponse.GetResponseStream()); responseString = reader.ReadToEnd(); reader.Close(); } catch (Exception e) { Peerfx_DB.SPs.UpdateApiErrors(2, request, e.Message, url).Execute(); string Toemail = System.Configuration.ConfigurationSettings.AppSettings.Get("ErrorToEmail").ToString(); SendGrid sg = new SendGrid(); sg.SimpleEmail("Lorne", "Passportfx API Error", Toemail, "*****@*****.**", e.Message, "Mixpanel Error"); } return responseString; }