Browse Source

Merge branch 'master' of ssh://10.10.101.21/source/mes-client

Hcsy 8 years ago
parent
commit
37497ad0cf

+ 2 - 3
UAS_KanBan/Process.cs

@@ -26,10 +26,9 @@ namespace UAS_KanBan
             int WorkHeight = Screen.PrimaryScreen.Bounds.Width;
             if (WorkHeight <= 1024)
             {
-                机型.MaximumSize = new Size(300, 0);
                 for (int i = 0; i < this.Controls.Count; i++)
                 {
-                    if (Controls[i] is Label ||Controls[i] is ValueLabel)
+                    if (Controls[i] is Label || Controls[i] is ValueLabel)
                     {
                         if (Controls[i].Tag != null && Controls[i].Tag.ToString() == "AutoFont")
                             Controls[i].Font = new Font("宋体", Controls[i].Font.Size - 10, FontStyle.Bold);
@@ -48,7 +47,6 @@ namespace UAS_KanBan
             Refresh.Interval = Setting.RefreshRate * 1000;
             Refresh.Start();
             WindowState = FormWindowState.Maximized;
-
         }
 
         private void Refresh_Tick(object sender, EventArgs e)
@@ -95,6 +93,7 @@ namespace UAS_KanBan
             直通率.Location = new Point(直通率_label.Location.X + 直通率_label.Width + 30, 直通率_label.Location.Y);
             收益率.Location = new Point(收益率_label.Location.X + 收益率_label.Width + 30, 收益率_label.Location.Y);
             故障数.Location = new Point(故障数_label.Location.X + 故障数_label.Width + 30, 故障数_label.Location.Y);
+            机型.MaximumSize = new Size(直通率_label.Location.X - 机型_label.Location.X - 机型_label.Width-40, 0);
         }
 
         private void Process_FormClosing(object sender, FormClosingEventArgs e)

+ 2 - 2
UAS_KanBan/UAS_KanBan.csproj

@@ -28,10 +28,10 @@
     <ProductName>UAS看板</ProductName>
     <PublisherName>深圳市优软科技有限公司</PublisherName>
     <SuiteName>UAS看板</SuiteName>
-    <MinimumRequiredVersion>1.0.0.14</MinimumRequiredVersion>
+    <MinimumRequiredVersion>1.0.0.16</MinimumRequiredVersion>
     <CreateWebPageOnPublish>true</CreateWebPageOnPublish>
     <WebPage>publish.htm</WebPage>
-    <ApplicationRevision>15</ApplicationRevision>
+    <ApplicationRevision>17</ApplicationRevision>
     <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
     <UseApplicationTrust>false</UseApplicationTrust>
     <CreateDesktopShortcut>true</CreateDesktopShortcut>

File diff suppressed because it is too large
+ 178 - 624
UAS_XmlAnalysor/DataHelper.cs


+ 47 - 26
UAS_XmlAnalysor/Form1.cs

@@ -3,7 +3,6 @@ using System;
 using System.Collections.Generic;
 using System.Data;
 using System.IO;
-using System.Threading;
 using System.Windows.Forms;
 using System.Xml;
 
@@ -16,6 +15,8 @@ namespace UAS_XmlAnalysor
 
         DataTable dt;
 
+        string CachePath = Environment.GetEnvironmentVariable("windir").Substring(0, 1) + @":/Cache/Cache.xml";
+
         public Form1()
         {
             InitializeComponent();
@@ -23,30 +24,25 @@ namespace UAS_XmlAnalysor
 
         private void Form1_Load(object sender, EventArgs e)
         {
+            List<string> CacheInf = new List<string>();
             try
             {
-                StreamReader sr = new StreamReader(Application.StartupPath + @"/Cache/path.txt");
-                string line;
-                while ((line = sr.ReadLine()) != null)
+                XmlReader myReader = XmlReader.Create(CachePath);
+                while (myReader.Read())
                 {
-                    if (line != "")
-                    {
-                        break;
-                    }
+                    if (myReader.NodeType == XmlNodeType.Text)
+                        CacheInf.Add(myReader.Value);
                 }
-                object[] Data = line.Split('|');
-                FolderPath.Text = Data[0].ToString();
-                BackUpFolderPath.Text = Data[1].ToString();
-                Source.Text = Data[2].ToString();
-                Master.Text = Data[3].ToString();
-                AutoStart.Checked = (Data[4].ToString() == "True") ? true : false;
-                sr.Close();
-            }
-            catch (Exception)
-            {
-
+                myReader.Close();
+                string[] Info = CacheInf.ToArray();
+                FolderPath.Text = Info[0];
+                BackUpFolderPath.Text = Info[1];
+                Source.Text = Info[2];
+                Master.Text = Info[3];
+                AutoStart.Checked = (Info[4] == "True" ? true : false);
             }
-            dt = (DataTable)dh.ExecuteSql("select ms_pwd,ma_user,ma_address from master ", "select");
+            catch (Exception) { }
+            dt = (DataTable)dh.ExecuteSql("select ms_pwd,ma_user,ma_address from master", "select");
             Master.DataSource = dt;
             Master.DisplayMember = "ma_user";
             Master.ValueMember = "ma_user";
@@ -60,7 +56,11 @@ namespace UAS_XmlAnalysor
                 OperateResult.AppendText("请选择监控文件夹和备份文件夹\n");
                 return;
             }
-
+            if (FolderPath.Text == BackUpFolderPath.Text)
+            {
+                OperateResult.AppendText("监控文件夹和备份文件夹不能相同\n");
+                return;
+            }
             for (int i = 0; i < dt.Rows.Count; i++)
             {
                 if (Master.Text == dt.Rows[i]["ma_user"].ToString())
@@ -80,10 +80,24 @@ namespace UAS_XmlAnalysor
             XmlWatcher.EnableRaisingEvents = true;
             string CacheString = FolderPath.Text + "|" + BackUpFolderPath.Text + "|" + Source.Text + "|" + Master.Text + "|" + AutoStart.Checked;
             //写入前先删除文件
-            File.Delete(Application.StartupPath + @"/Cache/path.txt");
-            StreamWriter sw = File.AppendText(Application.StartupPath + @"\Cache\path.txt");
-            sw.WriteLine(CacheString);
-            sw.Close();
+            try
+            {
+                File.Delete(CachePath);
+            }
+            catch (Exception) { }
+            XmlDocument xmlDoc = new XmlDocument();
+            //创建类型声明节点  
+            XmlNode node = xmlDoc.CreateXmlDeclaration("1.0", "utf-8", "");
+            xmlDoc.AppendChild(node);
+            //创建根节点  
+            XmlElement xeRoot = xmlDoc.CreateElement("CacheInf");
+            xmlDoc.AppendChild(xeRoot);
+            CreateNode(xmlDoc, xeRoot, "FolderPath", FolderPath.Text);
+            CreateNode(xmlDoc, xeRoot, "BackUpFolderPath", BackUpFolderPath.Text);
+            CreateNode(xmlDoc, xeRoot, "Source", Source.Text);
+            CreateNode(xmlDoc, xeRoot, "Master", Master.Text);
+            CreateNode(xmlDoc, xeRoot, "AutoStart", AutoStart.Checked.ToString());
+            xmlDoc.Save(CachePath);
             Source.Enabled = false;
             StartWatch.Enabled = false;
             ChooseFolder.Enabled = false;
@@ -92,6 +106,13 @@ namespace UAS_XmlAnalysor
             OperateResult.AppendText("开始执行监控\n");
         }
 
+        public void CreateNode(XmlDocument xmlDoc, XmlNode parentNode, string name, string value)
+        {
+            XmlNode node = xmlDoc.CreateNode(XmlNodeType.Element, name, null);
+            node.InnerText = value;
+            parentNode.AppendChild(node);
+        }
+
         public void SetAutoRun()
         {
             if (AutoStart.Checked) //设置开机自启动  
@@ -171,7 +192,7 @@ namespace UAS_XmlAnalysor
             {
                 try
                 {
-                    file.MoveTo(BackUpFolderPath.Text + @"\" + e.Name);
+                    file.MoveTo(BackUpFolderPath.Text + @"\" + DateTime.Now.ToString("yyyy-MM-dd-hh-mm-ss") + "-" + e.Name);
                 }
                 catch (Exception ex)
                 {

+ 44 - 3
UAS_XmlAnalysor/Program.cs

@@ -4,6 +4,7 @@ using System.Collections.Generic;
 using System.IO;
 using System.Linq;
 using System.Security.Principal;
+using System.Text;
 using System.Threading.Tasks;
 using System.Windows.Forms;
 
@@ -21,10 +22,18 @@ namespace UAS_XmlAnalysor
             {
                 WindowsIdentity identity = WindowsIdentity.GetCurrent();
                 WindowsPrincipal principal = new WindowsPrincipal(identity);
+
+                string sysdisc = Environment.GetEnvironmentVariable("windir").Substring(0, 1);
+                Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
+                //处理UI线程异常
+                Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
+                //处理非UI线程异常
+                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
+
                 Application.EnableVisualStyles();
                 Application.SetCompatibleTextRenderingDefault(false);
-                if (!Directory.Exists(Application.StartupPath+@"\Cache"))
-                    Directory.CreateDirectory(Application.StartupPath + @"\Cache");
+                if (!Directory.Exists(sysdisc + @":\Cache"))
+                    Directory.CreateDirectory(sysdisc + @":\Cache");
                 if (principal.IsInRole(WindowsBuiltInRole.Administrator))
                     Application.Run(new Form1());
                 else
@@ -71,5 +80,37 @@ namespace UAS_XmlAnalysor
                     reg.Close();
             }
         }
+        //处理线程的异常
+        static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
+        {
+            string str = GetExceptionMsg(e.Exception, e.ToString());
+            MessageBox.Show(str, "提示", MessageBoxButtons.OK, MessageBoxIcon.Stop);
+        }
+
+        //未处理的异常统一通过这里返回
+        static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
+        {
+            string str = GetExceptionMsg(e.ExceptionObject as Exception, e.ToString());
+            MessageBox.Show(str, "提示", MessageBoxButtons.OK, MessageBoxIcon.Stop);
+        }
+
+        /// <summary>
+        /// 生成自定义异常消息
+        /// </summary>
+        /// <param name="ex">异常对象</param>
+        /// <param name="backStr">备用异常消息:当ex为null时有效</param>
+        /// <returns>异常字符串文本</returns>
+        static string GetExceptionMsg(Exception ex, string backStr)
+        {
+            StringBuilder sb = new StringBuilder();
+            if (ex != null)
+            {
+                sb.AppendLine(ex.Message);
+                //sb.AppendLine("【异常方法】:" + ex.StackTrace);
+            }
+            //else { sb.AppendLine("【未处理异常】:" + backStr); }
+            return sb.ToString();
+        }
     }
-}
+
+}

+ 4 - 4
UAS_XmlAnalysor/UAS_XmlAnalysor.csproj

@@ -14,7 +14,7 @@
     <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
     <TargetFrameworkProfile>Client</TargetFrameworkProfile>
     <IsWebBootstrapper>true</IsWebBootstrapper>
-    <PublishUrl>ftp://192.168.253.9/MESSetting/Xml/</PublishUrl>
+    <PublishUrl>E:\s_user_site\Xml\</PublishUrl>
     <Install>true</Install>
     <InstallFrom>Web</InstallFrom>
     <UpdateEnabled>true</UpdateEnabled>
@@ -24,14 +24,14 @@
     <UpdatePeriodically>false</UpdatePeriodically>
     <UpdateRequired>true</UpdateRequired>
     <MapFileExtensions>true</MapFileExtensions>
-    <InstallUrl>http://218.17.158.219:8888/Xml/</InstallUrl>
+    <InstallUrl>http://172.16.11.99/Xml/</InstallUrl>
     <ProductName>UAS_XML解析器</ProductName>
     <PublisherName>深圳市优软科技有限公司</PublisherName>
     <SuiteName>UAS_XML解析器</SuiteName>
     <MinimumRequiredVersion>1.0.0.5</MinimumRequiredVersion>
     <CreateWebPageOnPublish>true</CreateWebPageOnPublish>
     <WebPage>publish.htm</WebPage>
-    <ApplicationRevision>15</ApplicationRevision>
+    <ApplicationRevision>16</ApplicationRevision>
     <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
     <UseApplicationTrust>false</UseApplicationTrust>
     <CreateDesktopShortcut>true</CreateDesktopShortcut>
@@ -67,7 +67,7 @@
     <GenerateManifests>true</GenerateManifests>
   </PropertyGroup>
   <PropertyGroup>
-    <SignManifests>true</SignManifests>
+    <SignManifests>false</SignManifests>
   </PropertyGroup>
   <PropertyGroup>
     <ApplicationIcon>Resources\xml_48px_1124003_easyicon.net.ico</ApplicationIcon>

Some files were not shown because too many files changed in this diff