public static string showAllChunks(int fileId) { utils.DbUtils dbUtil = new utils.DbUtils(); List <string> blackList = (List <string>)HttpContext.Current.Session["blackList"]; List <int> ids = dbUtil.getChunksFile(fileId); string html = ""; html += "<tr><th>Chunk Id</th><th> Peer</th><th>Choose</th></tr>"; for (int i = 0; i < ids.Count(); i++) { System.Diagnostics.Debug.Write(ids[i] + "\n"); List <string> peers = dbUtil.getPeersChunk(ids[i]); for (int j = 0; j < peers.Count(); j++) { if (!blackList.Contains(peers[j])) { html += "<tr><td>" + ids[i] + "</td><td>" + peers[j] + "</td><td><input type=\"checkbox\" onclick=\"addPeer('" + ids[i] + "','" + peers[j] + "')\"></td>" + "</tr>"; } } } return(html); }
protected void Page_Load(object sender, EventArgs e) { if (Session["username"] == null) { Response.Redirect("index.aspx"); } else { utils.DbUtils dbUtils = new utils.DbUtils(); string username = Session["username"].ToString(); List <string> urls = dbUtils.getUrlsOfUser(username); System.Text.StringBuilder table = new System.Text.StringBuilder(); table.Append("<table border='1'>"); table.Append("<tr><th>Url</th></tr>"); for (int i = 0; i < urls.Count; i++) { table.Append("<tr>"); table.Append("<td>" + urls[i] + "</td>"); table.Append("</tr>"); } table.Append("</table>"); urlsTable.Controls.Clear(); urlsTable.Controls.Add(new Literal { Text = table.ToString() }); } }
protected void DoSignUp(object sender, EventArgs e) { utils.DbUtils db = new utils.DbUtils(); db.addUser(username.Text, password.Text); Response.Redirect("Login.aspx"); }
public static void addRezervation(string username, string flightName) { utils.DbUtils dbUtil = new utils.DbUtils(); int id = dbUtil.getIdOfFlight(flightName); dbUtil.addRezervation(id, username); dbUtil.decreaseSeatsFlight(id); HttpContext.Current.Session["flight"] = flightName; }
public static void addRezervation(string username, string hotelName) { utils.DbUtils dbUtil = new utils.DbUtils(); int id = dbUtil.getIdOfHotel(hotelName); dbUtil.addRezervationHotel(id, username); dbUtil.decreaseSeatsHotel(id); HttpContext.Current.Session["hotel"] = hotelName; }
protected void Page_Load(object sender, EventArgs e) { utils.DbUtils db = new utils.DbUtils(); string res = db.selectPopular(); string p = "<p>" + res + "</p>"; confP.Controls.Clear(); confP.Controls.Add(new Literal { Text = p.ToString() }); }
protected void DoLogin(object sender, EventArgs e) { Console.WriteLine("YUHUUU"); utils.DbUtils db = new utils.DbUtils(); if (db.findUser(username.Text, password.Text)) { Console.WriteLine("YUHUUU FOUND"); Session["username"] = username.Text; Response.Redirect("indexLogged.aspx"); } }
public static string selectUsers() { utils.DbUtils dbUtil = new utils.DbUtils(); string html = "<tr><th>Username</th></tr>"; List <string> slist = dbUtil.selectUsers(); for (int i = 0; i < slist.Count; i++) { Console.WriteLine("YUHUUU"); html += "<tr><td>" + slist[i] + "</td></tr>"; } return(html); }
public static string addLike(string username, string owner, string url) { Console.WriteLine(username, owner, url); utils.DbUtils dbUtil = new utils.DbUtils(); if (dbUtil.addLike(username, owner, url)) { return("yes"); } else { return("no"); } }
public static string selectLiked(string username) { utils.DbUtils dbUtil = new utils.DbUtils(); string html = "<tr><th>Username</th><th>Owner</th></tr>"; List <string> slist = dbUtil.getLikedUrls(username); for (int i = 0; i < slist.Count; i++) { string[] vals = slist[i].Split(' '); html += "<tr><td>" + vals[1] + "</td><td>" + vals[0] + "</td><td</tr>"; } return(html); }
public static string showPeers() { utils.DbUtils dbUtil = new utils.DbUtils(); string html = "<tr><th>Peers</th><th>Add to Black List</th></tr>"; List <string> slist = dbUtil.getPeers(); for (int i = 0; i < slist.Count; i++) { html += "<tr><td>" + slist[i] + "</td>" + "<td onclick =\"addPeerBlack('" + slist[i] + "')\">Add</td>" + "</tr>"; } return(html); }
public static string searchFiles(string keywords) { utils.DbUtils dbUtil = new utils.DbUtils(); string html = "<tr><th>File</th><th></th></tr>"; List <string> slist = dbUtil.getFiles(keywords); for (int i = 0; i < slist.Count; i++) { html += "<tr><td>" + slist[i] + "</td>" + "<td onclick =\"showChunks('" + dbUtil.getId(slist[i]) + "')\">Show</td>" + "</tr>"; } return(html); }
public static string selectAllUrls(string username) { utils.DbUtils dbUtil = new utils.DbUtils(); string html = "<tr><th>Username</th><th></th></tr>"; List <Url> slist = dbUtil.getAllUrls(username); for (int i = 0; i < slist.Count; i++) { html += "<tr><td>" + slist[i].url + "</td><td onclick=\"addLike('" + username + "','" + slist[i].owner + "','" + slist[i].url + "')\">Like</td>" + "<td onclick =\"addShare('" + username + "','" + slist[i].id + "')\">Share</td>" + "</tr>"; } return(html); }
public static void addRezConf(string username, string confName) { utils.DbUtils dbUtil = new utils.DbUtils(); int id = dbUtil.getIdOfConference(confName); if (dbUtil.areSlots(confName)) { System.Diagnostics.Debug.Write("YUHUUUUUUUUUU"); dbUtil.addRezervationConference(id, username); dbUtil.decreaseSeatsConference(id); } else { dbUtil.cancelAnything(username, HttpContext.Current.Session["hotel"].ToString(), HttpContext.Current.Session["flight"].ToString()); } }
public static string showHotels(string username, string date, string city) { System.Diagnostics.Debug.Write(date); System.Diagnostics.Debug.Write(username); string html = "<tr><td>Flight Name</td><th></th></tr>"; utils.DbUtils dbUtils = new utils.DbUtils(); List <String> hotels = dbUtils.selectHotels(date, city); for (int i = 0; i < hotels.Count; i++) { html += "<tr><td>" + hotels[i] + "</td>" + "<td onclick =\"rezerveHotel('" + username + "','" + hotels[i] + "')\">Rezerve</td></tr>"; } return(html); }
public static string showConferences(string username, string date, string city) { System.Diagnostics.Debug.Write(date); System.Diagnostics.Debug.Write(username); System.Diagnostics.Debug.Write(city); string html = "<tr><td>Conference Name</td><th></th></tr>"; utils.DbUtils dbUtils = new utils.DbUtils(); List <String> confs = dbUtils.selectConferences(date, city); for (int i = 0; i < confs.Count; i++) { html += "<tr><td>" + confs[i] + "</td>" + "<td onclick =\"rezerveConference('" + username + "','" + confs[i] + "')\">Register</td></tr>"; } return(html); }
public static string showFlights(string username, string departure, string destination, string date) { string html = "<tr><td>Flight Name</td><th></th></tr>"; utils.DbUtils dbUtils = new utils.DbUtils(); List <String> flights = dbUtils.selectFlights(departure, destination, date); for (int i = 0; i < flights.Count; i++) { html += "<tr><td>" + flights[i] + "</td>" + "<td onclick =\"rezerveFlight('" + username + "','" + flights[i] + "')\">Rezerve</td></tr>"; } HttpContext.Current.Session["date"] = date; HttpContext.Current.Session["city"] = destination; System.Diagnostics.Debug.Write(HttpContext.Current.Session["city"]); return(html); }
public static string sharedUrls(int userId) { utils.DbUtils dbUtil = new utils.DbUtils(); string html = "<tr><th>Shared Url</th></tr>"; String username = dbUtil.getNameOfUserId(userId); if (username == "no") { return(""); } else { List <string> slist = dbUtil.getSharedUrls(username); for (int i = 0; i < slist.Count; i++) { html += "<tr><td>" + slist[i] + "</td><td</tr>"; } return(html); } }
public static void addShare(string username, int urlId) { utils.DbUtils dbUtil = new utils.DbUtils(); dbUtil.addShare(username, urlId); }