/*
     * Returns an arraylist filled with all the blog entries for that specific store in a specific format. Its
     * used when displaying the blog entries (so on all Store_X.aspx pages)
     */
    public ArrayList getBlogListInformation()
    {
        // Declares a string array that stores all lines into the array
        string[] lines = System.IO.File.ReadAllLines(this.filePath);
        // checking if there are any lines in file
        if (lines.Length > 0)
        {
            //if there are lines in the file, declare a new arrayList to store blog entry strings
            ArrayList blogList = new ArrayList();

            // Display the file contents by using a foreach loop.
            for (int i = 0; i < lines.Length; i++)
            {
                // declares a String array that split the line into parsable account info
                String[] lineData = lines[i].Split(',');
                // gets the blog entry's loginID (Ie. the person who made that specific blog entry)
                string blogItemLoginID = lineData[0];

                // Delcares a FileInfo object that help get the full name of the directory
                FileInfo fi = new FileInfo(this.filePath);
                // Declares a LoginIDFileReaderWriter object that allows us to read and write to the LoginID file
                LoginIDFileReaderWriter loginIDFileReader = new LoginIDFileReaderWriter(fi.Directory.FullName + "\\LoginIDFile.txt");
                // Declares a dictionary that holds all the account information for blogItemLoginID
                Dictionary <string, string> accInfo = loginIDFileReader.getAccountInfoByLoginID(blogItemLoginID);
                // declare an int that get the unix Time from lineData
                int blogItemUnixTime = int.Parse(lineData[1]);
                // declare a string that get blogItemExperience from lineData
                string blogItemExperience = lineData[2];

                // Declare a DateTime object that is set to 0 unix seconds in universal time
                System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);
                // add the time the blog entry was posted
                dtDateTime = dtDateTime.AddSeconds(blogItemUnixTime).ToLocalTime();
                // Declare a string that contains the date and time of the blog in a readable format
                string dateTimeOfBlog = dtDateTime.ToLongDateString() + " " + dtDateTime.ToShortTimeString();
                // Add the following string into the blogList arraylist
                blogList.Add("On " + dateTimeOfBlog + ", " + accInfo["name"] + " posted their experience:<br \\>" + blogItemExperience);
            }
            // once looping is all done, we return the arraylist
            return(blogList);
        }
        else
        {
            // if there are no entries available, then we create a "dummy" array list
            ArrayList blogList = new ArrayList();
            // add a fake entry that states that no entries are available in the "dummy" array list
            blogList.Add("No Entries are available");
            // return the "dummy" array list
            return(blogList);
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // When this page loads, we display the user's account information (and if appliable, access to moderator only features)s

        // Sets the title label as the same name as the loginID to signify that is is their user panel
        contentTitle.Text = (string)Session["LoginID"];

        // Declares a LoginIDFileReaderWriter instance which allows reading and writing of the loginID file
        LoginIDFileReaderWriter loginIDFileReader = new LoginIDFileReaderWriter(Path.GetFullPath(Server.MapPath("~\\files\\LoginIDFile.txt")));
        // Declares a dictionary object that hold all account information of the loginID
        Dictionary <string, string> accInfo = loginIDFileReader.getAccountInfoByLoginID((string)Session["LoginID"]);

        // Set the labels' text to the corosponding account information thats related to that label
        loginIDLabel.Text = (string)Session["LoginID"];
        emailLabel.Text   = (string)accInfo["email"];
        nameLabel.Text    = (string)accInfo["name"];

        // checks the size of the account's password
        if (((string)accInfo["password"]).Length == 0)
        {
            // if the size is zero, then we set the label saying that there is no password
            passwordLabel.Text = "(No Password Specified)";
        }
        else
        {
            // if the size is bigger than zero, than the password is not an empty string therefore we show it by
            // seeting the string accordingly
            passwordLabel.Text = (string)accInfo["password"];
        }

        // Instead of just showing the accessLevel number, we are gonna show what the number actually means
        // instead, so we use a switch statement
        switch ((int)int.Parse(accInfo["accessLevel"]))
        {
        case 1:
            //if the accessLevel is 1, then we can see the access level label's text to normal user
            accessLevelLabel.Text = "Normal User";
            // because the users is not a moderator, they will not be able to see the moderator only section
            moderatorSection.Visible = false;
            //break out of swtich/case statement
            break;

        case 2:
            //if the accessLevel is 2, then we can see the access level label's text to moderator
            accessLevelLabel.Text = "Moderator";
            // because the users is a moderator, they will be able to see the moderator only section
            moderatorSection.Visible = true;
            //break out of swtich/case statement
            break;
        }
    }
Esempio n. 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // When this page loads, we display the user's account information (and if appliable, access to moderator only features)s

        // Sets the title label as the same name as the loginID to signify that is is their user panel
        contentTitle.Text = (string) Session["LoginID"];

        // Declares a LoginIDFileReaderWriter instance which allows reading and writing of the loginID file
        LoginIDFileReaderWriter loginIDFileReader = new LoginIDFileReaderWriter(Path.GetFullPath(Server.MapPath("~\\files\\LoginIDFile.txt")));
        // Declares a dictionary object that hold all account information of the loginID
        Dictionary<string,string> accInfo = loginIDFileReader.getAccountInfoByLoginID((string) Session["LoginID"]);

        // Set the labels' text to the corosponding account information thats related to that label
        loginIDLabel.Text = (string) Session["LoginID"];
        emailLabel.Text = (string) accInfo["email"];
        nameLabel.Text = (string)accInfo["name"];

        // checks the size of the account's password
        if(((string) accInfo["password"]).Length == 0)
        {
            // if the size is zero, then we set the label saying that there is no password
            passwordLabel.Text = "(No Password Specified)";
        }
        else
        {
            // if the size is bigger than zero, than the password is not an empty string therefore we show it by
            // seeting the string accordingly
            passwordLabel.Text = (string) accInfo["password"];
        }

        // Instead of just showing the accessLevel number, we are gonna show what the number actually means
        // instead, so we use a switch statement
        switch ((int) int.Parse(accInfo["accessLevel"]))
        {
            case 1:
                //if the accessLevel is 1, then we can see the access level label's text to normal user
                accessLevelLabel.Text = "Normal User";
                // because the users is not a moderator, they will not be able to see the moderator only section
                moderatorSection.Visible = false;
                //break out of swtich/case statement
                break;
            case 2:
                //if the accessLevel is 2, then we can see the access level label's text to moderator
                accessLevelLabel.Text = "Moderator";
                // because the users is a moderator, they will be able to see the moderator only section
                moderatorSection.Visible = true;
                //break out of swtich/case statement
                break;
        }
    }