| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
-
- using System;
- using System.Diagnostics;
- using System.IO;
- using System.Reflection;
- using System.Threading;
- using System.Windows.Forms;
- using Dongke.IBOSS.PRD.Basics.BaseResources;
- using Dongke.IBOSS.PRD.Basics.Library;
- using Dongke.IBOSS.PRD.Client.CommonModule;
- namespace Dongke.IBOSS.PRD.Client.Public
- {
- static class Program
- {
- /// <summary>
- /// 应用程序的主入口点。
- /// </summary>
- [STAThread]
- static void Main()
- {
- //Application.EnableVisualStyles();
- //Application.SetCompatibleTextRenderingDefault(false);
- //Application.Run(new F_P_00001());
-
- // 检查程序是否已经在运行中
- bool isCreatedNew = true;
- string ibossMutexName = SystemAPI.UserName + "-iboss.prd.public-";
- Mutex ibossMutex = new Mutex(true, ibossMutexName, out isCreatedNew);
- // 取得程序的版本
- FileVersionInfo info = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
- string _mainFormTitle = "查询系统" + " - " + Constant.M_SYSTEM_CHINESE_SERIES + " - ver " + info.FileVersion;
- if (isCreatedNew)
- {
- try
- {
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- Application.ThreadException += Application_ThreadException;
- {
- // 更新自动更新程序
- if (Directory.Exists(LocalPath.InstallerPublicDownloadPath))
- {
- string[] downFiles = Directory.GetFiles(LocalPath.InstallerPublicDownloadPath);
- if (downFiles.Length > 0)
- {
- foreach (string name in downFiles)
- {
- string filename = Path.GetFileName(name);
- if (filename.StartsWith("AutoUpgrade")
- || "SharpZipLib.dll".Equals(filename))
- {
- string localFile = System.Environment.CurrentDirectory + @"\" + filename;
- if (File.Exists(localFile))
- {
- File.Delete(localFile);
- }
- File.Copy(name, localFile);
- File.Delete(name);
- }
- }
- }
- }
- }
- // 主程序
- using (F_P_00001 main = new F_P_00001())
- {
- main.Text = _mainFormTitle;
- Application.Run(main);
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException("PublicProgram.cs", "Main()", Messages.MSG_TITLE_E01, ex);
- }
- finally
- {
- if (ibossMutex != null)
- {
- ibossMutex.Close();
- }
- }
- }
- else
- {
- IntPtr iptWndMain = Utility.FindWindow(null, _mainFormTitle);
- if (iptWndMain == IntPtr.Zero)
- {
- }
- else
- {
- Utility.WakeupWindow(iptWndMain);
- }
- }
- }
- private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
- {
- //throw new NotImplementedException();
- ExceptionManager.HandleEventException(
- "PublicProgram.cs",
- "Application_ThreadException()",
- Messages.MSG_TITLE_E01,
- e.Exception);
- }
- }
- }
|