コード例 #1
0
        public static string GenerateIndex(List <Message> messages, List <Users> users)
        {
            string html = System.IO.File.ReadAllText("C:/Users/MadsV/OneDrive/Dokumenter/GitHub/Mads-Verner-Klausen-Portfolio/Discard/Studio Project/Discard (message)/Discard (message)/HTML/DiscordIndex.html");

            html = html.Replace("{{MessageWindow}}", HTML_Generator.GenerateMessage(messages));
            html = html.Replace("{{UserWindow}}", HTML_Generator.GenerateUser(users));
            return(html);
        }
コード例 #2
0
        public static string GenerateIndex(List <Message> messages, List <Users> users, int userID)
        {
            string html = System.IO.File.ReadAllText(@"C:\Users\MadsV\OneDrive\Dokumenter\GitHub\Mads-Verner-Klausen-Portfolio\Discard\Studio Project\Discard\Discard\HTML\DiscordIndex.html");

            html = html.Replace("{{MessageWindow}}", HTML_Generator.GenerateMessage(messages));
            html = html.Replace("{{UserWindow}}", HTML_Generator.GenerateUser(users));
            html = html.Replace("{{USERID}}", userID.ToString());
            return(html);
        }
コード例 #3
0
        //Brugeren request localhost:8080
        string requestRoot(Request r)
        {
            if (r.HttpMethod == "POST")
            {
                RequestData data = r.Data;
                string      msg  = data.Post["msg"];
                MessagesMethods.insertMessage(msg, 1);
            }

            List <Message> messages = Database.GetMessages();
            List <Users>   users    = Database.GetUsers();

            return(HTML_Generator.GenerateIndex(messages, users));
        }
コード例 #4
0
        //Brugeren requester localhost:8080
        string requestRoot(Request r)
        {
            Users user = null;

            if (r.HttpMethod == "POST")
            {
                RequestData data = r.Data;
                if (r.Data.Post.ContainsKey("Author_Name"))
                {
                    user = logUserIn(r.Data);
                    //Sæt ID på indlogget bruger på CurrenUserId
                    Users.CurrentUserId = user.Author_ID;
                }
                else if (r.Data.Post.ContainsKey("msg"))
                {
                    int recipientID = 0;
                    int userID      = 0;
                    int.TryParse(r.Data.Post["Author_ID"], out userID);
                    user = Database.GetUser(userID);

                    if (user != null)
                    {
                        string msg = data.Post["msg"];
                        if (r.Data.Post.ContainsKey("Recipient_ID"))
                        {
                            int.TryParse(r.Data.Post["Recipient_ID"], out recipientID);
                        }
                        MessagesMethods.insertMessage(msg.ToString(), userID, recipientID);
                    }
                }
            }
            if (user != null)
            {
                List <Message> messages = Database.GetMessages();
                List <Users>   users    = Database.GetUsers();
                return(HTML_Generator.GenerateIndex(messages, users, user.Author_ID));
            }
            return(HTML_Generator.generateLogin());
        }
コード例 #5
0
        static void Main_(string[] args)
        {
            SQLet.ConnectSqlServer("Discard", @"MADS-V-KLAUSEN\MSSQLSERVER01", "SA", "Muskel-Jack");
            Database.SetupSQLServer();

            Database.GetMessages();
            List <Message> beskeder   = Database.GetMessages();
            string         beskedHTML = HTML_Generator.GenerateMessage(beskeder);

            Console.WriteLine(beskedHTML);
            List <Users> user     = Database.GetUsers();
            string       userList = HTML_Generator.GenerateUser(user);

            Console.WriteLine(user);
            string userHTML = HTML_Generator.GenerateUser(user);
            string index    = HTML_Generator.GenerateIndex(beskeder, user);

            Console.WriteLine(index);
            System.IO.File.WriteAllText("C:/Users/MadsV/OneDrive/Dokumenter/GitHub/Mads-Verner-Klausen-Portfolio/Discard/Studio Project/Discard (message)/Discard (message)/HTML/test.html", index);
            Console.ReadKey();
            const ConsoleKey keyInfo1 = ConsoleKey.D1;
            const ConsoleKey keyInfo2 = ConsoleKey.D2;
            const ConsoleKey keyInfo3 = ConsoleKey.D3;
            const ConsoleKey keyInfo4 = ConsoleKey.D4;
            const ConsoleKey keyInfo5 = ConsoleKey.D5;
            const ConsoleKey keyInfo6 = ConsoleKey.D6;
            const ConsoleKey keyInfo7 = ConsoleKey.D7;
            const ConsoleKey keyInfo8 = ConsoleKey.D8;

            while (true)
            {
                Console.Clear();
                Console.ForegroundColor
                    = ConsoleColor.DarkGray;
                MessagesMethods.SelectAllMessage();
                Console.WriteLine("" +
                                  "Press 1 :Insert Message.\n" +
                                  "Press 2 :Delete Message.\n" +
                                  "Press 3 :Update Message.\n" +
                                  "Press 4 :Show Message from user.\n\n" +
                                  "Press 5 :Insert new Author.\n" +
                                  "Press 6 :Delete Author.\n" +
                                  "Press 7 :Update Author.\n" +
                                  "Press 8 :Show Message from Author.\n");

                ConsoleKey pressedKey = PressedKey();

                switch (pressedKey)
                {
                case keyInfo1:
                    Console.ForegroundColor
                        = ConsoleColor.Blue;
                    Console.Write("Enter new message > ");
                    string input = Console.ReadLine();
                    Console.Write("What author ID is this message connected to? > ");

                    int messagesauthor = int.Parse(Console.ReadLine());
                    MessagesMethods.insertMessage(input, messagesauthor);
                    break;

                case keyInfo2:
                    Console.ForegroundColor
                        = ConsoleColor.Blue;
                    Console.Write("Specify what Message_ID you want to delete > ");
                    string inputdelete = Console.ReadLine();
                    MessagesMethods.deleteMessage(inputdelete);
                    break;

                case keyInfo3:
                    Console.ForegroundColor
                        = ConsoleColor.Blue;
                    Console.Write("What Message_ID do you want to update > ");
                    string inputUpdate = Console.ReadLine();
                    Console.Write("What do you want to update the message to > ");
                    string inputMessage = Console.ReadLine();
                    MessagesMethods.updateMessage(inputUpdate, inputMessage);
                    break;

                case keyInfo4:
                    Console.ForegroundColor
                        = ConsoleColor.Green;
                    Console.Write("What Author_ID do you want to see messages from? > ");
                    string aInputID = Console.ReadLine();
                    MessagesMethods.SelectMessage(aInputID);
                    break;

                case keyInfo5:
                    Console.ForegroundColor
                        = ConsoleColor.Green;
                    Console.Write("Enter new Author Name > ");
                    string Authorinput = Console.ReadLine();
                    UserMethods.insertAuthor(Authorinput);
                    break;

                case keyInfo6:
                    Console.ForegroundColor
                        = ConsoleColor.Green;
                    Console.Write("Specify what Author_ID you want to delete > ");
                    string Authorinputdelete = Console.ReadLine();
                    UserMethods.deleteAuthor(Authorinputdelete);
                    break;

                case keyInfo7:
                    Console.ForegroundColor
                        = ConsoleColor.Green;
                    Console.Write("What Author_ID do you want to update > ");
                    string AuthorinputUpdate = Console.ReadLine();
                    Console.Write("What do you want to update the Author_Name to > ");
                    string AuthorinputMessage = Console.ReadLine();
                    UserMethods.updateAuthor(AuthorinputUpdate, AuthorinputMessage);
                    break;

                case keyInfo8:
                    Console.ForegroundColor
                        = ConsoleColor.Green;
                    Console.Write("What Author_ID do you want to see messages from(Under construction)? > ");
                    string AuthoraInputID = Console.ReadLine();
                    UserMethods.SelectAuthor(AuthoraInputID);
                    break;
                }
            }
            ConsoleKey PressedKey()
            {
                do
                {
                    while (!Console.KeyAvailable)
                    {
                        ;
                    }
                    ConsoleKey pressed = Console.ReadKey(true).Key;
                    if (pressed == keyInfo1 || pressed == keyInfo2 || pressed == keyInfo3 || pressed == keyInfo4 || pressed == keyInfo5 || pressed == keyInfo6 || pressed == keyInfo7 || pressed == keyInfo8)
                    {
                        return(pressed);
                    }
                    Console.Clear();
                } while (true);
            }
        }
コード例 #6
0
        string requestUsers(Request r)
        {
            List <Users> users = Database.GetUsers();

            return(HTML_Generator.GenerateUser(users));
        }
コード例 #7
0
        string requestMessages(Request r)
        {
            List <Message> messages = Database.GetMessages();

            return(HTML_Generator.GenerateMessage(messages));
        }