Exemplo n.º 1
0
 public ActionResult Connect(SFTPConnectionString sFTPConnectionString)
 {
     if (ModelState.IsValid)
     {
         try
         {
             SFTPClientConnector.SetConnectionInSession(sFTPConnectionString);
             EventLogWriter.SetEvent(LogEvents.Connecting);
             SFTPClientConnector.ConnectToRemote();
             EventLogWriter.SetEvent(LogEvents.Connected);
             return(new HttpStatusCodeResult(HttpStatusCode.OK));
         }
         catch (Exception e)
         {
             return(HttpNotFound(e.Message));
         }
     }
     return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
 }
Exemplo n.º 2
0
 public ActionResult CopyLocalToRemote(TransferFile transferFile)
 {
     try
     {
         string filename = Path.GetFileName(transferFile.SourcePath);
         EventLogWriter.SetEvent(LogEvents.StartTransferFile);
         EventLogWriter.SetEvent(LogEvents.TransferingFile);
         SftpClient client     = SFTPClientConnector.ConnectToRemote();
         var        fileStream = new FileStream(transferFile.SourcePath, FileMode.Open);
         client.UploadFile(fileStream, transferFile.DestinationPath + "/" + filename);
         fileStream.Dispose();
         client.Dispose();
         EventLogWriter.SetEvent(LogEvents.TransferCompleted);
         return(new HttpStatusCodeResult(HttpStatusCode.OK));
     }
     catch (Exception e)
     {
         return(HttpNotFound(e.Message));
     }
 }