public int Run()
        {
            _thisDialog.ShowAll();

            int result;
            for (;; )
            {
                result = _thisDialog.Run();
                if ((result != ((int)(ResponseType.None))))
                {
                    break;
                }

                Thread.Sleep(500);
            }

            if (result == 1) {
                var env = new EnvironmentVariables {
                    ArduinoPath = etPath.Text,
                    ArduinoBoard = etBoard.Text,
                    ArduinoPort = etPort.Text
                };

                CController.Instance.SetEnvironmentVariables (env);
            }

            _thisDialog.Destroy();
            return result;
        }
Пример #2
0
 public ResourceCatalog(IEnumerable <DynamicService> managementServices)
 {
     InitializeWorkspaceResources();
     _serverVersionRepository = new ServerVersionRepository(new VersionStrategy(), this, _directoryWrapper, EnvironmentVariables.GetWorkspacePath(GlobalConstants.ServerWorkspaceID), new FileWrapper(), new FilePathWrapper());
     _catalogPluginContainer  = new ResourceCatalogPluginContainer(_serverVersionRepository, WorkspaceResources, managementServices);
     _catalogPluginContainer.Build(this);
 }
Пример #3
0
		public void SetEnvironmentVariables(EnvironmentVariables env )
		{
			ConfigManager.Write<EnvironmentVariables> (env, "Environment.xml".GetAbsolutePath ());
		}
Пример #4
0
 public Command GetCommand()
 {
     CMD_CLS.SetFunction(() => { ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).Clear(); return(""); });
     return(CMD_CLS);
 }
Пример #5
0
 public string GetValue(EnvironmentVariables variable)
 {
     return(Environment.GetEnvironmentVariable(variable.ToString()));
 }
 internal static void Log(string runId, string scenarioTitle, int level, DateTime date, string message, Exception exception, EnvironmentVariables environmentVariables)
 {
     using (var connection = new SqlConnection(environmentVariables.DedsDatabaseConnectionString))
     {
         connection.Execute("INSERT INTO AT.Logs " +
                            "(RunId,LogLevel,LogDtTm,LogMessage,ExceptionDetails,ScenarioTitle) " +
                            "VALUES " +
                            "(@runId,@level,@date,@message,@exception,@scenarioTitle)",
                            new { runId, level, date, message, exception = exception?.ToString(), scenarioTitle });
     }
 }
Пример #7
0
 public CoinKernelViewModel(Guid id)
 {
     _id = id;
     this.AddEnvironmentVariable = new DelegateCommand(() => {
         VirtualRoot.Execute(new EnvironmentVariableEditCommand(this, new EnvironmentVariable()));
     });
     this.EditEnvironmentVariable = new DelegateCommand <EnvironmentVariable>(environmentVariable => {
         VirtualRoot.Execute(new EnvironmentVariableEditCommand(this, environmentVariable));
     });
     this.RemoveEnvironmentVariable = new DelegateCommand <EnvironmentVariable>(environmentVariable => {
         this.ShowDialog(message: $"您确定删除环境变量{environmentVariable.Key}吗?", title: "确认", onYes: () => {
             this.EnvironmentVariables.Remove(environmentVariable);
             EnvironmentVariables = EnvironmentVariables.ToList();
         }, icon: IconConst.IconConfirm);
     });
     this.AddSegment = new DelegateCommand(() => {
         VirtualRoot.Execute(new InputSegmentEditCommand(this, new InputSegment()));
     });
     this.EditSegment = new DelegateCommand <InputSegment>((segment) => {
         VirtualRoot.Execute(new InputSegmentEditCommand(this, segment));
     });
     this.RemoveSegment = new DelegateCommand <InputSegment>((segment) => {
         this.ShowDialog(message: $"您确定删除片段{segment.Name}吗?", title: "确认", onYes: () => {
             this.InputSegments.Remove(segment);
             InputSegments = InputSegments.ToList();
         }, icon: IconConst.IconConfirm);
     });
     this.RemoveFileWriter = new DelegateCommand <FileWriterViewModel>((writer) => {
         this.ShowDialog(message: $"您确定删除文件书写器{writer.Name}吗?", title: "确认", onYes: () => {
             this.FileWriterVms.Remove(writer);
             List <Guid> writerIds = new List <Guid>(this.FileWriterIds);
             writerIds.Remove(writer.Id);
             this.FileWriterIds = writerIds;
         }, icon: IconConst.IconConfirm);
     });
     this.RemoveFragmentWriter = new DelegateCommand <FragmentWriterViewModel>((writer) => {
         this.ShowDialog(message: $"您确定删除文件书写器{writer.Name}吗?", title: "确认", onYes: () => {
             this.FragmentWriterVms.Remove(writer);
             List <Guid> writerIds = new List <Guid>(this.FragmentWriterIds);
             writerIds.Remove(writer.Id);
             this.FragmentWriterIds = writerIds;
         }, icon: IconConst.IconConfirm);
     });
     this.Save = new DelegateCommand(() => {
         if (NTMinerRoot.Instance.CoinKernelSet.Contains(this.Id))
         {
             VirtualRoot.Execute(new UpdateCoinKernelCommand(this));
         }
         CloseWindow?.Invoke();
     });
     this.Edit = new DelegateCommand <FormType?>((formType) => {
         VirtualRoot.Execute(new CoinKernelEditCommand(formType ?? FormType.Edit, this));
     });
     this.Remove = new DelegateCommand(() => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         this.ShowDialog(message: $"您确定删除{Kernel.Code}币种内核吗?", title: "确认", onYes: () => {
             VirtualRoot.Execute(new RemoveCoinKernelCommand(this.Id));
             Kernel.OnPropertyChanged(nameof(Kernel.SupportedCoins));
         }, icon: IconConst.IconConfirm);
     });
     this.SortUp = new DelegateCommand(() => {
         CoinKernelViewModel upOne = AppContext.Instance.CoinKernelVms.AllCoinKernels.OrderByDescending(a => a.SortNumber).FirstOrDefault(a => a.CoinId == this.CoinId && a.SortNumber < this.SortNumber);
         if (upOne != null)
         {
             int sortNumber   = upOne.SortNumber;
             upOne.SortNumber = this.SortNumber;
             VirtualRoot.Execute(new UpdateCoinKernelCommand(upOne));
             this.SortNumber = sortNumber;
             VirtualRoot.Execute(new UpdateCoinKernelCommand(this));
             if (AppContext.Instance.CoinVms.TryGetCoinVm(this.CoinId, out CoinViewModel coinVm))
             {
                 coinVm.OnPropertyChanged(nameof(coinVm.CoinKernels));
             }
             this.Kernel.OnPropertyChanged(nameof(this.Kernel.CoinKernels));
             AppContext.Instance.CoinVms.OnPropertyChanged(nameof(AppContext.CoinViewModels.MainCoins));
         }
     });
     this.SortDown = new DelegateCommand(() => {
         CoinKernelViewModel nextOne = AppContext.Instance.CoinKernelVms.AllCoinKernels.OrderBy(a => a.SortNumber).FirstOrDefault(a => a.CoinId == this.CoinId && a.SortNumber > this.SortNumber);
         if (nextOne != null)
         {
             int sortNumber     = nextOne.SortNumber;
             nextOne.SortNumber = this.SortNumber;
             VirtualRoot.Execute(new UpdateCoinKernelCommand(nextOne));
             this.SortNumber = sortNumber;
             VirtualRoot.Execute(new UpdateCoinKernelCommand(this));
             if (AppContext.Instance.CoinVms.TryGetCoinVm(this.CoinId, out CoinViewModel coinVm))
             {
                 coinVm.OnPropertyChanged(nameof(coinVm.CoinKernels));
             }
             this.Kernel.OnPropertyChanged(nameof(this.Kernel.CoinKernels));
             AppContext.Instance.CoinVms.OnPropertyChanged(nameof(AppContext.CoinViewModels.MainCoins));
         }
     });
 }
 public Task <Credentials> GetCredentials() => Task.FromResult(new Credentials(EnvironmentVariables.GetGithubToken()));
Пример #9
0
 internal static RequiredPaymentEntity[] GetPaymentsDueForPeriod(long ukprn, int year, int month, EnvironmentVariables environmentVariables)
 {
     using (var connection = new SqlConnection(environmentVariables.DedsDatabaseConnectionString))
     {
         var query = "SELECT * FROM PaymentsDue.RequiredPayments WHERE UKPRN = @ukprn AND CollectionPeriodMonth = @month AND CollectionPeriodYear = @year";
         return(connection.Query <RequiredPaymentEntity>(query, new { ukprn, month, year }).ToArray());
     }
 }
Пример #10
0
 public void SetEnvironmentVariables(EnvironmentVariables env)
 {
     ConfigManager.Write <EnvironmentVariables> (env, "Environment.xml".GetAbsolutePath());
 }
Пример #11
0
 internal static string GetDetailLogFilePath(IDSFDataObject dsfDataObject) =>
 Path.Combine(EnvironmentVariables.WorkflowDetailLogPath(dsfDataObject.ResourceID, dsfDataObject.ServiceName)
              , "Detail.log");
Пример #12
0
 internal static OpaApprenticeshipPriceEpisode GetOpaApprenticeshipPriceEpisode(long ukprn, string priceEpisodeIdentifier, EnvironmentVariables environmentVariables)
 {
     using (var connection = new SqlConnection(environmentVariables.DedsDatabaseConnectionString))
     {
         var query = "SELECT * FROM [Rulebase].[AEC_ApprenticeshipPriceEpisode] WHERE UKPRN = @ukprn AND PriceEpisodeIdentifier = @priceEpisodeIdentifier ";
         return(connection.QuerySingleOrDefault <OpaApprenticeshipPriceEpisode>(query, new { ukprn, priceEpisodeIdentifier }));
     }
 }
Пример #13
0
 internal static OpaApprenticeshipPriceEpisode GetOpaApprenticeshipPriceEpisode(long ukprn,
                                                                                string learnRefNumber,
                                                                                DateTime learnStartDate,
                                                                                DateTime learnPlanEndDate,
                                                                                EnvironmentVariables environmentVariables)
 {
     using (var connection = new SqlConnection(environmentVariables.DedsDatabaseConnectionString))
     {
         var query = "SELECT * FROM [Rulebase].[AEC_ApprenticeshipPriceEpisode] WHERE UKPRN = @ukprn AND LearnRefNumber = @learnRefNumber AND EpisodeStartDate= @learnStartDate AND PriceEpisodePlannedEndDate=@learnPlanEndDate ";
         return(connection.QuerySingleOrDefault <OpaApprenticeshipPriceEpisode>(query, new { ukprn, learnRefNumber, learnStartDate, learnPlanEndDate }));
     }
 }
Пример #14
0
 public HomeController(IOptions <EnvironmentVariables> configuration)
 {
     _configuration = configuration.Value;
     storeID        = _configuration.StoreId;
     storePassword  = _configuration.StorePassword;
 }
Пример #15
0
 private static void PrepareDatabaseForComponent(ProcessService processService, ComponentType componentType, EnvironmentVariables environmentVariables, RebuildStatusWatcher watcher)
 {
     processService.RebuildDedsDatabase(componentType, environmentVariables, watcher);
     if (watcher.LastError != null)
     {
         throw new Exception($"Error rebuilding deds for {componentType} - {watcher.LastError.Message}", watcher.LastError);
     }
 }
 internal static void CreateCommitment(CommitmentEntity commitment, EnvironmentVariables environmentVariables)
 {
     using (var connection = new SqlConnection(environmentVariables.DedsDatabaseConnectionString))
     {
         connection.Execute("INSERT INTO DasCommitments ("
                            + "CommitmentId, "
                            + "VersionId, "
                            + "Uln, "
                            + "Ukprn, "
                            + "AccountId, "
                            + "StartDate, "
                            + "EndDate, "
                            + "AgreedCost, "
                            + "StandardCode, "
                            + "ProgrammeType, "
                            + "FrameworkCode, "
                            + "PathwayCode, "
                            + "PaymentStatus, "
                            + "PaymentStatusDescription, "
                            + "Priority, "
                            + "EffectiveFromDate, "
                            + "EffectiveToDate"
                            + ") VALUES ("
                            + "@commitmentId, "
                            + "@versionId, "
                            + "@uln, "
                            + "@ukprn, "
                            + "@accountId, "
                            + "@startDate, "
                            + "@endDate, "
                            + "@agreedCost, "
                            + "@standardCode, "
                            + "@programmeType, "
                            + "@frameworkCode, "
                            + "@pathwayCode, "
                            + "@paymentStatus, "
                            + "@paymentStatusDescription, "
                            + "@priority, "
                            + "@effectiveFromDate, "
                            + "@effectiveToDate"
                            + ")",
                            new
         {
             commitmentId             = commitment.CommitmentId,
             ukprn                    = commitment.Ukprn,
             uln                      = commitment.Uln,
             accountId                = commitment.AccountId,
             startDate                = commitment.StartDate,
             endDate                  = commitment.EndDate,
             agreedCost               = commitment.AgreedCost,
             standardCode             = commitment.StandardCode > 0 ? commitment.StandardCode : (long?)null,
             frameworkCode            = commitment.FrameworkCode > 0 ? commitment.FrameworkCode : (int?)null,
             programmeType            = commitment.ProgrammeType > 0 ? commitment.ProgrammeType : (int?)null,
             pathwayCode              = commitment.PathwayCode > 0 ? commitment.PathwayCode : (int?)null,
             priority                 = commitment.Priority,
             versionId                = commitment.VersionId,
             paymentStatus            = commitment.PaymentStatus,
             paymentStatusDescription = commitment.PaymentStatusDescription,
             effectiveFromDate        = commitment.EffectiveFrom,
             effectiveToDate          = commitment.EffectiveTo
         });
     }
 }
 internal static void UpdateCommitmentEffectiveTo(long commitmentId, long versionId, DateTime effectiveTo, EnvironmentVariables environmentVariables)
 {
     using (var connection = new SqlConnection(environmentVariables.DedsDatabaseConnectionString))
     {
         connection.Execute("UPDATE dbo.DasCommitments SET " +
                            "EffectiveToDate = @effectiveTo " +
                            "WHERE CommitmentId = @commitmentId " +
                            "AND VersionId = @versionId",
                            new
         {
             effectiveTo,
             commitmentId,
             versionId
         });
     }
 }
Пример #18
0
        public bool Startup(Func <ILogHandler>?logHandlerFactory = null)
        {
            ReadInitialLaunchState();

            SetupLogging(_logManager, logHandlerFactory ?? (() => new ConsoleLogHandler()));

            _taskManager.Initialize();

            // Figure out user data directory.
            var userDataDir = GetUserDataDir();

            _configurationManager.Initialize(false);

            if (LoadConfigAndUserData)
            {
                var configFile = Path.Combine(userDataDir, "client_config.toml");
                if (File.Exists(configFile))
                {
                    // Load config from user data if available.
                    _configurationManager.LoadFromFile(configFile);
                }
                else
                {
                    // Else we just use code-defined defaults and let it save to file when the user changes things.
                    _configurationManager.SetSaveFile(configFile);
                }
            }

            _configurationManager.LoadCVarsFromAssembly(typeof(GameController).Assembly);        // Client
            _configurationManager.LoadCVarsFromAssembly(typeof(IConfigurationManager).Assembly); // Shared

            _configurationManager.OverrideConVars(EnvironmentVariables.GetEnvironmentCVars());

            if (_commandLineArgs != null)
            {
                _configurationManager.OverrideConVars(_commandLineArgs.CVars);
            }

            _signalHandler.MaybeStart();

            _resourceCache.Initialize(LoadConfigAndUserData ? userDataDir : null);

#if FULL_RELEASE
            _resourceCache.MountContentDirectory(@"Resources/");
#else
            var contentRootDir = ProgramShared.FindContentRootDir();
            _resourceCache.MountContentDirectory($@"{contentRootDir}RobustToolbox/Resources/");
            _resourceCache.MountContentDirectory($@"{contentRootDir}bin/Content.Client/",
                                                 new ResourcePath("/Assemblies/"));
            _resourceCache.MountContentDirectory($@"{contentRootDir}Resources/");
#endif

            // Bring display up as soon as resources are mounted.
            if (!_clyde.Initialize())
            {
                return(false);
            }

            _clyde.SetWindowTitle("Space Station 14");

            _fontManager.Initialize();

            // Disable load context usage on content start.
            // This prevents Content.Client being loaded twice and things like csi blowing up because of it.
            _modLoader.SetUseLoadContext(!_disableAssemblyLoadContext);

            //identical code for server in baseserver
            if (!_modLoader.TryLoadAssembly <GameShared>(_resourceManager, $"Content.Shared"))
            {
                Logger.FatalS("eng", "Could not load any Shared DLL.");
                throw new NotSupportedException("Cannot load client without content assembly");
            }

            if (!_modLoader.TryLoadAssembly <GameClient>(_resourceManager, $"Content.Client"))
            {
                Logger.FatalS("eng", "Could not load any Client DLL.");
                throw new NotSupportedException("Cannot load client without content assembly");
            }


            _configurationManager.LoadCVarsFromAssembly(_modLoader.GetAssembly("Content.Client"));
            _configurationManager.LoadCVarsFromAssembly(_modLoader.GetAssembly("Content.Shared"));

            // Call Init in game assemblies.
            _modLoader.BroadcastRunLevel(ModRunLevel.PreInit);
            _modLoader.BroadcastRunLevel(ModRunLevel.Init);

            _userInterfaceManager.Initialize();
            _networkManager.Initialize(false);
            _serializer.Initialize();
            _inputManager.Initialize();
            _console.Initialize();
            _prototypeManager.LoadDirectory(new ResourcePath(@"/Prototypes/"));
            _prototypeManager.Resync();
            _mapManager.Initialize();
            _entityManager.Initialize();
            _gameStateManager.Initialize();
            _placementManager.Initialize();
            _viewVariablesManager.Initialize();
            _conGroupController.Initialize();
            _scriptClient.Initialize();

            _client.Initialize();
            _discord.Initialize();
            _modLoader.BroadcastRunLevel(ModRunLevel.PostInit);

            if (_commandLineArgs?.Username != null)
            {
                _client.PlayerNameOverride = _commandLineArgs.Username;
            }

            _clyde.Ready();

            if ((_commandLineArgs?.Connect == true || _commandLineArgs?.Launcher == true) &&
                LaunchState.ConnectEndpoint != null)
            {
                _client.ConnectToServer(LaunchState.ConnectEndpoint);
            }

            return(true);
        }
Пример #19
0
 private void SetEnvironment()
 {
     EnvironmentVariables.CurrentEnvironment = EnvironmentType.Web;
     EnvironmentVariables.RegisterViewer(new IseWebBussinessExceptionViewer(), EnvironmentVariables.CurrentEnvironment);
 }
Пример #20
0
        public Command GetCommand()
        {
            TABLE.Add(new CommandArgumentEntry("[string] [string] [string]", false, "[type(STR/EXSTR/MSTR/DWORD/QWORD/BINARY)] [name] [value]"));
            CMD_VAL_MAKE = new Command("VAL-MAKE", TABLE, false, "Creates a new value in the current subkey.", ExecutionLevel.Administrator, CLIMode.Regedit);
            CMD_VAL_MAKE.SetFunction(() =>
            {
                RegistryKey key = RegistryKey.OpenBaseKey((RegistryHive)Enum.Parse(typeof(RegistryHive), EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().Substring(0, EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().IndexOf("\\"))), RegistryView.Default).OpenSubKey(EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().Substring(EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().IndexOf("\\") + 1), true);
                string name     = CMD_VAL_MAKE.InputArgumentEntry.Arguments[1].Value.ToString();
                string value    = CMD_VAL_MAKE.InputArgumentEntry.Arguments[2].Value.ToString();
                string type_str = CMD_VAL_MAKE.InputArgumentEntry.Arguments[0].Value.ToString();
                RegistryValueKind type;
                switch (type_str)
                {
                case "STR":
                    type = RegistryValueKind.String;
                    break;

                case "EXSTR":
                    type = RegistryValueKind.ExpandString;
                    break;

                case "MSTR":
                    type = RegistryValueKind.MultiString;
                    break;

                case "DWORD":
                    type = RegistryValueKind.DWord;
                    break;

                case "QWORD":
                    type = RegistryValueKind.QWord;
                    break;

                case "BINARY":
                    type = RegistryValueKind.Binary;
                    break;

                default:
                    return("\nInvalid type!");
                }
                try
                {
                    if (key.GetValueNames().Contains(name))
                    {
                        return("\nValue already exists!");
                    }
                    else
                    {
                        key.SetValue(name, value, type);
                        return("");
                    }
                }
                catch (Exception ex)
                {
                    return("\n" + ex.Message);
                }
            });
            return(CMD_VAL_MAKE);
        }
Пример #21
0
        public bool Startup(Func <ILogHandler>?logHandlerFactory = null)
        {
            ReadInitialLaunchState();

            SetupLogging(_logManager, logHandlerFactory ?? (() => new ConsoleLogHandler()));

            _taskManager.Initialize();

            // Figure out user data directory.
            var userDataDir = GetUserDataDir();

            _configurationManager.Initialize(false);

            // MUST load cvars before loading from config file so the cfg manager is aware of secure cvars.
            // So SECURE CVars are blacklisted from config.
            _configurationManager.LoadCVarsFromAssembly(typeof(GameController).Assembly);        // Client
            _configurationManager.LoadCVarsFromAssembly(typeof(IConfigurationManager).Assembly); // Shared

            if (LoadConfigAndUserData)
            {
                var configFile = Path.Combine(userDataDir, "client_config.toml");
                if (File.Exists(configFile))
                {
                    // Load config from user data if available.
                    _configurationManager.LoadFromFile(configFile);
                }
                else
                {
                    // Else we just use code-defined defaults and let it save to file when the user changes things.
                    _configurationManager.SetSaveFile(configFile);
                }
            }

            _configurationManager.OverrideConVars(EnvironmentVariables.GetEnvironmentCVars());

            if (_commandLineArgs != null)
            {
                _configurationManager.OverrideConVars(_commandLineArgs.CVars);
            }

            _resourceCache.Initialize(LoadConfigAndUserData ? userDataDir : null);

            ProgramShared.DoMounts(_resourceCache, _commandLineArgs?.MountOptions, "Content.Client", _loaderArgs != null);
            if (_loaderArgs != null)
            {
                _stringSerializer.EnableCaching = false;
                _resourceCache.MountLoaderApi(_loaderArgs.FileApi, "Resources/");
                _modLoader.VerifierExtraLoadHandler = VerifierExtraLoadHandler;
            }

            // Bring display up as soon as resources are mounted.
            if (!_clyde.Initialize())
            {
                return(false);
            }

            _clyde.SetWindowTitle("Space Station 14");

            _fontManager.Initialize();

            // Disable load context usage on content start.
            // This prevents Content.Client being loaded twice and things like csi blowing up because of it.
            _modLoader.SetUseLoadContext(!_disableAssemblyLoadContext);
            _modLoader.SetEnableSandboxing(true);

            if (!_modLoader.TryLoadModulesFrom(new ResourcePath("/Assemblies/"), "Content."))
            {
                Logger.Fatal("Errors while loading content assemblies.");
                return(false);
            }

            foreach (var loadedModule in _modLoader.LoadedModules)
            {
                _configurationManager.LoadCVarsFromAssembly(loadedModule);
            }

            // Call Init in game assemblies.
            _modLoader.BroadcastRunLevel(ModRunLevel.PreInit);
            _modLoader.BroadcastRunLevel(ModRunLevel.Init);

            _userInterfaceManager.Initialize();
            _networkManager.Initialize(false);
            _serializer.Initialize();
            _inputManager.Initialize();
            _console.Initialize();
            _prototypeManager.LoadDirectory(new ResourcePath(@"/Prototypes/"));
            _prototypeManager.Resync();
            _mapManager.Initialize();
            _entityManager.Initialize();
            _gameStateManager.Initialize();
            _placementManager.Initialize();
            _viewVariablesManager.Initialize();
            _scriptClient.Initialize();

            _client.Initialize();
            _discord.Initialize();
            _modLoader.BroadcastRunLevel(ModRunLevel.PostInit);

            if (_commandLineArgs?.Username != null)
            {
                _client.PlayerNameOverride = _commandLineArgs.Username;
            }

            _clyde.Ready();

            if ((_commandLineArgs?.Connect == true || _commandLineArgs?.Launcher == true) &&
                LaunchState.ConnectEndpoint != null)
            {
                _client.ConnectToServer(LaunchState.ConnectEndpoint);
            }

            return(true);
        }
 private static Task <int> Main(string[] args) =>
 App.CreateAndRunAsync(args, EnvironmentVariables.GetEnvironmentVariables().Variables);
 internal static void CreateTestRun(string runId, DateTime startDate, string machineName, EnvironmentVariables environmentVariables)
 {
     using (var connection = new SqlConnection(environmentVariables.DedsDatabaseConnectionString))
     {
         connection.Execute("INSERT INTO AT.TestRuns (RunId,StartDtTm,MachineName) VALUES (@runId,@startDate,@machineName)",
                            new { runId, startDate, machineName });
     }
 }
 public CommandProcessor(IApplicationFactoriesProvider applicationFactoriesProvider, EnvironmentVariables environmentVariables)
 {
     _commandParser = new SimpleCommandParser();
     _applicationFactoriesProvider = applicationFactoriesProvider;
     _environmentVariables         = environmentVariables;
     EnvironmentVariables.Set(_environmentVariables);
 }
Пример #25
0
        /// <inheritdoc />
        public bool Start(Func <ILogHandler>?logHandlerFactory = null)
        {
            if (LoadConfigAndUserData)
            {
                // Sets up the configMgr
                // If a config file path was passed, use it literally.
                // This ensures it's working-directory relative
                // (for people passing config file through the terminal or something).
                // Otherwise use the one next to the executable.
                if (_commandLineArgs?.ConfigFile != null)
                {
                    _config.LoadFromFile(_commandLineArgs.ConfigFile);
                }
                else
                {
                    var path = PathHelpers.ExecutableRelativeFile("server_config.toml");
                    if (File.Exists(path))
                    {
                        _config.LoadFromFile(path);
                    }
                    else
                    {
                        _config.SetSaveFile(path);
                    }
                }
            }

            _config.OverrideConVars(EnvironmentVariables.GetEnvironmentCVars());

            if (_commandLineArgs != null)
            {
                _config.OverrideConVars(_commandLineArgs.CVars);
            }


            //Sets up Logging
            _config.RegisterCVar("log.enabled", true, CVar.ARCHIVE);
            _config.RegisterCVar("log.path", "logs", CVar.ARCHIVE);
            _config.RegisterCVar("log.format", "log_%(date)s-T%(time)s.txt", CVar.ARCHIVE);
            _config.RegisterCVar("log.level", LogLevel.Info, CVar.ARCHIVE);
            _config.RegisterCVar("log.runtimelog", true, CVar.ARCHIVE);

            _logHandlerFactory = logHandlerFactory;

            var logHandler = logHandlerFactory?.Invoke() ?? null;

            var logEnabled = _config.GetCVar <bool>("log.enabled");

            if (logEnabled && logHandler == null)
            {
                var logPath     = _config.GetCVar <string>("log.path");
                var logFormat   = _config.GetCVar <string>("log.format");
                var logFilename = logFormat.Replace("%(date)s", DateTime.Now.ToString("yyyy-MM-dd"))
                                  .Replace("%(time)s", DateTime.Now.ToString("hh-mm-ss"));
                var fullPath = Path.Combine(logPath, logFilename);

                if (!Path.IsPathRooted(fullPath))
                {
                    logPath = PathHelpers.ExecutableRelativeFile(fullPath);
                }

                logHandler = new FileLogHandler(logPath);
            }

            _log.RootSawmill.Level = _config.GetCVar <LogLevel>("log.level");

            if (logEnabled && logHandler != null)
            {
                _logHandler = logHandler;
                _log.RootSawmill.AddHandler(_logHandler !);
            }

            SelfLog.Enable(s =>
            {
                System.Console.WriteLine("SERILOG ERROR: {0}", s);
            });

            if (!SetupLoki())
            {
                return(true);
            }

            // Has to be done early because this guy's in charge of the main thread Synchronization Context.
            _taskManager.Initialize();

            LoadSettings();

            // Load metrics really early so that we can profile startup times in the future maybe.
            _metricsManager.Initialize();

            var netMan = IoCManager.Resolve <IServerNetManager>();

            try
            {
                netMan.Initialize(true);
                netMan.StartServer();
                netMan.RegisterNetMessage <MsgSetTickRate>(MsgSetTickRate.NAME);
            }
            catch (Exception e)
            {
                var port = netMan.Port;
                Logger.Fatal(
                    "Unable to setup networking manager. Check port {0} is not already in use and that all binding addresses are correct!\n{1}",
                    port, e);
                return(true);
            }

            var dataDir = LoadConfigAndUserData ?
                          _commandLineArgs?.DataDir ?? PathHelpers.ExecutableRelativeFile("data") :
                          null;

            // Set up the VFS
            _resources.Initialize(dataDir);

#if FULL_RELEASE
            _resources.MountContentDirectory(@"./Resources/");
#else
            // Load from the resources dir in the repo root instead.
            // It's a debug build so this is fine.
            var contentRootDir = ProgramShared.FindContentRootDir();
            _resources.MountContentDirectory($@"{contentRootDir}RobustToolbox/Resources/");
            _resources.MountContentDirectory($@"{contentRootDir}bin/Content.Server/", new ResourcePath("/Assemblies/"));
            _resources.MountContentDirectory($@"{contentRootDir}Resources/");
#endif

            _modLoader.SetUseLoadContext(!DisableLoadContext);

            //identical code in game controller for client
            if (!_modLoader.TryLoadAssembly <GameShared>(_resources, $"Content.Shared"))
            {
                Logger.FatalS("eng", "Could not load any Shared DLL.");
                return(true);
            }

            if (!_modLoader.TryLoadAssembly <GameServer>(_resources, $"Content.Server"))
            {
                Logger.FatalS("eng", "Could not load any Server DLL.");
                return(true);
            }

            _modLoader.BroadcastRunLevel(ModRunLevel.PreInit);

            // HAS to happen after content gets loaded.
            // Else the content types won't be included.
            // TODO: solve this properly.
            _serializer.Initialize();

            //IoCManager.Resolve<IMapLoader>().LoadedMapData +=
            //    IoCManager.Resolve<IRobustMappedStringSerializer>().AddStrings;
            IoCManager.Resolve <IPrototypeManager>().LoadedData +=
                (yaml, name) => _stringSerializer.AddStrings(yaml);

            // Initialize Tier 2 services
            IoCManager.Resolve <IGameTiming>().InSimulation = true;

            _stateManager.Initialize();
            IoCManager.Resolve <IPlayerManager>().Initialize(MaxPlayers);
            _mapManager.Initialize();
            _mapManager.Startup();
            IoCManager.Resolve <IPlacementManager>().Initialize();
            IoCManager.Resolve <IViewVariablesHost>().Initialize();
            IoCManager.Resolve <IDebugDrawingManager>().Initialize();

            // Call Init in game assemblies.
            _modLoader.BroadcastRunLevel(ModRunLevel.Init);

            _entities.Initialize();

            // because of 'reasons' this has to be called after the last assembly is loaded
            // otherwise the prototypes will be cleared
            var prototypeManager = IoCManager.Resolve <IPrototypeManager>();
            prototypeManager.LoadDirectory(new ResourcePath(@"/Prototypes"));
            prototypeManager.Resync();

            IoCManager.Resolve <IConsoleShell>().Initialize();
            IoCManager.Resolve <IConGroupController>().Initialize();
            _entities.Startup();
            _scriptHost.Initialize();

            _modLoader.BroadcastRunLevel(ModRunLevel.PostInit);

            IoCManager.Resolve <IStatusHost>().Start();

            AppDomain.CurrentDomain.ProcessExit += ProcessExiting;

            _watchdogApi.Initialize();

            _stringSerializer.LockStrings();

            return(false);
        }
Пример #26
0
 public Command GetCommand()
 {
     TABLE.Add(new CommandArgumentEntry("[int]", false, "[entry index]"));
     TABLE.Add(new CommandArgumentEntry("[int] -r", false, "[entry index] -r(reverse search)"));
     CMD_HISTORY_GETENTRY = new Command("HISTORY-GETENTRY", TABLE, false, "Returns the specified history entry of the current CLI mode.", ExecutionLevel.User, CLIMode.Any);
     CMD_HISTORY_GETENTRY.SetFunction(() =>
     {
         int entry       = (int)CMD_HISTORY_GETENTRY.InputArgumentEntry.Arguments.Find(x => x.Call == "").Value;
         string var_name = (string)EnvironmentVariables.GetCurrentValue("CLI_MODE") == "Default" ? "DEF_HIST_SIZE" : "REG_HIST_SIZE";
         if ((int)EnvironmentVariables.GetCurrentValue(var_name) >= entry && entry > 0)
         {
             if (CMD_HISTORY_GETENTRY.InputArgumentEntry.Arguments.Exists(x => x.Call == "-r"))
             {
                 IOInteractLayer.StandardOutput(CMD_HISTORY_GETENTRY, "\n\t" + ((List <string>)EnvironmentVariables.GetCurrentValue(var_name))[((List <string>)EnvironmentVariables.GetCurrentValue(var_name)).Count - (int)CMD_HISTORY_GETENTRY.InputArgumentEntry.Arguments.Find(x => x.Call == "").Value]);
             }
             else
             {
                 IOInteractLayer.StandardOutput(CMD_HISTORY_GETENTRY, "\n\t" + ((List <string>)EnvironmentVariables.GetCurrentValue(var_name))[(int)CMD_HISTORY_GETENTRY.InputArgumentEntry.Arguments.Find(x => x.Call == "").Value]);
             }
         }
         return("");
     });
     return(CMD_HISTORY_GETENTRY);
 }
Пример #27
0
 public CoinKernelViewModel(Guid id)
 {
     _id = id;
     this.AddEnvironmentVariable = new DelegateCommand(() => {
         VirtualRoot.Execute(new EnvironmentVariableEditCommand(this, new EnvironmentVariable()));
     });
     this.EditEnvironmentVariable = new DelegateCommand <EnvironmentVariable>(environmentVariable => {
         VirtualRoot.Execute(new EnvironmentVariableEditCommand(this, environmentVariable));
     });
     this.RemoveEnvironmentVariable = new DelegateCommand <EnvironmentVariable>(environmentVariable => {
         this.ShowDialog(new DialogWindowViewModel(message: $"您确定删除环境变量{environmentVariable.Key}吗?", title: "确认", onYes: () => {
             this.EnvironmentVariables.Remove(environmentVariable);
             EnvironmentVariables = EnvironmentVariables.ToList();
         }));
     });
     this.AddSegment = new DelegateCommand(() => {
         VirtualRoot.Execute(new InputSegmentEditCommand(this, new InputSegmentViewModel()));
     });
     this.EditSegment = new DelegateCommand <InputSegmentViewModel>((segment) => {
         VirtualRoot.Execute(new InputSegmentEditCommand(this, segment));
     });
     this.RemoveSegment = new DelegateCommand <InputSegment>((segment) => {
         this.ShowDialog(new DialogWindowViewModel(message: $"您确定删除片段{segment.Name}吗?", title: "确认", onYes: () => {
             this.InputSegments.Remove(segment);
             InputSegments = InputSegments.ToList();
         }));
     });
     this.RemoveFileWriter = new DelegateCommand <FileWriterViewModel>((writer) => {
         this.ShowDialog(new DialogWindowViewModel(message: $"您确定删除文件书写器{writer.Name}吗?", title: "确认", onYes: () => {
             this.FileWriterVms.Remove(writer);
             List <Guid> writerIds = new List <Guid>(this.FileWriterIds);
             writerIds.Remove(writer.Id);
             this.FileWriterIds = writerIds;
         }));
     });
     this.RemoveFragmentWriter = new DelegateCommand <FragmentWriterViewModel>((writer) => {
         this.ShowDialog(new DialogWindowViewModel(message: $"您确定删除文件书写器{writer.Name}吗?", title: "确认", onYes: () => {
             this.FragmentWriterVms.Remove(writer);
             List <Guid> writerIds = new List <Guid>(this.FragmentWriterIds);
             writerIds.Remove(writer.Id);
             this.FragmentWriterIds = writerIds;
         }));
     });
     this.Save = new DelegateCommand(() => {
         if (NTMinerRoot.Instance.CoinKernelSet.Contains(this.Id))
         {
             VirtualRoot.Execute(new UpdateCoinKernelCommand(this));
         }
         CloseWindow?.Invoke();
     });
     this.Edit = new DelegateCommand <FormType?>((formType) => {
         VirtualRoot.Execute(new CoinKernelEditCommand(formType ?? FormType.Edit, this));
     });
     this.Remove = new DelegateCommand(() => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         this.ShowDialog(new DialogWindowViewModel(message: $"您确定删除{Kernel.Code}币种内核吗?", title: "确认", onYes: () => {
             VirtualRoot.Execute(new RemoveCoinKernelCommand(this.Id));
             Kernel.OnPropertyChanged(nameof(Kernel.SupportedCoins));
         }));
     });
 }
        private List <IResource> LoadWorkspaceImpl(Guid workspaceID)
        {
            var workspacePath = workspaceID == GlobalConstants.ServerWorkspaceID ? EnvironmentVariables.ResourcePath : EnvironmentVariables.GetWorkspacePath(workspaceID);
            IList <IResource> userServices = new List <IResource>();

            if (Directory.Exists(workspacePath))
            {
                var folders    = Directory.EnumerateDirectories(workspacePath, "*", SearchOption.AllDirectories);
                var allFolders = folders.ToList();
                allFolders.Add(workspacePath);
                userServices = LoadWorkspaceViaBuilder(workspacePath, workspaceID == GlobalConstants.ServerWorkspaceID, allFolders.ToArray());
            }
            var result    = userServices.Union(ManagementServices.Values);
            var resources = result.ToList();

            return(resources);
        }
 internal static void CreateNewCommmitmentVersion(long commitmentId, long versionId, CommitmentPaymentStatus paymentStatus, DateTime effectiveFrom, EnvironmentVariables environmentVariables)
 {
     using (var connection = new SqlConnection(environmentVariables.DedsDatabaseConnectionString))
     {
         connection.Execute("INSERT INTO DasCommitments ("
                            + "CommitmentId, "
                            + "VersionId, "
                            + "Uln, "
                            + "Ukprn, "
                            + "AccountId, "
                            + "StartDate, "
                            + "EndDate, "
                            + "AgreedCost, "
                            + "StandardCode, "
                            + "ProgrammeType, "
                            + "FrameworkCode, "
                            + "PathwayCode, "
                            + "PaymentStatus, "
                            + "PaymentStatusDescription, "
                            + "Priority, "
                            + "EffectiveFromDate"
                            + ") "
                            + "SELECT "
                            + "CommitmentId, "
                            + "VersionId + 1, "
                            + "Uln, "
                            + "Ukprn, "
                            + "AccountId, "
                            + "StartDate, "
                            + "EndDate, "
                            + "AgreedCost, "
                            + "StandardCode, "
                            + "ProgrammeType, "
                            + "FrameworkCode, "
                            + "PathwayCode, "
                            + "@paymentStatus, "
                            + "@paymentStatusDescription, "
                            + "Priority, "
                            + "@effectiveFromDate "
                            + "FROM DasCommitments "
                            + "WHERE CommitmentId = @commitmentId "
                            + "AND VersionId = @versionId",
                            new
         {
             commitmentId,
             versionId,
             paymentStatus            = (int)paymentStatus,
             paymentStatusDescription = paymentStatus.ToString(),
             effectiveFromDate        = effectiveFrom
         });
     }
 }
Пример #30
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ResourceCatalog" /> class.
        /// <remarks>
        /// DO NOT instantiate directly - use static Instance property instead; this is for testing only!
        /// </remarks>
        /// </summary>
        /// <param name="managementServices">The management services to be loaded.</param>
        public ResourceCatalog(IEnumerable <DynamicService> managementServices = null)
        {
            InitializeWorkspaceResources();
            // MUST load management services BEFORE server workspace!!
            IServerVersionRepository versioningRepository = new ServerVersionRepository(new VersionStrategy(), this, new DirectoryWrapper(), EnvironmentVariables.GetWorkspacePath(GlobalConstants.ServerWorkspaceID), new FileWrapper());

            _catalogPluginContainer = new ResourceCatalogPluginContainer(versioningRepository, WorkspaceResources, managementServices);
            _catalogPluginContainer.Build(this);
        }