Guest User

Untitled

a guest
May 23rd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.18 KB | None | 0 0
  1.     protected void Page_Load(object sender, EventArgs e)
  2.     {
  3.         dx = new dbWrap();
  4.         UserId = Funcs.CheckLogin(this, dx, ref RedirectURL, true);
  5.         if (UserId == -1) { Redirect = true; return; }
  6.  
  7.         GalaxyId = GeneralExtensions.SafeToLong((string)RouteData.Values["galaxyid"]);
  8.         LogEventId = GeneralExtensions.SafeToLong((string)RouteData.Values["logid"]);
  9.         if (LogEventId <= 0)
  10.         {
  11.             //we wanna pull the last 5
  12.             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";
  13.         }
  14.         else
  15.         {
  16.             //we only pulling the latest one
  17.             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";
  18.         }
  19.         //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";
  20.         EventLogInfo = DB.RunSQL(dx, SQL, UserId, GalaxyId);
  21.  
  22.         //now create the format to read
  23.         if (EventLogInfo != null && EventLogInfo.Rows.Count > 0)
  24.         {
  25.             int i = 0;
  26.             Response.Write("{");
  27.             Response.Write("\"LogItems\":[");
  28.             foreach (System.Data.DataRow item in EventLogInfo.Rows)
  29.             {
  30.                 if (i > 0) { Response.Write(","); }
  31.                 i++;
  32.                 Response.Write("{");
  33.                 Response.Write("\"Date\": \"" + ((DateTimeOffset)item["Date"]).ToString("dd/MM/yy 'at' HH:mm") + "\",");
  34.                 Response.Write("\"Name\": \"" + item["Name"].ToString() + "\",");
  35.                 Response.Write("\"DirectCoordinate\": \"" + item["DirectCoordinate"].ToString().Trim() + "\",");
  36.                 Response.Write("\"LogString\": \"" + item["LogString"].ToString() + "\",");
  37.                 Response.Write("}");
  38.             }
  39.  
  40.             Response.Write("]");
  41.             Response.Write("}");
  42.         }
  43.     }
Add Comment
Please, Sign In to add comment