Exemple #1
0
        public string SessionStart(MessageData messageData)
        {
            string answer = "";

            try
            {
                using (var authentication = new SendReceive(new TcpClient(_host, _port)))
                {
                    try
                    {
                        authentication.SendData(messageData);
                    }
                    catch (Exception ex)
                    {
                        authentication?.Dispose();
                    }
                    answer = authentication.ReceiveData().ToString();
                }
            }
            catch (SocketException ex)
            {
            }
            finally
            {
            }
            return(answer);
        }
Exemple #2
0
 public DepartmentsData SessionStart(DepartmentsData departmentsData)
 {
     try
     {
         using (var authentication = new SendReceive(new TcpClient(_host, _port)))
         {
             try
             {
                 authentication.SendData(departmentsData);
             }
             catch (Exception ex)
             {
                 authentication?.Dispose();
             }
             departmentsData = (DepartmentsData)authentication.ReceiveData();
         }
     }
     catch (SocketException ex)
     {
     }
     finally
     {
     }
     return(departmentsData);
 }
Exemple #3
0
 public Authentication SessionStart(Authentication authenticationData)
 {
     try
     {
         using (var authentication = new SendReceive(new TcpClient(_host, _port)))
         {
             try
             {
                 authentication.SendData(authenticationData);
             }
             catch (Exception ex)
             {
                 authentication?.Dispose();
             }
             authenticationData = (Authentication)authentication.ReceiveData();
         }
     }
     catch (SocketException ex)
     {
     }
     finally
     {
     }
     return(authenticationData);
 }
Exemple #4
0
 public TicketsInfo SessionStart(TicketsInfo ticketsInfo)
 {
     try
     {
         using (var authentication = new SendReceive(new TcpClient(_host, _port)))
         {
             try
             {
                 authentication.SendData(ticketsInfo);
             }
             catch (Exception ex)
             {
                 authentication?.Dispose();
             }
             ticketsInfo = (TicketsInfo)authentication.ReceiveData();
         }
     }
     catch (SocketException ex)
     {
     }
     finally
     {
     }
     return(ticketsInfo);
 }
Exemple #5
0
        private static void GetConnection(SendReceive sendReceive)
        {
            try
            {
                var    receiveData = sendReceive.ReceiveData();
                string className   = receiveData.GetType().Name;
                switch (className)
                {
                case "Authentication":    //авторизация
                {
                    var authenticationData = (Authentication)receiveData;
                    var result             = IsTrueData(authenticationData);
                    sendReceive.SendData(result);
                }
                break;

                case "TicketsInfo":
                {
                    var tickets = (TicketsInfo)receiveData;
                    foreach (var item in GetData.GetTickets())
                    {
                        List <string> nameCitizen = new List <string>();
                        foreach (var citizen in item.Citizens)
                        {
                            nameCitizen.Add(citizen.Family);
                        }
                        TicketInfo ticket = new TicketInfo
                        {
                            Id            = item.Id,
                            Criterion     = item.Criterion,
                            DepartmentId  = item.DepartmentId.GetValueOrDefault(),
                            Status        = item.Status,
                            Message       = item.Message,
                            Type          = item.Type,
                            CreatDateTime = item.CreatDateTime,
                            CloseDateTime = item.CloseDateTime.GetValueOrDefault(),
                            Citizens      = nameCitizen
                        };
                        tickets.Tickets.Add(ticket);
                    }
                    sendReceive.SendData(tickets);
                }
                break;

                case "DepartmentsData":
                {
                    var departments = (DepartmentsData)receiveData;
                    foreach (var item in GetData.GetDepartments())
                    {
                        DepartmentData departmentData = new DepartmentData
                        {
                            Id   = item.Id,
                            Name = item.Name
                        };
                        departments.departmentsData.Add(departmentData);
                    }
                    sendReceive.SendData(departments);
                }
                break;

                case "MessageData":
                {
                    var message = (MessageData)receiveData;
                    SendingData.SendTicket(message.Message, message.Criterion, 0, message.Type, message.DepartmentId, message.IdCitizen);
                    sendReceive.SendData("Готово");
                }
                break;

                default:
                {
                }
                break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Чтото не так");
            }
            finally
            {
                sendReceive.Dispose();
            }
        }