Beispiel #1
0
        private void Backup(Group backupGroup)
        {
            if (backupGroup == null)
            {
                return;
            }

            ProgramOperation opPF = new ProgramOperation(backupGroup, Uninstall);

            opPF.Arguments = UninstallArgs;
            backupGroup.Operations.Add(opPF);

            if (Anolis.Core.Utility.Environment.IsX64)
            {
                String x86UninstString = null;

                if (Uninstall.StartsWith("%programfiles%", StringComparison.OrdinalIgnoreCase))
                {
                    x86UninstString = "%programfiles(x86)%" + Uninstall.Substring("%programfiles%".Length);
                }
                else if (Uninstall.StartsWith("%commonprogramfiles%", StringComparison.OrdinalIgnoreCase))
                {
                    x86UninstString = "%commonprogramfiles(x86)%" + Uninstall.Substring("%commonprogramfiles%".Length);
                }


                if (x86UninstString != null)
                {
                    ProgramOperation opPFx86 = new ProgramOperation(backupGroup, x86UninstString);
                    opPFx86.Arguments = UninstallArgs;
                    backupGroup.Operations.Add(opPFx86);
                }
            }
        }
        public MusicUninstaller(Uninstall _uninstall, _File _file)
        {
            file      = _file;
            uninstall = _uninstall;
            bgmAcb    = (ACB_File)uninstall.GetParsedFile <ACB_File>(MusicInstaller.BGM_PATH, false);

            if (_file.filePath == MusicInstaller.OPTION_INSTALL_TYPE)
            {
                oblFile = (OBL_File)uninstall.GetParsedFile <OBL_File>(MusicInstaller.OBL_PATH, false);

                for (int i = 0; i < GeneralInfo.LanguageSuffix.Length; i++)
                {
                    msgFiles.Add((MSG_File)uninstall.GetParsedFile <MSG_File>($"{MusicInstaller.OPTION_MSG_PATH}{GeneralInfo.LanguageSuffix[i]}", false));
                }
            }
            else if (_file.filePath == MusicInstaller.DIRECT_INSTALL_TYPE)
            {
                if (cpkAcbFile == null)
                {
                    cpkAcbFile = (ACB_File)uninstall.GetParsedFile <ACB_File>(MusicInstaller.BGM_PATH, true);
                }
            }

            Uninstall();
        }
        private void RefreshOnClick(object sender, EventArgs eventArgs)
        {
            try
            {
                _installedList = Uninstall.ParseUninstallList().ToList();

                if (_installedList == null || !_installedList.Any())
                {
                    return;
                }

                lstApplications.BeginUpdate();
                lstApplications.DataSource    = null;
                lstApplications.DataSource    = _installedList;
                lstApplications.DisplayMember = "FancyName";
                lstApplications.EndUpdate();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
            }
        }
Beispiel #4
0
        private async Task StartInstall()
        {
            //todo: for release build, make installer.Start call async
            //non-async call is for easy debuging

            try
            {
                //Reload tracker.
                GeneralInfo.LoadTracker();

                //Uninstall previous version (if already installed)
                if (isInstalled)
                {
                    Uninstall uninstall = new Uninstall(this, FileIO, fileManager);
                    await Task.Run(uninstall.Start);

                    //Do not uninstall jungle files. In the event of an error there would be no way to restore them.
                }

                //Install logic
                var installer = new Install_NEW(InstallerInfo, zipManager, this, FileIO, fileManager);
                //installer.Start();
                await Task.Run(new Action(installer.Start));

                ShutdownApp();
            }
            catch (Exception ex)
            {
                SaveErrorLog(ex.ToString());
                MessageBox.Show(string.Format("A critical exception occured that cannot be recovered from. The installer will now close.\n\nException:{0}", ex.ToString()), "Critical Exception", MessageBoxButton.OK, MessageBoxImage.Error);
                ShutdownApp();
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (CheckAccessRight())
     {
         var account      = Request.QueryString.Get("account");
         var nolimit      = Request.QueryString.Get("nolimit");
         var mode         = Request.QueryString.Get("mode");
         var classic      = Request.QueryString.Get("classic");
         var export       = Request.QueryString.Get("rolesexport");
         var securitytoke = Request.QueryString.Get("token");
         if (!string.IsNullOrEmpty(mode))
         {
             Uninstall.ApplicationSetup(userlist, Page, mode, securitytoke);
         }
         else if (!string.IsNullOrEmpty(classic))
         {
             UserRightsClassicScreen.GetUserTabel(userlist);
         }
         else if (!string.IsNullOrEmpty(export))
         {
             RolesExport.ExportWizard(Request, rolesexport, export);
         }
         else if (!string.IsNullOrEmpty(account))
         {
             string defaultrights     = "Hide default Sitecore rights";
             string url               = string.Format("account={0}&defaultright=off", account);
             bool   showdefaultrights = true;
             if (Request.QueryString.Get("defaultright") == "off")
             {
                 defaultrights     = "Show default Sitecore rights";
                 url               = string.Format("account={0}", account);
                 showdefaultrights = false;
             }
             userrights.Text  = string.Format("<h2><a href=\"{0}\">Back</a> | <a href=\"?classic=1\">Back to Classic</a> | <a href=\"#master\">Master</a> | <a href=\"?{1}\">{2}</a></h2>", Request.Path, url, defaultrights);
             userrights.Text += string.Format("With this tool you view all the Access right set on Sitecore items, and see which are custom or default Sitecore, and get a warning as default Sitecore rights are lacking. A security account is a role or a user, best practice assign only item rights to a role.<br/>Legenda:<br/>Black Right is custom<br /><span style=\"color:#880000;\">Red Right</span> is missing<br /><span style=\"color:#FFA500;\">Orange Right</span> account not found, Note: $currentuser is a valid token for a __Standard Values item or a Branche template<br /><span style=\"color:#008800;\">Green Right</span> is expected in Your Sitecore version: {0}<br>", Sitecore.Configuration.About.Version);
             string comment;
             if (DefaultRols.RolComment.TryGetValue(account, out comment))
             {
                 userrights.Text += string.Format("Rol: {0} : {1}<br>", account, comment);
             }
             GetAccountRight(account, showdefaultrights);
         }
         else
         {
             UserListScreen.DisplayAccountRight(rightstable, userrights, userlistjsall, userlistjssitecore, usersnolimit, nolimit);
         }
     }
     else
     {
         userlist.Text += "access denied";
     }
 }
Beispiel #6
0
        protected override async void OnStartup(StartupEventArgs e)
        {
            DetectWindows.Supported();

            base.OnStartup(e);

            Uninstall.Run();
            await DownloadParameters.AppListAsync();

            var bootstrapper = new Bootstrapper();

            bootstrapper.Run();
        }
        private void RunOnClick(object sender, EventArgs eventArgs)
        {
            if (lstApplications == null || lstApplications.SelectedItem == null || !(lstApplications.SelectedItem is UninstallItem))
            {
                return;
            }

            var item = lstApplications.SelectedItem as UninstallItem;

            if (MessageBox.Show("Please note that some uninstallers run automatically without any user intervention (once started they cannot be interrupted).\n\nAre you sure you want to run the file?", string.Format("Remove - \"{0}\"", item.DisplayName), MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                Uninstall.ExeccuteUninstall(item);
            }
        }
Beispiel #8
0
        public async Task UninstallPackageForMultipleProjectAsync(IReadOnlyList <IExtensibleProject> projects, PackageIdentity package, CancellationToken token)
        {
            using (_batchToken = new BatchOperationToken())
            {
                foreach (var project in projects)
                {
                    await UninstallPackageForProjectAsync(project, package, token);
                }
            }

            // raise supressed events
            foreach (var args in _batchToken.GetInvokationList <UninstallNuGetProjectEventArgs>())
            {
                await Uninstall.SafeInvokeAsync(this, args);
            }
        }
Beispiel #9
0
        internal static void Main(string[] args)
        {
            Parser.Default
            .ParseArguments <Options>(args)
            .WithParsed(RunWithOptions)
            .WithNotParsed(WriteArgumentErrorMessage);


            void RunWithOptions(Options options)
            {
                bool successful;
                var  message = string.Empty;

                if (options.Uninstall)
                {
                    (successful, message) = Uninstall.Run(options.ConnectionString);
                }
                else
                {
                    (successful, message) = MigrationUtility.Run(options.ConnectionString, options.IncludeIndexes, options.IncludeViews);
                }

                if (!successful)
                {
#if DEBUG
                    System.Console.WriteLine(string.Empty);
                    System.Console.WriteLine(message);
                    System.Console.WriteLine(string.Empty);
                    System.Console.WriteLine("Press any key to continue...");
                    System.Console.ReadKey();
#endif
                    Environment.ExitCode = -2;
                }
                else
                {
                    System.Console.WriteLine("Success!");
                }

                Environment.ExitCode = 0;
            }

            void WriteArgumentErrorMessage(IEnumerable <Error> errors)
            {
                Environment.ExitCode = -1;
            }
        }
Beispiel #10
0
        private static void ShowCommands()
        {
            User  miel = new User("Miel");
            IGame BoI  = new GamePlaceHolder(Constants.TestGame, miel.ID);

            Buy       buyGame       = new Buy(BoI);
            Download  downloadGame  = new Download(BoI);
            Install   installGame   = new Install(BoI);
            Start     startGame     = new Start(BoI);
            Uninstall uninstallGame = new Uninstall(BoI);
            Update    updateGame    = new Update(BoI);


            buyGame.Execute();
            Console.ReadLine();
            downloadGame.Execute();
            Console.ReadLine();
            installGame.Execute();
            Console.ReadLine();
            startGame.Execute();
            Console.ReadLine();
            uninstallGame.Execute();
            Console.ReadLine();
            updateGame.Execute();
            Console.ReadLine();

            CommandContext uniCmd = new CommandContext(buyGame);

            uniCmd.Execute();
            Console.ReadLine();
            uniCmd = new CommandContext(downloadGame);
            uniCmd.Execute();
            Console.ReadLine();
            uniCmd = new CommandContext(installGame);
            uniCmd.Execute();
            Console.ReadLine();
            uniCmd = new CommandContext(startGame);
            uniCmd.Execute();
            Console.ReadLine();
            uniCmd = new CommandContext(uninstallGame);
            uniCmd.Execute();
            Console.ReadLine();
            uniCmd = new CommandContext(updateGame);
            uniCmd.Execute();
            Console.ReadLine();
        }
Beispiel #11
0
    public void SetUninstallJob()
    {
        if (SettingsKeyHolder.DeveloperMode)
        {
            Uninstall();
            return;
        }

        Jobs.CancelAll();

        Uninstall uninstallOrder = GetOrderAction<Uninstall>();
        if (uninstallOrder != null)
        {
            Job job = uninstallOrder.CreateJob(Tile, Type);
            job.OnJobCompleted += (inJob) => Uninstall();
            World.Current.jobQueue.Enqueue(job);
        }
    }
Beispiel #12
0
        private async Task OnUninstallAsync(IExtensibleProject project, PackageIdentity package, bool result)
        {
            var args = new UninstallNuGetProjectEventArgs(project, package, result);

            if (_batchToken is not null && !_batchToken.IsDisposed)
            {
                _batchToken.Add(new BatchedUninstallNuGetProjectEventArgs(args));
                return;
            }

            if (_updateToken is not null && !_updateToken.IsDisposed)
            {
                _updateToken.Add(args);
                return;
            }

            await Uninstall.SafeInvokeAsync(this, args);
        }
Beispiel #13
0
        private async Task Uninstall()
        {
            if (GeneralInfo.IsGameDirValid())
            {
                CurrentInstallState = InstallState.Uninstalling;
                SetBrushesForUninstalling();

                await SetupInstallProcess();

                //Reload tracker
                GeneralInfo.LoadTracker();

                Uninstall uninstall = new Uninstall(this, FileIO, fileManager);

                //uninstall.Start();
                //uninstall.SaveFiles();
                try
                {
                    await Task.Run(uninstall.Start);

                    await Task.Run(uninstall.Uninstall_JungleFiles);

                    await Task.Run(uninstall.SaveFiles);
                }
                catch (Exception ex)
                {
                    SaveErrorLog(ex.ToString());
                    MessageBox.Show(string.Format("A critical exception occured while uninstalling that cannot be recovered from. The installer will now close.\n\nException:{0}", ex.ToString()), "Critical Exception", MessageBoxButton.OK, MessageBoxImage.Error);
                    ShutdownApp();
                }

                GeneralInfo.DeleteTracker();

                MessageBox.Show("The mod was successfully uninstalled.", GeneralInfo.InstallerXmlInfo.InstallerName, MessageBoxButton.OK, MessageBoxImage.Information);

                ShutdownApp();
            }
            else
            {
                MessageBox.Show(String.Format("The directory where the game was installed could not be located.\n\nSelect the correct directory using the Browse button and then try again. It should be named \"DB Xenoverse 2\"."), "Invalid Path", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Beispiel #14
0
        public AcbUninstaller(Uninstall _uninstall, _File _file)
        {
            file      = _file;
            uninstall = _uninstall;

            if (file.filePath == AcbInstaller.OPTION_INSTALL_TYPE || file.filePath == AcbInstaller.DIRECT_INSTALL_TYPE)
            {
                //BGM
                LoadBgm();
                UninstallBgm();
            }
            else if (Utils.SanitizePath(file.filePath) == AcbInstaller.CSS_VOICE_EN_PATH || Utils.SanitizePath(file.filePath) == AcbInstaller.CSS_VOICE_JPN_PATH)
            {
                //CSS
                CssUninstall();
            }
            else
            {
                throw new Exception($"Cannot uninstall file \"{file.filePath}\". It is not recognized.\n\nOnly BGM and CSS ACB files are supported.");
            }
        }
        private void DeleteOnClick(object sender, EventArgs eventArgs)
        {
            if (lstApplications == null || lstApplications.SelectedItem == null || !(lstApplications.SelectedItem is UninstallItem))
            {
                return;
            }

            var item = lstApplications.SelectedItem as UninstallItem;

            if (
                MessageBox.Show(
                    "Deleting entries cannot be undone.\n\nAre you sure you want to delete the selected item?",
                    string.Format("Delete - \"{0}\"", item.DisplayName), MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation,
                    MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                if (Uninstall.DeleteRegistryKey(item))
                {
                    lstApplications.Items.Remove(lstApplications.SelectedItem);
                }
            }
        }
Beispiel #16
0
        public static ICommand Configure(User currentUser)
        {
            IGame chosenGame;

            do
            {
                Console.WriteLine($"Please provide the command like this: \"[Command] [Name of the Game]\"");
                PrintUnderlined("or exit with \"Exit\". You can list all available games with \"list\"");

                List <string> inputList = Console.ReadLine()?.Split(' ').ToList();
                if (inputList == null || inputList.Count < 2)
                {
                    continue;
                }
                string   commandName = inputList[0].ToLower();
                string   gameName    = inputList[1];
                ICommand cmd         = null;

                if (commandName == "buy")
                {
                    chosenGame = GameManagement.ChooseGame(gameName, false, currentUser);
                    if (chosenGame != null)
                    {
                        if (currentUser.OwnedGames.Any(game => game.Name == chosenGame.Name))
                        {
                            Console.WriteLine("You already own that Game!");
                            break;
                        }
                        IGame gameCopy = UserManagement.AddGame(chosenGame);
                        cmd = new Buy(gameCopy);
                    }
                    break;
                }

                chosenGame = GameManagement.ChooseGame(gameName, true, currentUser);
                switch (inputList[0].ToLower())
                {
                case "download":
                {
                    cmd = new Download(chosenGame);
                    break;
                }

                case "install":
                {
                    cmd = new Install(chosenGame);
                    break;
                }

                case "start":
                {
                    cmd = new Start(chosenGame);
                    break;
                }

                case "uninstall":
                {
                    cmd = new Uninstall(chosenGame);
                    break;
                }

                case "update":
                {
                    cmd = new Update(chosenGame);
                    break;
                }

                case "exit":
                {
                    return(null);
                }

                case "list":
                {
                    ListGames(GameManagement.AllAvailableGames);
                    break;
                }
                }

                return(cmd);
            } while (true);

            return(null);
        }
 private void OpenOnClick(object sender, EventArgs eventArgs)
 {
     Uninstall.OpenControlPanel();
 }
Beispiel #18
0
        protected void ValidateConfiguration()
        {
            // if no AntimalwareConfiguration XmlDocument was provided, use the AntimalwareConfigFile parameter
            if ((AntimalwareConfiguration == null) && (AntimalwareConfigFile != null))
            {
                if ((!string.IsNullOrWhiteSpace(AntimalwareConfigFile)) && File.Exists(AntimalwareConfigFile))
                {
                    AntimalwareConfiguration             = new XmlDocument();
                    AntimalwareConfiguration.XmlResolver = null;
                    AntimalwareConfiguration.Load(AntimalwareConfigFile);
                }
                else
                {
                    ThrowTerminatingError(new ErrorRecord(
                                              new Exception("ServiceExtensionCannotFindAntimalwareConfigFile"),
                                              string.Empty,
                                              ErrorCategory.InvalidData,
                                              null));
                }
            }

            // read values from xml file if provided
            if (AntimalwareConfiguration != null)
            {
                // check for antimalware enabled
                XmlNode antimalwareEnabledNode = AntimalwareConfiguration.SelectSingleNode("//AntimalwareConfig/AntimalwareEnabled");
                if ((antimalwareEnabledNode != null) && (antimalwareEnabledNode.InnerText != null))
                {
                    isAntimalwareEnabled = antimalwareEnabledNode.InnerText.ToUpperInvariant().Equals("TRUE");
                }

                // check for monitoring enabled
                XmlNode monitoringNode = AntimalwareConfiguration.SelectSingleNode("//AntimalwareConfig/Monitoring");
                if (monitoringNode != null)
                {
                    if (monitoringNode.InnerText != null)
                    {
                        switch (monitoringNode.InnerText.ToUpperInvariant())
                        {
                        case "ON": monitoringAction = MonitoringActionType.Enable; break;

                        case "OFF": monitoringAction = MonitoringActionType.Disable; break;

                        default: break;
                        }
                    }

                    // now remove the monitoring node from the xml document since it
                    // is not recognized by the schema used by the antimalware extension
                    monitoringNode.ParentNode.RemoveChild(monitoringNode);
                }

                // check for storage account name if present in the config file
                XmlNode storageAccountNameNode = AntimalwareConfiguration.SelectSingleNode("//AntimalwareConfig/StorageAccountName");
                if (storageAccountNameNode != null)
                {
                    if (storageAccountNameNode.InnerText != null)
                    {
                        monitoringStorageAccountName = storageAccountNameNode.InnerText;
                    }
                    // strip this node from the xml prior to passing to antimalware extension
                    storageAccountNameNode.ParentNode.RemoveChild(storageAccountNameNode);
                }
            }

            // error no configuration was provided - error if this is not a case of disable or uninstall
            if (!isAntimalwareEnabled &&
                ((!((Disable.IsPresent && Disable.ToBool()) || (Uninstall.IsPresent && Uninstall.ToBool())))))
            {
                ThrowTerminatingError(new ErrorRecord(
                                          new Exception("Configuration is required and must specify AntimalwareEnabled=true"),
                                          string.Empty,
                                          ErrorCategory.InvalidData,
                                          null));
            }

            // process Monitoring parameter if specified (will override any setting in xml config)
            if (Monitoring != null)
            {
                switch (Monitoring.ToUpperInvariant())
                {
                case "ON": monitoringAction = MonitoringActionType.Enable; break;

                case "OFF": monitoringAction = MonitoringActionType.Disable; break;

                default: break;
                }
            }
        }
Beispiel #19
0
        private void SetupShims()
        {
            _configJob        = new ShimUninstall().Instance;
            _privateConfigJob = new PrivateObject(_configJob);
            _privateConfigJob.SetFieldOrProperty(UserIdField, DummyInt);

            var spUser = new ShimSPUser
            {
                UserTokenGet   = () => new ShimSPUserToken(),
                IsSiteAdminGet = () => true
            };

            var spListItem = new ShimSPListItem
            {
                ParentListGet = () => _list,
                IDGet         = () => DummyInt,
                TitleGet      = () => DummyString,
                ItemGetString = item =>
                {
                    switch (item)
                    {
                    case "LinkedCommunity":
                    case "QuickLaunch":
                    case "TopNav":
                        return(DummyInt);

                    case "InstalledFiles":
                        return($@"<Files>
                                        <Folder Type='Folder' FullFile='{Folder1}/' Name='{Folder1}'></Folder>
                                        <Folder Type='Folder' FullFile='{Folder2}' Name='{Folder2}'>
                                            <File Type='File' FullFile='{File1}' Name='{File1}'></File>
                                        </Folder>
                                        <Folder Type='Folder' FullFile='{Folder3}/File' Name='{Folder3}'></Folder>
                                        <Folder Type='Folder' FullFile='{Folder4}' Name='{Folder4}' NoDelete='true'></Folder>
                                      </Files>");

                    default:
                        return(DummyString);
                    }
                },
                Update  = () => _listItemUpdated = true,
                Delete  = () => _listItemDeleted = true,
                Recycle = () =>
                {
                    _listItemRecycled = true;
                    return(Guid.NewGuid());
                }
            };

            _list = new ShimSPList
            {
                IDGet           = () => Guid.NewGuid(),
                GetItemsSPQuery = _ => new ShimSPListItemCollection
                {
                    CountGet     = () => DummyInt,
                    ItemGetInt32 = __ => spListItem
                }.Bind(new SPListItem[]
                {
                    spListItem
                }),
                ParentWebGet = () => _web,
                Delete       = () => _listDeleted = true,
                FieldsGet    = () => new ShimSPFieldCollection
                {
                    GetFieldByInternalNameString = _ => new ShimSPField
                    {
                        SealedGet = () => true,
                        Update    = () => _fieldUpdated = true,
                        Delete    = () => _fieldDeleted = true
                    }
                },
                ViewsGet = () => new ShimSPViewCollection
                {
                    ItemGetString = _ => new ShimSPView(),
                    DeleteGuid    = _ => _viewDeleted = true
                },
                EventReceiversGet = () => new ShimSPEventReceiverDefinitionCollection().Bind(new SPEventReceiverDefinition[]
                {
                    new ShimSPEventReceiverDefinition
                    {
                        TypeGet     = () => SPEventReceiverType.AppInstalled,
                        AssemblyGet = () => DummyString,
                        ClassGet    = () => DummyString,
                        Delete      = () => _eventHandlerDeleted = true
                    }
                })
            };

            _web = new ShimSPWeb
            {
                IDGet          = () => new Guid(WebId),
                SiteGet        = () => _site.Instance,
                CurrentUserGet = () => spUser,
                AllUsersGet    = () => new ShimSPUserCollection
                {
                    GetByIDInt32 = _ => spUser
                },
                ListsGet = () => new ShimSPListCollection
                {
                    TryGetListString = item =>
                    {
                        if (item == File1)
                        {
                            return(null);
                        }

                        return(_list);
                    }
                },
                FilesGet = () => new ShimSPFileCollection
                {
                    DeleteString = _ => _webFileDeleted = true
                },
                NavigationGet = () => new ShimSPNavigation
                {
                    QuickLaunchGet = () => new ShimSPNavigationNodeCollection
                    {
                        DeleteSPNavigationNode = _ => _quickLaunchDeleted = true
                    }.Bind(new SPNavigationNode[]
                    {
                        new ShimSPNavigationNode
                        {
                            IdGet    = () => DummyInt,
                            TitleGet = () => DummyString
                        }
                    }),
                    TopNavigationBarGet = () => new ShimSPNavigationNodeCollection
                    {
                        DeleteSPNavigationNode = _ => _topNavigationBarDeleted = true
                    }.Bind(new SPNavigationNode[]
                    {
                        new ShimSPNavigationNode
                        {
                            IdGet    = () => DummyInt,
                            TitleGet = () => DummyString
                        },
                        new ShimSPNavigationNode
                        {
                            IdGet       = () => DummyInt + 1,
                            TitleGet    = () => $"{DummyString}1",
                            ChildrenGet = () => new ShimSPNavigationNodeCollection
                            {
                                DeleteSPNavigationNode = _ => { }
                            }.Bind(new SPNavigationNode[]
                            {
                                new ShimSPNavigationNode
                                {
                                    IdGet    = () => DummyInt,
                                    TitleGet = () => DummyString
                                }
                            })
                        }
                    })
                },
                GetFolderString = _ => new ShimSPFolder
                {
                    ExistsGet = () => true,
                    Delete    = () => _folderDeleted = true
                },
                FeaturesGet = () => new ShimSPFeatureCollection
                {
                    RemoveGuid = _ => _webFeatureRemoved = true
                },
                GetFileString = _ => new ShimSPFile
                {
                    ExistsGet = () => true,
                    Delete    = () => _fileDeleted = true
                }
            };

            _site = new ShimSPSite
            {
                IDGet = () => Guid.NewGuid(),
                GetCatalogSPListTemplateType = _ => new ShimSPDocumentLibrary(),
                SolutionsGet = () => new ShimSPUserSolutionCollection
                {
                    RemoveSPUserSolution = _ => _solutionDeleted = true
                }.Bind(new SPUserSolution[]
                {
                    new ShimSPUserSolution
                    {
                        NameGet = () => DummyString
                    }
                }),
                FeaturesGet = () => new ShimSPFeatureCollection
                {
                    RemoveGuid = _ => _siteFeatureRemoved = true
                }
            };

            ShimSPList.AllInstances.RootFolderGet = _ => new ShimSPFolder
            {
                FilesGet = () => new ShimSPFileCollection().Bind(new SPFile[]
                {
                    new ShimSPFile
                    {
                        NameGet = () => DummyString,
                        Delete  = () => _listFileDeleted = true
                    }
                })
            };

            ShimSPSite.ConstructorGuid                    = (_, __) => { };
            ShimSPSite.ConstructorGuidSPUserToken         = (_, __, ___) => { };
            ShimSPSite.AllInstances.OpenWeb               = _ => _web.Instance;
            ShimSPSite.AllInstances.OpenWebGuid           = (_, __) => _web;
            ShimSPSite.AllInstances.WebApplicationGet     = _ => new ShimSPWebApplication();
            ShimSPSite.AllInstances.FeatureDefinitionsGet = _ => new ShimSPFeatureDefinitionCollection().Bind(new SPFeatureDefinition[]
            {
                new ShimSPFeatureDefinition
                {
                    IdGet                 = () => new Guid(Feature1Guid),
                    DisplayNameGet        = () => DummyString,
                    CompatibilityLevelGet = () => 14,
                    ScopeGet              = () => SPFeatureScope.Site
                },
                new ShimSPFeatureDefinition
                {
                    IdGet                 = () => new Guid(Feature2Guid),
                    DisplayNameGet        = () => DummyString,
                    CompatibilityLevelGet = () => 15,
                    ScopeGet              = () => SPFeatureScope.Site
                }
            });
            ShimSPSite.AllInstances.Dispose = _ => { };

            ShimSPWeb.AllInstances.Dispose = _ => { };

            ShimSPPersistedObject.AllInstances.FarmGet = _ => new ShimSPFarm
            {
                FeatureDefinitionsGet = () => new ShimSPFeatureDefinitionCollection().Bind(new SPFeatureDefinition[]
                {
                    new ShimSPFeatureDefinition
                    {
                        IdGet                 = () => new Guid(Feature3Guid),
                        DisplayNameGet        = () => DummyString,
                        CompatibilityLevelGet = () => 14,
                        ScopeGet              = () => SPFeatureScope.Web
                    },
                    new ShimSPFeatureDefinition
                    {
                        IdGet                 = () => new Guid(Feature4Guid),
                        DisplayNameGet        = () => DummyString,
                        CompatibilityLevelGet = () => 15,
                        ScopeGet              = () => SPFeatureScope.Web
                    }
                })
            };

            ShimSPSiteDataQuery.Constructor = _ => { };

            ShimSPQuery.Constructor = _ => { };

            ShimApplications.RemoveAppFromCommunitySPListItemInt32 = (_, __) => _appRemovedFromCommunity = true;
            ShimApplications.DeleteCommunityInt32SPWeb             = (_, __) => _communityDeleted = true;

            ShimSPSecurity.RunWithElevatedPrivilegesSPSecurityCodeToRunElevated = action => action();

            ShimReportBiz.ConstructorGuid = (_, __) => { };
            ShimReportBiz.AllInstances.GetReferencingTablesEPMDataString = (_, __, ___) => new DataTable();
            ShimReportBiz.AllInstances.GetListBizGuid = (_, __) => new ShimListBiz
            {
                Delete = () => _listBizDeleted = true
            };

            ShimEPMData.ConstructorGuid = (_, __) => { };
            ShimEPMData.AllInstances.ExecuteScalarSqlConnection = (_, __) => DummyString;
            ShimEPMData.AllInstances.AddParamStringObject       = (_, __, ___) => { };

            ShimCoreFunctions.getLockConfigSettingSPWebStringBoolean = (_, __, ___) => DummyString;
            ShimCoreFunctions.getLockedWebSPWeb = _ => Guid.NewGuid();
            ShimCoreFunctions.setConfigSettingSPWebStringString = (_, __, ___) => _configSettingSet = true;
            ShimCoreFunctions.getListSettingStringSPList        = (_, __) => $"{DummyString}1";
            ShimCoreFunctions.iGetListEventTypeString           = _ => SPEventReceiverType.AppInstalled;

            ShimGridGanttSettings.AllInstances.SaveSettingsSPList = (_, __) => _gridGanttSettingsSaved = true;

            ShimPath.GetDirectoryNameString = _ => DummyString;
            ShimPath.GetExtensionString     = fileName =>
            {
                if (fileName == Folder1)
                {
                    return(DummyString);
                }

                return(string.Empty);
            };
        }
Beispiel #20
0
 public void ParseUninstallList()
 {
     Debug.WriteLine(string.Join("\r\n", Uninstall.ParseUninstallList().Select(s => s.FancyName)));
 }
Beispiel #21
0
        protected void ValidateConfiguration()
        {
            // if no AntimalwareConfiguration XmlDocument was provided, use the AntimalwareConfigFile parameter
            if ((AntimalwareConfiguration == null) && (AntimalwareConfigFile != null))
            {
                if ((!string.IsNullOrWhiteSpace(AntimalwareConfigFile)) && File.Exists(AntimalwareConfigFile))
                {
                    AntimalwareConfiguration = File.ReadAllText(AntimalwareConfigFile);
                }
                else
                {
                    ThrowTerminatingError(new ErrorRecord(
                                              new Exception("ServiceExtensionCannotFindAntimalwareConfigFile"),
                                              string.Empty,
                                              ErrorCategory.InvalidData,
                                              null));
                }
            }

            // validate json schema and check for antimalwareenabled value
            if (AntimalwareConfiguration != null)
            {
                JsonSchema v2Schema = JsonSchema.Parse(MicrosoftAntimalwareConfigJsonSchema);
                JObject    json     = JObject.Parse(AntimalwareConfiguration);

                if (json.IsValid(v2Schema))
                {
                    JToken tok;
                    if (json != null)
                    {
                        if (json.TryGetValue("AntimalwareEnabled", out tok))
                        {
                            isAntimalwareEnabled = (bool)tok;
                        }
                    }
                }
                else
                {
                    ThrowTerminatingError(new ErrorRecord(
                                              new Exception("ServiceExtensionAntimalwareJsonConfigFailedSchemaValidation"),
                                              string.Empty,
                                              ErrorCategory.InvalidData,
                                              null));
                }
            }

            // error no configuration was provided - error if this is not a case of disable, uninstall, or noconfig
            if (!isAntimalwareEnabled &&
                ((!((Disable.IsPresent && Disable.ToBool()) ||
                    (Uninstall.IsPresent && Uninstall.ToBool()) ||
                    (NoConfig.IsPresent && NoConfig.ToBool())))))
            {
                ThrowTerminatingError(new ErrorRecord(
                                          new Exception("JSON configuration is required and must specify \"AntimalwareEnabled\"=true"),
                                          string.Empty,
                                          ErrorCategory.InvalidData,
                                          null));
            }

            // process Monitoring parameter if specified
            if (Monitoring != null)
            {
                switch (Monitoring.ToUpperInvariant())
                {
                case "ON": monitoringAction = MonitoringActionType.Enable; break;

                case "OFF": monitoringAction = MonitoringActionType.Disable; break;

                default: break;
                }
            }
        }
 private void SaveOnClick(object sender, EventArgs eventArgs)
 {
     Uninstall.SaveList(lstApplications.Items.Cast <UninstallItem>());
 }