示例#1
0
        public string showTotalTimeConsumed(int totalMinutes)
        {
            Utilities.MathConverters importMathConverters = new Utilities.MathConverters();

            string output = "";

            output += "<h1>You have spent " + importMathConverters.convertFromRawMinutes(totalMinutes) + " on all activities, combined.</h1>\n";

            return output;
        }
示例#2
0
        protected string totalTimeSpentOnSingleActivity(string usernameValue)
        {
            Utilities.MathConverters importMathConverters = new Utilities.MathConverters();

            string output = "";

            if (this.searchNumberOfRecords(usernameValue, "activity started but not complete") == 0 && this.searchNumberOfRecords(usernameValue, "activity complete but not saved") == 1)
            {
                using (SqlConnection connection = new SqlConnection())
                {
                    connection.ConnectionString = "connectionString";

                    try
                    {
                        connection.Open();

                        SqlCommand findRecords = new SqlCommand("SELECT * FROM savedActivities WHERE username LIKE @prepareUsername", connection);

                        findRecords.Parameters.AddWithValue("@prepareUsername", usernameValue);

                        using (SqlDataReader extractSearchResults = findRecords.ExecuteReader())
                        {
                            while (extractSearchResults.Read())
                            {
                                if (extractSearchResults.GetString(8) != "yes")
                                {
                                    int intRawStartingTime = Convert.ToInt32(extractSearchResults.GetString(4));
                                    int intRawEndingTime = Convert.ToInt32(extractSearchResults.GetString(5));

                                    int intTotalMinutesForActivity = intRawEndingTime - intRawStartingTime;

                                    output += "<label>You spent " + importMathConverters.convertFromRawMinutes(intTotalMinutesForActivity) + " on this current activity.</label><br />\n";
                                }
                            }
                        }

                        connection.Close();
                    }
                    catch (Exception)
                    {
                        output += "<div style='width: 100%'><br /><label>The website had a hiccup. Click <a class='textLink' href='http://www.timothysdigitalsolutions.somee.com/stop-watch/'>here</a> to refresh.</label></div>\n";
                    }
                }
            }

            return output;
        }
示例#3
0
        protected string savedActivitiesLog(string usernameValue, string selectSavedActivities, string deleteSelected)
        {
            Utilities.TextFormatter importTextFormatter = new Utilities.TextFormatter();
            Utilities.MathConverters importMathConverters = new Utilities.MathConverters();

            string output = "";

            if (this.searchNumberOfRecords(usernameValue, "completely saved") > 0)
            {
                output += "<div style='width: 100%'><input id='deleteSelected' name='deleteSelected' type='submit' value='Delete selected' /></div>\n";

                using (SqlConnection connection = new SqlConnection())
                {
                    connection.ConnectionString = "connectionString";

                    try
                    {
                        connection.Open();

                        SqlCommand searchSavedActivitiesLog = new SqlCommand("SELECT * FROM savedActivities WHERE username LIKE @prepareUsername ORDER BY recorded DESC", connection);

                        searchSavedActivitiesLog.Parameters.AddWithValue("@prepareUsername", usernameValue);

                        using (SqlDataReader extractSavedActivitiesLog = searchSavedActivitiesLog.ExecuteReader())
                        {
                            if (deleteSelected == "Delete selected")
                            {
                                if (usernameValue != "" && usernameValue != "cookie exception")
                                {
                                    if (this.deleteSavedActivities(selectSavedActivities) != "query exception")
                                    {
                                        output += "<div style='width: 100%'><br />" + this.deleteSavedActivities(selectSavedActivities) + "</div>\n";
                                    }
                                    else
                                    {
                                        output += "<div style='width: 100%'><br /><label>The website had a hiccup. Click <a class='textLink' href='http://www.timothysdigitalsolutions.somee.com/stop-watch/'>here</a> to refresh.</label></div>\n";
                                    }
                                }
                            }

                            while (extractSavedActivitiesLog.Read())
                            {
                                if (!(String.IsNullOrWhiteSpace(extractSavedActivitiesLog.GetString(4))) && !(String.IsNullOrWhiteSpace(extractSavedActivitiesLog.GetString(5))) && !(String.IsNullOrWhiteSpace(extractSavedActivitiesLog.GetString(6))) && !(String.IsNullOrWhiteSpace(extractSavedActivitiesLog.GetString(7))) && extractSavedActivitiesLog.GetString(8) == "yes")
                                {
                                    try
                                    {
                                        int intRawStartingTime = Convert.ToInt32(extractSavedActivitiesLog.GetString(4));
                                        int intRawEndingTime = Convert.ToInt32(extractSavedActivitiesLog.GetString(5));

                                        int intTotalMinutesForActivity = intRawEndingTime - intRawStartingTime;

                                        output += "<div style='width: 100%'><br /><br /><input class='selectSavedActivities' name='selectSavedActivities' type='checkbox' value='" + extractSavedActivitiesLog.GetString(0) + "' /></div>\n";
                                        output += "<div style='width: 100%'>\n";
                                        output += "<label><b>Activity name:</b> " + importTextFormatter.chopText(extractSavedActivitiesLog.GetString(2), 40) + "</label>\n";
                                        output += "</div>\n";
                                        output += "<div style='width: 100%'>\n";
                                        output += "<label>Started on " + extractSavedActivitiesLog.GetString(6) + "</label>\n";
                                        output += "</div>\n";
                                        output += "<div style='width: 100%'>\n";
                                        output += "<label>Completed on " + extractSavedActivitiesLog.GetString(7) + "</label>\n";
                                        output += "</div>\n";
                                        output += "<div style='width: 100%'>\n";
                                        output += "<label><i>You spent " + importMathConverters.convertFromRawMinutes(intTotalMinutesForActivity) + " on this activity.</i></label>\n";
                                        output += "</div>\n";
                                        output += "<div style='width: 100%'>\n";

                                        if (String.IsNullOrWhiteSpace(extractSavedActivitiesLog.GetString(3)) || extractSavedActivitiesLog.GetString(3) == "no value")
                                        {
                                            output += "<label><b>Description:</b> You do not have any details for this activity.</label>\n";
                                        }
                                        else
                                        {
                                            output += "<label><b>Description:</b> " + importTextFormatter.chopText(extractSavedActivitiesLog.GetString(3), 40) + "</label>\n";
                                        }

                                        output += "</div>\n";
                                    }
                                    catch (Exception)
                                    {
                                        output += "";
                                    }
                                }
                            }
                        }

                        connection.Close();
                    }
                    catch (Exception)
                    {
                        output += "<label>The website had a hiccup. Click <a class='textLink' href='http://www.timothysdigitalsolutions.somee.com/stop-watch/'>here</a> to refresh.</label>\n";
                    }
                }
            }
            else
            {
                output += "<label>Your activity history is empty.</label>\n";
            }

            return output;
        }