protected override void OnExecute(object param)
        {
            try
            {
                string packagename = Microsoft.VisualBasic.Interaction.InputBox("Enter package name that you want to load.\nNote: package must be already installed using 'install package' option.", "Load Library", "");
                if (string.IsNullOrEmpty(packagename))
                {
                    //MessageBox.Show("Title/Command cannot be empty, Exiting Dialog install", "Info: Dialog Title Empty.");
                    return;
                }

                PackageHelperMethods phm = new PackageHelperMethods();
                UAReturn r = phm.PackageFileLoad(packagename);// PackageFileLoad(packagename);
                if (r != null && r.Success)
                {
                    SendToOutputWindow( "Load Package", r.CommandString);
                }
                else
                {
                    SendToOutputWindow("Error Loading User Session Package.", "");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error while loading package.", "Error Occurred!");
                logService.WriteToLogLevel("Error:", LogLevelEnum.Error, ex);
            }
        }
        protected override void OnExecute(object param)
        {
            Window1 appwindow = LifetimeService.Instance.Container.Resolve<Window1>();
            try
            {
                appwindow.setLMsgInStatusBar("Please wait ... Installing package(s) from CRAN ...");
                PackageHelperMethods phm = new PackageHelperMethods();
                UAReturn r = phm.InstallCRANPackage();// InstallCRANPackage();

                if (r != null)
                {
                    if (r.Success)
                    {
                        SendToOutputWindow("Install Package from CRAN", r.CommandString);
                    }
                    else if (!r.Success)
                    {
                        SendToOutputWindow("Install Package from CRAN", r.Error);
                    }
                }
                else
                {
                    if(r != null) // if user didn't press 'Cancel'
                    SendToOutputWindow("Error Installing CRAN Package", "Package names are case sensitive. Please check your packgename.", false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error while loading package.", "Error Occurred!");
                logService.WriteToLogLevel("Error:", LogLevelEnum.Error, ex);
            }
            appwindow.setLMsgInStatusBar("");
        }
        protected override void OnExecute(object param)
        {
            try
            {
                //string packagename = Microsoft.VisualBasic.Interaction.InputBox("Enter package name that you want to unload.", "Load Library", "");
                //if (string.IsNullOrEmpty(packagename))
                //{
                //    //MessageBox.Show("Title/Command cannot be empty, Exiting Dialog install", "Info: Dialog Title Empty.");
                //    return;
                //}

                PackageHelperMethods phm = new PackageHelperMethods();
                UAReturn rlst = phm.ShowLoadedPackages();
                string[] strarr = phm.GetUAReturnStringResult(rlst);

                //Create UI show list of installed packges so that user can select and load them
                SelectPackagesWindow spw = new SelectPackagesWindow(strarr);
                spw.header = "UnLoad Library(s)";
                spw.ShowDialog();
                IList<string> sel = spw.SelectedItems;
                if (sel == null)
                    return;

                string[] selectedpackages = new string[sel.Count];
                int i = 0;
                foreach (string s in sel)
                {
                    selectedpackages[i] = s;
                    i++;
                }


                //PackageHelperMethods phm = new PackageHelperMethods();
                UAReturn r = phm.PackageFileUnload(selectedpackages);// PackageFileUnload(packagename);
                if (r != null && r.Success)
                {
                    SendToOutputWindow( "Unload Package", r.CommandString);
                }
                else
                {
                    string error = string.Empty;
                    if(r!=null && r.Error!=null && r.Error.Length > 0)
                        error = r.Error;
                    SendToOutputWindow("Error Unloading Package", error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error while unloading package.", "Error Occurred!");
                logService.WriteToLogLevel("Error:", LogLevelEnum.Error, ex);
            }
        }
        protected override void OnExecute(object param)
        {
            try
            {
                //Get User Package names. 
                //NOTE :: Package must already be installed. This logic does not look for installing missing packages. It just loads.
                List<string> usrsesspkgs = userPackageList.RecentFileList;
                if (usrsesspkgs.Count > 0)//non-empty list
                {
                    string[] packagenames = new string[usrsesspkgs.Count];
                    int i = 0;
                    foreach (string pkgname in usrsesspkgs)
                    {
                        packagenames[i] = pkgname;
                        i++;
                    }




                    PackageHelperMethods phm = new PackageHelperMethods();
                    UAReturn r = phm.LoadPackageFromList(packagenames);// PackageFileLoad(packagename);
                    if (r != null)
                    {
                        if (r.Success)//all package got loaded
                        {
                            SendToOutputWindow("User Package(s)", r.CommandString);
                        }
                        else if (r.CommandString.Trim().Length > 0) // some got loaded some failed.
                        {
                            SendToOutputWindow("One or more User Session Package(s) failed to load.", r.CommandString);
                        }
                    }
                    else
                    {
                        SendToOutputWindow("Error Loading Package(s)", "");
                    }
                }
                else
                {
                    SendToOutputWindow("User Package(s)", "- User's Session List is Empty");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error while loading user session package(s).", "Error Occurred!");
                logService.WriteToLogLevel("Error:", LogLevelEnum.Error, ex);
            }
        }
 protected override void OnExecute(object param)
 {
     //Window1 appwindow = LifetimeService.Instance.Container.Resolve<Window1>();
     try
     {
         bool autoLoad = true, overwrite = true;
         OpenFileDialog openFileDialog = new OpenFileDialog();
         //// Get initial Dir ////
         //string initDir = confService.GetConfigValueForKey("InitialDirectory");
         //openFileDialog.InitialDirectory = initDir;
         openFileDialog.Filter = FileNameFilter;
         openFileDialog.Multiselect = true;
         bool? output = openFileDialog.ShowDialog(Application.Current.MainWindow);
         if (output.HasValue && output.Value)
         {
             string[] pkgfilenames = openFileDialog.FileNames;
             PackageHelperMethods phm = new PackageHelperMethods();
             UAReturn r = phm.PackageFileInstall(pkgfilenames, autoLoad, overwrite);// PackageFileInstall(pkgfilenames);//openFileDialog.FileName);
             if (r != null && r.Success)
             {
                 SendToOutputWindow("Install Package", r.SimpleTypeData.ToString());
                 MessageBox.Show("Please restart BlueSky Application to use the updated BlueSky package(s)", "Restart BlueSky Application", MessageBoxButton.OK, MessageBoxImage.Warning);
             }
             else
             {
                 if (r != null)
                 {
                     string msg = r.SimpleTypeData as string;
                     SendToOutputWindow("Error Installing Package", msg);
                 }
             }
             ///Set initial Dir.///
             //initDir = Path.GetDirectoryName(openFileDialog.FileName);
             //confService.ModifyConfig("InitialDirectory", initDir);
             //confService.RefreshConfig();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error while installing package.", "Error Occurred!");
         logService.WriteToLogLevel("Error:", LogLevelEnum.Error, ex);
     }
 }
示例#6
0
 protected override void OnExecute(object param)
 {
     //Window1 appwindow = LifetimeService.Instance.Container.Resolve<Window1>();
     try
     {
         OpenFileDialog openFileDialog = new OpenFileDialog();
         //// Get initial Dir 12Feb2013 ////
         //string initDir = confService.GetConfigValueForKey("InitialDirectory");
         //openFileDialog.InitialDirectory = initDir;
         openFileDialog.Filter      = FileNameFilter;
         openFileDialog.Multiselect = true;
         bool?output = openFileDialog.ShowDialog(Application.Current.MainWindow);
         if (output.HasValue && output.Value)
         {
             string[]             pkgfilenames = openFileDialog.FileNames;
             PackageHelperMethods phm          = new PackageHelperMethods();
             UAReturn             r            = phm.PackageFileInstall(pkgfilenames);// PackageFileInstall(pkgfilenames);//openFileDialog.FileName);
             if (r != null && r.Success)
             {
                 SendToOutputWindow(BSky.GlobalResources.Properties.Resources.InstallPkg, r.SimpleTypeData.ToString(), false);
             }
             else
             {
                 if (r != null)
                 {
                     string msg = r.SimpleTypeData as string;
                     SendToOutputWindow(BSky.GlobalResources.Properties.Resources.ErrInstallingRPkg, msg, false);
                 }
             }
             ///Set initial Dir. 12Feb2013///
             //initDir = Path.GetDirectoryName(openFileDialog.FileName);
             //confService.ModifyConfig("InitialDirectory", initDir);
             //confService.RefreshConfig();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(BSky.GlobalResources.Properties.Resources.ErrInstallingRPkg2, BSky.GlobalResources.Properties.Resources.ErrorOccurred);
         logService.WriteToLogLevel("Error:", LogLevelEnum.Error, ex);
     }
 }
示例#7
0
        public List <string> GetLoadedRPackages()
        {
            List <string> loaded = new List <string>();

            try
            {
                PackageHelperMethods phm = new PackageHelperMethods();
                UAReturn             r   = phm.ShowLoadedPackages(); // ShowLoadedPackages();
                if (r != null && r.Success && r.SimpleTypeData != null)
                {
                    //SendToOutputWindow(r.CommandString, "Show Installed Packages");
                    string[] strarr = null;

                    if (r.SimpleTypeData.GetType().Name.Equals("String"))
                    {
                        strarr    = new string[1];
                        strarr[0] = r.SimpleTypeData as string;
                    }
                    else if (r.SimpleTypeData.GetType().Name.Equals("String[]"))
                    {
                        strarr = r.SimpleTypeData as string[];
                    }

                    //strarr to list
                    foreach (string s in strarr)
                    {
                        loaded.Add(s);
                    }
                }
                else
                {
                    SendToOutputWindow("Error Getting Loaded Packages", "");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error while getting loaded packages.", "Error Occurred!");
                logService.WriteToLogLevel("Error:", LogLevelEnum.Error, ex);
            }
            return(loaded);
        }
        public List<string> GetLoadedRPackages()
        {
            List<string> loaded = new List<string>();
            try
            {
                PackageHelperMethods phm = new PackageHelperMethods();
                UAReturn r = phm.ShowLoadedPackages(); // ShowLoadedPackages();
                if (r != null && r.Success && r.SimpleTypeData != null)
                {
                    //SendToOutputWindow(r.CommandString, "Show Installed Packages");
                    string[] strarr = null;

                    if (r.SimpleTypeData.GetType().Name.Equals("String"))
                    {
                        strarr = new string[1];
                        strarr[0] = r.SimpleTypeData as string;
                    }
                    else if (r.SimpleTypeData.GetType().Name.Equals("String[]"))
                    {
                        strarr = r.SimpleTypeData as string[];
                    }

                    //strarr to list
                    foreach (string s in strarr)
                        loaded.Add(s);
                }
                else
                {
                    SendToOutputWindow("Error Getting Loaded Packages", "");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error while getting loaded packages.", "Error Occurred!");
                logService.WriteToLogLevel("Error:", LogLevelEnum.Error, ex);
            }
            return loaded;
        }
示例#9
0
        protected override void OnExecute(object param)
        {
            Window1 appwindow = LifetimeService.Instance.Container.Resolve <Window1>();

            try
            {
                appwindow.setLMsgInStatusBar(BSky.GlobalResources.Properties.Resources.PlzWait + " " + BSky.GlobalResources.Properties.Resources.InstallingFromCRAN);
                PackageHelperMethods phm = new PackageHelperMethods();
                UAReturn             r   = phm.InstallCRANPackage();// InstallCRANPackage();

                if (r != null)
                {
                    if (r.Success)
                    {
                        SendToOutputWindow(BSky.GlobalResources.Properties.Resources.InstallingFromCRAN, r.CommandString, false);
                    }
                    else if (!r.Success)
                    {
                        SendToOutputWindow(BSky.GlobalResources.Properties.Resources.InstallingFromCRAN, r.Error, false);
                    }
                }
                else
                {
                    if (r != null) // if user didn't press 'Cancel'
                    {
                        SendToOutputWindow(BSky.GlobalResources.Properties.Resources.ErrInstallingFromCRAN, BSky.GlobalResources.Properties.Resources.RPkgNameCaseSensitive, false);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(BSky.GlobalResources.Properties.Resources.ErrLoadingRPkg2, BSky.GlobalResources.Properties.Resources.ErrorOccurred);
                logService.WriteToLogLevel("Error:", LogLevelEnum.Error, ex);
            }
            appwindow.setLMsgInStatusBar("");
        }
示例#10
0
        protected override void OnExecute(object param)
        {
            Window1 appwindow = LifetimeService.Instance.Container.Resolve <Window1>();

            try
            {
                appwindow.setLMsgInStatusBar("Please wait ... Installing package(s) from CRAN ...");
                PackageHelperMethods phm = new PackageHelperMethods();
                UAReturn             r   = phm.InstallCRANPackage();// InstallCRANPackage();

                if (r != null)
                {
                    if (r.Success)
                    {
                        SendToOutputWindow("Install Package from CRAN", r.CommandString);
                    }
                    else if (!r.Success)
                    {
                        SendToOutputWindow("Install Package from CRAN", r.Error);
                    }
                }
                else
                {
                    if (r != null) // if user didn't press 'Cancel'
                    {
                        SendToOutputWindow("Error Installing CRAN Package", "Package names are case sensitive. Please check your packgename.", false);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error while loading package.", "Error Occurred!");
                logService.WriteToLogLevel("Error:", LogLevelEnum.Error, ex);
            }
            appwindow.setLMsgInStatusBar("");
        }
        protected override void OnExecute(object param)
        {
            Window1 appwindow = LifetimeService.Instance.Container.Resolve <Window1>();

            try
            {
                //Now trying to install R .zip packages from local drive (minimum required R packages)
                InstallRequiredPackagesFromZip instRzip = new InstallRequiredPackagesFromZip();
                instRzip.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                instRzip.ShowDialog();
                string zipPath = instRzip.SelectedZipPath;
                if (zipPath.Length > 0)
                {
                    if (Directory.Exists(zipPath))
                    {
                        string[] zipFiles = null;
                        appwindow.setLMsgInStatusBar("Please wait ... Installing required R packages from local drive...");
                        ShowMouseBusy();
                        zipFiles = Directory.GetFiles(zipPath, "*.zip");
                        if (zipFiles == null || zipFiles.Length == 0)
                        {
                            MessageBox.Show("The path you have selected does not contain any R zip package files. Try again.", "No R package files found", MessageBoxButton.OK, MessageBoxImage.Warning);
                        }
                        else
                        {
                            PackageHelperMethods phm = new PackageHelperMethods();
                            UAReturn             r   = phm.PackageFileInstall(zipFiles);// PackageFileInstall(pkgfilenames);//openFileDialog.FileName);
                            if (r != null && r.Success)
                            {
                                SendToOutputWindow("Package(s) Installation Status:", r.SimpleTypeData.ToString());//"Install Package"
                            }
                            else
                            {
                                if (r != null)
                                {
                                    string msg = r.SimpleTypeData as string;
                                    SendToOutputWindow("Package(s) Installation Status:", msg);//"Error Installing Packages:"
                                }
                            }
                            ///Set initial Dir. 12Feb2013///
                            //initDir = Path.GetDirectoryName(openFileDialog.FileName);
                            //confService.ModifyConfig("InitialDirectory", initDir);
                            //confService.RefreshConfig();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Invalid Path.", "Path not valid", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                }
                else//cancel minimum required install process
                {
                    MessageBox.Show("BlueSky application may not work properly if the required R pacakges are missing.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                ShowMouseFree();
            }
            catch (Exception ex)
            {
                ShowMouseFree();
                MessageBox.Show("Error while installing package.", "Error Occurred!");
                logService.WriteToLogLevel("Error:", LogLevelEnum.Error, ex);
            }
            appwindow.setLMsgInStatusBar("");
        }
 private UAReturn LoadPackages(List<string> pkglist)
 {
     string[] strarr = new string[pkglist.Count];
     int idx = 0;
     foreach (string s in pkglist)
     {
         strarr[idx] = s;
         idx++;
     }
     PackageHelperMethods phm = new PackageHelperMethods();
     UAReturn res = phm.LoadPackageFromList(strarr);
     return res;
 }
        private void dfltAddPackageButton_Click(object sender, RoutedEventArgs e)
        {
            #region This code is same as in LoadPackageFRomListCommand.cs in OnExecute()
            //get package name from another window
            PackageHelperMethods phm = new PackageHelperMethods();
            UAReturn rlst = phm.ShowInstalledPackages();
            string[] installedpkgs = phm.GetUAReturnStringResult(rlst);

            UAReturn rlst2 = phm.ShowLoadedPackages();
            string[] loadededpkgs = phm.GetUAReturnStringResult(rlst2);
            string[] strarr = phm.GetStringArrayUncommon(installedpkgs, loadededpkgs);

            //Create UI show list of installed packges so that user can select and load them
            SelectPackagesWindow spw = new SelectPackagesWindow(strarr);
            spw.header = "Select Packages.";
            spw.ShowDialog();
            IList<string> sel = spw.SelectedItems;
            if (sel == null)
                return;

            string[] selectedpackages = new string[sel.Count];
            int i = 0;
            foreach (string s in sel)
            {
                selectedpackages[i] = s;
                i++;
            }
            #endregion

            foreach (string s in selectedpackages)
                dfltpackagelistbox.Items.Add(s);
            //ApplyPackageButton.IsEnabled = true;
        }
示例#14
0
        protected override void OnExecute(object param)
        {
            Window1 appwindow = LifetimeService.Instance.Container.Resolve <Window1>();

            try
            {
                //Now trying to install R .zip packages from local drive (minimum required R packages)
                InstallRequiredPackagesFromZip instRzip = new InstallRequiredPackagesFromZip();
                instRzip.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                instRzip.ShowDialog();
                string zipPath = instRzip.SelectedZipPath;
                if (zipPath.Length > 0)
                {
                    if (Directory.Exists(zipPath))
                    {
                        string[] zipFiles = null;
                        appwindow.setLMsgInStatusBar(BSky.GlobalResources.Properties.Resources.PlzWait + " " + BSky.GlobalResources.Properties.Resources.InstallingRPkgFromLocal);
                        ShowMouseBusy();
                        zipFiles = Directory.GetFiles(zipPath, "*.zip");
                        if (zipFiles == null || zipFiles.Length == 0)
                        {
                            MessageBox.Show(BSky.GlobalResources.Properties.Resources.RZipPkgNotInPath, BSky.GlobalResources.Properties.Resources.NoRPkgFound, MessageBoxButton.OK, MessageBoxImage.Warning);
                        }
                        else
                        {
                            PackageHelperMethods phm = new PackageHelperMethods();
                            UAReturn             r   = phm.PackageFileInstall(zipFiles);// PackageFileInstall(pkgfilenames);//openFileDialog.FileName);
                            if (r != null && r.Success)
                            {
                                SendToOutputWindow(BSky.GlobalResources.Properties.Resources.RPkgInstallStatus, r.SimpleTypeData.ToString());//"Install Package"
                            }
                            else
                            {
                                if (r != null)
                                {
                                    string msg = r.SimpleTypeData as string;
                                    SendToOutputWindow(BSky.GlobalResources.Properties.Resources.RPkgInstallStatus, msg);//"Error Installing Packages:"
                                }
                            }
                            ///Set initial Dir. 12Feb2013///
                            //initDir = Path.GetDirectoryName(openFileDialog.FileName);
                            //confService.ModifyConfig("InitialDirectory", initDir);
                            //confService.RefreshConfig();
                        }
                    }
                    else
                    {
                        MessageBox.Show(BSky.GlobalResources.Properties.Resources.InvalidPath, BSky.GlobalResources.Properties.Resources.InvalidPath2, MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                }
                else//cancel minimum required install process
                {
                    MessageBox.Show(BSky.GlobalResources.Properties.Resources.BSkyNotWorkReqPkgMissing,
                                    BSky.GlobalResources.Properties.Resources.warning, MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                ShowMouseFree();
            }
            catch (Exception ex)
            {
                ShowMouseFree();
                MessageBox.Show(BSky.GlobalResources.Properties.Resources.ErrInstallingRPkg2, BSky.GlobalResources.Properties.Resources.ErrorOccurred);
                logService.WriteToLogLevel("Error:", LogLevelEnum.Error, ex);
            }
            appwindow.setLMsgInStatusBar("");
        }