Browse Source

产品标签维护保存路径需求更改

Hcsy 8 năm trước cách đây
mục cha
commit
fcfee55ef7

+ 1 - 0
UAS-MES/CustomControl/HeadBar/HeadBar.cs

@@ -60,6 +60,7 @@ namespace UAS_MES.CustomControl
                 if (logout_confirm == "Yes")
                 {
                     this.FindForm().Close();
+                    Application.Exit();
                 }
             }
             else

+ 11 - 3
UAS-MES/FunctionCode/SystemSetting/SystemSetting_LabelMaintain.cs

@@ -2,6 +2,7 @@
 using System;
 using System.Collections.Generic;
 using System.Data;
+using System.IO;
 using System.Drawing;
 using System.Text;
 using System.Threading;
@@ -458,7 +459,7 @@ namespace UAS_MES.SystemSetting
                             sql.Clear();
                             sql.Append("update productlabel set pl_labelcode=:pl_labelcode,pl_labeltype=:pl_labeltype,pl_labelurl=:pl_labelurl,pl_labelname=:pl_labelname,");
                             sql.Append("pl_prodcode=:pl_prodcode,pl_indate=sysdate where pl_id='" + pl_id2 + "'");
-                            dh.ExecuteSql(sql.GetString(), "update", la_code.Text, la_type.Text,ftpOperater.FTPAddress + la_name.Text,la_name.Text, pr_code.Text);
+                            dh.ExecuteSql(sql.GetString(), "update", la_code.Text, la_type.Text,SavePath.Text + la_name.Text,la_name.Text, pr_code.Text);
                         }
                         else
                         {
@@ -474,7 +475,7 @@ namespace UAS_MES.SystemSetting
                         {
                             sql.Clear();
                             sql.Append("insert into productlabel (pl_id,pl_labelcode,pl_labeltype,pl_isdefault,pl_labelurl,pl_labelsoft,pl_labelname,pl_prodcode,pl_indate) values( productlabel_seq.nextval, ");
-                            sql.Append("'" + la_code.Text + "','" + la_type.Text + "','" + isdefault(pr_code.Text, la_type.Text) + "','" + ftpOperater.FTPAddress + la_name.Text + "','" + SoftWare + "','" + la_name.Text + "','" + pr_code.Text + "',sysdate)");
+                            sql.Append("'" + la_code.Text + "','" + la_type.Text + "','" + isdefault(pr_code.Text, la_type.Text) + "','" + SavePath.Text + la_name.Text + "','" + SoftWare + "','" + la_name.Text + "','" + pr_code.Text + "',sysdate)");
                             dh.ExecuteSql(sql.GetString(), "insert");
                         }
                         else
@@ -512,6 +513,7 @@ namespace UAS_MES.SystemSetting
         private void Delete_Click(object sender, EventArgs e)
         {
             string[] deleteid = new string[LabelDataGridView.RowCount];
+            string[] deletelabel = new string[LabelDataGridView.RowCount];
             string[] deletelabname = new string[LabelDataGridView.RowCount];
             for (int i = 0; i < LabelDataGridView.RowCount; i++)
             {
@@ -523,6 +525,7 @@ namespace UAS_MES.SystemSetting
                         {
                             deleteid[i] = LabelDataGridView.Rows[i].Cells["pl_id"].Value.ToString();
                             deletelabname[i] = LabelDataGridView.Rows[i].Cells["pl_labelname"].Value.ToString();
+                            deletelabel[i] = LabelDataGridView.Rows[i].Cells["pl_labelurl"].Value.ToString();
                         }
                     }
                 }
@@ -540,7 +543,8 @@ namespace UAS_MES.SystemSetting
                     {
                         try
                         {
-                            ftp.Delete(deletelabname[i]);
+                            // ftp.Delete(deletelabname[i]);
+                            File.Delete(deletelabel[i]);
                         }
                         catch{
                             
@@ -559,7 +563,11 @@ namespace UAS_MES.SystemSetting
             DialogResult result = folder.ShowDialog();
             if (result == DialogResult.OK)
             {
+                
                 SavePath.Text = folder.SelectedPath;
+                if (SavePath.Text.LastIndexOf('\\') != SavePath.Text.Length-1) {
+                    SavePath.Text += ("\\");
+                }          
             }
             BaseUtil.SetCacheData("SavePath", SavePath.Text);
         }

+ 2 - 8
UAS-MES/PublicMethod/BaseUtil.cs

@@ -516,14 +516,8 @@ namespace UAS_MES.PublicMethod
         /// <returns></returns>
         public static string GetLabelUrl(string URL, string LabelName)
         {
-            //如果是传入的数据是从FTP取的文件
-            if (URL.Contains("ftp:"))
-            {
-                ftpOperater ftp = new ftpOperater();
-                return ftp.Download(LabelName);
-            }
-            else
-                return URL;
+            ftpOperater ftp = new ftpOperater();
+            return ftp.DownLoadFromSharePath(URL, LabelName);
         }
 
         /// <summary>

+ 21 - 7
UAS-MES/PublicMethod/ftpOperater.cs

@@ -248,10 +248,26 @@ namespace UAS_MES.PublicMethod
             }
         }
 
-             /// <summary>
-         /// 删除文件
-         /// </summary>
-         /// <param name="fileName"></param>
+
+        public string DownLoadFromSharePath(string URL,string fileName)
+        {
+            //目标路径
+            string targetPath = BaseUtil.GetCacheData("SavePath").ToString();
+            //var file = Directory.GetFiles(targetPath);
+            string sourceFile = Path.Combine(URL);
+            string destFile = Path.Combine(DownLoadTo+@"\", fileName);
+            //不存在文件的话进行创建
+            if (!Directory.Exists(DownLoadTo))
+            Directory.CreateDirectory(DownLoadTo);
+            //将文件复制到指定位置
+            File.Copy(sourceFile, destFile, true);
+            return destFile;
+        }
+
+        /// <summary>
+        /// 删除文件
+        /// </summary>
+        /// <param name="fileName"></param>
         public void Delete(string fileName)
         {
              try
@@ -278,8 +294,6 @@ namespace UAS_MES.PublicMethod
              {
                  throw ex;
              }
-         }
-
-       
+         }       
     }
 }