|
|
|
|
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;
|
|
|
|
|
class Program
|
|
|
|
|
{
|
|
|
|
|
[STAThread]
|
|
|
|
|
static void Main(string[] args)
|
|
|
|
|
{
|
|
|
|
|
if (Mesnac.Basic.ProcessHelper.HaveRunningInstance())
|
|
|
|
|
{
|
|
|
|
|
Mesnac.Basic.MessageBoxTimeOut.Show("The application is running, please be patient...", "Caption", 2000);
|
|
|
|
|
Application.Exit();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Application.EnableVisualStyles();
|
|
|
|
|
Application.SetCompatibleTextRenderingDefault(false);
|
|
|
|
|
//初始化服务管理器
|
|
|
|
|
MesnacServiceManager.Init();
|
|
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
|
|
|
|
ICSharpCode.Core.LoggingService<Program>.Info("starting the application...");
|
|
|
|
|
Assembly exe = typeof(Program).Assembly;
|
|
|
|
|
FileUtility.ApplicationRootPath = Path.GetDirectoryName(exe.Location);
|
|
|
|
|
|
|
|
|
|
CoreStartup cs = new CoreStartup("MCBackView");
|
|
|
|
|
//设备配置文件目录
|
|
|
|
|
cs.ConfigDirectory = Path.Combine(FileUtility.ApplicationRootPath, "Data", "Config");
|
|
|
|
|
|
|
|
|
|
ICSharpCode.Core.LoggingService<Program>.Info("starting core services...");
|
|
|
|
|
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));
|
|
|
|
|
|
|
|
|
|
ResourceService.RegisterNeutralStrings(new System.Resources.ResourceManager("MCBackView.Properties.Mesnac.Common", exe));
|
|
|
|
|
ResourceService.RegisterNeutralImages(new System.Resources.ResourceManager("MCBackView.Properties.Mesnac.Common", exe));
|
|
|
|
|
|
|
|
|
|
ResourceService.RegisterNeutralStrings(new System.Resources.ResourceManager("MCBackView.Properties.Mesnac.Controls.Default", exe));
|
|
|
|
|
ResourceService.RegisterNeutralImages(new System.Resources.ResourceManager("MCBackView.Properties.Mesnac.Controls.Default", exe));
|
|
|
|
|
|
|
|
|
|
ResourceService.RegisterNeutralStrings(new System.Resources.ResourceManager("MCBackView.Properties.Mesnac.BackView", exe));
|
|
|
|
|
ResourceService.RegisterNeutralImages(new System.Resources.ResourceManager("MCBackView.Properties.Mesnac.BackView", exe));
|
|
|
|
|
|
|
|
|
|
AddInTree.Doozers.TryAdd("Pad", new Mesnac.PlugIn.Pad.PadDoozer());
|
|
|
|
|
|
|
|
|
|
ICSharpCode.Core.LoggingService<Program>.Debug("search plugins...");
|
|
|
|
|
cs.AddAddInsFromDirectory(Path.Combine(FileUtility.ApplicationRootPath, "Data", "SharpPlugIn"));
|
|
|
|
|
|
|
|
|
|
ICSharpCode.Core.LoggingService<Program>.Debug("loading plugins...");
|
|
|
|
|
cs.RunInitialization();
|
|
|
|
|
|
|
|
|
|
ICSharpCode.Core.LoggingService<Program>.Debug("initializing workbench...");
|
|
|
|
|
WorkbenchSingleton.InitFinished += delegate(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<Program>.Debug("starting run engine...");
|
|
|
|
|
string projectPath = Path.Combine(Application.StartupPath, AppConfigHandler.Instance.MCProjectPath); //组态工程路径
|
|
|
|
|
if (Mesnac.Gui.Common.RunEngine.Instance.Init(projectPath, true, true, true)) //初始化运行引擎
|
|
|
|
|
{
|
|
|
|
|
AppConfigHandler.Instance.InitCustomerMenuAndToolStrip(WorkbenchSingleton.Workbench.TopMenu, WorkbenchSingleton.Workbench.ToolStrip); //初始化自定义系统菜单和工具栏
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
WorkbenchSingleton.InitializeWorkbench();
|
|
|
|
|
|
|
|
|
|
ICSharpCode.Core.LoggingService<Program>.Debug("starting workbench...");
|
|
|
|
|
Form frmMain = WorkbenchSingleton.Workbench as Form;
|
|
|
|
|
|
|
|
|
|
if (String.IsNullOrEmpty(Mesnac.Basic.UserInfo.Instance.RoleGUID) || String.IsNullOrEmpty(Mesnac.Basic.UserInfo.Instance.UserName))
|
|
|
|
|
{
|
|
|
|
|
Mesnac.Basic.UserInfo.Instance.RoleGUID = "3DCEC1A0-722F-446B-9490-35FA2DED1FD2"; //设置用户角色
|
|
|
|
|
Mesnac.Basic.UserInfo.Instance.UserGUID = "E91B9971-AC1F-418F-A4DB-267FE8EC5B78";
|
|
|
|
|
Mesnac.Basic.UserInfo.Instance.UserName = "Super";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WorkbenchSingleton.Workbench.CloseFlag = true;
|
|
|
|
|
|
|
|
|
|
Application.Run(frmMain);
|
|
|
|
|
|
|
|
|
|
PropertyService.Save();
|
|
|
|
|
|
|
|
|
|
//退出系统之前,关闭相关文档
|
|
|
|
|
Mesnac.Gui.Common.RunEngine.Instance.CloseAllForms();
|
|
|
|
|
Mesnac.Gui.Workbench.WorkbenchSingleton.Workbench.CloseAllViews();
|
|
|
|
|
|
|
|
|
|
ICSharpCode.Core.LoggingService<Program>.Info("closed the application.");
|
|
|
|
|
//关闭当前线程
|
|
|
|
|
System.Environment.Exit(System.Environment.ExitCode);
|
|
|
|
|
Application.ExitThread();
|
|
|
|
|
Application.Exit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|