Esempio n. 1
0
        //end
        public FrmMain1()
        {
            InitializeComponent();
            //kiểm tra version để update
            dtupdate = null;
            dtupdate = ud.dt_autoUpdate();

            if (dtupdate != null)
            {
                if (dtupdate.Rows[0]["capnhat"].ToString() == "1")
                {
                    if (this.ProductVersion != dtupdate.Rows[0]["version"].ToString())
                    {
                        fileName = "AutoUpdate.exe";
                        using (Process p = new Process())
                        {
                            p.StartInfo.FileName = fileName;
                            if (arguments.Length > 0)
                            {
                                p.StartInfo.Arguments = arguments;
                            }
                            //p.StartInfo.WindowStyle=System.Diagnostics.ProcessWindowStyle.Hidden;
                            p.Start();

                            Application.Exit();
                            if (this.waitMillisecs != -1)
                            {
                                p.WaitForExit(waitMillisecs);
                            }
                            else
                            {
                                if (this.waitUntilFinished == true)
                                {
                                    p.WaitForExit();
                                }
                            }
                            p.Close();
                        }
                    }
                }
                //lưu version máy
                DataTable dtversion      = new DataTable();
                string    s_ComputerName = Computer.getMachineName();
                ud        = new Oracle_autoUpdate();
                dtversion = ud.dtversionComputer(s_ComputerName);
                if (dtversion != null)
                {
                    ud.upd_version(int.Parse(dtversion.Rows[0]["id"].ToString()), s_ComputerName, this.ProductVersion, 0);
                }
                else
                {
                    int maxid = 0;
                    maxid = ud.maxid() + 1;
                    ud.ins_version(maxid, s_ComputerName, this.ProductVersion, 0);
                }
                //end lưu version máy
            }
            //end kiểm tra version để update
        }