ASP.NET Page /Admin/ViewLog.aspx.cs (C#)
1: using System;  
2: using System.Data;  
3: using System.Configuration;  
4: using System.Collections;  
5: using System.Web;  
6: using System.Web.Security;  
7: using System.Web.UI;  
8: using System.Web.UI.WebControls;  
9: using System.Web.UI.WebControls.WebParts;  
10: using System.Web.UI.HtmlControls;  
11: using System.Data.SqlClient;  
12: using QuizNetOnline.Logic;  
13: using QuiznetOnline.Data;  
14: using Microsoft.ApplicationBlocks.Data;  
15:   
16: public partial class ViewLog : System.Web.UI.Page  
17: {  
18:   
19:     protected void Page_Load(object sender, EventArgs e)  
20:     {  
21:         int count = 1;  
22:   
23:         if (Session["LogCount"] == null)  
24:             Session["LogCount"] = 0;  
25:         int LogCount = Convert.ToInt32(Session["LogCount"].ToString());  
26:   
27:         UpdateTimer.Interval = Convert.ToInt32(cmdRefreshRate.SelectedItem.Value);  
28:   
29:         if (!Page.IsPostBack)  
30:         {  
31:             if (Session["Validated"] == null || (bool)Session["Validated"] == false)  
32:                 Response.Redirect("Default.aspx");  
33:               
34:             grdLog.PageSize = Convert.ToInt32(lstPageSize.SelectedItem.Value);  
35:   
36:             Country country = new Country();  
37:             lstCountries.DataSource = country.GetCountries(new SqlWrapper());  
38:             lstCountries.DataTextField = "CountryDesc";  
39:             lstCountries.DataValueField = "CountryCode";  
40:             lstCountries.DataBind();  
41:             lstCountries.Items.Insert(0, new ListItem("All Countries", "ALL"));  
42:   
43:             LoadGrid(false, null, null);  
44:   
45:             for (int i = 0; i < Session.Count; i++)  
46:             {  
47:                 if (Session.Keys[i].ToString() == "username")  
48:                 {  
49:                     Response.Write(count.ToString() + " " + Session[i].ToString());  
50:                     count++;  
51:                     Response.Write(Environment.NewLine);  
52:                 }  
53:             }  
54:   
55:             if (grdLog.Rows.Count > LogCount)  
56:             {  
57:                 soundAlarm.Attributes["src"] = "../include/bleep.wav";  
58:                 Session["LogCount"] = grdLog.Rows.Count;  
59:             }  
60:             else  
61:             {  
62:                 soundAlarm.Attributes["src"] = "";  
63:             }  
64:         }  
65:         else  
66:         {  
67:             ProcessLog();  
68:         }  
69:     }  
70:   
71:     protected void UpdateTimer_Tick(object sender, EventArgs e)  
72:     {  
73:         ProcessLog();  
74:     }  
75:   
76:     private void ProcessLog()  
77:     {  
78:         string country = null,logArea=null;  
79:         bool OnlyRegisteredUsers = false;  
80:   
81:         if (lstCountries.SelectedItem.Value != "ALL")  
82:         {  
83:             country = lstCountries.SelectedItem.Text;  
84:         }  
85:   
86:   
87:         if (lstUserType.SelectedItem.Value != "0")  
88:         {  
89:             OnlyRegisteredUsers = true;  
90:         }  
91:   
92:         if(txtLogArea.Text==string.Empty)  
93:         {  
94:             logArea = null;  
95:         }  
96:         else  
97:         {  
98:             logArea=txtLogArea.Text;  
99:         }  
100:         LoadGrid(OnlyRegisteredUsers, logArea, country);  
101:     }  
102:   
103:     private void LoadGrid(bool OnlyRegisteredUsers,string LogArea,string LogLocation)  
104:     {  
105:         Log log = new Log();  
106:         grdLog.DataSource = log.GetLog(0, OnlyRegisteredUsers, LogArea, LogLocation, new SqlWrapper());  
107:         grdLog.DataBind();  
108:     }  
109:   
110:   
111:     protected void grdLog_RowCommand(object sender, GridViewCommandEventArgs e)  
112:     {  
113:         int Index = Convert.ToInt32(e.CommandArgument);  
114:         GridViewRow row = grdLog.Rows[Index];  
115:   
116:         if (e.CommandName == "ShowIP")  
117:         {  
118:             Label lblLong = (Label)row.FindControl("lblLong");  
119:             Label lblLat = (Label)row.FindControl("lblLat");  
120:             TableCell ipAddress = row.Cells[1];  
121:   
122:             if (ViewState["ipAddress"] != null && ViewState["ipAddress"].ToString() == ipAddress.Text)  
123:                 ViewState["ipAddress"] = string.Empty;  
124:             else  
125:                 ViewState["ipAddress"] = ipAddress.Text;  
126:   
127:             ProcessLog();  
128:         }  
129:     }  
130:   
131:     protected void grdLog_PageIndexChanged(object sender, EventArgs e)  
132:     {  
133:   
134:     }  
135:     protected void grdLog_PageIndexChanging(object sender, GridViewPageEventArgs e)  
136:     {  
137:         grdLog.PageIndex = e.NewPageIndex;  
138:         grdLog.DataBind();  
139:     }  
140:   
141:     protected void cmdSubmit_Click(object sender, EventArgs e)  
142:     {  
143:         ProcessLog();  
144:     }  
145:   
146:     protected void cmdMarkRow_Click(object sender, EventArgs e)  
147:     {  
148:         ViewState["bookmark"]=grdLog.Rows[0].Cells[3].Text;  
149:         ProcessLog();  
150:     }  
151: There is a limit of 150 source code lines in the evaluation version
152: There is a limit of 150 source code lines in the evaluation version
153: There is a limit of 150 source code lines in the evaluation version
154: There is a limit of 150 source code lines in the evaluation version
155: There is a limit of 150 source code lines in the evaluation version
156: There is a limit of 150 source code lines in the evaluation version
157: There is a limit of 150 source code lines in the evaluation version
158: There is a limit of 150 source code lines in the evaluation version
159: There is a limit of 150 source code lines in the evaluation version
160: There is a limit of 150 source code lines in the evaluation version
161: There is a limit of 150 source code lines in the evaluation version
162: There is a limit of 150 source code lines in the evaluation version
163: There is a limit of 150 source code lines in the evaluation version
164: There is a limit of 150 source code lines in the evaluation version
165: There is a limit of 150 source code lines in the evaluation version
166: There is a limit of 150 source code lines in the evaluation version
167: There is a limit of 150 source code lines in the evaluation version
168: There is a limit of 150 source code lines in the evaluation version
169: There is a limit of 150 source code lines in the evaluation version
170: There is a limit of 150 source code lines in the evaluation version
171: There is a limit of 150 source code lines in the evaluation version
172: There is a limit of 150 source code lines in the evaluation version
173: There is a limit of 150 source code lines in the evaluation version
174: There is a limit of 150 source code lines in the evaluation version

.NET Documentation Tool is © 2002 - 2009 Winnersh Triangle Web Solutions Limited.