예제 #1
0
        private void FrmUpdate_Load(object sender, System.EventArgs e)
        {
            Frmflash f = new Frmflash();

            f.Show();
            f.Refresh();
            GetNewFile();
            f.Close();
            FileUpdate();
            //Thread fileUpdate = new Thread(new ThreadStart(FileUpdate));
            //fileUpdate.Start();

            //FileUpdate();
        }
예제 #2
0
파일: Program.cs 프로젝트: Wooyme/HIS-1
        //static void Main(params string[] invokAppId)
        //Modify By Tany 2012-04-10 带参数启动
        static void Main(string[] args)
        {
            Classes.Logger.Write(new string[] { "Start Run Update Main Function" }, true);
            string hisStartupExe = "Trasen.exe";
            string procName      = "Trasen";

            //Modify By Tany 2012-03-09 获取主程序的exe名称
            hisStartupExe = GetIniString("MAINPROGRAMINFO", "hisStartupExe", Application.StartupPath + "\\ClientConfig.ini");
            procName      = GetIniString("MAINPROGRAMINFO", "Trasen", Application.StartupPath + "\\ClientConfig.ini");
            if (hisStartupExe.Trim() == "")
            {
                hisStartupExe = "Trasen.exe";
            }
            if (procName.Trim() == "")
            {
                procName = "Trasen";
            }

            //判断启动程序的参数,没有参数则是由Trasen.exe调用
            if (args.Length > 0)
            {
                hisStartupExe = args[0];
                //MessageBox.Show(args[0]);
            }
            if (args.Length > 1)
            {
                procName = args[1];

                //MessageBox.Show(args[1]);
            }

            Classes.Logger.Write(new string[] { "Beform CreateMutex" }, true);

            IntPtr hMutex = ApiFunction.CreateMutex(null, false, "SysUpdateEx");

            if (ApiFunction.GetLastError() == ApiFunction.ERROR_ALREADY_EXISTS)
            {
                ApiFunction.ReleaseMutex(hMutex);
                return;
            }

            #region add by wangzhi 记录升级程序的信息
            List <string> lstLogHeader = new List <string>();
            lstLogHeader.Add("*******************************************************************************************");
            lstLogHeader.Add(string.Format("hisStartupExe:{0}", hisStartupExe));
            lstLogHeader.Add(string.Format("procName:{0}", procName));
            if (args != null && args.Length > 0)
            {
                lstLogHeader.Add("Main.args[]:");
                for (int i = 0; i < args.Length; i++)
                {
                    if (!string.IsNullOrEmpty(args[i]))
                    {
                        lstLogHeader.Add(args[i]);
                    }
                }
            }
            lstLogHeader.Add("*******************************************************************************************");
            Classes.Logger.Write(lstLogHeader.ToArray(), false);
            #endregion

            Frmflash f = new Frmflash("正在关闭相关应用程序...");//jianqg  2013-4-22
            #region 关闭相关的程序
            try
            {
                f.Show();
                f.Refresh();
                KillProcess("");
            }
            catch (Exception err)
            {
                MessageBox.Show("升级程序无法关闭相关应用程序,请手工关闭程序后再试" + err.Message);
                return;
            }
            finally
            {
                f.Close();
            }
            #endregion

            //启动升级程序主界面
            Classes.Logger.Write("启动升级程序主界面.");
            Application.Run(new SystemUpdate.Forms.FrmFileUpdate());

            //升级结束后,启动HIS应用程序
            try
            {
                bool   invokeBySSO = false;
                string strags      = "";
                if (args.Length == 1 && args[0] == "SSO")
                {
                    //参数为SSO表示由单点登录的程序调用Trasen后再调用升级程序
                    invokeBySSO = true;
                }
                //jianqg  2013-4-22
                if (args.Length > 2)   //jianqg  2013-4-22 增加 通过接口如pacs 传入的参数
                {
                    strags += args[2];
                    //MessageBox.Show(args[2]);
                }
                if (args.Length > 3)   //jianqg  2013-4-22 增加 通过接口如pacs 传入的参数
                {
                    strags += " " + args[3] + " " + "IsFromUpdate";
                }
                //MessageBox.Show(hisStartupExe);
                //MessageBox.Show(strags);

                if (invokeBySSO)
                {
                    MessageBox.Show("升级完成,请重新由门户程序进入", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                if (strags == "")
                {
                    Classes.Logger.Write(string.Format("升级结束,正准备启动{0},参数{1}", hisStartupExe, "IsFormUpdate"));
                    Process.Start(Application.StartupPath + "\\" + hisStartupExe, "IsFormUpdate");
                }
                else
                {
                    Classes.Logger.Write(string.Format("升级结束,正准备启动{0},参数{1}", hisStartupExe, strags));
                    Process.Start(Application.StartupPath + "\\" + hisStartupExe, strags);
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }