protected void TestBTN_Click(object sender, EventArgs e) { int dbstatus = DBLibrary.Else_UpdateProcessftp(22759); reporttest(); }
public bool ReadyXMLUpload_FTP(string path, string name, string version, int id, string article, string journal) { string sURI = "ftp://ewiisftp.elsevier.com/ftpdata/dropzones/mcmbkpew/" + name; string readypathNew = "\\\\192.168.3.137\\s280_dd\\NDM\\MRWReady\\S280\\"; string username = "******"; string password = "******"; name = name.Replace(".zip", ".ready.xml"); string hostKey = "ssh-rsa 2048 a9:c8:c5:4a:dc:a7:22:0d:80:b8:f0:77:0a:73:24:bf"; try { #region FTPUpload if (path.StartsWith("d:") && version == "A300") { readypathNew = readypathNew.Replace(readypathNew, "\\\\192.168.3.137\\s280_dd\\NDM_A300\\MRWReady\\A300\\"); sURI = "ftp://ewiisftp.elsevier.com/ftpdata/dropzones/mpssatpew/" + name; username = "******"; password = "******"; } // Create FTP request variables bool status = UploadToSFTP(name, "ewiisftp.elsevier.com", username, password, readypathNew, sURI, hostKey, article, journal); int dbstatus = DBLibrary.Else_UpdateProcessftp(id); return(status); //FileInfo uploadfile = new FileInfo(readypathNew); //FtpWebRequest ftpReq; //// Create the buffer variable //byte[] buffer = new byte[BUFFERSIZE]; //// Create request by initializing it with the file we want to FTP //// Supply network credentials to the request and tell server the file size //ftpReq = (FtpWebRequest)FtpWebRequest.Create(sURI); //ftpReq.Credentials = new NetworkCredential(username, password); //// Set connection parameters //ftpReq.UseBinary = true; //ftpReq.KeepAlive = false; //ftpReq.Method = WebRequestMethods.Ftp.UploadFile; //FileStream fs = null; //Stream writeStream = null; //try //{ // // Its time to send the file, so create a FileStream to read from the file // fs = uploadfile.OpenRead(); // // Return our data stream used to upload the file // writeStream = ftpReq.GetRequestStream(); // // Write to the stream while there are still bytes left to stream // int bytesRead = fs.Read(buffer, 0, BUFFERSIZE); // while (bytesRead != 0) // { // writeStream.Write(buffer, 0, bytesRead); // bytesRead = fs.Read(buffer, 0, BUFFERSIZE); // } //} //catch (Exception ex) //{ // //Label1.Text = ex.ToString(); // throw ex; // return false; //} //finally //{ // // Close the streams (dont cross the streams, Ray... that would be bad) // if (fs != null) // fs.Close(); // if (writeStream != null) // writeStream.Close(); // report("ReadySignalFTP", name, "Uploaded TO FTP__" + sURI + ""); // int dbstatus = DBLibrary.Else_UpdateProcessftp(id); //} #endregion FTPUpload } catch (Exception ex) { throw ex; report("ReadySignalFTP_Error", name, ex.ToString()); return(false); } }