This commit is contained in:
180
source/UninstallSurvey/Form1.cs
Normal file
180
source/UninstallSurvey/Form1.cs
Normal file
@@ -0,0 +1,180 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Web;
|
||||
using System.Net;
|
||||
using System.IO;
|
||||
|
||||
namespace UninstallSurvey
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
//lblHelpUs.Text = "Please help us improve our product by telling us why you chose to uninstall AyaNova. Your feedback is anonymous and will be kept strictly confidential.";
|
||||
edResponse.Text = "Your feedback is anonymous\r\n\r\nIf you would like a response please include your email address here\r\n\r\nThank you!";
|
||||
}
|
||||
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (string.IsNullOrEmpty(edResponse.Text) || edResponse.ForeColor == SystemColors.GrayText)
|
||||
return;
|
||||
try
|
||||
{
|
||||
// Create a request using a URL that can receive a post.
|
||||
WebRequest request = WebRequest.Create("http://uisurvey.ayanova.com/uisurvey.aspx");
|
||||
// Set the Method property of the request to POST.
|
||||
request.Method = "POST";
|
||||
// Create POST data and convert it to a byte array.
|
||||
string postData = HttpUtility.UrlEncode("UNINSTALL SURVEY RESPONSE\r\n"+ edResponse.Text);
|
||||
|
||||
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
|
||||
// Set the ContentType property of the WebRequest.
|
||||
request.ContentType = "application/x-www-form-urlencoded";
|
||||
// Set the ContentLength property of the WebRequest.
|
||||
request.ContentLength = byteArray.Length;
|
||||
// Get the request stream.
|
||||
Stream dataStream = request.GetRequestStream();
|
||||
// Write the data to the request stream.
|
||||
dataStream.Write(byteArray, 0, byteArray.Length);
|
||||
// Close the Stream object.
|
||||
dataStream.Close();
|
||||
// Get the response.
|
||||
WebResponse response = request.GetResponse();
|
||||
// Display the status.
|
||||
Console.WriteLine(((HttpWebResponse)response).StatusDescription);
|
||||
// Get the stream containing content returned by the server.
|
||||
dataStream = response.GetResponseStream();
|
||||
// Open the stream using a StreamReader for easy access.
|
||||
StreamReader reader = new StreamReader(dataStream);
|
||||
// Read the content.
|
||||
string responseFromServer = reader.ReadToEnd();
|
||||
|
||||
// Clean up the streams.
|
||||
reader.Close();
|
||||
dataStream.Close();
|
||||
response.Close();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
this.Close();
|
||||
}
|
||||
|
||||
|
||||
private void edResponse_Enter(object sender, EventArgs e)
|
||||
{
|
||||
if (edResponse.ForeColor == SystemColors.GrayText)
|
||||
{
|
||||
edResponse.Text = "";
|
||||
edResponse.ForeColor = SystemColors.WindowText;
|
||||
}
|
||||
}
|
||||
|
||||
private void btnSkip_Click_1(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//----------------
|
||||
}
|
||||
}
|
||||
|
||||
/* This is the server page that accepts this response
|
||||
|
||||
<%@ Page Language="C#" %>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<script runat="server">
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
//if (Page.IsPostBack)
|
||||
//{
|
||||
SendInfo();
|
||||
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
protected void SendInfo()
|
||||
{
|
||||
|
||||
System.Text.StringBuilder sb = new StringBuilder();
|
||||
|
||||
NameValueCollection nvc = Request.Form;
|
||||
for (int x = 0; x < nvc.Count; x++)
|
||||
{
|
||||
sb.Append(nvc[x]);
|
||||
sb.Append("\r\n");
|
||||
}
|
||||
|
||||
string sResponse=sb.ToString();
|
||||
|
||||
if(sResponse.StartsWith("UNINSTALL SURVEY RESPONSE"))
|
||||
{
|
||||
sResponse=sResponse.Replace("UNINSTALL SURVEY RESPONSE","").Trim();
|
||||
try
|
||||
{
|
||||
System.Net.Mail.MailMessage m = new System.Net.Mail.MailMessage("noreply@ayanova.com", "support@ayanova.com");
|
||||
m.Subject = "Uninstall survey " + ed.Text; ;
|
||||
m.Body = "-=-=-=-=-=-=-=-=-=-\r\n" + sResponse + "\r\n-=-=-=-=-=-=-=-=-";
|
||||
m.IsBodyHtml = false;
|
||||
System.Net.Mail.SmtpClient c = new System.Net.Mail.SmtpClient();
|
||||
c.Send(m);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
lblError.Text += ex.Message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void bt_Click(object sender, EventArgs e)
|
||||
{
|
||||
SendInfo();
|
||||
}
|
||||
</script>
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" >
|
||||
<head id="Head1" runat="server">
|
||||
<title>Survey processor form</title>
|
||||
</head>
|
||||
<body>
|
||||
<form id="form1" runat="server">
|
||||
<div>
|
||||
Uninstall survey form
|
||||
<br />
|
||||
</div>
|
||||
<asp:TextBox ID="ed" runat="server" Width="376px"></asp:TextBox>
|
||||
<br />
|
||||
<br />
|
||||
<asp:Button ID="bt" runat="server" onclick="bt_Click" Text="submit" />
|
||||
<br />
|
||||
<br />
|
||||
<asp:Label ID="lblError" runat="server" ForeColor="Red"></asp:Label>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
*/
|
||||
Reference in New Issue
Block a user