Exemple #1
0
 private ServerConnector()
 {
     logger = LoggerBuilder.Init().Set(GetType()).Info("Connector Start!");
     QueueThread.Push(() =>
     {
         while (true)
         {
             try
             {
                 _socket         = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
                 IPEndPoint ipep = new IPEndPoint(IPAddress.Parse(ServerInfo.GetIp()), ServerInfo.GetPort());
                 _socket.Connect(ipep);
                 ControlFactory.GetForm <Main>().SetConnection(true);
                 while (true)
                 {
                     byte[] size = new byte[4];
                     _socket.Receive(size, 4, SocketFlags.None);
                     byte[] data = new byte[BitConverter.ToInt32(size, 0)];
                     _socket.Receive(data, data.Length, SocketFlags.None);
                     String buf = Encoding.UTF8.GetString(data);
                     if (OnReceive != null)
                     {
                         logger.Info(" [NODE LOG] The data is recieved from node- " + buf);
                         OnReceive(buf);
                     }
                 }
             }
             catch (Exception e)
             {
                 ControlFactory.GetForm <Main>().SetConnection(false);
                 logger.Error(" [SCRAP LOG] - " + e.ToString());
             }
         }
     });
 }
Exemple #2
0
 public void SetMessage(bool active)
 {
     QueueThread.InvokeControl(statusStrip1, () =>
     {
         toolStripStatusLabel4.Text    = "";
         toolStripProgressBar1.Visible = active;
     });
 }
Exemple #3
0
 public void SetMessage(String msg)
 {
     QueueThread.InvokeControl(statusStrip1, () =>
     {
         toolStripProgressBar1.Visible = true;
         toolStripStatusLabel4.Text    = msg;
     });
 }
 private static QueueThread Instance()
 {
     if (singleton == null)
     {
         singleton = new QueueThread();
     }
     return(singleton);
 }
Exemple #5
0
 public void RemoveGrid(Parameter param)
 {
     QueueThread.InvokeControl(dataGridView1, () =>
     {
         for (int i = 0; i < dataGridView1.Rows.Count; i++)
         {
             if (String.Equals(dataGridView1.Rows[i].Cells[0].Value, param.Key))
             {
                 dataGridView1.Rows.RemoveAt(i);
                 break;
             }
         }
     });
 }
Exemple #6
0
 public void SetConnection(bool active)
 {
     QueueThread.InvokeControl(statusStrip1, () =>
     {
         if (active)
         {
             onStatus.Visible           = true;
             offStatus.Visible          = false;
             toolStripStatusLabel3.Text = "Connected";
         }
         else
         {
             onStatus.Visible           = false;
             offStatus.Visible          = true;
             toolStripStatusLabel3.Text = "DIsconnected";
         }
     });
 }
Exemple #7
0
 public void SetGrid(Parameter param)
 {
     QueueThread.InvokeControl(dataGridView1, () =>
     {
         dataGridView1.Rows.Add(param.Key,
                                param.MallCD,
                                param.Id1,
                                param.Id2,
                                param.Id3,
                                param.Option1,
                                param.Option2,
                                param.Option3,
                                param.Sdate,
                                param.Edate,
                                param.Exec,
                                param.ScrapType,
                                Convert.ToDateTime(param.Starttime).ToString("yyyyMMdd"),
                                Convert.ToDateTime(param.Pingtime).ToString("yyyyMMdd"),
                                param.State
                                );
     });
 }
Exemple #8
0
 protected override void OnClosing(CancelEventArgs e)
 {
     base.OnClosing(e);
     logger.Info("This program will be exit.");
     QueueThread.Abort();
 }