Exemplo n.º 1
0
      public ClassDxc(string ip)
      {
          string methodName = new StackTrace(false).GetFrame(0).GetMethod().Name;

          Session = new TFTPSession();
          try
          {
              if (!MainForm.IsIPFormat(ip))
              {
                  MessageBox.Show("Неверный формат IP");
                  return;
              }
              dataStorage = new DataStorage(this);
              Buffer      = "";
              //Cfg=cfg;
              this.Ip         = ip;
              this.CustomName = "";
              this.BackupPath = "";
              this.Alarms     = new List <Alarm>();
              this.Info       = new Dxcinfo(false);
              this.Ports      = new List <Port>();

              Session.Connected        += new TFTPSession.ConnectedHandler(_session_Connected);
              Session.Transferring     += new TFTPSession.TransferringHandler(_session_Transferring);
              Session.TransferFailed   += new TFTPSession.TransferFailedHandler(_session_TransferFailed);
              Session.TransferFinished += new TFTPSession.TransferFinishedHandler(_session_TransferFinished);
              Session.Disconnected     += new TFTPSession.DisconnectedHandler(_session_Disconnected);
          }
          catch (Exception exception)
          {
              MessageBox.Show(exception.Message);
              Log.WriteLog(methodName, exception.Message);
          }
      }
Exemplo n.º 2
0
        public void update(string update_file_name)     //, Action<string, int> updatProgress)
        {
            TFTPSession tftp_client = new TFTPSession();

            tftp_client.Connected        += new TFTPSession.ConnectedHandler(_session_Connected);
            tftp_client.Transferring     += new TFTPSession.TransferringHandler(_session_Transferring);
            tftp_client.TransferFailed   += new TFTPSession.TransferFailedHandler(_session_TransferFailed);
            tftp_client.TransferFinished += new TFTPSession.TransferFinishedHandler(_session_TransferFinished);
            tftp_client.Disconnected     += new TFTPSession.DisconnectedHandler(_session_Disconnected);
            tftp_client.Mode              = TFTPSession.Modes.OCTET;
            tftp_client.BlockSize         = 512;

            TransferOptions tOptions = new TransferOptions();

            tOptions.LocalFilename  = update_file_name;
            tOptions.RemoteFilename = "update.bin";
            tOptions.Host           = this.device_ip.ToString();
            tOptions.Action         = TransferType.Put;

            tftp_client.Put(tOptions);
//			TransferFinishedEvent.WaitOne();
        }