示例#1
0
        public void BlakeRecentDocs()
        {
            var r = new RecentDocs();

            var reg = new RegistryHive(@"D:\SynologyDrive\Registry\NTUSER_dblake.DAT");

            reg.ParseHive();

            var key = reg.GetKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs");

            Check.That(r.Values.Count).IsEqualTo(0);

            r.ProcessValues(key);

            Check.That(r.Values.Count).IsEqualTo(192);
            Check.That(r.Errors.Count).IsEqualTo(0);

            var ff = (RecentDoc)r.Values[0];

            Check.That(ff.ValueName).IsEqualTo("83");
            Check.That(ff.Extension).Contains("RecentDocs");
        }
示例#2
0
        public App()
        {
            //25Aug2017 To see how Date fomatting changes in the Datagrid
            Thread.CurrentThread.CurrentCulture   = new CultureInfo("en-US");//US English en-US
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");

            //Calling order found was:: Dispatcher -> Main Window -> XAML Application Dispatcher -> Unhandeled
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            Dispatcher.UnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(Dispatcher_UnhandledException);
            Application.Current.DispatcherUnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(Application_DispatcherUnhandledException);

            MainWindow mwindow = container.Resolve <MainWindow>();

            container.RegisterInstance <MainWindow>(mwindow);///new line
            mwindow.Show();
            mwindow.Visibility = Visibility.Hidden;

            ShowProgressbar();

            bool BlueSkyFound = true;

            string upath      = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "BlueSky");;//Per User path
            string applogpath = BSkyAppData.RoamingUserBSkyLogPath;

            DirectoryHelper.UserPath = upath;

            LifetimeService.Instance.Container = container;
            container.RegisterInstance <ILoggerService>(new LoggerService(applogpath));

            //Check if user profies has got old files. If so overwrite all(dialogs, modelclasses and other xmls, txt etc.)
            bool hasOldUserContent = CheckIfOldInUserProfile();

            //Copy folders inside Bin/Config to User profile BlueSky\config.
            if (hasOldUserContent)
            {
                CopyL18nDialogsToUserRoamingConfig();
            }

            //copy config file to user profile.
            CopyNewAndRetainOldSettings(string.Format(@"{0}BlueSky.exe.config", "./"),
                                        string.Format(@"{0}BlueSky.exe.config", BSkyAppData.RoamingUserBSkyConfigPath));

            container.RegisterInstance <IConfigService>(new ConfigService());                   //For App Config file

            container.RegisterInstance <IAdvancedLoggingService>(new AdvancedLoggingService()); //For Advanced Logging
            ////////////// TRY LOADING BSKY R PACKAGES HERE  /////////

            ILoggerService logService = container.Resolve <ILoggerService>();

            logService.SetLogLevelFromConfig();                                               //loading log level from config file
            logService.WriteToLogLevel("R.Net,Logger and Config loaded:", LogLevelEnum.Info); ///

            ////Recent default packages. This code must appear before loading any R package. (including BlueSky R package)
            XMLitemsProcessor defaultpackages = container.Resolve <XMLitemsProcessor>();//06Feb2014

            defaultpackages.MaxRecentItems = 100;
            if (hasOldUserContent)
            {
                CopyIfNotExistsOrOld(string.Format(@"{0}DefaultPackages.xml", BSkyAppData.BSkyAppDirConfigPath), string.Format(@"{0}DefaultPackages.xml", BSkyAppData.RoamingUserBSkyConfigPath));
            }
            defaultpackages.XMLFilename = string.Format(@"{0}DefaultPackages.xml", BSkyAppData.RoamingUserBSkyConfigPath);//23Apr2015 ;BSkyAppData.BSkyDataDirConfigFwdSlash
            defaultpackages.RefreshXMLItems();
            container.RegisterInstance <XMLitemsProcessor>("defaultpackages", defaultpackages);

            //Recent user packages. This code must appear before loading any R package. (including uadatapackage)
            RecentItems userpackages = container.Resolve <RecentItems>();//06Feb2014

            userpackages.MaxRecentItems = 100;
            userpackages.XMLFilename    = string.Format(@"{0}UserPackages.xml", BSkyAppData.RoamingUserBSkyConfigPath);//23Apr2015 @"./Config/UserPackages.xml";
            userpackages.RefreshXMLItems();
            container.RegisterInstance <RecentItems>(userpackages);

            ////User listed model classes.
            XMLitemsProcessor modelClasses = container.Resolve <XMLitemsProcessor>();//

            modelClasses.MaxRecentItems = 100;
            if (hasOldUserContent)
            {
                CopyIfNotExistsOrOld(string.Format(@"{0}ModelClasses.xml", BSkyAppData.BSkyAppDirConfigPath), string.Format(@"{0}ModelClasses.xml", BSkyAppData.RoamingUserBSkyConfigPath));
            }
            modelClasses.XMLFilename = string.Format(@"{0}ModelClasses.xml", BSkyAppData.RoamingUserBSkyConfigPath);//23Apr2015 ;BSkyAppData.BSkyDataDirConfigFwdSlash
            modelClasses.RefreshXMLItems();
            container.RegisterInstance <XMLitemsProcessor>("modelClasses", modelClasses);

            if (hasOldUserContent)
            {
                CopyIfNotExistsOrOld(string.Format(@"{0}GraphicCommandList.txt", BSkyAppData.BSkyAppDirConfigPath), string.Format(@"{0}GraphicCommandList.txt", BSkyAppData.RoamingUserBSkyConfigPath));
            }

            try
            {
                BridgeSetup.ConfigureContainer(container);
            }
            catch (Exception ex)
            {
                bool anothersessionrunning = false;
                if (ex.Message.Contains("used by another process"))
                {
                    anothersessionrunning = true;
                }

                string s1         = "\n" + BSky.GlobalResources.Properties.Resources.MakeSureRInstalled;
                string s2         = "\n" + BSky.GlobalResources.Properties.Resources.MakeSure32x64Compatibility;
                string s3         = "\n" + BSky.GlobalResources.Properties.Resources.MakeSureAnotherBSkySession;
                string s4         = "\n" + BSky.GlobalResources.Properties.Resources.MakeSureRHOME2LatestR;
                string s5         = "\n" + BSky.GlobalResources.Properties.Resources.PleaseMakeSure;
                string mboxtitle0 = "\n" + BSky.GlobalResources.Properties.Resources.CantLaunchBSkyApp;

                //MessageBox.Show(s5 + s3 + s4, mboxtitle0, MessageBoxButton.OK, MessageBoxImage.Stop);
                if (anothersessionrunning)
                {
                    MessageBox.Show(s5 + s3, mboxtitle0, MessageBoxButton.OK, MessageBoxImage.Stop);
                }
                else
                {
                    MessageBox.Show(s5 + s4, mboxtitle0, MessageBoxButton.OK, MessageBoxImage.Stop);
                }

                #region R Home Dir edit prompt
                if (!anothersessionrunning)
                {
                    //Provide R Home Dir check/modify option to the user so that he can have a chance to fix this issue.
                    //Otherwise app will not launch until reinstalled or manually modify the config file.
                    //So following is much better and easier way to fix the issue.
                    HideMouseBusy();
                    HideProgressbar();
                    ChangeConfigForRHome();
                }
                #endregion
                logService.WriteToLogLevel("Unable to launch the BlueSky Statistics Application." + s1 + s3, LogLevelEnum.Error);
                logService.WriteToLogLevel("Exception:" + ex.Message, LogLevelEnum.Fatal);
                Environment.Exit(0);
            }
            finally
            {
                HideProgressbar();
            }
            container.RegisterInstance <IDashBoardService>(container.Resolve <XmlDashBoardService>());
            container.RegisterInstance <IDataService>(container.Resolve <DataService>());

            IOutputWindowContainer iowc = container.Resolve <OutputWindowContainer>();
            container.RegisterInstance <IOutputWindowContainer>(iowc);

            SessionDialogContainer sdc = container.Resolve <SessionDialogContainer>();                    //13Feb2013
            //Recent Files settings
            RecentDocs rdoc = container.Resolve <RecentDocs>();                                           //21Feb2013
            rdoc.MaxRecentItems = 7;
            rdoc.XMLFilename    = string.Format(@"{0}Recent.xml", BSkyAppData.RoamingUserBSkyConfigPath); //23Apr2015 @"./Config/Recent.xml";
            container.RegisterInstance <RecentDocs>(rdoc);

            Window1 window = container.Resolve <Window1>();
            container.RegisterInstance <Window1>(window);     ///new line
            window.Closed += new EventHandler(window_Closed); //28Jan2013
            window.Owner   = mwindow;                         //28Jan2013

            //17Apr2017 Showing version number on titlebar of main window
            Version ver            = Assembly.GetExecutingAssembly().GetName().Version;
            string  strfullversion = ver.ToString(); //Full version with four parts
            string  shortversion   = string.Format("{0}.{1}", ver.Major.ToString(), ver.Minor.ToString());
            string  titlemsg       = string.Empty;

            titlemsg = string.Format("BlueSky Statistics (Open Source Desktop Edition. Ver- {0})", shortversion);

            window.Title = titlemsg;

            window.Show();
            window.Activate();
            ShowMouseBusy();//02Apr2015 show mouse busy
            //// one Syntax Editor window for one session ////29Jan2013
            SyntaxEditorWindow sewindow = container.Resolve <SyntaxEditorWindow>();
            container.RegisterInstance <SyntaxEditorWindow>(sewindow);///new line
            sewindow.Owner = mwindow;

            #region Create Column Significance codes List
            SignificanceCodesHandler.CreateSignifColList();
            #endregion

            //load default packages
            window.setLMsgInStatusBar(BSky.GlobalResources.Properties.Resources.StatMsgPkgLoad);
            IAnalyticsService IAService = LifetimeService.Instance.Container.Resolve <IAnalyticsService>();
            BridgeSetup.LoadDefaultRPackages(IAService);
            string PkgLoadStatusMessage = BridgeSetup.PkgLoadStatusMessage;
            bool   BlueSkyPkgErr        = PkgLoadStatusMessage.Contains("BlueSky") ? true : false;

            if (PkgLoadStatusMessage != null && PkgLoadStatusMessage.Trim().Length > 0)
            {
                StringBuilder sb          = new StringBuilder();
                string[]      defpacklist = PkgLoadStatusMessage.Split('\n');

                foreach (string s in defpacklist)
                {
                    if (s != null && (s.ToLower().Contains("error")))//|| s.ToLower().Contains("warning")))
                    {
                        //sb.Append(s.Substring(0, s.IndexOf(". ")) + "\n");
                        sb.Append(s.Replace("Error loading R package:", "") + "\n");
                    }
                }
                if (sb.Length > 0)
                {
                    sb.Remove(sb.Length - 1, 1);//removing last comma

                    string defpkgs  = sb.ToString();
                    string firstmsg = BSky.GlobalResources.Properties.Resources.ErrLoadingRPkg + "\n\n";

                    string msg = "\n\n" + BSky.GlobalResources.Properties.Resources.DisableAntivirus;// +
                    if (BlueSkyPkgErr)
                    {
                        msg = string.Empty;
                    }

                    HideMouseBusy();
                    string mboxtitle1 = BSky.GlobalResources.Properties.Resources.ErrReqRPkgMissing;
                    MessageBox.Show(firstmsg + defpkgs + msg, mboxtitle1, MessageBoxButton.OK, MessageBoxImage.Error);

                    Window1.DatasetReqPackages = defpkgs;

                    BlueSkyFound = false;
                }
            }

            //deimal default should be set here as now BlueSky is loaded
            window.SetRDefaults();
            IAdvancedLoggingService advlog = container.Resolve <IAdvancedLoggingService>();;//01May2015
            advlog.RefreshAdvancedLogging();

            window.setInitialAllModels(); //select All_Models in model class dropdown.
            window.setLMsgInStatusBar("");
            HideMouseBusy();              //02Apr2015 hide mouse busy
            if (BlueSkyFound)
            {
                try
                {
                    FileNewCommand newds = new FileNewCommand();
                    newds.NewFileOpen("");
                }
                catch (Exception ex)
                {
                    string so         = BSky.GlobalResources.Properties.Resources.ErrLoadingNewDS;
                    string mboxtitle2 = BSky.GlobalResources.Properties.Resources.BSkyPkgMissing;
                    logService.WriteToLogLevel("ERROR: " + ex.Message, LogLevelEnum.Error);
                    MessageBox.Show(so, mboxtitle2, MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
示例#3
0
        public App()
        {
            //Calling order found was:: Dispatcher -> Main Window -> XAML Application Dispatcher -> Unhandeled
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            Dispatcher.UnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(Dispatcher_UnhandledException);
            Application.Current.DispatcherUnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(Application_DispatcherUnhandledException);
            MainWindow mwindow = container.Resolve <MainWindow>();

            container.RegisterInstance <MainWindow>(mwindow);///new line
            mwindow.Show();
            mwindow.Visibility = Visibility.Hidden;

            ShowProgressbar();        //strat showing progress bar
            bool BlueSkyFound = true; //Assuming BlueSky R package is present.

            LifetimeService.Instance.Container = container;
            container.RegisterInstance <ILoggerService>(new LoggerService());                   /// For Application log. Starts with default level "Error"
            container.RegisterInstance <IConfigService>(new ConfigService());                   //For App Config file
            container.RegisterInstance <IAdvancedLoggingService>(new AdvancedLoggingService()); //For Advanced Logging
            ////////////// TRY LOADING BSKY R PACKAGES HERE  /////////

            ILoggerService logService = container.Resolve <ILoggerService>();

            logService.SetLogLevelFromConfig();                                               //loading log level from config file
            logService.WriteToLogLevel("R.Net,Logger and Config loaded:", LogLevelEnum.Info); ///

            ////Recent default packages. This code must appear before loading any R package. (including uadatapackage)
            XMLitemsProcessor defaultpackages = container.Resolve <XMLitemsProcessor>();//06Feb2014

            defaultpackages.MaxRecentItems = 50;
            defaultpackages.XMLFilename    = string.Format(@"{0}DefaultPackages.xml", BSkyAppData.BSkyDataDirConfigFwdSlash);//23Apr2015 @"./Config/DefaultPackages.xml";
            defaultpackages.RefreshXMLItems();
            container.RegisterInstance <XMLitemsProcessor>(defaultpackages);

            //Recent user packages. This code must appear before loading any R package. (including uadatapackage)
            RecentItems userpackages = container.Resolve <RecentItems>();//06Feb2014

            userpackages.MaxRecentItems = 50;
            userpackages.XMLFilename    = string.Format(@"{0}UserPackages.xml", BSkyAppData.BSkyDataDirConfigFwdSlash);//23Apr2015 @"./Config/UserPackages.xml";
            userpackages.RefreshXMLItems();
            container.RegisterInstance <RecentItems>(userpackages);

            try
            {
                BridgeSetup.ConfigureContainer(container);
            }
            catch (Exception ex)
            {
                string s1 = "\n1. R is installed. BlueSky Statistics requires R.";
                string s2 = "\n2. Binary incompatibility between BlueSky Statistics and R. 64bit BlueSky Statistics requires 64bit R and 32bit BlueSky Statistics required 32bit R. (Go to Help > About in BlueSky Statistics)";
                string s3 = "\n3. Another session of the BlueSky application is not already running.";
                MessageBox.Show("Please make sure:" + s1 + s2 + s3, "Error: Can't Launch BlueSky Application!", MessageBoxButton.OK, MessageBoxImage.Stop);
                logService.WriteToLogLevel("Unable to launch the BlueSky Application." + s1 + s3, LogLevelEnum.Error);
                Environment.Exit(0);
            }
            finally
            {
                HideProgressbar();
            }
            container.RegisterInstance <IDashBoardService>(container.Resolve <XmlDashBoardService>());
            container.RegisterInstance <IDataService>(container.Resolve <DataService>());

            IOutputWindowContainer iowc = container.Resolve <OutputWindowContainer>();

            container.RegisterInstance <IOutputWindowContainer>(iowc);

            SessionDialogContainer sdc = container.Resolve <SessionDialogContainer>(); //13Feb2013
            //Recent Files settings
            RecentDocs rdoc = container.Resolve <RecentDocs>();                        //21Feb2013

            rdoc.MaxRecentItems = 7;
            rdoc.XMLFilename    = string.Format(@"{0}Recent.xml", BSkyAppData.BSkyDataDirConfigFwdSlash);
            container.RegisterInstance <RecentDocs>(rdoc);

            Window1 window = container.Resolve <Window1>();

            container.RegisterInstance <Window1>(window);     ///new line
            window.Closed += new EventHandler(window_Closed); //28Jan2013
            window.Owner   = mwindow;                         //28Jan2013

            window.Show();
            window.Activate();
            ShowMouseBusy();//02Apr2015 show mouse busy
            //// one Syntax Editor window for one session ////29Jan2013
            SyntaxEditorWindow sewindow = container.Resolve <SyntaxEditorWindow>();

            container.RegisterInstance <SyntaxEditorWindow>(sewindow);///new line
            sewindow.Owner = mwindow;

            //load default packages
            window.setLMsgInStatusBar("Please wait ... Loading required R packages ...");
            IAnalyticsService IAService = LifetimeService.Instance.Container.Resolve <IAnalyticsService>();

            BridgeSetup.LoadDefaultRPackages(IAService);
            string PkgLoadStatusMessage = BridgeSetup.PkgLoadStatusMessage;

            if (PkgLoadStatusMessage != null && PkgLoadStatusMessage.Trim().Length > 0)
            {
                StringBuilder sb          = new StringBuilder();
                string[]      defpacklist = PkgLoadStatusMessage.Split('\n');
                foreach (string s in defpacklist)
                {
                    if (s != null && (s.ToLower().Contains("error"))) //|| s.ToLower().Contains("warning")))
                    {
                        sb.Append(s.Replace("Error loading R package:", "") + "\n");
                    }
                }
                if (sb.Length > 0)
                {
                    sb.Remove(sb.Length - 1, 1);//removing last comma
                    string defpkgs  = sb.ToString();
                    string firstmsg = "Error loading following R package(s):\n\n";
                    string msg      = "\n\nInstall required R packages from CRAN by clicking:\nTools > Package > Install required package(s) from CRAN.";// +

                    HideMouseBusy();
                    MessageBox.Show(firstmsg + defpkgs + msg, "Error: Required R Package(s) Missing", MessageBoxButton.OK, MessageBoxImage.Warning);

                    if (defpkgs.Contains("BlueSky"))
                    {
                        BlueSkyFound = false;
                    }
                }
            }

            //deimal default should be set here as now BlueSky is loaded
            window.SetRDefaults();
            IAdvancedLoggingService advlog = container.Resolve <IAdvancedLoggingService>();;//01May2015

            advlog.RefreshAdvancedLogging();

            HideMouseBusy();//02Apr2015 hide mouse busy
            if (BlueSkyFound)
            {
                try
                {
                    //Try loading empty dataset(newdataset) just after app finished loading itself and R packages.
                    FileNewCommand newds = new FileNewCommand();
                    newds.NewFileOpen("");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error Loading new dataset. Make sure you have BlueSky R package installed", "BlueSky pacakge missing", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            window.setLMsgInStatusBar("For additional functionality and for details on the commercial edition, ");
        }