Ejemplo n.º 1
0
 public void ClientEvents_ReadPhotoLink(object sender, SocketEventArgs e)
 {
     using (FileStream fs = new FileStream(e.Command.Data + "_" + e.Command.FilePath, FileMode.Open))
     {
         byte[] buffer = new byte[fs.Length];
         fs.Read(buffer, 0, (int)fs.Length);
         Command command = new Command(Command.Commands.ReadPhotoLink, string.Empty);
         command.File = buffer;
         command.FilePath = e.Command.FilePath;
         jsonProtocol.SendObject(command, (sender as ClientThread).Socket);
     }
 }
Ejemplo n.º 2
0
        public void FireEvent(ClientThread clientThread, Command command)
        {
            System.Diagnostics.Debug.WriteLine("ClientEvents: New message from client: {0}, {1}", command.CurrentCommand, command.Data);

            switch (command.CurrentCommand)
            {
                case "Exit":
                    Exit(clientThread, new SocketEventArgs(command));
                    break;
                case "FullData":
                    FullData(clientThread, new SocketEventArgs(command));
                    break;
                case "UpdateRecord":
                    UpdateRecord(clientThread, new SocketEventArgs(command));
                    break;
                case "DeleteRecord":
                    DeleteRecord(clientThread, new SocketEventArgs(command));
                    break;
                case "AddRecord":
                    AddRecord(clientThread, new SocketEventArgs(command));
                    break;
                case "SendPhoto":
                    SendPhoto(clientThread, new SocketEventArgs(command));
                    break;
                case "SendPhotoLink":
                    SendPhotoLink(clientThread, new SocketEventArgs(command));
                    break;
                case "ReadPhoto":
                    ReadPhoto(clientThread, new SocketEventArgs(command));
                    break;
                case "SendFile":
                    SendFile(clientThread, new SocketEventArgs(command));
                    break;
                case "ReadFile":
                    ReadFile(clientThread, new SocketEventArgs(command));
                    break;
                case "ReadPhotoLink":
                    ReadPhotoLink(clientThread, new SocketEventArgs(command));
                    break;

            }
        }
Ejemplo n.º 3
0
        void ClientEvents_ReadPhoto(object sender, SocketEventArgs e)
        {
            byte[] photo = dao.GetPhoto(int.Parse(e.Command.Data));

            Command command = new Command(Command.Commands.ReadPhoto, string.Empty);
            command.File = photo;
            command.FilePath = e.Command.FilePath;
            jsonProtocol.SendObject(command, (sender as ClientThread).Socket);
        }
Ejemplo n.º 4
0
 private void ClientEvents_ReadFile(object sender, SocketEventArgs e)
 {
     byte[] file = dao.GetFile(int.Parse(e.Command.Data));
     Command command = new Command(Command.Commands.ReadFile, string.Empty);
     command.File = file;
     command.FilePath = e.Command.FilePath;
     jsonProtocol.SendObject(command, (sender as ClientThread).Socket);
 }
Ejemplo n.º 5
0
        private void ClientEvents_FullData(object sender, SocketEventArgs e)
        {
            Table table = dao.GetQuery(e.Command.Data);
            Command command = new Command(Command.Commands.FullData, string.Empty);
            command.TypesList = table.TypesList;
            command.ValuesList = table.ValuesList;
            command.ColumnsList = table.ColumnsList;

            jsonProtocol.SendObject(command, (sender as ClientThread).Socket);
        }
Ejemplo n.º 6
0
        private void ClientEvents_Exit(object sender, SocketEventArgs e)
        {
            ClientThread clientThread = sender as ClientThread;
            clientThread.Stop();
            Command command = new Command(Command.Commands.Confirm, string.Empty);

            jsonProtocol.SendObject(command, clientThread.Socket);
        }
Ejemplo n.º 7
0
 public SocketEventArgs(Command command)
 {
     this.command = command;
 }