GetDataPath() public static method

Gets a path where data (logs/dumps/other data) can be saved. Default is the program path (development) or the data path which is by default "{localappdata}\ED-IBE\"
public static GetDataPath ( String subPath = "" ) : String
subPath String subpath to be added (optional)
return String
示例#1
0
        public static RegulatedNoiseSettings LoadSettings()
        {
            var serializer = new XmlSerializer(typeof(RegulatedNoiseSettings));

            if (File.Exists(Program.GetDataPath("RegulatedNoiseSettings.xml")))
            {
                var fs     = new FileStream(Program.GetDataPath("RegulatedNoiseSettings.xml"), FileMode.Open);
                var reader = XmlReader.Create(fs);

                try
                {
                    instance = (RegulatedNoiseSettings)serializer.Deserialize(reader);
                }
                catch (Exception)
                {
                    instance = new RegulatedNoiseSettings();
                }
                fs.Close();
            }
            else
            {
                instance = new RegulatedNoiseSettings();
            }

            return(instance);
        }
示例#2
0
        public void ShowDialog(Exception ex, string infotext, Boolean ignoreAllowed)
        {
            string Info;

            _LogPath = Program.GetDataPath("Logs");
            SingleThreadLogger _logger          = new SingleThreadLogger(ThreadLoggerType.Exception, _LogPath, true);
            Exception          currentException = ex;

            String errorMessage = GetErrorMessage(ref infotext, currentException);

            _logger.Log(errorMessage);

            cmdIgnore.Visible = ignoreAllowed;

            txtErrorDetail.Text            = errorMessage;
            lblErrorInfo.Text              = infotext;
            lblLogDestination.Text         = string.Format("(Logfile : {0})", _logger.logPathName);
            txtErrorDetail.SelectionStart  = 0;
            txtErrorDetail.SelectionLength = 0;


            SplashScreenForm.SetTopmost(false);
            if (SplashScreenForm.GetPrimaryGUI(Program.MainForm).InvokeRequired)
            {
                SplashScreenForm.GetPrimaryGUI(Program.MainForm).Invoke(new ShowDialogInvokedDelegate(ShowDialogInvoked), ex, infotext);
            }
            else
            {
                ShowDialogInvoked(ex, infotext);
            }


            SplashScreenForm.SetTopmost(true);
        }
示例#3
0
        private void dgvData_CurrentCellChanged(object sender, EventArgs e)
        {
            StringBuilder SBuilder = new StringBuilder();

            suspendTextChanged = true;

            lastRow = currentRow;
            if (dgvData.CurrentRow != null)
            {
                currentRow = dgvData.CurrentRow.Index;
            }
            else
            {
                currentRow = -1;
            }

            if (lastRow >= 0)
            {
                for (int i = 0; i < 12; i++)
                {
                    if (i > 0)
                    {
                        SBuilder.Append(";");
                    }

                    SBuilder.Append(dgvData.Rows[lastRow].Cells[i].Value.ToString());
                }

                bool implausible = Program.PlausibiltyCheck.CheckPricePlausibility(new string[] { SBuilder.ToString() });
                dgvData.Rows[lastRow].Cells[12].Value = implausible.ToString();

                setRowStyle(dgvData.Rows[lastRow], implausible);
            }

            if (dgvData.CurrentRow != null)
            {
                string rowId = dgvData.CurrentRow.Cells[11].Value.ToString();

                if (pbEditOcrResultsOriginalImage.Image != null)
                {
                    pbEditOcrResultsOriginalImage.Image.Dispose();
                }

                if (File.Exists(Program.GetDataPath(@"OCR Correction Images\" + rowId + ".png")))
                {
                    pbEditOcrResultsOriginalImage.Image = Bitmap.FromFile(Program.GetDataPath(@"OCR Correction Images\" + rowId + ".png"));
                }

                tbEditOcrResultsCommodityName.Text = dgvData.CurrentRow.Cells[2].Value.ToString();
                tbEditOcrResultsSellPrice.Text     = dgvData.CurrentRow.Cells[3].Value.ToString();
                tbEditOcrResultsBuyPrice.Text      = dgvData.CurrentRow.Cells[4].Value.ToString();
                tbEditOcrResultsDemand.Text        = dgvData.CurrentRow.Cells[5].Value.ToString();
                tbEditOcrResultsDemandLevel.Text   = dgvData.CurrentRow.Cells[6].Value.ToString();
                tbEditOcrResultsSupply.Text        = dgvData.CurrentRow.Cells[7].Value.ToString();
                tbEditOcrResultsSupplyLevel.Text   = dgvData.CurrentRow.Cells[8].Value.ToString();
            }

            suspendTextChanged = false;
        }
示例#4
0
        private void cmdChangeSQLPort_Click(object sender, EventArgs e)
        {
            try
            {
                UInt16 newPort;
                UInt16 oldPort;

                if (UInt16.TryParse(txtSQLConnectionPort.Text, out newPort))
                {
                    Boolean isOccupied = DBProcess.IsListenerOnPort(newPort) || DBProcess.IsConnectionOnPort(newPort);

                    if (!isOccupied)
                    {
                        oldPort = Program.IniFile.GetValue <UInt16>("DB_Server", "Port", "3306");

                        if (MessageBox.Show(this, "Change db-port from " + oldPort + " to " + newPort + " ?", "Aborted", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK)
                        {
                            // switch off the general log for the database
                            STA.Settings.INIFile dbIniFile;

                            if (Debugger.IsAttached)
                            {
                                dbIniFile = new STA.Settings.INIFile(Path.Combine(Program.IniFile.GetValue("DB_Server", "WorkingDirectory", @"..\..\..\RNDatabase\Database"), "Elite.ini"), false, true, true);
                            }
                            else
                            {
                                dbIniFile = new STA.Settings.INIFile(Program.GetDataPath(@"Database\Elite.ini"), false, true, true);
                            }

                            Program.IniFile.SetValue("DB_Server", "Port", newPort.ToString());
                            dbIniFile.SetValue("mysqld", "port", newPort.ToString());

                            MessageBox.Show(this, "Port changed, restart required.", "Changed configuration", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            txtSQLConnectionPort.Text = Program.IniFile.GetValue <UInt16>("DB_Server", "Port", "3306").ToString();
                        }
                    }
                    else
                    {
                        MessageBox.Show(this, "Selected port is already occupied", "Aborted", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        txtSQLConnectionPort.Text = Program.IniFile.GetValue <UInt16>("DB_Server", "Port", "3306").ToString();
                    }
                }
                else
                {
                    MessageBox.Show(this, "Couldn't parse value as <UInt16>", "Aborted", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtSQLConnectionPort.Text = Program.IniFile.GetValue <UInt16>("DB_Server", "Port", "3306").ToString();
                }
            }
            catch (Exception ex)
            {
                CErr.processError(ex, "Error while changing the tcp-port of the sql-server");
            }
        }
示例#5
0
        /// <summary>
        /// selects another "traineddata" file for TesseractOCR
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdSelectTraineddataFile_Click(object sender, EventArgs e)
        {
            OpenFileDialog OCRFile = new OpenFileDialog();

            OCRFile.Filter           = "Tesseract-Files|*.traineddata|All Files|*.*";
            OCRFile.FileName         = Program.DBCon.getIniValue <String>(IBE.IBESettingsView.DB_GROUPNAME, "TraineddataFile");
            OCRFile.InitialDirectory = Program.GetDataPath("tessdata");
            OCRFile.Title            = "select Tesseract Traineddata-File...";

            if (OCRFile.ShowDialog(this) == DialogResult.OK)
            {
                txtOCRTraineddataFile.Text = System.IO.Path.GetFileNameWithoutExtension(OCRFile.FileName);
                m_GUIInterface.saveSetting(txtOCRTraineddataFile);
            }
        }
示例#6
0
        private Int32 maxFileSize = 10 * 1024 * 1024; // max. file size in MB

        public SingleThreadLogger(ThreadLoggerType threadLoggerType, String destPath = "", Boolean reuseLog = false)
        {
            if (String.IsNullOrEmpty(destPath))
            {
                destPath = Program.GetDataPath("Logs");
            }

            if (!Directory.Exists(destPath))
            {
                Directory.CreateDirectory(destPath);
            }

            if (reuseLog)
            {
                _logPathName = Path.Combine(destPath, string.Format("{0}.log", threadLoggerType));
            }
            else
            {
                _logPathName = Path.Combine(destPath, string.Format("{0}_{1:yyyy-MM-dd HH-mm-ss}.log", threadLoggerType, DateTime.UtcNow));
            }
        }
示例#7
0
文件: Program.cs 项目: mlof/ED-IBE
        /// <summary>
        /// starts the initialization of the global objects
        /// </summary>
        public static void Init()
        {
            try
            {
                if (!m_initDone)
                {
                    Program.SplashScreen.Logger = MainLog;

                    Program.SplashScreen.InfoAdd("initializing logger...");
                    Program.MainLog.Log("Initialising...\n");
                    Program.SplashScreen.InfoAppendLast("<OK>");

                    Program.SplashScreen.InfoAdd("starting sql server...");

                    // load settings from file
                    IniFile = new STA.Settings.INIFile(GetDataPath("ED-IBE.ini"), false, true);


                    // prepare architecture-dependend files
                    PrepareDepFiles();

                    // start database process (if not running)
                    DBProcess.DBProcessParams newProcessParams = new DBProcess.DBProcessParams()
                    {
                    };
                    newProcessParams.Commandline      = IniFile.GetValue("DB_Server", "Commandline", @"bin\mysqld.exe");
                    newProcessParams.Commandargs      = IniFile.GetValue("DB_Server", "CommandArgs", @"--defaults-file=Elite.ini --console");
                    newProcessParams.Workingdirectory = IniFile.GetValue("DB_Server", "WorkingDirectory", @"..\..\..\RNDatabase\Database");
                    newProcessParams.Port             = IniFile.GetValue <UInt16>("DB_Server", "Port", "3306");
                    newProcessParams.DBStartTimeout   = IniFile.GetValue <Int16>("DB_Server", "DBStartTimeout", "60");

                    Program.SplashScreen.InfoAppendLast("on port " + newProcessParams.Port + "...");

                    EliteDBProcess = new DBProcess(newProcessParams);

                    if (EliteDBProcess.WasRunning)
                    {
                        Program.SplashScreen.InfoAppendLast("already running...<OK>");
                    }
                    else
                    {
                        Program.SplashScreen.InfoAppendLast("<OK>");
                    }



                    // connecT to the database
                    Program.SplashScreen.InfoAdd("connect to sql server...");

                    DBConnector.ConnectionParams newConnectionParams = new DBConnector.ConnectionParams()
                    {
                    };

                    newConnectionParams.Name           = IniFile.GetValue("DB_Connection", "Name", "master");
                    newConnectionParams.Server         = IniFile.GetValue("DB_Connection", "Server", "localhost");
                    newConnectionParams.Port           = IniFile.GetValue <UInt16>("DB_Server", "Port", "3306");
                    newConnectionParams.Database       = IniFile.GetValue("DB_Connection", "Database", "Elite_DB");
                    newConnectionParams.User           = IniFile.GetValue("DB_Connection", "User", "RN_User");
                    newConnectionParams.Pass           = IniFile.GetValue("DB_Connection", "Pass", "Elite");
                    newConnectionParams.ConnectTimeout = IniFile.GetValue <Int16>("DB_Connection", "ConnectTimeout", "60");
                    newConnectionParams.StayAlive      = IniFile.GetValue <Boolean>("DB_Connection", "StayAlive", "false");
                    newConnectionParams.TimeOut        = IniFile.GetValue <Int16>("DB_Connection", "TimeOut", "10000");

                    DBCon = new DBConnector(newConnectionParams);

                    DBCon.Connect();

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

                    /* **************** database is running ********************** */

                    /* perform updates */
                    Updater.DBUpdate();

                    if (DBCon.getIniValue <Boolean>(IBESettingsView.DB_GROUPNAME, "AutoMinimize", false.ToString(), false))
                    {
                        Program.SplashScreen.AutoMinimizeAsync();
                    }

                    Program.SplashScreen.InfoAdd("preparing global objects...");

                    // prepare colors-object
                    Colors = new GUIColors();

                    // preprare main data object
                    Data = new IBE.SQL.EliteDBIO();
                    Data.PrepareBaseTables();

                    // create global paths-object
                    //Paths                                       = new ProgramPaths();

                    // prepare settings
//                    Settings                                    = new Settings();
//                    Settings.BaseData                           = Data.BaseData;

                    // prepare commanders log
                    CommandersLog          = new CommandersLog();
                    CommandersLog.BaseData = Data.BaseData;

                    // prepare price analysis
                    PriceAnalysis          = new PriceAnalysis(new DBConnector(DBCon.ConfigData, true));
                    PriceAnalysis.BaseData = Data.BaseData;

                    //// starting the external data interface
                    //ExternalData                                = new ExternalDataInterface();

                    // Companion IO
                    CompanionIO = new IBECompanion.CompanionData(Program.GetDataPath());
                    if (CompanionIO.ConditionalLogIn())
                    {
                        CompanionIO.GetProfileDataAsync();
                    }

                    // initializing the object for the actual condition
                    actualCondition = new Condition();

                    // initializing the LogfileScanner
                    //LogfileScanner                              = new EDLogfileScanner();
                    JournalScanner = new EDJournalScanner();

                    // EDDN Interface
                    EDDNComm = new IBE.EDDN.EDDNCommunicator();

                    // EDSMComm Interface
                    EDSMComm = new IBE.EDSM.EDStarmapInterface(Program.DBCon);

                    CommandersLog.registerJournalScanner(JournalScanner);
                    CommandersLog.registerExternalTool(CompanionIO);

                    CompanionIO.registerJournalScanner(JournalScanner);

                    PriceAnalysis.registerJournalScanner(JournalScanner);
                    PriceAnalysis.registerExternalTool(CompanionIO);

                    EDSMComm.registerJournalScanner(JournalScanner);

                    actualCondition.RegisterJournalScanner(JournalScanner);
                    EDDNComm.RegisterJournalScanner(JournalScanner);


                    // Plausibility-Checker
                    PlausibiltyCheck = new PlausibiltyChecker();

                    /// early variant of DoSpecial();
                    Updater.DoSpecial_Early();

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

                    m_initDone = true;
                }
            }
            catch (Exception ex)
            {
                CErr.processError(ex, "Error while initializing the program object");
            }
        }
示例#8
0
        /// <summary>
        /// imports the market data from a csv file
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdImportFromCSV_Click(object sender, EventArgs e)
        {
            EliteDBIO.enLocalizationType       activeSetting;
            EliteDBIO.enLocalisationImportType importType;

            String infoString;
            String parameterName;

            try
            {
                parameterName = gbType.Tag.ToString().Split(new char[] { ';' })[0];
                activeSetting = m_DBCon.getIniValue <EliteDBIO.enLocalizationType>(DB_GROUPNAME, parameterName, EliteDBIO.enLocalizationType.Commodity.ToString(), false);

                if (rbImportOnlyNew.Checked)
                {
                    importType = EliteDBIO.enLocalisationImportType.onlyNew;
                }
                else if (rbImportOverwriteButBase.Checked)
                {
                    importType = EliteDBIO.enLocalisationImportType.overwriteNonBase;
                }
                else if (rbImportIntelligent.Checked)
                {
                    importType = EliteDBIO.enLocalisationImportType.intelligent;
                }
                else
                {
                    importType = EliteDBIO.enLocalisationImportType.overWriteAll;
                }


                switch (activeSetting)
                {
                case EliteDBIO.enLocalizationType.Commodity:
                    infoString = "Import commodity localisation data";
                    break;

                case EliteDBIO.enLocalizationType.Category:
                    infoString = "Import category localisation data";
                    break;

                case EliteDBIO.enLocalizationType.Economylevel:
                    infoString = "Import economy localisation data";
                    break;

                default:
                    throw new Exception("unknown setting :  " + activeSetting);
                }

                OpenFileDialog openFileDialog1 = new OpenFileDialog();

                openFileDialog1.Filter           = "csv files (*.csv)|*.csv|All files (*.*)|*.*";
                openFileDialog1.DefaultExt       = "csv";
                openFileDialog1.Title            = infoString;
                openFileDialog1.InitialDirectory = m_DBCon.getIniValue("General", "Path_Import", Program.GetDataPath("data"), false);

                DialogResult result = openFileDialog1.ShowDialog();

                if (result == DialogResult.OK)
                {
                    Cursor = Cursors.WaitCursor;

                    Program.Data.ImportLocalizationDataFromCSV(openFileDialog1.FileName, activeSetting, importType);

                    Program.Data.CleanupCommoditynames();
                    Program.Data.AddMissingLocalizationEntries();
                    Program.Data.updateTranslation();
                    Program.Data.PrepareBaseTables("tbcommodity");
                    Program.Data.PrepareBaseTables("tbcommoditylocalization");
                    Program.Data.PrepareBaseTables("tbcommoditybase");

                    Cursor = Cursors.Default;
                }

                LoadData();
            }
            catch (Exception ex)
            {
                Cursor = Cursors.Default;
                CErr.processError(ex, "Error while importing from csv");
            }
        }
示例#9
0
        /// <summary>
        /// exports the market data to a csv file
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdExportCSV_Click(object sender, EventArgs e)
        {
            EliteDBIO.enLocalizationType activeSetting;
            String infoString;
            String parameterName;

            try
            {
                parameterName = gbType.Tag.ToString().Split(new char[] { ';' })[0];
                activeSetting = m_DBCon.getIniValue <EliteDBIO.enLocalizationType>(DB_GROUPNAME, parameterName, EliteDBIO.enLocalizationType.Commodity.ToString(), false);

                switch (activeSetting)
                {
                case EliteDBIO.enLocalizationType.Commodity:
                    infoString = "Export commodity localisation data";
                    break;

                case EliteDBIO.enLocalizationType.Category:
                    infoString = "Export category localisation data";
                    break;

                case EliteDBIO.enLocalizationType.Economylevel:
                    infoString = "Export economy localisation data";
                    break;

                default:
                    throw new Exception("unknown setting :  " + activeSetting);
                }

                SaveFileDialog saveFileDialog1 = new SaveFileDialog();

                saveFileDialog1.Filter           = "csv files (*.csv)|*.csv|All files (*.*)|*.*";
                saveFileDialog1.DefaultExt       = "csv";
                saveFileDialog1.Title            = infoString;
                saveFileDialog1.OverwritePrompt  = true;
                saveFileDialog1.InitialDirectory = m_DBCon.getIniValue("General", "Path_Import", Program.GetDataPath("data"), false);

                DialogResult result = saveFileDialog1.ShowDialog();

                if (result == DialogResult.OK)
                {
                    Cursor = Cursors.WaitCursor;

                    Program.Data.ExportLocalizationDataToCSV(saveFileDialog1.FileName, activeSetting);

                    Cursor = Cursors.Default;
                }
            }
            catch (Exception ex)
            {
                Cursor = Cursors.Default;
                CErr.processError(ex, "Error while exporting to csv");
            }
        }
示例#10
0
        private void cmdDumpfile_Click(object sender, EventArgs e)
        {
            String filename = String.Format("ed-ibe-dump-v{0}.dmp", IBE.Enums_and_Utility_Classes.VersionHelper.Parts(System.Reflection.Assembly.GetExecutingAssembly().GetName().Version, 3).Replace(".", "_"));;
            String subPath  = @"Logs\" + filename;

            Program.CreateMiniDump(subPath);
            MessageBox.Show("A dump file (\"" + filename + "\") has been created in " + Program.GetDataPath("Logs") + "\r\n\r\n" +
                            "You may place this in a file-sharing service such as SendSpace, Google Drive or Dropbox," +
                            "then link to the file in the Frontier forums or on the GitHub archive or send e mail to [email protected] . " +
                            "This will allow the developer to fix this problem.  \r\n\r\nThanks, and sorry about the crash...");
        }