protected void Login1_LoggedIn(object sender, EventArgs e) { RecipeWS.RecipeWebService ws = new RecipeWS.RecipeWebService(); string userName = Login1.UserName; if (userName == "") { userName = "******"; } ws.ReadUserInformation(userName, DateTime.Now.ToString(), "Logged In"); }
protected void LoginStatus2_LoggedOut(object sender, EventArgs e) { RecipeWS.RecipeWebService ws = new RecipeWS.RecipeWebService(); ws.ReadUserInformation(User.Identity.Name.ToString(), DateTime.Now.ToString(), "Logged Out"); }
protected void Page_Load(object sender, EventArgs e) { string userName = User.Identity.Name; if (userName == "") { userName = "******"; } Session.Add("userName", userName); try { // Preload reg recipe list database to be displayed on grid view RecipeWS.RecipeWebService ws = new RecipeWS.RecipeWebService(); RecipeWS.WSRecipe[] wsList = ws.GetWebServiceRecipes(); int count = wsList.Length; for (int i = 0; i < count; i++) { Recipe recipe = new Recipe(); recipe.RecipeName = wsList[i].RecipeName; recipe.RecipeIngredients = wsList[i].RecipeIngredients; recipe.RecipeInstructions = wsList[i].RecipeInstructions; recipe.RecipeSize = wsList[i].RecipeSize; recipe.RecipeImage = wsList[i].RecipeImage; list.Add(recipe); } } catch { Debug.WriteLine("Unable to load data from Service1Client!"); Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('Error! Unable to retrieve recipe list from host!');</script>"); } RecipeMgr recipeMgr = new RecipeMgr(); RecipeLists loadData = new RecipeLists(); // Create the recipe list database with preloaded recipes recipeMgr.storeRecipes(list); // Try to retrieve bool recipeAdded variable if available try { recipeAdded = (bool)(Session["recipeAdded"]); } catch (Exception ex) { Debug.Write(ex.StackTrace); Debug.WriteLine("Form loaded with no recipeAdded variable available."); } // Try to retrieve recipeDeleted bool variable if available try { recipeDeleted = (bool)(Session["recipeDeleted"]); } catch (Exception ex) { Debug.Write(ex.StackTrace); Debug.WriteLine("Form loaded with no recipeDeleted variable available."); } // Display success message if recipe successfully added to list from AddRecipeForm // Change the session bool variables back to false if (recipeAdded) { Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('Success! Recipe Added to List!');</script>"); Session["recipeAdded"] = false; } else if (recipeDeleted) { Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('Recipe successfully deleted from list!');</script>"); Session["recipeDeleted"] = false; } }