Exemple #1
0
        /// <summary>
        /// 锁定系统
        /// </summary>
        private static void ActionLockSystem()
        {
            LoginFrm loginForm = new LoginFrm();

            loginForm.TopLevel = true;
            loginForm.TopMost  = true;
            DialogResult dialogResult = loginForm.ShowDialog();

            if (dialogResult != DialogResult.OK)
            {
                try
                {
                    Application.Exit();
                }
                catch
                {
                    //if (!string.IsNullOrEmpty(ExtendApplicationContext.Current.LoginUserContext.LoginName))
                    //    PermissionProxy.UpdateHisTag(ExtendApplicationContext.Current.LoginUserContext.LoginName, true);
                    System.Environment.Exit(0);
                }
                return;
            }

            if (LoginFrm.IsChangeUser)
            {
                // _form.InitMainForm();
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            //System.Threading.Mutex mutexMyapplication = new System.Threading.Mutex(false, "MedicalSystem.Anes.Client.AppPC.exe");
            //if (!mutexMyapplication.WaitOne(100, false))
            //{
            //    MessageBoxFormPC.Show("复苏程序已经运行!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
            //    return;
            //}
            Process current = Process.GetCurrentProcess();

            Process[] processes = Process.GetProcessesByName(current.ProcessName);
            foreach (Process process in processes)
            {
                if (process.Id != current.Id)
                {
                    if (process.MainModule.FileName
                        == current.MainModule.FileName)
                    {
                        MessageBoxFormPC.Show("复苏程序已经运行!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                }
            }

            #region 自动更新
            UpdateDLL.Update.CheckVerion();
            #endregion
            bool requestInitialOwnership = true;
            bool mutexWasCreated         = false;

            DevHandlerLib.DevHandler.CloseDevWindowKeepRunning();

            Logger.Error(string.Format("系统启动,当前的时间{0}", DateTime.Now));
            ///显示错误定义:暂时用系统消息框显示,等美工设计好界面后替换


            //MedicalSystem.Anes.Core.ExceptionHandle.ExceptionHelper.ShowExceptionAction =
            //    (exMessage) =>
            //    {
            //        ExceptionMessageBox.Show(exMessage.SourceException);
            //    };

            Application.ThreadException += Application_ThreadException;
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            ExtendApplicationContext.Current.ClientIP = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList[0].ToString();

            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                bool loginFlag = false;
                using (LoginFrm loginFrm = new LoginFrm(args))
                {
                    if (loginFrm.ShowDialog() == DialogResult.OK)
                    {
                        loginFlag      = true;
                        t              = new Thread(new ThreadStart(LoadingForm));
                        t.Name         = "LoadingFormThread";
                        t.IsBackground = true;
                        t.Start();
                    }
                }
                if (loginFlag)
                {
                    while (true)
                    {
                        if (LoadingFrm.EndOfTask)
                        {
                            WebApiVisitor.ApiStartRequest += WebApiVisitor_ApiStartRequest;
                            WebApiVisitor.ApiEndRequest   += WebApiVisitor_ApiEndRequest;
                            Application.Run(new MainFrm());
                            break;
                        }
                        else
                        {
                            Thread.Sleep(20);
                        }
                    }
                }
                else
                {
                    Application.Exit();
                }
            }
            catch (Exception ex)
            {
                Logger.Error("MedicalSystem.Anes.Client.AppPC.Program.Main", ex);
            }

            Logger.Error(string.Format("系统退出,当前的时间{0}", DateTime.Now));
        }