protected void Page_Load(object sender, EventArgs e) { EsriForms data = new EsriForms(); string conferenceID = ""; string sessionID = ""; string comments = ""; string q1Rating = ""; string q2Rating = ""; string q3Rating = ""; string formValue; if (!string.IsNullOrEmpty(Request.Form["txtFormValue"])) { formValue = Request.Form["txtFormValue"]; conferenceID = ""; sessionID = ""; comments = ""; q1Rating = ""; q2Rating = ""; q3Rating = ""; } string ret = ParseCall(); if (ret != "") { string cookieContent = data.Ratings_Save(conferenceID, sessionID, comments, q1Rating, q2Rating, q3Rating); if (cookieContent != null) { HttpCookie myCookie = new HttpCookie("UserSettings"); myCookie["Font"] = "Arial"; myCookie["Color"] = "Blue"; myCookie.Expires = DateTime.Now.AddDays(1d); Response.Cookies.Add(myCookie); } } Response.Redirect("ThankYou.aspx"); }
private bool WasEmailSent(string objectID) { EsriForms data = new EsriForms(); DataTable dtSentEmail = data.Get_Parse_Sent_Email(); foreach (DataRow dr in dtSentEmail.Rows) { if (dr["ObjectId"] != DBNull.Value) { if (dr["ObjectId"].ToString() == objectID) return true; } } return false; }
//TODO: figure out time zones for other conferences for "request_time" // Curl request pull back only form yesterday to today // protected void Page_Load(object sender, EventArgs e) { int sentCount = 0; int totalCount = 0; string responseText = ""; string listener_SendTo = ConfigurationManager.AppSettings["Listener_SendTo"].ToString(); string listener_ParseUserName = ConfigurationManager.AppSettings["Listener_ParseUserName"].ToString(); string listener_ParsePassword = ConfigurationManager.AppSettings["Listener_ParsePassword"].ToString(); string listener_ParseAuthenticationID = ConfigurationManager.AppSettings["Listener_ParseAuthenticationID"].ToString(); string listener_ParseRestAPIKey = ConfigurationManager.AppSettings["Listener_ParseRestAPIKey"].ToString(); string listener_ParseMasterKey = ConfigurationManager.AppSettings["Listener_ParseMasterKey"].ToString(); string listener_SMTPClient = ConfigurationManager.AppSettings["Listener_SMTPClient"].ToString(); string listener_SMTPPort = ConfigurationManager.AppSettings["Listener_SMTPPort"].ToString(); string listener_MessageFailEmailAddress = ConfigurationManager.AppSettings["Listener_MessageFailEmailAddress"].ToString(); string listener_BaseURL = ConfigurationManager.AppSettings["Listener_BaseURL"].ToString(); string url = listener_BaseURL; //+ CreateDateWhereClause(); var httpWebRequest = (HttpWebRequest)WebRequest.Create(url); httpWebRequest.ContentType = "text/xml"; httpWebRequest.Credentials = new NetworkCredential(listener_ParseUserName, listener_ParsePassword); httpWebRequest.Headers.Add("X-Parse-Application-Id: " + listener_ParseAuthenticationID); //httpWebRequest.Headers.Add("X-Parse-REST-API-Key: " + listener_ParseRestAPIKey); httpWebRequest.Headers.Add("X-Parse-Master-Key: " + listener_ParseMasterKey); httpWebRequest.Method = "GET"; HttpWebResponse httpResponse = null; try { httpResponse = (HttpWebResponse)httpWebRequest.GetResponse(); } catch (Exception) { return; } using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { responseText = streamReader.ReadToEnd(); } var jss = new JavaScriptSerializer(); dynamic data = jss.Deserialize<dynamic>(responseText); foreach (dynamic item in data) { foreach (dynamic row in item.Value) { string oID = row["objectId"]; string body = ""; string userEmail = ""; userEmail = GetValueByKey(row, "user_email_address"); if (!WasEmailSent(oID)) { string requestTime = SafeDateFormat(GetValueByKey(row, "date_request_entered")); string scheduleDate = SafeDateFormat(GetValueByKey(row, "schedule_time_requested")); string scheduleDay = SafeSplit(scheduleDate ,' ', 0); string scheduleTime = SafeSplit(scheduleDate, ' ', 1) + " " + SafeSplit(scheduleDate, ' ', 2); body = "Esriid:" + GetValueByKey(row, "user_esri_registration") + Environment.NewLine + "Name:" + GetValueByKey(row, "user_name") + Environment.NewLine + "Organization:" + GetValueByKey(row, "user_organization_name") + Environment.NewLine + "Email:" + GetValueByKey(row, "user_email_address") + Environment.NewLine + "Phone:" + GetValueByKey(row, "user_phone_number") + Environment.NewLine + "Product:" + GetValueByKey(row, "support_skill_type_name") + Environment.NewLine + "Technology:" + GetValueByKey(row, "support_skill_subtype_name") + Environment.NewLine + "Availableday:" + scheduleDay + Environment.NewLine + "Availabletime:" + scheduleTime + Environment.NewLine + "Requesttime:" + requestTime + Environment.NewLine + "Description:" + ReplaceCharacters(GetValueByKey(row, "problem_description"), @"\\n,\n,%0A,\") + Environment.NewLine + "EventID:" + "a0E3000000D0VFo"; try { SendMessage(listener_SendTo, "Esri Events mobile app - Support Request" , "*****@*****.**" , body , listener_SMTPClient , listener_SMTPPort); litMessage.Text += userEmail + "<br />"; sentCount++; EsriForms db = new EsriForms(); db.Add_Parse_Sent_Email(row["objectId"], GetValueByKey(row, "updatedAt")); } catch (Exception) { SendMessage(listener_MessageFailEmailAddress , "Send Failure." , "*****@*****.**" , body , listener_SMTPClient , listener_SMTPPort); } } litParseEmail.Text += userEmail + "<br />"; totalCount++; } } litSentCount.Text = "(" + sentCount.ToString() + ")"; litTotalCount.Text = "(" + totalCount.ToString() + ")"; }
private string CreateQueryString() { string query = "?"; EsriForms data = new EsriForms(); DataTable dt = data.Get_Parse_Sent_Email(); foreach (DataRow dr in dt.Rows) query += "objectId<>" + dr["ObjectId"].ToString() + "&"; query = query.TrimEnd('&'); return query; }
private string CreateDateWhereClause() { EsriForms data = new EsriForms(); string lastDate = data.Get_Parse_LastUpdateDate(); if (lastDate != "") { DateTime dt = Convert.ToDateTime(lastDate); return "?where={'updatedAt':{'$gt':{'__type':'Date','iso':'" + String.Format("{0:s}", dt) + "'}}}"; } else return ""; }