Ejemplo n.º 1
0
 internal bool ConnectWMS(string sServerAddress)
 {
     m_ecLastError = WM9_ERROR_CODE.WM9_ERROR_NONE;
     m_wms = new WMS9();
     try
     {
         if (m_wms.Init(sServerAddress))
             return true;
         else
         {
             m_ecLastError = WM9_ERROR_CODE.WM9_ERROR_COULD_NOT_INITIALIZE_SERVER;
             return false;
         }
     }
     catch
     {
         m_ecLastError = WM9_ERROR_CODE.WM9_ERROR_COULD_NOT_INITIALIZE_SERVER;
         return false;
     }
 }
Ejemplo n.º 2
0
 public bool Upload(string sPathFile, string sFtpUploadSubDirectory)
 {
     string sSubDirectory;
     m_ecLastError = WM9_ERROR_CODE.WM9_ERROR_NONE;
     if (!m_ftp.IsConnected)
     {
         m_ecLastError = WM9_ERROR_CODE.WM9_ERROR_NOT_CONNECTED;
         return false;
     }
     if (sFtpUploadSubDirectory == null)
         sSubDirectory = ".";
     else
         sSubDirectory = sFtpUploadSubDirectory;
     KCommon.Net.FTP.FtpDirectory dirTemp = m_ftp.CurrentDirectory;
     KCommon.Net.FTP.FtpDirectory dir = m_ftp.RootDirectory.FindSubdirectory(sSubDirectory,true);
     if (dir == null)
     {
         m_ecLastError = WM9_ERROR_CODE.WM9_ERROR_INVALID_FTP_DIRECTORY_STRUCTURE;
         return false;
     }
     m_ftp.CurrentDirectory = dir;
     m_iPercentUploadingComplete = 0;
     dir.PutFile(sPathFile);
     m_ftp.CurrentDirectory = dirTemp;
     return true;
 }
Ejemplo n.º 3
0
        public bool DeleteFTP(string sFTPFileName, string sFTPFilePath)
        {
            if (m_ftp == null)
            {
                m_ecLastError = WM9_ERROR_CODE.WM9_ERROR_NOT_CONNECTED;
                return false;
            }
            KCommon.Net.FTP.FtpDirectory dirTemp = m_ftp.CurrentDirectory;
            KCommon.Net.FTP.FtpDirectory dir;

            if (sFTPFilePath != "")
            {
                dir = m_ftp.RootDirectory.FindSubdirectory(sFTPFilePath,true);
                if (dir == null)
                {
                    m_ecLastError = WM9_ERROR_CODE.WM9_ERROR_INVALID_FTP_DIRECTORY;
                    return false;
                }
                m_ftp.CurrentDirectory = dir;
            }
            else
            {
                dir = m_ftp.CurrentDirectory;
            }

            KCommon.Net.FTP.IFtpFile file;

            file = dir.FindFile(sFTPFileName);
            if (null == file)
            {
                m_ftp.CurrentDirectory = dirTemp;
                m_ecLastError = WM9_ERROR_CODE.WM9_ERROR_INVALID_FTP_FILE;
                return false;
            }
            else
            {
                dir.RemoveFile(sFTPFileName);
            }

            m_ftp.CurrentDirectory = dirTemp;
            return true;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// downloads a file from the Oyster area on WMS9
 /// </summary>
 public bool Download(string sOysterFileName, string sLocalDirectory)
 {
     if (m_ftp == null)
     {
         m_ecLastError = WM9_ERROR_CODE.WM9_ERROR_NOT_CONNECTED;
         return false;
     }
     KCommon.Net.FTP.FtpDirectory dirTemp = m_ftp.CurrentDirectory;
     KCommon.Net.FTP.FtpDirectory dir = m_ftp.RootDirectory;
     if (dir == null)
     {
         m_ecLastError = WM9_ERROR_CODE.WM9_ERROR_INVALID_FTP_DIRECTORY_STRUCTURE;
         return false;
     }
     m_ftp.CurrentDirectory = dir;
     m_iPercentUploadingComplete = 0;
     if (sLocalDirectory[sLocalDirectory.Length - 1] != '\\')
         sLocalDirectory += "\\";
     string sLocalFile = sLocalDirectory + sOysterFileName;
     dir.GetFile(sLocalFile,sOysterFileName);
     m_ftp.CurrentDirectory = dirTemp;
     return true;
 }
Ejemplo n.º 5
0
        public bool ConnectFTP(string sServerAddress, int iFTPPort, string sLoginName, string sPassword)
        {
            m_ecLastError = WM9_ERROR_CODE.WM9_ERROR_NONE;
            if (m_ftp != null)
            {
                m_ecLastError = WM9_ERROR_CODE.WM9_ERROR_ALREADYCONNECTED;
                return false;
            }

            if (sLoginName == "")
                sLoginName = "Anonymous";
            if (sPassword == "")
                sPassword = "******";

            m_ftp = new KCommon.Net.FTP.Session();
            m_ftp.CommandSent += new KCommon.Net.FTP.FtpCommandEventHandler(FtpSession_CommandSent);
            m_ftp.BeginPutFile += new KCommon.Net.FTP.FtpFileEventHandler(FtpSession_BeginPutFile);
            m_ftp.EndPutFile += new KCommon.Net.FTP.FtpFileEventHandler(FtpSession_EndPutFile);
            m_ftp.FileTransferProgress += new KCommon.Net.FTP.FtpFileEventHandler(FtpSession_FileTransferProgress);
            m_ftp.ResponseReceived += new KCommon.Net.FTP.FtpResponseEventHandler(FtpSession_ResponseReceived);
            m_ftp.BeginGetFile += new KCommon.Net.FTP.FtpFileEventHandler(FtpSession_BeginGetFile);
            m_ftp.EndGetFile += new KCommon.Net.FTP.FtpFileEventHandler(FtpSession_EndGetFile);

            m_ftp.Port = iFTPPort;
            m_ftp.Server = sServerAddress;
            try
            {
                m_ftp.Connect(sLoginName,sPassword);
            }
            catch
            {
                m_ecLastError = WM9_ERROR_CODE.WM9_ERROR_COULD_NOT_CONNECT_TO_SERVER;
            }
            if (m_ftp.IsConnected)
            {
                return true;
            }
            return false;
        }