Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected void Page_Load(object sender, EventArgs e)
- {
- dx = new dbWrap();
- UserId = Funcs.CheckLogin(this, dx, ref RedirectURL, true);
- if (UserId == -1) { Redirect = true; return; }
- GalaxyId = GeneralExtensions.SafeToLong((string)RouteData.Values["galaxyid"]);
- LogEventId = GeneralExtensions.SafeToLong((string)RouteData.Values["logid"]);
- if (LogEventId <= 0)
- {
- //we wanna pull the last 5
- SQL = "SELECT TOP 5 el.Date,el.LogString,b.Name,b.DirectCoordinate FROM EventsLog AS el LEFT OUTER JOIN Bodies AS b ON el.BodyId=b.BodyId WHERE el.UserId=@P0 AND el.GalaxyId=@P1 ORDER BY el.Date DESC";
- }
- else
- {
- //we only pulling the latest one
- SQL = "SELECT TOP 1 el.Date,el.LogString,el.LogId,b.Name,b.DirectCoordinate FROM EventsLog AS el LEFT OUTER JOIN Bodies AS b ON el.BodyId=b.BodyId WHERE el.UserId=@P0 AND el.GalaxyId=@P1";
- }
- //SQL = "SELECT TOP 5 el.Date,el.LogString,b.Name,b.DirectCoordinate FROM EventsLog AS el LEFT OUTER JOIN Bodies AS b ON el.BodyId=b.BodyId WHERE el.UserId=@P0 AND el.GalaxyId=@P1 ORDER BY el.Date DESC";
- EventLogInfo = DB.RunSQL(dx, SQL, UserId, GalaxyId);
- //now create the format to read
- if (EventLogInfo != null && EventLogInfo.Rows.Count > 0)
- {
- int i = 0;
- Response.Write("{");
- Response.Write("\"LogItems\":[");
- foreach (System.Data.DataRow item in EventLogInfo.Rows)
- {
- if (i > 0) { Response.Write(","); }
- i++;
- Response.Write("{");
- Response.Write("\"Date\": \"" + ((DateTimeOffset)item["Date"]).ToString("dd/MM/yy 'at' HH:mm") + "\",");
- Response.Write("\"Name\": \"" + item["Name"].ToString() + "\",");
- Response.Write("\"DirectCoordinate\": \"" + item["DirectCoordinate"].ToString().Trim() + "\",");
- Response.Write("\"LogString\": \"" + item["LogString"].ToString() + "\",");
- Response.Write("}");
- }
- Response.Write("]");
- Response.Write("}");
- }
- }
Add Comment
Please, Sign In to add comment