Exemple #1
0
        static void Main(string[] args)
        {
            var   remotingConfigPath = AppDomain.CurrentDomain.BaseDirectory + "RemotingConfig.xml";
            bool  createdNew;
            Mutex instance = new Mutex(true, "CallClient", out createdNew);
            var   ini      = new OperateIni(Application.StartupPath + @"\WindowConfig.ini");

            if (bool.Parse(ini.ReadString("WindowSet", "Restart", "false")))
            {
                createdNew = true;
                ini.DelKey("WindowSet", "Restart");
            }
            if (createdNew)
            {
                var updatePath = AppDomain.CurrentDomain.BaseDirectory + "AutoUpdate.exe";
                if (args.Length == 0)
                {
                    if (File.Exists(updatePath))
                    {
                        System.Diagnostics.Process.Start(updatePath, "CallClient.exe");
                        return;
                    }
                }
                else
                {
                    var newUpdatePath = AppDomain.CurrentDomain.BaseDirectory + "AutoUpdate.exe.tmp";
                    if (File.Exists(newUpdatePath))
                    {
                        File.Delete(updatePath);
                        File.Move(newUpdatePath, updatePath);
                    }
                    //有新的更新内容
                    if (bool.Parse(args[1]))
                    {
                        frmMain.SetConfigValue("RemotingConfig", "192.168.0.253:5566");
                        var config = File.ReadAllText(remotingConfigPath).Replace("0.0.0.0:0000", ConfigurationManager.AppSettings["RemotingConfig"]);
                        File.WriteAllText(remotingConfigPath, config);
                    }
                }
                string dir = AppDomain.CurrentDomain.BaseDirectory + "log\\" + DateTime.Now.ToString("yyyy-MM-dd");
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }
                RemotingConfiguration.Configure(remotingConfigPath, false);
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
                Application.Run(new frmMain());
            }
            else
            {
                MessageBox.Show("程序已运行,不能重复启动!");
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            bool  createdNew;
            Mutex instance = new Mutex(true, "CallClient", out createdNew);
            var   ini      = new OperateIni(Application.StartupPath + @"\WindowConfig.ini");

            if (bool.Parse(ini.ReadString("WindowSet", "Restart", "false")))
            {
                createdNew = true;
                ini.DelKey("WindowSet", "Restart");
            }
            if (createdNew)
            {
                var updatePath = AppDomain.CurrentDomain.BaseDirectory + "AutoUpdate.exe";
                if (args.Length == 0)
                {
                    if (File.Exists(updatePath))
                    {
                        System.Diagnostics.Process.Start(updatePath, "CallClient.exe");
                        return;
                    }
                }
                else
                {
                    var newUpdatePath = AppDomain.CurrentDomain.BaseDirectory + "AutoUpdate.exe.tmp";
                    if (File.Exists(newUpdatePath))
                    {
                        File.Delete(updatePath);
                        File.Move(newUpdatePath, updatePath);
                    }
                }
                string dir = AppDomain.CurrentDomain.BaseDirectory + "log\\" + DateTime.Now.ToString("yyyy-MM-dd");
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
                Application.Run(new frmMain());
            }
            else
            {
                MessageBox.Show("程序已运行,不能重复启动!");
            }
        }