Browse Source

文件打包生成修改

样式分支
pry 2 years ago
parent
commit
a5837969da
6 changed files with 21 additions and 109 deletions
  1. +0
    -18
      BPASmart.ConfigurationSoftware/BasicInformation.cs
  2. +0
    -89
      BPASmart.ConfigurationSoftware/FileHelper.cs
  3. +5
    -0
      BPASmart.ConfigurationSoftware/Servers/ServiceCenter.cs
  4. +0
    -0
      BPASmart.ConfigurationSoftware/ViewModel/MainWindowViewModel.cs
  5. +5
    -0
      BPASmart.Model/Config/FileConfigModel.cs
  6. +11
    -2
      BPASmartClient.SmallBatchingSystem/Services/PlcServer.cs

+ 0
- 18
BPASmart.ConfigurationSoftware/BasicInformation.cs View File

@@ -1,18 +0,0 @@
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;

//namespace BPASmart.ConfigurationSoftware
//{
// public class BasicInformation
// {
// /// <summary>
// /// 项目上次保存的目录
// /// </summary>
// public string ProjectDefaultPath { get; set; } = string.Empty;


// }
//}

+ 0
- 89
BPASmart.ConfigurationSoftware/FileHelper.cs View File

@@ -1,89 +0,0 @@
//using BPA.Helper;
//using BPASmart.Model;
//using Microsoft.Win32;
//using System;
//using System.Collections.Generic;
//using System.IO;
//using System.Linq;
//using System.Runtime.InteropServices;
//using System.Text;
//using System.Threading.Tasks;
//using System.Windows.Forms;

//namespace BPASmart.ConfigurationSoftware
//{
// public class FileHelper
// {

// private volatile static FileHelper _Instance;
// public static FileHelper GetInstance => _Instance ?? (_Instance = new FileHelper());
// private FileHelper() { }

// public void RegisterOpenFileType()
// {
// string icoFile = System.Windows.Forms.Application.StartupPath + $"\\Images\\fyf.ico";
// string DirectoryPath = $"{Json<ProjectModel>.Data.ProjectPath}\\Images";
// Directory.CreateDirectory(DirectoryPath);
// File.Copy(icoFile, $"{DirectoryPath}\\fyf.ico");
// RegisterFileType(".project", "HBL", ".project", System.Windows.Forms.Application.ExecutablePath, $"{DirectoryPath}\\fyf.ico");
// }

// private void RegisterFileType(string typeName, string fileType, string fileContent, string app, string ico)
// {
// string toolPath = app;//工具启动路径
// string extension = typeName;//fileType = "自定义文件类型";

// //fileContent = "AAAA";
// //获取信息
// RegistryKey registryKey = Registry.ClassesRoot.OpenSubKey(extension);
// if (registryKey != null)
// {
// try
// {
// RegistryKey _Regkey = Registry.ClassesRoot.OpenSubKey("", true);

// RegistryKey _VRPkey = _Regkey.OpenSubKey(extension);
// if (_VRPkey != null) _Regkey.DeleteSubKeyTree(extension, false);
// if (_VRPkey != null) _Regkey.DeleteSubKeyTree("Exec");
// }
// catch (Exception e)
// {

// }
// }

// if (registryKey != null && registryKey.OpenSubKey("shell") != null && registryKey.OpenSubKey("shell").OpenSubKey("open") != null &&
// registryKey.OpenSubKey("shell").OpenSubKey("open").OpenSubKey("command") != null)
// {
// var varSub = registryKey.OpenSubKey("shell").OpenSubKey("open").OpenSubKey("command");
// var varValue = varSub.GetValue("");

// if (Equals(varValue, toolPath + " \"%1\""))
// {
// return;
// }
// }

// //文件注册
// registryKey = Registry.ClassesRoot.CreateSubKey(extension);
// registryKey.SetValue("", fileType);
// registryKey.SetValue("Content Type", fileContent);
// //设置默认图标
// RegistryKey iconKey = registryKey.CreateSubKey("DefaultIcon");
// //iconKey.SetValue("", Application.StartupPath + $"\\{ico}.ico");
// iconKey.SetValue("", ico);
// iconKey.Close();
// //设置默认打开程序路径
// registryKey = registryKey.CreateSubKey("shell\\open\\command");
// registryKey.SetValue("", toolPath + " \"%1\"");
// //关闭
// registryKey.Close();
// SHChangeNotify(0x8000000, 0, IntPtr.Zero, IntPtr.Zero);
// }

// [DllImport("shell32.dll")]
// public static extern void SHChangeNotify(uint wEventId, uint uFlags, IntPtr dwItem1, IntPtr dwItem2);
// }

//}


+ 5
- 0
BPASmart.ConfigurationSoftware/Servers/ServiceCenter.cs View File

@@ -319,6 +319,7 @@ namespace BPASmart.ConfigurationSoftware
/// </summary>
public async Task ApplicationBaleAsync()
{
ProjectSave();
await Task.Factory.StartNew(new Action(() =>
{
if (string.IsNullOrEmpty(FileConfigModel.ConstPath))
@@ -351,6 +352,10 @@ namespace BPASmart.ConfigurationSoftware
string pageFilePath = $"{FileConfigModel.ConstPath}\\{FileConfigModel.PageDirName}";
if (Directory.Exists(pageFilePath)) CopyFolder(pageFilePath, $"{path}\\{FileConfigModel.PageDirName}");

//打包图片文件资源
string imageFilePath = $"{FileConfigModel.ConstPath}\\{FileConfigModel.ImageDirName}";
if (Directory.Exists(imageFilePath)) CopyFolder(imageFilePath, $"{path}\\{FileConfigModel.ImageDirName}");

MessageLog.GetInstance.Show("打包完成");
}));
}


BPASmart.ConfigurationSoftware/MainWindowViewModel.cs → BPASmart.ConfigurationSoftware/ViewModel/MainWindowViewModel.cs View File


+ 5
- 0
BPASmart.Model/Config/FileConfigModel.cs View File

@@ -72,5 +72,10 @@ namespace BPASmart.Model
/// 二进制配置文件名
/// </summary>
public const string BinConfigFileName = "BinConfigFile.ser";

/// <summary>
/// 图片文件夹名称
/// </summary>
public const string ImageDirName = "Images";
}
}

+ 11
- 2
BPASmartClient.SmallBatchingSystem/Services/PlcServer.cs View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using BPA.Communication;
using BPA.Helper;
@@ -19,9 +20,17 @@ namespace BPASmartClient.SmallBatchingSystem.Services

public void Connect()
{
Communication.IsReconnect = true;
Communication.ConnectOk = new Action(() =>
{
MessageLog.GetInstance.Show("设备连接成功");
ThreadManage.GetInstance().StartLong(new Action(() =>
{

Communication.ModbusTcpConnect(Json<CommunicationPar>.Data.Host,Json<CommunicationPar>.Data.Port);

Thread.Sleep(10);
}), "PLC 数据监听");
});
Communication.ModbusTcpConnect(Json<CommunicationPar>.Data.Host, Json<CommunicationPar>.Data.Port);
}

}


Loading…
Cancel
Save