diff --git a/ButcherFactory.BO/Utils/ButcherFactoryUtil.cs b/ButcherFactory.BO/Utils/ButcherFactoryUtil.cs index b194f6c..51ddd3e 100644 --- a/ButcherFactory.BO/Utils/ButcherFactoryUtil.cs +++ b/ButcherFactory.BO/Utils/ButcherFactoryUtil.cs @@ -42,9 +42,10 @@ namespace ButcherFactory.BO.Utils { if (clientRpc != null) return; - if (!File.Exists("MESUrl.cfg")) + var fileName = @"Config\MESUrl.cfg"; + if (!File.Exists(fileName)) throw new Exception("缺少配置文件MESUrl.cfg"); - var url = File.ReadAllText("MESUrl.cfg"); + var url = File.ReadAllText(fileName); if (string.IsNullOrEmpty(url)) throw new Exception("MESUrl.cfg 配置文件错误"); clientRpc = new ClientRpc(url); diff --git a/ButcherFactory.BO/Utils/XmlUtil.cs b/ButcherFactory.BO/Utils/XmlUtil.cs index 21c95be..6f05c1b 100644 --- a/ButcherFactory.BO/Utils/XmlUtil.cs +++ b/ButcherFactory.BO/Utils/XmlUtil.cs @@ -10,12 +10,12 @@ namespace ButcherFactory.BO.Utils { public static class XmlUtil { - static string currentPath = Directory.GetCurrentDirectory(); + static string config = "Config"; public static void SerializerObjToFile(object obj, string fileName = "") { if (string.IsNullOrWhiteSpace(fileName)) { - fileName = Path.Combine(currentPath, obj.GetType().Name + ".xml"); + fileName = Path.Combine(config, obj.GetType().Name + ".xml"); } var ser = new XmlSerializer(obj.GetType()); @@ -30,7 +30,7 @@ namespace ButcherFactory.BO.Utils { if (string.IsNullOrWhiteSpace(fileName)) { - fileName = Path.Combine(currentPath, typeof(T).Name + ".xml"); + fileName = Path.Combine(config, typeof(T).Name + ".xml"); } if (!File.Exists(fileName)) { diff --git a/ButcherFactory.Form/CarcassInStore_/CarcassInStoreForm.cs b/ButcherFactory.Form/CarcassInStore_/CarcassInStoreForm.cs index c601f19..c342b41 100644 --- a/ButcherFactory.Form/CarcassInStore_/CarcassInStoreForm.cs +++ b/ButcherFactory.Form/CarcassInStore_/CarcassInStoreForm.cs @@ -42,12 +42,8 @@ namespace ButcherFactory.CarcassInStore_ long? batchID; List errorWeight = new List(); string strErrorWeight = ""; - string fileName; public CarcassInStoreForm() { - fileName = string.Format("{0:yyyyMMdd}WeightErrorLog.log", DateTime.Today); - if (!System.IO.File.Exists(fileName)) - System.IO.File.Create(fileName); InitializeComponent(); netStateWatch1.GetConnectState = () => LoginUtil.TestConnection(500); this.FormClosing += delegate diff --git a/ButcherFactory.Form/SegmentProduction_/SegmentProductionForm.cs b/ButcherFactory.Form/SegmentProduction_/SegmentProductionForm.cs index cbffecf..eb8600b 100644 --- a/ButcherFactory.Form/SegmentProduction_/SegmentProductionForm.cs +++ b/ButcherFactory.Form/SegmentProduction_/SegmentProductionForm.cs @@ -48,14 +48,6 @@ namespace ButcherFactory.SegmentProduction_ public SegmentProductionForm() { InitializeComponent(); - if (!System.IO.Directory.Exists("TempImg")) - System.IO.Directory.CreateDirectory("TempImg"); - else - { - var files = new System.IO.DirectoryInfo("TempImg").GetFiles(); - foreach (var f in files) - f.Delete(); - } netStateWatch1.GetConnectState = () => LoginUtil.TestConnection(500); this.FormClosing += delegate { diff --git a/ButcherFactory.Form/SegmentProduction_/SegmentProductionPrint.cs b/ButcherFactory.Form/SegmentProduction_/SegmentProductionPrint.cs index e1f144d..319dee0 100644 --- a/ButcherFactory.Form/SegmentProduction_/SegmentProductionPrint.cs +++ b/ButcherFactory.Form/SegmentProduction_/SegmentProductionPrint.cs @@ -11,6 +11,9 @@ namespace ButcherFactory.SegmentProduction_ public static class SegmentProductionPrint { static int id = 1; + const string PRINTFILE = @"PrintTemplate\SegmentProductionPrint.html"; + const string ENDFILE = @"PrintTemplate\SegmentProductionPrintEnd.html"; + const string IMGFILE = @"TempImg\_img{0}.png"; public static void Print(SegmentProduction entity, DateTime? dt) { if (dt == null) @@ -18,10 +21,10 @@ namespace ButcherFactory.SegmentProduction_ var dic = new Dictionary(); dic.Add("$Goods_Name", entity.Goods_Name); dic.Add("$Date", dt.Value.ToString("yyyy/MM/dd")); - var imgUrl = string.Format("TempImg\\_img{0}.png", id); + var imgUrl = string.Format(IMGFILE, id); BwpClientPrint.BwpClientWebPrint.Create2DPic(entity.BarCode, imgUrl, 120); dic.Add("$ImageUrl", imgUrl); - BwpClientPrint.BwpClientWebPrint.Print("PrintTemplate\\SegmentProductionPrint.html", dic); + BwpClientPrint.BwpClientWebPrint.Print(PRINTFILE, dic); AfterPrint(); } @@ -47,11 +50,11 @@ namespace ButcherFactory.SegmentProduction_ var dic = new Dictionary(); dic.Add("$tableContent", builder.ToString()); var groupID = list.First().GroupID.ToString(); - var imgUrl = string.Format("TempImg\\_img{0}.png", id); + var imgUrl = string.Format(IMGFILE, id); BwpClientPrint.BwpClientWebPrint.Create2DPic(groupID, imgUrl, 120); dic.Add("$ImageUrl", imgUrl); dic.Add("$DateTime", DateTime.Now.ToString("yyyy/MM/dd HH:ss")); - BwpClientPrint.BwpClientWebPrint.Print("PrintTemplate\\SegmentProductionPrintEnd.html", dic); + BwpClientPrint.BwpClientWebPrint.Print(ENDFILE, dic); AfterPrint(); } diff --git a/ButcherFactory.Login/App.xaml.cs b/ButcherFactory.Login/App.xaml.cs index 4dfe847..e8b5707 100644 --- a/ButcherFactory.Login/App.xaml.cs +++ b/ButcherFactory.Login/App.xaml.cs @@ -18,6 +18,8 @@ namespace ButcherFactory.Login { public EventWaitHandle ProgramStarted { get; set; } + readonly string[] FOLDERS = new string[] { "Config", "PrintTemplate", "Log", "TempImg" }; + protected override void OnStartup(StartupEventArgs e) { bool createNew; @@ -35,6 +37,14 @@ namespace ButcherFactory.Login RegisterEvents(); base.OnStartup(e); + foreach (var folder in FOLDERS) + { + if (!System.IO.Directory.Exists(folder)) + System.IO.Directory.CreateDirectory(folder); + } + var tempImages = new System.IO.DirectoryInfo("TempImg").GetFiles(); + foreach (var f in tempImages) + f.Delete(); } /// diff --git a/ButcherFactorySolution/ButcherFactorySolution.vdproj b/ButcherFactorySolution/ButcherFactorySolution.vdproj index 2dd6b58..6ad39b1 100644 --- a/ButcherFactorySolution/ButcherFactorySolution.vdproj +++ b/ButcherFactorySolution/ButcherFactorySolution.vdproj @@ -533,7 +533,7 @@ "SourcePath" = "8:..\\ButcherFactory.Login\\bin\\Debug\\DbSelectList.xml" "TargetName" = "8:DbSelectList.xml" "Tag" = "8:" - "Folder" = "8:_A4535DAA71C54DC088A3FA09FCED8C88" + "Folder" = "8:_DDF0E5520C37445FBCDCE0D5082C076B" "Condition" = "8:" "Transitive" = "11:FALSE" "Vital" = "11:TRUE" @@ -1176,7 +1176,7 @@ "SourcePath" = "8:..\\ButcherFactory.Login\\bin\\Debug\\MESUrl.cfg" "TargetName" = "8:MESUrl.cfg" "Tag" = "8:" - "Folder" = "8:_A4535DAA71C54DC088A3FA09FCED8C88" + "Folder" = "8:_DDF0E5520C37445FBCDCE0D5082C076B" "Condition" = "8:" "Transitive" = "11:FALSE" "Vital" = "11:TRUE" @@ -1302,6 +1302,17 @@ { } } + "{9EF0B969-E518-4E46-987F-47570745A589}:_DDF0E5520C37445FBCDCE0D5082C076B" + { + "Name" = "8:Config" + "AlwaysCreate" = "11:FALSE" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Property" = "8:_557ADC8EE8A04B99876F388F4924E380" + "Folders" + { + } + } } } "{1525181F-901A-416C-8A58-119130FE478E}:_ABD60611E8FE4923AC9AD915648E417C"