Exemplo n.º 1
0
 private void Close_internal()
 {
     _CloseTimer.Dispose();
     _Logger      = null;
     SplashObject = null;
     this.Close();
 }
Exemplo n.º 2
0
        public void ShowDialog(Exception ex, string infotext)
        {
            string Info;
            Boolean oldValue = true;
            _LogPath = Program.GetDataPath("Logs");
            SingleThreadLogger _logger = new SingleThreadLogger(ThreadLoggerType.Exception, _LogPath, true);
            Exception currentException = ex;

            String errorMessage = GetErrorMessage(ref infotext, currentException);

            _logger.Log(errorMessage);

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

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

            this.ShowDialog();


            if (!Program.SplashScreen.IsDisposed)
            {
                Program.SplashScreen.TopMost = oldValue;
            }
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
 void _CloseTimer_Tick(object sender, EventArgs e)
 {
     _CloseTimer.Dispose();
     _Logger = null;
     this.Close();
 }
Exemplo n.º 5
0
        /// <summary>
        /// starts the initialization of the global objects
        /// </summary>
        public static void Init()
        {
            try
            {
                if(!m_initDone)
                {
                    Program.SplashScreen = new SplashScreenForm();
                    Program.SplashScreen.Show();

                    Program.SplashScreen.InfoAdd("initializing logger...");
                    Program.Logger = new SingleThreadLogger(ThreadLoggerType.Form);
                    Program.Logger.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);

                    // 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<Int16>("DB_Server", "Port",             "3306");
                    newProcessParams.DBStartTimeout             = IniFile.GetValue<Int16>("DB_Server", "DBStartTimeout",   "60");

                    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.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",        "60");

                    DBCon                                       = new DBConnector(newConnectionParams);

                    DBCon.Connect();

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

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

                    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();

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

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

                    // forwards a potentially new system or station information to database
                    Program.LogfileScanner.LocationInfo += LogfileScanner_LocationInfo;
                    Program.ExternalData.LocationInfo   += ExternalData_LocationInfo;

                    // register the LogfileScanner in the CommandersLog for the ExternalDataEvent-event
                    CommandersLog.registerLogFileScanner(LogfileScanner);
                    CommandersLog.registerExternalTool(ExternalData);

                    PriceAnalysis.registerLogFileScanner(LogfileScanner);
                    PriceAnalysis.registerExternalTool(ExternalData);

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

                    m_initDone = true;

                }
            }
            catch (Exception ex)
            {
                cErr.processError(ex, "Error while initializing the program object", true);
            }
        }
Exemplo n.º 6
0
        public bool Start(IPAddress ipAddress, int port, int maxNOfCon, string contentPath, Form1 callingForm)
        {
            _callingForm = callingForm;

            _logger = new SingleThreadLogger(ThreadLoggerType.Webserver);

            if (Running)
            {
                return(false);         // If it is already running, exit.
            }
            Running = true;
            //try
            {
                // A tcp/ip socket (ipv4)
                _serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
                                           ProtocolType.Tcp);
                _serverSocket.Bind(new IPEndPoint(ipAddress, port));
                _serverSocket.Listen(maxNOfCon);
                _serverSocket.ReceiveTimeout = timeout;
                _serverSocket.SendTimeout    = timeout;

                this._contentPath = contentPath;
            }
            //catch { return false; }

            // Our thread that will listen connection requests
            // and create new threads to handle them.
            _requestListenerT = new Thread(() =>
            {
                while (Running)
                {
                    Socket clientSocket;
                    try
                    {
                        clientSocket = _serverSocket.Accept();
                        // Create new thread to handle the request and continue to listen the socket.
                        Thread requestHandler = new Thread(() =>
                        {
                            clientSocket.ReceiveTimeout = timeout;
                            clientSocket.SendTimeout    = timeout;
                            try { HandleRequest(clientSocket); }
                            catch (Exception)
                            {
                                try { clientSocket.Close(); }
                                catch (Exception ex2)
                                {
                                    _logger.Log("Error in webserver start 2:");
                                    _logger.Log(ex2.ToString());
                                    _logger.Log(ex2.Message);
                                    _logger.Log(ex2.StackTrace);
                                    if (ex2.InnerException != null)
                                    {
                                        _logger.Log(ex2.InnerException.ToString());
                                    }
                                }
                            }
                        });
                        requestHandler.Start();
                    }
                    catch (Exception ex)
                    {
                        _logger.Log("Error in webserver start 1:");
                        _logger.Log(ex.ToString());
                        _logger.Log(ex.Message);
                        _logger.Log(ex.StackTrace);
                        if (ex.InnerException != null)
                        {
                            _logger.Log(ex.InnerException.ToString());
                        }
                    }
                }
            });
            _requestListenerT.Start();

            return(true);
        }
Exemplo n.º 7
0
        public bool Start(IPAddress ipAddress, int port, int maxNOfCon, string contentPath, Form1 callingForm)
        {
            _callingForm = callingForm;

            _logger = new SingleThreadLogger(ThreadLoggerType.Webserver);

            if (Running) return false; // If it is already running, exit.
            Running = true;
            //try
            {
                // A tcp/ip socket (ipv4)
                _serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
                               ProtocolType.Tcp);
                _serverSocket.Bind(new IPEndPoint(ipAddress, port));
                _serverSocket.Listen(maxNOfCon);
                _serverSocket.ReceiveTimeout = timeout;
                _serverSocket.SendTimeout = timeout;

                this._contentPath = contentPath;
            }
            //catch { return false; }

            // Our thread that will listen connection requests
            // and create new threads to handle them.
            _requestListenerT = new Thread(() =>
            {
                while (Running)
                {
                    Socket clientSocket;
                    try
                    {
                        clientSocket = _serverSocket.Accept();
                        // Create new thread to handle the request and continue to listen the socket.
                        Thread requestHandler = new Thread(() =>
                        {
                            clientSocket.ReceiveTimeout = timeout;
                            clientSocket.SendTimeout = timeout;
                            try { HandleRequest(clientSocket); }
                            catch (Exception)
                            {

                                try { clientSocket.Close(); }
                                catch (Exception ex2)
                                {
                                _logger.Log("Error in webserver start 2:", true);
                                _logger.Log(ex2.ToString(), true);
                                _logger.Log(ex2.Message, true);
                                _logger.Log(ex2.StackTrace, true);
                                if (ex2.InnerException != null)
                                    _logger.Log(ex2.InnerException.ToString(), true);

                                }
                            }
                        });
                        requestHandler.Start();
                    }
                    catch (Exception ex)
                    {
                        _logger.Log("Error in webserver start 1:", true);
                        _logger.Log(ex.ToString(), true);
                        _logger.Log(ex.Message, true);
                        _logger.Log(ex.StackTrace, true);
                        if (ex.InnerException != null)
                            _logger.Log(ex.InnerException.ToString(), true);
                    }
                }
            });
            _requestListenerT.Start();

            return true;
        }