You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
113 lines
4.9 KiB
C#
113 lines
4.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.IO;
|
|
using System.Windows.Forms;
|
|
using ICSharpCode.Core;
|
|
using ICSharpCode.Core.Services;
|
|
using Mesnac.Gui.Run.Global;
|
|
|
|
namespace MCBackView
|
|
{
|
|
using Mesnac.Core.Service;
|
|
using Mesnac.Gui.Workbench;
|
|
static class Program
|
|
{
|
|
[STAThread]
|
|
static void Main(string[] args)
|
|
{
|
|
if (Mesnac.Basic.ProcessHelper.HaveRunningInstance())
|
|
{
|
|
Mesnac.Basic.MessageBoxTimeOut.Show("应用已在运行,请耐心等待...", "提示", 2000);
|
|
Application.Exit();
|
|
return;
|
|
}
|
|
Application.EnableVisualStyles();
|
|
Application.SetCompatibleTextRenderingDefault(false);
|
|
|
|
#region 授权处理
|
|
|
|
#if (!DEBUG)
|
|
//MesnacServiceManager.Instance.LoggingService.Info("软件授权...");
|
|
//if (!Mesnac.Basic.Register.IsExist("MCRun") || Mesnac.Basic.Register.GetRegData("MCRun") != Mesnac.Basic.Register.GetRegCode())
|
|
//{
|
|
// Mesnac.Gui.Run.FrmRegister frmRegister = new Mesnac.Gui.Run.FrmRegister();
|
|
// frmRegister.ShowDialog();
|
|
// if (frmRegister.DialogResult == DialogResult.Cancel)
|
|
// {
|
|
// Application.Exit();
|
|
// return;
|
|
// }
|
|
//}
|
|
#endif
|
|
|
|
#endregion
|
|
|
|
MesnacServiceManager.Instance.LoggingService.Info("启动应用程序...");
|
|
Assembly exe = typeof(Program).Assembly;
|
|
FileUtility.ApplicationRootPath = Path.GetDirectoryName(exe.Location);
|
|
|
|
CoreStartup cs = new CoreStartup("MCBackView");
|
|
//设备配置文件目录
|
|
cs.ConfigDirectory = Path.Combine(FileUtility.ApplicationRootPath, "Data", "Config");
|
|
|
|
MesnacServiceManager.Instance.LoggingService.Info("启动核心服务...");
|
|
cs.StartCoreServices();
|
|
//注册资源文件,文本和图片
|
|
ResourceService.RegisterNeutralStrings(new System.Resources.ResourceManager("MCBackView.Properties.SDRes", exe));
|
|
ResourceService.RegisterNeutralImages(new System.Resources.ResourceManager("MCBackView.Properties.SDRes", exe));
|
|
|
|
ResourceService.RegisterNeutralStrings(new System.Resources.ResourceManager("MCBackView.Properties.MesnacResource", exe));
|
|
ResourceService.RegisterNeutralImages(new System.Resources.ResourceManager("MCBackView.Properties.MesnacResource", exe));
|
|
|
|
ResourceService.RegisterNeutralStrings(new System.Resources.ResourceManager("MCBackView.Properties.Resources", exe));
|
|
ResourceService.RegisterNeutralImages(new System.Resources.ResourceManager("MCBackView.Properties.Resources", exe));
|
|
|
|
AddInTree.Doozers.TryAdd("Pad", new Mesnac.PlugIn.Pad.PadDoozer());
|
|
|
|
MesnacServiceManager.Instance.LoggingService.Debug("搜索插件...");
|
|
cs.AddAddInsFromDirectory(Path.Combine(FileUtility.ApplicationRootPath, "Data", "SharpPlugIn"));
|
|
|
|
MesnacServiceManager.Instance.LoggingService.Debug("加载插件...");
|
|
cs.RunInitialization();
|
|
|
|
MesnacServiceManager.Instance.LoggingService.Debug("初始化工作台...");
|
|
WorkbenchSingleton.InitFinished += delegate(object sender, EventArgs e)
|
|
{
|
|
MesnacServiceManager.Instance.LoggingService.Debug("初始化运行引擎...");
|
|
string projectPath = Path.Combine(Application.StartupPath, AppConfigHandler.Instance.MCProjectPath); //组态工程路径
|
|
if (Mesnac.Gui.Common.RunEngine.Instance.Init(projectPath, true, true)) //初始化运行引擎
|
|
{
|
|
AppConfigHandler.Instance.InitCustomerMenuAndToolStrip(WorkbenchSingleton.Workbench.TopMenu, WorkbenchSingleton.Workbench.ToolStrip); //初始化自定义系统菜单和工具栏
|
|
}
|
|
};
|
|
WorkbenchSingleton.InitializeWorkbench();
|
|
|
|
MesnacServiceManager.Instance.LoggingService.Debug("启动工作台...");
|
|
Form frmMain = WorkbenchSingleton.Workbench as Form;
|
|
|
|
//Mesnac.Basic.UserInfo.Instance.RoleID = "2"; //设置用户角色
|
|
//Mesnac.Basic.UserInfo.Instance.UserID = "1";
|
|
//Mesnac.Basic.UserInfo.Instance.UserName = "lix";
|
|
|
|
|
|
WorkbenchSingleton.Workbench.CloseFlag = true;
|
|
|
|
Application.Run(frmMain);
|
|
|
|
PropertyService.Save();
|
|
|
|
//退出系统之前,关闭相关文档
|
|
Mesnac.Gui.Common.RunEngine.Instance.CloseAllForms();
|
|
Mesnac.Gui.Workbench.WorkbenchSingleton.Workbench.CloseAllViews();
|
|
|
|
MesnacServiceManager.Instance.LoggingService.Info("关闭了应用程序。");
|
|
//关闭当前线程
|
|
System.Environment.Exit(System.Environment.ExitCode);
|
|
Application.ExitThread();
|
|
Application.Exit();
|
|
}
|
|
}
|
|
}
|