This repository has been archived by the owner on Feb 8, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdmin.aspx.cs
90 lines (78 loc) · 2.56 KB
/
Admin.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Windows.Forms;
using System.Net.Mail;
public partial class _Default : System.Web.UI.Page
{
// Variables and structures\
protected string errorMessage = "";
protected Dictionary<int, TableGroup> tableList;
Database db = new Database();
private string GetAssemblyPath()
{
string path;
path = System.IO.Path.GetDirectoryName(
System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
path = path.Substring(6, path.Length - 6);
return path;
}
protected void addEmail(object sender, EventArgs e)
{
string[] allEmails = emailToAdd.Text.Split(';');
try
{
foreach (string email in allEmails)
{
string password = Membership.GeneratePassword(12, 3);
db.create_user(email, password);
sendEmail(email, password);
}
}
catch (Exception ex)
{
errorMessage = String.Format("An error occurred: {0}", ex.Message);
}
}
private void sendEmail(string emailAddress, string password)
{
MailMessage outgoingMessage = new MailMessage();
outgoingMessage.From = new MailAddress(Config.SMTP_FROM_EMAIL, Config.SMTP_FROM_NAME);
outgoingMessage.To.Add(emailAddress);
outgoingMessage.Subject = String.Format(Config.SMTP_NEWUSER_SUBJECT, Config.EVENT_NAME);
outgoingMessage.Body = String.Format(Config.SMTP_NEWUSER_BODY,
Config.EVENT_NAME,
Config.EVENT_HOST_NAME,
Config.URL,
password,
Config.EVENT_HOST_NAME);
SmtpClient server = new SmtpClient(Config.SMTP_SERVER, Config.SMTP_PORT);
server.UseDefaultCredentials = true;
server.EnableSsl = false;
server.Send(outgoingMessage);
}
// Driver method
protected void Page_Load(object sender, EventArgs e)
{
tableList = db.getTables();
if (Session.IsNewSession == true || Session["AdminLoggedIn"] == null)
Response.Redirect("adminLogin.aspx");
try
{
tableList = db.getTables();
}
catch (Exception ex)
{
errorMessage = "Could not load database. <br>" + ex.Message;
}
}
// Reset entire XML file
protected void resetChairs(object sender, EventArgs e)
{
db.resetChairs();
}
}