Exemplo 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);
     }
 }
Exemplo n.º 2
0
 private void ClientEvents_SendFile(object sender, SocketEventArgs e)
 {
     dao.SaveFile(int.Parse(e.Command.Data), e.Command.File);
 }
Exemplo n.º 3
0
 private void ClientEvents_UpdateRecord(object sender, SocketEventArgs e)
 {
     Table table = new Table();
     table.TypesList = e.Command.TypesList;
     table.ValuesList = e.Command.ValuesList;
     dao.UpdatePerson(table);
 }
Exemplo 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);
 }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
 private void ClientEvents_Photo(object sender, SocketEventArgs e)
 {
     dao.AddPhoto(e.Command.File, int.Parse(e.Command.Data));
 }
Exemplo n.º 7
0
 private void ClientEvents_PhotoLink(object sender, SocketEventArgs e)
 {
     using (FileStream fs = new FileStream(e.Command.Data + "_" + e.Command.FilePath, FileMode.Create))
     {
         int bufferSize = int.Parse(Resources.Buffer);
         int position = 0;
         while (position < e.Command.File.Length)
         {
             fs.Write(e.Command.File, position, bufferSize);
             position += bufferSize;
         }
         fs.Write(e.Command.File, position - bufferSize, e.Command.File.Length - position);
     }
     dao.SetPhotoLinkName(e.Command.FilePath, int.Parse(e.Command.Data));
 }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
0
 private void ClientEvents_DeleteRecord(object sender, SocketEventArgs e)
 {
     dao.DeletePerson(e.Command.Data);
 }
Exemplo n.º 11
0
 private void ClientEvents_AddRecord(object sender, SocketEventArgs e)
 {
     Table table = new Table();
     dao.AddPerson(e.Command.ValuesList);
 }
Exemplo n.º 12
0
 private void ClientEvents_UpdateRecord(object sender, SocketEventArgs e)
 {
     Table table = new Table();
     table.TypesList = e.Command.TypesList;
     table.ValuesList = e.Command.ValuesList;
     dao.UpdatePerson(int.Parse(e.Command.ValuesList.First().First().ToString()), e.Command.ValuesList.First());
 }