protected async Task InitProject() { // Login - temporary for fast testing if (Session["user"] == null) { //Query query = new Query(); //user = query.login("nguymin4", ""); //Session["user"] = user; //Session["userID"] = user.User_ID; //query.Dipose(); Response.Redirect("Login.aspx"); } else { user = (Model.UserModel)Session["user"]; } // Init variables int userID = user.User_ID; int role = user.Role; lists = new StringBuilder("const userID=" + userID + ";"); // Start tasks // var timer = System.Diagnostics.Stopwatch.StartNew(); Task[] task = new Task[2]; task[0] = Task.Run(() => loadProject(userID, role)); task[1] = Task.Run(() => loadUser(userID)); // Profile area var profile = (Image)Master.FindControl("profile"); profile.ToolTip = user.Name; profile.ImageUrl = user.Avatar; new Controller.LanbanAuthentication().Authenticate(Response, user); // Wait all tasks to be completed await Task.WhenAll(task); // timer.Stop(); // System.Diagnostics.Debug.WriteLine(timer.ElapsedMilliseconds.ToString()); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "projectScript", lists.ToString(), true); }
// 3. Event handler of clicking on a project box public void gotoProject(string data) { string[] info = data.Split('$'); Session["projectID"] = info[0]; Session["projectName"] = info[1]; user = (Model.UserModel)Session["user"]; var myQuery = new Query(); if (!myQuery.IsProjectMember(int.Parse(info[0]), user.User_ID, user.Role)) { myQuery.Dipose(); Response.Redirect("/Error/error.html", true); } else { Response.Redirect("Board.aspx"); } }
protected async void InitBoard() { Model.UserModel user = (Model.UserModel)Session["user"]; userID = user.User_ID; projectID = Convert.ToInt32(Session["projectID"]); // Start initialize // var timer = System.Diagnostics.Stopwatch.StartNew(); Task task1 = createKanban(); Task task2 = Task.Run(() => initDropdownList()); // Profile general info string name = Session["projectName"].ToString(); Page.Title = "Lanban - " + name; lblProjectName.Text = name; //Profile area var profile = (Image)Master.FindControl("profile"); profile.ToolTip = user.Name; profile.ImageUrl = user.Avatar; // Authentication var authen = new Controller.LanbanAuthentication(); var ticket = authen.GetAuthenTicket(user.Username, projectID.ToString(), 30); authen.SetAuthenCookie(Response, ticket); string script = "const userID = " + userID + "; const projectID = " + projectID + ";"; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "boardScript", script, true); // Wait all task to complete await Task.WhenAll(task1, task2); // timer.Stop(); // System.Diagnostics.Debug.WriteLine(timer.ElapsedMilliseconds); }