예제 #1
0
        public static void Main()
        {
            string        s    = String.Empty;
            string        type = String.Empty;
            string        rs   = String.Empty;
            string        resString;
            var           guid = Guid.NewGuid().ToString();
            ClientHandler ch   = new ClientHandler();

            try
            {
                Console.WriteLine("Welcome to the application!" + Environment.NewLine);
                ch.ShowMenu();

                bool isRunning = true;

                while (isRunning)
                {
                    int caseswitch = Int32.Parse(Console.ReadLine());

                    switch (caseswitch)
                    {
                    case 1:
                        Console.WriteLine("Enter a type of new event.");
                        type = Console.ReadLine();
                        Console.WriteLine("First, name all columns with their types in a event's log ('Esc' finishes this operation):");
                        while (true)
                        {
                            Console.WriteLine("Now enter name and type of column, separated by a space bar (for example: ID int)");
                            s = Console.ReadLine();
                            if (s.Equals("Esc"))
                            {
                                break;
                            }
                            rs += s;
                            rs += "#";
                        }
                        resString = "1" + type + "(&ID varchar(MAX)#Event_time varchar(255)#" + rs;
                        ch.PostData(resString);
                        rs = String.Empty;
                        Console.Clear();
                        ch.ShowMenu();
                        break;

                    case 2:
                        DateTime dt = DateTime.Now;
                        Console.WriteLine("First, choose type of event to fill.");
                        type = Console.ReadLine();
                        Console.WriteLine("Now create new event by giving values of each column in log table");
                        while (true)
                        {
                            s = Console.ReadLine();
                            if (s.Equals("Esc"))
                            {
                                break;
                            }
                            rs += "'" + s + "'";
                            rs += "#";
                        }
                        resString = "2" + type + " values (&" + "'" + guid + "'" + ",'" + dt.ToString("d MMM yyyy, HH:mm:ss.ff") + "'," + rs;
                        ch.PostData(resString);
                        rs = String.Empty;
                        Console.Clear();
                        ch.ShowMenu();
                        break;

                    case 3:
                        ch.GetData();
                        Thread.Sleep(700);
                        ch.ShowMenu();
                        break;

                    case 4:
                        Console.WriteLine("bigint, binary(50), bit, char(10), date, datetime, datetime2(7)," + Environment.NewLine +
                                          "datetimeoffset(7), decimal(18,0), float, hierarchyid, image, int, " + Environment.NewLine +
                                          "money, nchar(10), ntext, numeric(18,0), nvarchar(50), nvarchar(max), " + Environment.NewLine +
                                          "real, smalldatetime, smallint, smallmoney, sql_variant, table, text, " + Environment.NewLine +
                                          "time(7), timestamp, tinyint, uniqueidentifier, varbinary(50), " + Environment.NewLine +
                                          "varbinary(max), varchar(50), varchar(max), xml" + Environment.NewLine);
                        ch.ShowMenu();
                        break;

                    case 5:
                        Environment.Exit(0);
                        break;

                    default:
                        isRunning = false;
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
예제 #2
0
 public LogClient(ClientHandler ch)
 {
 }
 private void btnEnterGame_Click(object sender, RoutedEventArgs e)
 {
     ClientHandler.GetInstance().SetName(txtUsername.Text);
     this.connector.SendCheckUsername(txtUsername.Text);
 }
예제 #4
0
 /// <summary>
 /// Leave the current room and return to hub
 /// </summary>
 public void LeaveRoom()
 {
     ClientHandler.GetInstance().LeaveRoom();
     this.sendMessage(new Message(MessageTypes.LeaveRoom, JsonConvert.SerializeObject(new RoomModel(ClientHandler.GetInstance().Roomname, 0))));
 }
예제 #5
0
        /// <summary>
        /// Handle thie incoming message, destination from: ReadMessage();
        /// </summary>
        /// <param name="stringMessage"></param>
        private void HandleMessage(string stringMessage)
        {
            Message message = JsonConvert.DeserializeObject <Message>(stringMessage);

            switch (message.Type)
            {
            case MessageTypes.Inform:
                GuessModel guessModel = JsonConvert.DeserializeObject <GuessModel>(message.Data);
                DrawHandler.GetInstance().WriteMessage(guessModel.Word);
                break;

            case MessageTypes.SendDrawing:
                DrawPoint drawPoint = JsonConvert.DeserializeObject <DrawPoint>(message.Data);
                DrawHandler.GetInstance().DrawLine(drawPoint);
                break;

            case MessageTypes.NewDrawer:
                DrawHandler.GetInstance().CheckDrawer(JsonConvert.DeserializeObject <ClientModel>(message.Data));
                break;

            case MessageTypes.NewHost:
                ClientHandler.GetInstance().SetHost(JsonConvert.DeserializeObject <ClientModel>(message.Data));
                break;

            case MessageTypes.JoinRoom:
                RoomModel room = JsonConvert.DeserializeObject <RoomModel>(message.Data);
                ClientHandler.GetInstance().SetRoomname(room.Name);
                ClientHandler.GetInstance().SetRoomSize(room.AmountOfPlayers);
                break;

            case MessageTypes.StartGame:
                GameModel gameModel = JsonConvert.DeserializeObject <GameModel>(message.Data);
                ClientHandler.GetInstance().SetWordSize(gameModel.LengthOfWord);
                ClientHandler.GetInstance().SetRoundLabel(gameModel.CurrentRound);
                DrawHandler.GetInstance().HideHostGrid();
                DrawHandler.GetInstance().HideWinners();
                break;

            case MessageTypes.EndGame:
                EndGameModel endGameModel = JsonConvert.DeserializeObject <EndGameModel>(message.Data);
                ClientHandler.GetInstance().ShowWinners(endGameModel);
                ClientHandler.GetInstance().EndGame();
                break;

            case MessageTypes.GuessWord:
                ClientHandler.GetInstance().SetWord(JsonConvert.DeserializeObject <GuessModel>(message.Data).Word);
                break;

            case MessageTypes.NewRound:
                gameModel = JsonConvert.DeserializeObject <GameModel>(message.Data);
                ClientHandler.GetInstance().SetWordSize(gameModel.LengthOfWord);
                ClientHandler.GetInstance().SetRoundLabel(gameModel.CurrentRound);
                DrawHandler.GetInstance().ClearCanvas();
                break;

            case MessageTypes.UsernameCheck:
                bool validName = JsonConvert.DeserializeObject <ClientModel>(message.Data).ValidName;
                ClientHandler.GetInstance().CheckUsername(validName);
                break;

            case MessageTypes.Ping:
                this.sendMessage(new Message(MessageTypes.Pong, ""));
                break;

            default:
                break;
            }
        }
예제 #6
0
 static void Main(string[] args)
 {
     ClientHandler console = new ClientHandler();
 }