Beispiel #1
0
 public frmMSMSWizard(clsRconnect rconn)
 {
     rConnector = rconn;
     InitializeComponent();
     Init();
     //
     // backgroundWorker1
     //
     this.backgroundWorker1.WorkerReportsProgress = true;
     this.backgroundWorker1.DoWork += this.backgroundWorker1_DoWork;
     this.backgroundWorker1.RunWorkerCompleted += this.backgroundWorker1_RunWorkerCompleted;
     this.backgroundWorker1.ProgressChanged += this.backgroundWorker1_WorkProgressChanged;
 }
Beispiel #2
0
        public frmDAnTEmdi(string danteFilePath, string customLogFilePath)
        {
            mSessionFile = danteFilePath;

            InitializeComponent();

            if (!string.IsNullOrEmpty(customLogFilePath))
            {
                mCustomLoggerEnabled = true;

                if (File.Exists(customLogFilePath))
                {
                    mCustomLogWriter = File.AppendText(customLogFilePath);
                }
                else
                {
                    mCustomLogWriter = new StreamWriter(customLogFilePath);
                }
            }

            this.Text = "InfernoRDN"; //Application.ProductVersion.ToString();

            var startupErrString = new StringBuilder();

            SplashScreen.ShowSplashScreen();
            Application.DoEvents();

            Log(mCustomLoggerEnabled, string.Format("Starting Inferno [{0}]...", DateTime.Now), mCustomLogWriter);
            SplashScreen.SetStatus(string.Format("Starting Inferno [{0}]...", DateTime.Now));
            System.Threading.Thread.Sleep(100);
            SplashScreen.SetStatus("Reading Configuration Parameters...");

            if (!ConfigParameters())
            {
                Log(mCustomLoggerEnabled, "Error: Error in reading inferno.conf file.", mCustomLogWriter);
                startupErrString.Append("* Error in reading inferno.conf file.").AppendLine();
                //SplashScreen.CloseForm();
                //MessageBox.Show("Error in reading inferno.conf file.",
                //    "inferno.conf error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                //this.Close();
            }
            Log(mCustomLoggerEnabled, "Done reading configuration parameters.", mCustomLogWriter);

            SplashScreen.SetStatus("Initializing Folders...");

            // Initialize folders
            var tempFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

            var appDataFldrPath = Path.Combine(tempFolderPath, "Inferno");
            if (!Directory.Exists(appDataFldrPath))
            {
                Directory.CreateDirectory(appDataFldrPath);
            }

            mRTempFilePath = appDataFldrPath.Replace(@"\", "/") + "/_temp.png";
            mhelpProviderDAnTE.HelpNamespace = Path.Combine(Application.StartupPath, "InfernoHelp.chm");

            System.Threading.Thread.Sleep(10);
            Log(mCustomLoggerEnabled, "Done setting folders.", mCustomLogWriter);

            SplashScreen.SetStatus("Establishing Connection to R...");
            mRConnector = new clsRconnect();
            if (!mRConnector.initR())
            {
                startupErrString.Append(string.Format("* R failed to initialize: {0}", mRConnector.Message)).AppendLine();
                //SplashScreen.CloseForm();
                //MessageBox.Show("Try again. R failed to initialize for some unknown reason.",
                //    "R connection failed.", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                Log(mCustomLoggerEnabled, "Error: Connection to R failed.", mCustomLogWriter);
                //this.Close();
            }
            System.Threading.Thread.Sleep(10);
            Log(mCustomLoggerEnabled, "Done Connecting to R.", mCustomLogWriter);

            SplashScreen.SetStatus("Initializing R Functions...");
            if (!LoadRfunctions("Inferno.RData"))
            {
                startupErrString.Append("* Error in sourcing R functions.").AppendLine();
                //SplashScreen.CloseForm();
                //MessageBox.Show("Error in sourcing R functions", "Initializing R error",
                //    MessageBoxButtons.OK, MessageBoxIcon.Error);
                Log(mCustomLoggerEnabled, "Error: Sourcing R functions failed.", mCustomLogWriter);
                //this.Close();
            }
            Log(mCustomLoggerEnabled, "Done sourcing R functions.", mCustomLogWriter);

            SplashScreen.SetStatus("Initializing R Plotting Functions...");

            var usePlotgg = Settings.Default.useGG;
            string mstrPlotFuncFileName;

            if (usePlotgg)
                mstrPlotFuncFileName = "Inferno_ggplots.RData";
            else
                mstrPlotFuncFileName = "Inferno_stdplots.RData";

            if (!LoadRfunctions(mstrPlotFuncFileName))
            {
                startupErrString.Append("* Error in sourcing R plotting functions.").AppendLine();
                //SplashScreen.CloseForm();
                //MessageBox.Show("Error in sourcing R plotting functions", "Initializing R error",
                //    MessageBoxButtons.OK, MessageBoxIcon.Error);
                Log(mCustomLoggerEnabled, "Error: Sourcing R plotting functions failed.", mCustomLogWriter);
                //this.Close();
            }
            Log(mCustomLoggerEnabled, "Done sourcing R plotting functions.", mCustomLogWriter);

            //if (!InitLoadRpackages()) {
            //  startupErrString.Append("* Error loading key R packages.").AppendLine();
            //  //SplashScreen.CloseForm();
            //  //MessageBox.Show("Error loading key R packages", "Error loading key R packs",
            //  //    MessageBoxButtons.OK, MessageBoxIcon.Error);
            //  Log(mblLog, "Error: Loading key R packages failed.", logwriter);
            //  //this.Close();
            //}
            //Log(mblLog, "Done loading key R packages.", logwriter);
            ////InitLoadRpackages();
            System.Threading.Thread.Sleep(10);

            SplashScreen.SetStatus("Checking R version...");
            if (!CheckRVersion("2", "8.0"))
            {
                startupErrString.Append("* R version is not compatible. Install a more recent version.").AppendLine();
                //SplashScreen.CloseForm();
                //MessageBox.Show("R version is not compatible." + Environment.NewLine +
                //    "Please install R version 2.9.x." + Environment.NewLine +
                //    "R can be downloaded from http://cran.r-project.org/",
                //    "R version incompatible", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Log(mCustomLoggerEnabled, "Error: R version incompatible.", mCustomLogWriter);
                //this.Close();
            }
            System.Threading.Thread.Sleep(10);

            SplashScreen.SetStatus(SplashScreen.VALIDATING_R_PACKAGES);

            if (!InstallRequiredRPackages())
            {
                startupErrString.Append("* R failed to install required packages.").AppendLine();
                //SplashScreen.CloseForm();
                //MessageBox.Show("Try again. R failed to install required packages." + Environment.NewLine +
                //    "If this is the first time you run Inferno after installing, check permissions to modify R install folder, else " +
                //    "try changing the repository in the inferno.conf file.",
                //    "R problem...", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                Log(mCustomLoggerEnabled, "Error: Loading required R packages failed.", mCustomLogWriter);
                //this.Close();
            }
            Log(mCustomLoggerEnabled, "Done loading required R packages.", mCustomLogWriter);
            System.Threading.Thread.Sleep(10);

            SplashScreen.SetStatus("Cleaning up temp files; checking for " + mRTempFilePath.Replace("/", @"\"));
            if (!DeleteTempFile())
            {
                // This is not a fatal error
                // Log it, but move on
                startupErrString.Append("* Error cleaning temp files.").AppendLine();
                Log(mCustomLoggerEnabled, "Error: Cleaning temp files failed.", mCustomLogWriter);
            }
            System.Threading.Thread.Sleep(10);

            // No longer used (only used on Windows XP and 2000)
            //
            //SplashScreen.SetStatus("Setting Up Child Forms...");
            //if (RunRlogs())
            //{
            //    mRmsgForm = new frmRmsg();
            //    try
            //    {
            //        //-// rConnector.SetCharacterOutputDevice((StatConnectorCommonLib.IStatConnectorCharacterDevice)mfrmRmsg.axStatConnectorCharacterDevice1.GetOcx());
            //        mRConnector.EvaluateNoReturn("print(version)");
            //        Log(mCustomLoggerEnabled, "Done starting R log viewer.", mCustomLogWriter);
            //    }
            //    catch (Exception ex)
            //    {
            //        startupErrString.Append("* Error starting R log viewer.").AppendLine();
            //        //MessageBox.Show("Error: " + ex.Message, "Watchout!");
            //        Log(mCustomLoggerEnabled, "Error: Error starting R log viewer." + ex.Message, mCustomLogWriter);
            //    }
            //}
            //else
            //{
            //    Log(mCustomLoggerEnabled, "R log viewer not used for this OS.", mCustomLogWriter);
            //}

            this.Activate();
            SplashScreen.CloseForm();

            Log(mCustomLoggerEnabled, "Inferno started.", mCustomLogWriter);
            if (startupErrString.Length > 1)
            {
                var errorMessage = startupErrString.ToString();
                if (!string.IsNullOrEmpty(clsRCmdLog.CurrentLogFilePath))
                {
                    errorMessage += "\nFor more information, see file " + clsRCmdLog.CurrentLogFilePath;
                }

                MessageBox.Show(errorMessage, "Errors Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }