Beispiel #1
0
        public void InitApp()
        {
            //
            //TODO: add init code before main form show.
            //

            this.lbSplash.Text = MainForm.LocRM.GetString("strSplashLabelText");

            if (MainForm.myCmdMgr == null)
            {
                MainForm.myCmdMgr = new CmdMgr();
            }

            //if we already build one, no need to check the file.
            if (MainForm.myCmdMgr.Config == null)
            {
                //load config file
                if (File.Exists(configFile))
                {
                    MainForm.myCmdMgr.Config = (AppInfoConfig)WinAptLib.ReadFromFile(typeof(AppInfoConfig), configFile);
                }
                else
                {
                    //no config file, need to builder one
                    throw new Exception("new");
                }
            }
            //download update page.
            string content = "";

            this.lbSplash.Text = MainForm.LocRM.GetString("strSplashLabelLoadDB");
            lbSplash.Update();
            try
            {
                string fileName = MainForm.myCmdMgr.Config.usingDB;
                if (!File.Exists(fileName))
                {
                    this.lbSplash.Text = MainForm.LocRM.GetString("strSplashLabelDownloadDB");
                    lbSplash.Update();
                    progressBar1.Visible = true;
                    if (!WinAptLib.DownloadDbFile(MainForm.myCmdMgr.Config.updateUrl, progressBar1))
                    {
                        throw new Exception(string.Format(MainForm.LocRM.GetString("strSplashLabelDownloadError"), MainForm.myCmdMgr.Config.updateUrl));
                    }
                }
                content = WinAptLib.GetAppInfoContent(fileName);
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                //save the config file, then quit program.
                WinAptLib.WriteToFile(MainForm.myCmdMgr.Config, configFile);
            }
            MainForm.myCmdMgr.UpdateAppDB(content);
        }
Beispiel #2
0
        public void UpdateDB(bool isDownload)
        {
            if (isDownload)
            {
                btnUpdate.Enabled = false;
                UpdateForm upForm = new UpdateForm(myCmdMgr.Config.updateUrl);
                this.Enabled = false;
                upForm.ShowDialog();
                this.Enabled = true;
            }
            string fileName = myCmdMgr.Config.usingDB;
            string content  = WinAptLib.GetAppInfoContent(fileName);

            if (content == "")
            {
                return;
            }
            myCmdMgr.UpdateAppDB(content);
            updateLvApp();
        }