public override void Remove()
        {
            if (TargetFileSystem.FileExists(PathToConfig))
            {
                TargetFileSystem.DeleteFile(PathToConfig);
            }

            if (TargetFileSystem.DirectoryExists(InstallationPath) &&
                !string.Equals(LocalFileSystem.GetFullPath(BaselineSourcePath), TargetFileSystem.GetFullPath(InstallationPath), StringComparison.OrdinalIgnoreCase))
            {
                try
                {
                    TargetFileSystem.DeleteDirectory(InstallationPath);
                }
                catch (UnauthorizedAccessException)
                {
                    foreach (System.Diagnostics.Process p in Win32ProcessHelper.GetProcessesLockingFile(GetUnremovedFile(InstallationPath)))
                    {
                        Console.WriteLine("File is locked by Process(ID: {0}, NAME: {1}). Killing the process to unlock files", p.Id, p.ProcessName);
                        if (!p.WaitForExit(1000))
                        {
                            Win32ProcessHelper.TerminateProcess(p);
                            p.WaitForExit(5000);
                        }
                    }

                    TargetFileSystem.DeleteDirectory(InstallationPath);
                }
            }
        }
Пример #2
0
        public override void ApplyPackage(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException(nameof(package));
            }

            string pathToAppOfflineHtm = BaseFileSystem.CombinePaths(InstallationPath, "app_offline.htm");

            if (string.IsNullOrEmpty(ManagedRuntimeVersion))
            {
                using (FileStream appOfflineHtm = TargetFileSystem.OpenFile(pathToAppOfflineHtm))
                {
                    StreamWriter appOfflineHtmWriter = new StreamWriter(appOfflineHtm);
                    appOfflineHtmWriter.WriteLine("This is temporary app_offline.htm generated by a deployment script to stop web application.");
                    appOfflineHtmWriter.WriteLine("If you see this - please remove the file");
                }
            }

            package.ApplyToWebComponent(this);

            if (string.IsNullOrEmpty(ManagedRuntimeVersion) && TargetFileSystem.FileExists(pathToAppOfflineHtm))
            {
                TargetFileSystem.DeleteFile(pathToAppOfflineHtm);
            }
        }
        private string GetUnremovedFile(string dir)
        {
            foreach (string subdir in TargetFileSystem.EnumerateDirectories(dir))
            {
                return(GetUnremovedFile(subdir));
            }

            return(TargetFileSystem.EnumerateFiles(dir).FirstOrDefault());
        }
        protected void SetupNtfsPermissionsToFolder(string pathToFolder)
        {
            if (!TargetFileSystem.DirectoryExists(pathToFolder))
            {
                TargetFileSystem.CreateDirectory(pathToFolder);
            }

            ProcessWrapper.Execute("icacls", "\"{0}\" /grant *S-1-5-11:(OI)(CI)(M)", TargetFileSystem.GetFullPath(pathToFolder));
        }
Пример #5
0
        public override void Remove()
        {
            base.Remove();

            if (TargetFileSystem.DirectoryExists(PathToVaultFolder))
            {
                TargetFileSystem.DeleteDirectory(PathToVaultFolder);
            }
        }
        private void SetupConfig()
        {
            Logger.Instance.Log(LogLevel.Info, "\nSetting up config for component ({0}):\n", Id);

            SetupConfigFromTemplate(PathToConfig, PathToConfigTemplate);

            if (!string.IsNullOrEmpty(PathToBasicConfig))
            {
                Logger.Instance.Log(LogLevel.Info, "\tCreating basic config '{0}'",
                                    TargetFileSystem.GetFullPath(PathToBasicConfig));

                string configContent = string.Format(CultureInfo.InvariantCulture, "<ConfigFilePath value=\"{0}\" />", PathToConfig);
                TargetFileSystem.WriteAllTextToFile(PathToBasicConfig, configContent);
            }
        }
        protected void SetupConfigFromTemplate(string pathToConfig, string pathToTemplate)
        {
            if (LocalFileSystem.FileExists(pathToTemplate))
            {
                if (!TargetFileSystem.FileExists(pathToConfig))
                {
                    Logger.Instance.Log(LogLevel.Info, "\tCreating config '{0}' from '{1}' template",
                                        TargetFileSystem.GetFullPath(pathToConfig),
                                        LocalFileSystem.GetFullPath(pathToTemplate));

                    LocalFileSystem.CopyFile(pathToTemplate, TargetFileSystem, pathToConfig, true);
                }

                EnvironmentHelper.ExpandEnvironmentVariablesInConfig(pathToConfig, TargetFileSystem);
            }
        }
Пример #8
0
 private void AutoLoadImpl(string sourcePath,
                           string?mappedPath,
                           bool isFromGameFileSystem,
                           bool loadArtOnly)
 {
     if (!Path.EndsInDirectorySeparator(sourcePath))
     {
         sourcePath += Path.DirectorySeparatorChar;
     }
     var paths = isFromGameFileSystem
         ? TargetFileSystem.FindFiles(_ => true).Select(entry => entry.FilePath)
         : _autoDetect;
     var normalizedSourcePath = FileSystem.NormalizeFilePath(sourcePath);
     var filtered             = from path in paths
                                let normalized = FileSystem.NormalizeFilePath(path)
                                                 where normalized.StartsWith(normalizedSourcePath)
                                                 let relative = normalized[(normalizedSourcePath.Length)..]
        private void SetupInnovatorServerConfig()
        {
            TargetFileSystem.CopyFile(PathToBasicConfig, TargetFileSystem, Path.Combine(InstallationPath, "Client\\Innovator.xml"), true);

            TargetFileSystem.XmlHelper.XmlPoke(PathToConfig, "/Innovator/operating_parameter[@key='temp_folder']/@value", Path.Combine(InstallationPath, "Server\\temp"));
            TargetFileSystem.XmlHelper.XmlPoke(PathToConfig, "/Innovator/operating_parameter[@key='ServerMethodTempDir']/@value", Path.Combine(InstallationPath, "Server\\dll"));
            TargetFileSystem.XmlHelper.XmlPoke(PathToConfig, "/Innovator/operating_parameter[@key='debug_log_prefix']/@value", Path.Combine(InstallationPath, "Server\\logs"));

            foreach (OperatingParameter operatingParameter in OperatingParameters)
            {
                SetupOperatingParameter(operatingParameter);
            }

            TargetFileSystem.XmlHelper.XmlPoke(PathToConfig, "/Innovator/Mail/@SMTPServer", SmtpServer);

            SetupLicense();
        }
Пример #10
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            MainScreen            mainScreen              = new MainScreen();
            TargetCommunication   targetConnection        = new TargetCommunication();
            RealTimeModel         realTimeModelProperties = new RealTimeModel();
            RealTimeMonitor       realTimeMonitor         = new RealTimeMonitor();
            SimulationEnvironment simulationState         = new SimulationEnvironment();
            TargetFileSystem      targetFileSystem        = new TargetFileSystem();
            RealTimeLogging       realTimeLogger          = new RealTimeLogging();

            CommunicationController communicationController = new CommunicationController(mainScreen, targetConnection);
            RealTimeModelController realTimeModelController = new RealTimeModelController(mainScreen, targetConnection, realTimeModelProperties, simulationState);
            ApplicationController   applicationController   = new ApplicationController(mainScreen, targetConnection, realTimeModelProperties, realTimeMonitor, simulationState);
            FileSystemController    fileSystemController    = new FileSystemController(mainScreen, targetConnection, targetFileSystem, realTimeLogger, simulationState);

            Application.Run(mainScreen);
        }
Пример #11
0
        public bool AutoLoad(string requiredAptFile, bool loadArtOnly)
        {
            requiredAptFile = FileSystem.NormalizeFilePath(requiredAptFile);
            var mappedPath = Path.GetDirectoryName(requiredAptFile);
            var name       = Path.GetFileName(requiredAptFile);

            var detectedFromGameFileSystem = TargetFileSystem
                                             .FindFiles(entry => Path.GetFileName(entry.FilePath) == name)
                                             .Select(entry => entry.FilePath)
                                             .ToArray();
            var detectedFromCustomFiles = _autoDetect
                                          .Where(path => FileSystem.NormalizeFilePath(Path.GetFileName(path)) == name);

            if (!detectedFromGameFileSystem.Any() && !detectedFromCustomFiles.Any())
            {
                return(false);
            }

            void Trace(string sourcePath, string from)
            {
                var text = $"Automatically loaded game:{sourcePath}  => game:{mappedPath} for {requiredAptFile}";

                Console.WriteLine(text + (loadArtOnly ? " (art)" : string.Empty));
            }

            foreach (var file in detectedFromCustomFiles)
            {
                var sourcePath = Path.GetDirectoryName(file);
                AutoLoadImpl(sourcePath !, mappedPath, isFromGameFileSystem: false, loadArtOnly);
                Trace(sourcePath !, "file");
            }

            foreach (var gameFile in detectedFromGameFileSystem)
            {
                var sourcePath = Path.GetDirectoryName(gameFile);
                AutoLoadImpl(sourcePath !, mappedPath, isFromGameFileSystem: true, loadArtOnly);
                Trace(sourcePath !, "game");
            }

            return(true);
        }
Пример #12
0
 private void SetupVaultServerConfig()
 {
     Directory.CreateDirectory(PathToVaultFolder);
     TargetFileSystem.XmlHelper.XmlPoke(PathToConfig, "/configuration/appSettings/add[@key = 'LocalPath']/@value", PathToVaultFolder);
     ProcessWrapper.Execute("icacls", "{0} /grant *S-1-5-11:(OI)(CI)(M)", TargetFileSystem.GetFullPath(PathToVaultFolder));
 }
        public override void Setup()
        {
            base.Setup();

            TransferJobs(LocalFileSystem.GetFullPath(PathToConfigTemplate), TargetFileSystem.GetFullPath(PathToConfig));
        }