Inheritance: IBE.Enums_and_Utility_Classes.RNBaseForm
Example #1
0
        /// <summary>
        /// opens the data import dialog
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void importToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                var DataIO = new frmDataIO();

                DataIO.ShowDialog(this);

                DataIO.Dispose();
            }
            catch (Exception ex)
            {
                cErr.showError(ex, "Error while opening import tool");
            }
        }
Example #2
0
        /// <summary>
        /// this sub starts special things to do if this version runs
        /// for the first time
        /// </summary>
        internal static void DoSpecial()
        {
            Version dbVersion;
            Version appVersion;
            Version testVersion = new Version();

            try
            {
                dbVersion   = Program.DBCon.getIniValue<Version>("Database", "Version", new Version(0,0,0,0).ToString(), false);
                appVersion  = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;

                if (dbVersion < appVersion)
                {
                    if (dbVersion < (testVersion = new Version(0,1,0)))
                    {
                        // here it's required to import all master data
                        var DataIO = new frmDataIO();

                        Program.SplashScreen.InfoAdd("Importing master data...");
                        Thread.Sleep(3000);

                        DataIO.InfoTarget = Program.SplashScreen.SplashInfo;
                        DataIO.ReUseLine  = true;

                        DataIO.StartMasterImport(GetDataPath("Data"));

                        DataIO.Close();
                        DataIO.Dispose();

                        Program.DBCon.setIniValue("Database", "Version", appVersion.ToString());
                    }

                    Program.DBCon.setIniValue("Database", "Version", appVersion.ToString());
                }

            }
            catch (Exception ex)
            {
                throw new Exception("Error while doing special things", ex);
            }
        }
Example #3
0
        /// <summary>
        /// 
        /// this sub starts special things to do if this version runs
        /// for the first time 
        /// 
        /// <param name="parent"></param>
        internal async static System.Threading.Tasks.Task DoSpecial(Form parent)
        {
            Boolean didUpdate = false;

            try
            {

                if (!Program.Data.InitImportDone)
                {
                    if (m_OldDBVersion != new Version(0,1,0))
                    { 
                        // here it's required to import all master data 
                        var DataIO = new frmDataIO();

                        Program.SplashScreen.InfoAdd("importing master data...");
                        Thread.Sleep(1500);

                        DataIO.InfoTarget = Program.SplashScreen.SplashInfo;

                        await DataIO.StartMasterImport(Program.GetDataPath("Data"));

                        if(!Program.SplashScreen.IsDisposed)
                            Program.SplashScreen.TopMost = false;

                        MessageBox.Show(parent, "Do you want to get a starters data kit ?\r\n\r\n" +
                                                "You will get the existing market data from all stations in\r\n" +
                                                "the bubble of 20 ly around your current location.\r\n\r\n" +
                                                "Go to the 'Data' => 'Import&Export' menu.\r\n" +
                                                "Download the latest EDDB files and start\r\n" +
                                                "the import with the 'Starters Kit' option enabled.\r\n" +
                                                "More information in the 'StarterTipps' files.", 
                                                "wanna get a starters data kit ?", 
                                                MessageBoxButtons.OK, 
                                                MessageBoxIcon.Information);

                        if(!Program.SplashScreen.IsDisposed)
                            Program.SplashScreen.TopMost = true;

                        DataIO.Close();
                        DataIO.Dispose();
                        
                        Program.SplashScreen.InfoAdd("importing master data...<OK>");
                    }

                    Program.Data.InitImportDone = true;
                }
                else if(m_OldDBVersion < m_NewDBVersion)
                { 
                    // new version installed
                    if(!Program.SplashScreen.IsDisposed)
                        Program.SplashScreen.TopMost = false;

                    var dResult = MessageBox.Show(parent, "Want to update your master data using the supplied files ?", 
                                                          "Update master data", 
                                                          MessageBoxButtons.YesNo, 
                                                          MessageBoxIcon.Question, 
                                                          MessageBoxDefaultButton.Button1);

                    if(!Program.SplashScreen.IsDisposed)
                        Program.SplashScreen.TopMost = true;

                    if(dResult ==  System.Windows.Forms.DialogResult.Yes)
                    {
                        var DataIO = new frmDataIO();

                        Program.SplashScreen.InfoAdd("updating master data...");
                        Thread.Sleep(1500);

                        DataIO.InfoTarget = Program.SplashScreen.SplashInfo;

                        await DataIO.StartMasterUpdate(Program.GetDataPath("Data"));

                        DataIO.Close();
                        DataIO.Dispose();
                        
                        didUpdate = true;

                        Program.SplashScreen.InfoAdd("updating master data...<OK>");
                    }

                    if(m_NewDBVersion == new Version(0,2,1,0))
                    {

                        if(  Program.DBCon.getIniValue<Boolean>(IBE.EDDN.EDDNView.DB_GROUPNAME, "AutoListen", false.ToString(), false) && 
                           (!Program.DBCon.getIniValue<Boolean>(IBE.EDDN.EDDNView.DB_GROUPNAME, "AutoSend",   false.ToString(), false)))
                        {
                            if(!Program.SplashScreen.IsDisposed)
                                Program.SplashScreen.TopMost = false;

                            if(MessageBox.Show(parent, "You decided to recieve data from the EDDN permanently\r\n" +
                                                       "but not to send to EDDN.\r\n\r\n" +
                                                       "The EDDN/EDDB lives from the data. If you want to receive data\r\n" +
                                                       "permanently, it would be fair in return also to send data.\r\n\r\n" +
                                                       "Shall I activate sending of market data for you?", 
                                                       "EDDN Network", 
                                                       MessageBoxButtons.YesNo, 
                                                       MessageBoxIcon.Question, 
                                                       MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes)
                            {
                                Program.DBCon.setIniValue(IBE.EDDN.EDDNView.DB_GROUPNAME, "AutoSend", true.ToString());

                                if(!Program.EDDNComm.SenderIsActivated)
                                    Program.EDDNComm.ActivateSender();
                            }

                            if(!Program.SplashScreen.IsDisposed)
                                Program.SplashScreen.TopMost = true;

                        }
                    }

                    if(m_NewDBVersion == new Version(0,3,0,0))
                    {
                        Program.SplashScreen.InfoAdd("checking spell of commodity names once...");

                        var count = Program.Data.CorrectMisspelledCommodities();

                        if(count > 0)
                            Program.SplashScreen.InfoAdd("checking spell of commodity names once...<OK>");
                        else
                            Program.SplashScreen.InfoAppendLast("<OK>");


                        var wasOn = Program.DBCon.getIniValue<Boolean>(IBE.EDDN.EDDNView.DB_GROUPNAME, "AutoSend", true.ToString(), false) &&
                                    Program.DBCon.getIniValue<Boolean>(IBE.EDDN.EDDNView.DB_GROUPNAME, "EDDNPostCompanionData", true.ToString(), false);;
                        if(wasOn)
                        {
                            Program.DBCon.setIniValue(IBE.EDDN.EDDNView.DB_GROUPNAME, "AutoSend",                true.ToString());
                            Program.DBCon.setIniValue(IBE.EDDN.EDDNView.DB_GROUPNAME, "EDDNPostOCRData",         true.ToString());
                            Program.DBCon.setIniValue(IBE.EDDN.EDDNView.DB_GROUPNAME, "EDDNPostCompanionData",   true.ToString());
                            Program.DBCon.setIniValue(IBE.EDDN.EDDNView.DB_GROUPNAME, "QuickDecisionDefault",    "Send");
                            Program.DBCon.setIniValue(IBE.EDDN.EDDNView.DB_GROUPNAME, "EDDNPostOutfittingData",  true.ToString());
                            Program.DBCon.setIniValue(IBE.EDDN.EDDNView.DB_GROUPNAME, "EDDNPostShipyardData",    true.ToString());
                            Program.DBCon.setIniValue(IBE.EDDN.EDDNView.DB_GROUPNAME, "QuickDecisionValue",      true.ToString());
                        }
                        else
                        { 
                            Program.DBCon.setIniValue(IBE.EDDN.EDDNView.DB_GROUPNAME, "AutoSend",                true.ToString());
                            Program.DBCon.setIniValue(IBE.EDDN.EDDNView.DB_GROUPNAME, "EDDNPostOCRData",         true.ToString());
                            Program.DBCon.setIniValue(IBE.EDDN.EDDNView.DB_GROUPNAME, "EDDNPostCompanionData",   true.ToString());
                            Program.DBCon.setIniValue(IBE.EDDN.EDDNView.DB_GROUPNAME, "QuickDecisionDefault",    "Hold");
                            Program.DBCon.setIniValue(IBE.EDDN.EDDNView.DB_GROUPNAME, "EDDNPostOutfittingData",  true.ToString());
                            Program.DBCon.setIniValue(IBE.EDDN.EDDNView.DB_GROUPNAME, "EDDNPostShipyardData",    true.ToString());
                            Program.DBCon.setIniValue(IBE.EDDN.EDDNView.DB_GROUPNAME, "QuickDecisionValue",      false.ToString());
                        }

                    }

                    if (m_NewDBVersion == new Version(0,4,0,0))
                    {
                        // at least one time this data has to be imported
                        var DataIO = new frmDataIO();

                        Program.SplashScreen.InfoAdd("importing FDevIDs for the first time...");

                        DataIO.InfoTarget = Program.SplashScreen.SplashInfo;

                        await DataIO.StartFDevIDImport(Program.GetDataPath("Data"));

                        DataIO.Close();
                        DataIO.Dispose();
                        
                        didUpdate = true;

                        Program.SplashScreen.InfoAdd("importing FDevIDs for the first time...<OK>");
                    }

                    if (m_NewDBVersion == new Version(0,5,0,0))
                    {
                        if (!Program.DBCon.getIniValue<Boolean>("EDDN", "AutoSend", true.ToString(), false))
                        {
                            Program.DBCon.setIniValue("EDDN", "AutoSend", true.ToString());

                            if(!Program.SplashScreen.IsDisposed)
                                Program.SplashScreen.TopMost = false;

                            MessageBox.Show(parent, "EDDN sender activated once, please check if not wanted.", 
                                                       "EDDN Network", 
                                                       MessageBoxButtons.OK, 
                                                       MessageBoxIcon.Question);

                            if(!Program.SplashScreen.IsDisposed)
                                Program.SplashScreen.TopMost = true;


                        }
                    }

                }
            }
            catch (Exception ex)
            {
                throw new Exception("Error while doing special things (2)", ex);
            }
        }
Example #4
0
        private async void Form_Shown_async(object sender, System.EventArgs e)
        {
            try
            {
                enableToolStripMenuItem.Checked = Program.DBCon.getIniValue<Boolean>("Debug",   "extLog_Journal", false.ToString(), false);
                debugToolStripMenuItem.Visible = enableToolStripMenuItem.Checked;

                Stopwatch st = new Stopwatch();
                st.Start();
                Version newVersion;
                String newInfo;

                Debug.Print("Zeit (1) : " + st.ElapsedMilliseconds);
                st.Start();

                Program.SplashScreen.InfoAdd("checking for updates");
                CheckUpdateExists(out newVersion, out newInfo);
                Program.SplashScreen.InfoAppendLast("<OK>");

                Debug.Print("Zeit (2) : " + st.ElapsedMilliseconds);
                st.Start();

                Program.SplashScreen.InfoAdd("load system data...");
                loadSystemData(Program.actualCondition.System);
                loadStationData(Program.actualCondition.System, Program.actualCondition.Station);
                Program.SplashScreen.InfoAppendLast("<OK>");

                Debug.Print("Zeit (3) : " + st.ElapsedMilliseconds);
                st.Start();

                Debug.Print("Zeit (4) : " + st.ElapsedMilliseconds);
                st.Start();

                Program.SplashScreen.InfoAdd("init price analysis gui");
                Program.PriceAnalysis.GUI.Init();
                Program.SplashScreen.InfoAppendLast("<OK>");

                Debug.Print("Zeit (5) : " + st.ElapsedMilliseconds);
                st.Start();

                Program.SplashScreen.InfoAdd("init commanders log gui");
                Program.CommandersLog.GUI.Init();
                Program.SplashScreen.InfoAppendLast("<OK>");

                Debug.Print("Zeit (6) : " + st.ElapsedMilliseconds);
                st.Start();

                Program.SplashScreen.InfoAdd("init system numbers");
                showSystemNumbers();
                Program.SplashScreen.InfoAppendLast("<OK>");

                Debug.Print("Zeit (7) : " + st.ElapsedMilliseconds);
                st.Start();

                Program.SplashScreen.InfoAdd("init main gui");
                SetupGui();

                ShowLocationData();
                Program.SplashScreen.InfoAppendLast("<OK>");

                Debug.Print("Zeit (8) : " + st.ElapsedMilliseconds);
                st.Start();

                Program.SplashScreen.InfoAdd("starting logfile scanner");
                //Program.JournalScanner.Start();
                Program.SplashScreen.InfoAppendLast("<OK>");

                Debug.Print("Zeit (9) : " + st.ElapsedMilliseconds);
                st.Start();

                // *******************************************************************
                await Updater.DoSpecial(this);
                // *******************************************************************

                if (Program.DBCon.getIniValue<Boolean>("EDDN", "AutoListen", false.ToString(), false))
                {
                    Program.SplashScreen.InfoAdd("starting eddn listening");
                    Program.EDDNComm.StartEDDNListening();
                    Program.SplashScreen.InfoAppendLast("<OK>");
                }

                if (Program.DBCon.getIniValue<Boolean>("EDDN", "AutoSend", true.ToString(), false))
                    Program.EDDNComm.ActivateSender();

                SetQuickDecisionSwitch();

                Debug.Print("Zeit (11) : " + st.ElapsedMilliseconds);
                st.Start();

                if (Program.DBCon.getIniValue<Boolean>(frmDataIO.DB_GROUPNAME, "AutoImportEDCDData", true.ToString(), false))
                {
                    // import new edcd data if available
                    var DataIO = new frmDataIO();

                    DataIO.InfoTarget = Program.SplashScreen.SplashInfo;

                    DataIO.StartEDCDCheck();

                    DataIO.Close();
                    DataIO.Dispose();

                }

                Debug.Print("Zeit (12) : " + st.ElapsedMilliseconds);
                st.Start();

                /// last preparations for companion io 
                ShowStatus();
                Program.CompanionIO.AsyncDataRecievedEvent += CompanionIO_AsyncDataRecievedEvent;
                if ((Program.CompanionIO.CompanionStatus == EDCompanionAPI.Models.LoginStatus.Ok) && (!Program.CompanionIO.StationHasShipyardData()))
                {
                    int? stationID = Program.actualCondition.Station_ID;

                    if ((stationID != null) && Program.DBCon.Execute<Boolean>("select has_shipyard from tbStations where id = " + stationID))
                    {
                        // probably companion error, try once again in 5 seconds
                        Program.CompanionIO.ReGet_StationData();
                    }
                }

                // inform GUI from EDSM
                Program.EDSMComm.DataTransmittedEvent += EDSMComm_DataTransmittedEvent;

                this.Enabled = true;

                Program.JournalScanner.Start();
                Program.StartVNCServer(this);

                Program.SplashScreen.InfoAdd("init sequence finished !");
                Program.SplashScreen.CloseDelayed();

            }
            catch (Exception ex)
            {
                this.Enabled = true;
                CErr.processError(ex, "Error in Form_Shown");
                Program.SplashScreen.Close();
            }
        }