Ejemplo n.º 1
0
 public void AddClient(TcpClient newClient)
 {
     try
     {
         _clientPool.Add(new Client(newClient, this));
     }
     catch (Exception)
     {
         ShellMenu.ShowError("eroare la adaugare client in clientPool");
     }
 }
Ejemplo n.º 2
0
 public DataController()
 {
     //ma conectez la serverul SQL
     this.connection = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString);
     try
     {
         connection.Open();
     }
     catch (SqlException e)
     {
         ShellMenu.ShowError(e.ToString());
     }
 }
Ejemplo n.º 3
0
 public void WriteLog(string s)
 {
     try
     {
         lock (padlock)
         {
             File.AppendAllText(_path, s + Environment.NewLine);
         }
     }
     catch (Exception e)
     {
         ShellMenu.ShowError(e.ToString());
     }
 }
Ejemplo n.º 4
0
 public Logger()
 {
     try
     {
         string name = RandomString(8, true) + ".log";
         _path = System.IO.Directory.GetCurrentDirectory();
         _path = System.IO.Path.Combine(_path, "logs");
         System.IO.Directory.CreateDirectory(_path);
         _path = System.IO.Path.Combine(_path, name);
     }catch (Exception e)
     {
         ShellMenu.ShowError(e.ToString());
     }
 }
Ejemplo n.º 5
0
 public void StartListener()
 {
     try
     {
         while (true)
         {
             if (server.Pending())
             {
                 _clientPool.AddClient(server.AcceptTcpClient());
             }
         }
     }
     catch (SocketException e)
     {
         ShellMenu.ShowError("SocketException: " + e);
         server.Stop();
     }
 }