Example #1
0
 /// <summary>
 /// Ftp上传文件
 /// </summary>
 /// <param name="FileName">完整路径文件名</param>
 /// <returns></returns>
 private bool UpLoadConfigurationFile(string FileName)
 {
     try
     {
         FtpHelper ftp = new FtpHelper();
         ftp.RemoteHost = Parameters.ServerBaseParameter.StrFtpIpAddr;
         ftp.RemotePort = int.Parse(Parameters.ServerBaseParameter.StrFtpPort);
         ftp.RemoteUser = Parameters.ServerBaseParameter.StrFtpUserId;
         ftp.RemotePath = Parameters.ServerBaseParameter.StrFtpUpdateDir;
         ftp.RemotePass = Parameters.ServerBaseParameter.StrFtpUserPsw;
         ftp.Connect();
         if (ftp.Connected)
         {
             ftp.Put(
                 new FileInfo(FileName).DirectoryName,
                 new FileInfo(FileName).Name
                 );
         }
         else
         {
             MessageBox.Show("建立连接不成功,批量配置导入失败!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
             return(false);
         }
         return(true);
     }
     catch (Exception ex)
     {
         JsonInterFace.SystemLogsInfo.Input(DateTime.Now.ToString(), "批量配置导入导出" + ex.Message, "配置批量导入", "失败");
     }
     return(false);
 }
Example #2
0
        private void DownLoadConfigurationFile()
        {
            try
            {
                FtpHelper ftp = new FtpHelper();
                ftp.RemoteHost = JsonInterFace.BatchConfigurationOutputParameter.FtpServerIp;
                ftp.RemotePort = int.Parse(JsonInterFace.BatchConfigurationOutputParameter.FtpPort);
                ftp.RemoteUser = JsonInterFace.BatchConfigurationOutputParameter.FtpUsrName;
                ftp.RemotePath = JsonInterFace.BatchConfigurationOutputParameter.FtpRootDir;
                ftp.RemotePass = JsonInterFace.BatchConfigurationOutputParameter.FtpPwd;
                ftp.Connect();
                if (ftp.Connected)
                {
                    ftp.Get(
                        JsonInterFace.BatchConfigurationOutputParameter.FileName,
                        new FileInfo(JsonInterFace.BatchConfigurationOutputParameter.LocalDir).DirectoryName,
                        JsonInterFace.BatchConfigurationOutputParameter.FileName
                        );
                }
                else
                {
                    MessageBox.Show("建立连接不成功,批量配置导出失败!");
                    return;
                }

                MessageBox.Show("批量配置导出到文件[" + JsonInterFace.BatchConfigurationOutputParameter.LocalDir + "]成功!"
                                , "提示"
                                , MessageBoxButton.OK
                                , MessageBoxImage.Information
                                );
            }
            catch (Exception ex)
            {
                JsonInterFace.SystemLogsInfo.Input(DateTime.Now.ToString(), "批量配置导入导出" + ex.Message, "配置批量导出", "失败");
            }
        }