Exemplo n.º 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);
        }
Exemplo n.º 2
0
        internal void MergeDB(string newFile)
        {
            AppInfoDB tmpDB = (AppInfoDB)WinAptLib.ReadFromFile(typeof(AppInfoDB), newFile);

            foreach (AppInfoBase item in tmpDB.Items)
            {
                myAppDB.Add(item);
            }
        }
Exemplo n.º 3
0
 public void LoadDB(string fileName)
 {
     myAppDB = (AppInfoDB)WinAptLib.ReadFromFile(typeof(AppInfoDB), fileName);
     for (int i = 0; i < myAppDB.Items.Count; i++)
     {
         ((AppInfoBase)myAppDB.Items[i]).setIndex(i);
     }
     myAppDB.SetIndex(myAppDB.Items.Count);
 }