Przeglądaj źródła

1、增加port设置;
2、不允许离线时,终端断网自动退出。

Dail 1 rok temu
rodzic
commit
9902601632

BIN
.vs/Welling_Motor_Debug_Tool/v17/.suo


BIN
Welling_Motor_Debug_Tool/bin/Debug/Welling_Motor_Debug_Tool.exe


+ 7 - 7
Welling_Motor_Debug_Tool/ftp.cs

@@ -38,7 +38,7 @@ namespace Welling_Motor_Debug_Tool
         {
             try
             {
-                Uri uri = new Uri(string.Format("ftp://{0}/{1}", serverIP, "/"));
+                Uri uri = new Uri(string.Format("ftp://" + serverIP + ":" + serverPort));
                 FtpWebRequest ftpRequest = (FtpWebRequest)FtpWebRequest.Create(uri);
                 ftpRequest.Credentials = new NetworkCredential(userId, passWord);
                 ftpRequest.Method = WebRequestMethods.Ftp.PrintWorkingDirectory;
@@ -126,7 +126,7 @@ namespace Welling_Motor_Debug_Tool
                 if (Directory.Exists(targetFullPath) == false)
                     Directory.CreateDirectory(targetFullPath);
                 outputStream = new FileStream(targetFullPath + "\\" + fileName, FileMode.Create);
-                Uri uri = new Uri("ftp://" + serverIP + "/" + sourceFullPath);
+                Uri uri = new Uri("ftp://" + serverIP + ":" + serverPort + "/" + sourceFullPath);
                 ftpRequest = (FtpWebRequest)FtpWebRequest.Create(uri);
                 ftpRequest.Method = WebRequestMethods.Ftp.DownloadFile;
                 ftpRequest.UseBinary = true;
@@ -165,7 +165,7 @@ namespace Welling_Motor_Debug_Tool
         {
             try
             {
-                Uri uri = new Uri("ftp://" + serverIP + "/" + fileName);
+                Uri uri = new Uri("ftp://" + serverIP + ":" + serverPort + "/" + fileName);
                 FtpWebRequest reqFTP;
                 reqFTP = (FtpWebRequest)FtpWebRequest.Create(uri);
 
@@ -198,7 +198,7 @@ namespace Welling_Motor_Debug_Tool
         {
             try
             {
-                Uri uri = new Uri("ftp://" + serverIP + "/" + folderName);
+                Uri uri = new Uri("ftp://" + serverIP + ":" + serverPort + "/" + folderName);
                 FtpWebRequest reqFTP;
                 reqFTP = (FtpWebRequest)FtpWebRequest.Create(uri);
 
@@ -240,7 +240,7 @@ namespace Welling_Motor_Debug_Tool
             try
             {
                 result = new StringBuilder();
-                Uri uri = new Uri("ftp://" + serverIP + "/" + ServerPath);
+                Uri uri = new Uri("ftp://" + serverIP + ":" + serverPort + "/" + ServerPath);
                 ftp = (FtpWebRequest)FtpWebRequest.Create(uri);
                 ftp.Credentials = new NetworkCredential(userId,passWord);
                 ftp.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
@@ -401,7 +401,7 @@ namespace Welling_Motor_Debug_Tool
             FtpWebRequest reqFTP;
             try
             {
-                Uri uri = new Uri("ftp://" + serverIP + "/" + dirName);
+                Uri uri = new Uri("ftp://" + serverIP + ":" + serverPort + "/" + dirName);
                 reqFTP = (FtpWebRequest)FtpWebRequest.Create(uri);
                 reqFTP.Method = WebRequestMethods.Ftp.MakeDirectory;
                 reqFTP.UseBinary = true;
@@ -428,7 +428,7 @@ namespace Welling_Motor_Debug_Tool
             FtpWebRequest reqFTP;
             try
             {
-                Uri uri = new Uri("ftp://" + serverIP + "/" + currentFilename);
+                Uri uri = new Uri("ftp://" + serverIP + ":" + serverPort + "/" + currentFilename);
                 reqFTP = (FtpWebRequest)FtpWebRequest.Create(uri);
                 reqFTP.Method = WebRequestMethods.Ftp.Rename;
                 reqFTP.RenameTo = newFilename;

+ 16 - 0
Welling_Motor_Debug_Tool/mainForm.cs

@@ -543,6 +543,22 @@ namespace Welling_Motor_Debug_Tool
             else//服务器连接失败
             {
                 myFtp.IsNetConnected = false;
+                if (允许ToolStripMenuItem.Checked == false) ///不允许离线使用,自动关闭 
+                {
+                    if ((EnterForm1.comboBox_User.Text != "管理员") && (EnterForm1.comboBox_User.Text != "FCT治具测试"))
+                    {
+                        timer_1s.Enabled = false;
+                        MessageBox.Show("网络断开,将自动关闭!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+                        timer_1s.Enabled = true;
+                        System.Environment.Exit(0);
+                    }
+                }
+                else //离线使用
+                {
+                    timer_1s.Enabled = false;
+                    MessageBox.Show("网络断开,离线使用!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
+                    timer_1s.Enabled = true;
+                }
             }            
         }
 

BIN
Welling_Motor_Debug_Tool/obj/Debug/Welling_Motor_Debug_Tool.exe


BIN
Welling_Motor_Debug_Tool/obj/Debug/Welling_Motor_Debug_Tool.pdb