示例#1
0
        private void startWorkerServer(
            ConfigurationState configurationState,
            ConfigurationOptions options,
            BackgroundJobServerOptions serverOptions,
            List <IBackgroundProcess> backgroundProcesses)
        {
            serverOptions = copyOptions(serverOptions);

            if (options.UseWorkerDeterminer)
            {
                serverOptions.WorkerCount = _workerDeterminer.DetermineWorkerCount(
                    configurationState.MonitoringApi,
                    configurationState.Configuration,
                    options.WorkerDeterminerOptions
                    );
            }

            _hangfire.UseHangfireServer(
                configurationState.JobStorage,
                serverOptions,
                backgroundProcesses.ToArray()
                );

            backgroundProcesses.Clear();
        }
        public int Invoke(Dictionary<string, string> args)
        {
            var saveAsTemplate = args.Keys.Contains(Arguments.SaveTemplate) &&
                                 Boolean.Parse(args[Arguments.SaveTemplate]);
            var credentials = new Credentials(args[Arguments.Username], args[Arguments.Password]);
            var configName = args[Arguments.ConfigName];
            var logger = LoggerFactory.GetLogger();

            // Deserialize the persisted values from a previous run. The previous run would have saved off
            // a config URL, any IDs for reference, among other things.
            var configState = new ConfigurationState();
            var config = configState.Deserialize(configName);

            // FUTURE: May want to consider cleaning up the interim persistence XML file here after every run,
            // although it can be useful for debugging purposes.

            // FUTURE: Use the log file path in the persisted data to append to an existing log file instead of
            // creating a new one. Note that this will need to be done at the program level as opposed to individual
            // commands, which is more work. Suggest moving the deserialization logic earlier (program level) and
            // setting up the log file once.

            logger.LogInfo(config.ToString());

            // Saving a template will automatically put the configuration into a suspended state. If a template is
            // not being saved, then force the suspended state. Although not strictly necessary, this makes deleting
            // connections and subsequently shutdown more robust.
            if (saveAsTemplate)
            {
                SkytapApi.SaveAsSkytapTemplate(credentials, config.ConfigurationUrl);
            }
            else
            {
                SkytapApi.SetConfigurationState(credentials, config.ConfigurationUrl, ConfigurationStates.Suspended);
            }

            // Wait for Skytap to return the expected configuration state. Do this with a retry block
            // to test for the desired state every second for 5 minutes.
            Retry.Execute(() => SkytapApi.CheckConfigurationForDesiredState(credentials, config.ConfigurationUrl,
                                                                                ConfigurationStates.Suspended),
                                                                                NumRetriesCheckConfigState,
                                                                                _retryIntervalCheckConfigState);

            // Prior to deleting a configuration, query the current connection state and disconnect
            // any existing ICNR or VPN connection. This helps prevent state issues on the Skytap side
            // with not being able to recreate the configuration once again.
            CleanupConnections(credentials, config);

            // HACKHACK: this state check is an attempted workaround at resolving a response not received when deleting a configuration
            Retry.Execute(() => SkytapApi.CheckConfigurationForDesiredState(credentials, config.ConfigurationUrl,
                                                                                ConfigurationStates.Suspended),
                                                                                NumRetriesCheckConfigState,
                                                                                _retryIntervalCheckConfigState);

            // NOTE: It was determined by the engineering team that shutting down the configuration need not
            // be in a finally block. If the configuration does not shut down due to a previous error, we can
            // live with it.
            SkytapApi.ShutDownConfiguration(credentials, config.ConfigurationUrl);

            return CommandResults.Success;
        }
        internal static void Handle(JToken token, SubscribedResponse subscription, ConfigurationState config,
                                    Subject <Book> subject, Subject <Book[]> subjectSnapshot, Subject <ChecksumResponse> subjectChecksum)
        {
            var data = token[1];

            if (config.IsChecksumEnabled)
            {
                if (data?.Type == JTokenType.String && data.Value <string>() == "cs")
                {
                    ChecksumResponse.Handle(token, subscription, config, subjectChecksum);
                    return;
                }
            }

            if (data?.Type != JTokenType.Array)
            {
                return; // heartbeat, ignore
            }

            if (data.First?.Type == JTokenType.Array)
            {
                // initial snapshot
                Handle(token, data.ToObject <Book[]>(), subscription, config, subject, subjectSnapshot);
                return;
            }

            var book = data.ToObject <Book>();

            book.Pair   = subscription.Pair;
            book.Symbol = subscription.Symbol;
            book.ChanId = subscription.ChanId;
            SetGlobalData(book, config, token);
            subject.OnNext(book);
        }
示例#4
0
        private void FrmAddressBook_Load(object sender, EventArgs e)
        {
            ConfigurationState state    = new ConfigurationState();
            string             fileName = state.Get("AddressBookFileName");

            this.selectDialog.Text = fileName;
        }
示例#5
0
        private void UploadFile_Load(object sender, EventArgs e)
        {
            ConfigurationState state = new ConfigurationState();
            string             path  = state.Get(localPathKey);

            this.dialogLocal.Text = path;
        }
示例#6
0
 private void InitForSucces(ConfigurationState state)
 {
     state.ShowWelcome = true;
     factory.Stub(x => x.CreateWelcomeView()).Return(view);
     config.Stub(x => x.LoadConfiguration()).Repeat.Once().Return(state);
     view.Stub(x => x.ShowView()).Repeat.Once().Return(true);
 }
示例#7
0
        private void SysteConfig_Load(object sender, EventArgs e)
        {
            ConfigurationState state = new ConfigurationState();

            this.checkAutoLogon.Checked  = state.Get(StateKeys.IsAutoLogon) == "1" ? true : false;
            this.checkAutoUpdate.Checked = state.Get(StateKeys.IsAutoUpdate) == "1" ? true : false;
        }
示例#8
0
        private void InitializeStatePanel(ConfigurationState state)
        {
            walkthroughIndexLabel.Dock = DockStyle.None;
            walkthroughIndexLabel.Text = (int)(ConfigWalkthroughState + 1) + ".";
            walkthroughIndexLabel.Dock = DockStyle.Fill;

            if (CurrentStatePanel != null)
            {
                Panel curStatePanel = CurrentStatePanel;
                curStatePanel.Dock    = DockStyle.None;
                curStatePanel.Anchor  = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom;
                curStatePanel.Visible = false;
            }

            switch (state)
            {
            case ConfigurationState.SELECT_DOWNSCALING:
                sizeWidthTextBox.IntegerValue  = 0;
                sizeHeightTextBox.IntegerValue = 0;
                sizeScaleTrackBar.Minimum      = 0;
                sizeScaleTrackBar.Maximum      = 10;
                sizeScaleTrackBar.Value        = 10;

                CurrentStatePanel = SizeValueStatePanel;
                break;

            case ConfigurationState.SELECT_ANCHORS:
                CurrentStatePanel = AnchorsStatePanel;
                break;
            }

            CurrentStatePanel.Location = new Point(400, 0);
            CurrentStatePanel.Visible  = true;
            CurrentStatePanel.Dock     = DockStyle.Fill;
        }
示例#9
0
        public void VerifyConfiguration()
        {
            try
            {
                string path       = Path.Combine(Directory, Name + ".cfg");
                var    serializer = new XmlSerializer(DataLoaderParams.GetType());

                if (File.Exists(path))
                {
                    using (FileStream stream = File.Open(path, FileMode.Open, FileAccess.Read))
                    {
                        var parameters = (DataLoaderParams)serializer.Deserialize(stream);
                        ConfigurationState = parameters.TableMetadataEntity.IsEmpty ? VerifyPlanned(parameters) : VerifyPublished(parameters);
                    }
                }
                else
                {
                    ConfigurationState = IsPlanned ? ConfigurationState.Ready : ConfigurationState.Incomplete;
                }
            }
            catch (Exception)
            {
                ConfigurationState = ConfigurationState.Incomplete;
            }
        }
示例#10
0
        /// <summary>
        /// Sets global data (timestamp, sequence) if it is enabled by configuration.
        /// </summary>
        internal static void SetGlobalData(ResponseBase response, ConfigurationState config, JToken data, int lastPosition = 1, bool isPrivateChannel = false)
        {
            try
            {
                var position = lastPosition + 1;

                if (config.IsSequencingEnabled)
                {
                    var sequence = data[position].Value <long?>();
                    response.ServerSequence = sequence;
                    position++;

                    if (isPrivateChannel)
                    {
                        // private channels send different sequence numbers
                        var privateSequence = data[position].Value <long?>();
                        response.ServerPrivateSequence = privateSequence;
                        position++;
                    }
                }

                if (config.IsTimestampEnabled)
                {
                    var mts = data[position].Value <long?>();
                    response.ServerTimestamp = BitfinexTime.ConvertToTime(mts);
                    // position++;
                }
            }
            catch (Exception e)
            {
                Log.Warn($"[BFX response] Failed to parse global data (timestamp, sequence). Error: {e.Message}");
            }
        }
示例#11
0
 private void Main_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (!string.IsNullOrEmpty(Global.GetCurrentProjectID()))
     {
         ConfigurationState state = new ConfigurationState();
         state.Set("HistoryProjectID", Global.GetCurrentProjectID());
     }
 }
 void Init(SignalBus signalBus)
 {
     _signalBus = signalBus;
     _signalBus.Subscribe <SystemSignal.GameMode.ConfigureShip.Activate>(ActivateUI);
     _signalBus.Subscribe <SystemSignal.GameMode.ConfigureShip.Deactivate>(DeactivateUI);
     DeactivateUI();
     _state = ConfigurationState.SelectControlSlot;
 }
示例#13
0
        public override bool SaveData()
        {
            ConfigurationState state = new ConfigurationState();

            state.Set(StateKeys.IsAutoLogon, this.checkAutoLogon.Checked ? "1" : "0");
            state.Set(StateKeys.IsAutoUpdate, this.checkAutoUpdate.Checked ? "1" : "0");
            return(true);
        }
 internal ConfigurationInfo(ConfigurationState state)
 {
     _state = state;
     // storage should be created when querying
     // because... compatibility?
     // well, there's red tests without it
     _state.EnsureJobStorageInitialized();
 }
示例#15
0
 private void selectDialog_OnSelectDialogOk(object sender, string url)
 {
     if (!string.IsNullOrEmpty(url))
     {
         ConfigurationState state = new ConfigurationState();
         state.Set("AddressBookFileName", url);
     }
 }
示例#16
0
        static void Main(string[] args)
        {
            Console.Title = "Ryujinx Console";

            string systemPath = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.Machine);

            Environment.SetEnvironmentVariable("Path", $"{Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin")};{systemPath}");

            GLib.ExceptionManager.UnhandledException += Glib_UnhandledException;

            // Initialize the configuration
            ConfigurationState.Initialize();

            // Initialize the logger system
            LoggerModule.Initialize();

            // Initialize Discord integration
            DiscordIntegrationModule.Initialize();

            string configurationPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config.json");

            // Now load the configuration as the other subsystems are now registered
            if (File.Exists(configurationPath))
            {
                ConfigurationFileFormat configurationFileFormat = ConfigurationFileFormat.Load(configurationPath);
                ConfigurationState.Instance.Load(configurationFileFormat);
            }
            else
            {
                // No configuration, we load the default values and save it on disk
                ConfigurationState.Instance.LoadDefault();
                ConfigurationState.Instance.ToFileFormat().SaveConfig(configurationPath);
            }


            Profile.Initialize();

            Application.Init();

            string appDataPath     = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Ryujinx", "system", "prod.keys");
            string userProfilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".switch", "prod.keys");

            if (!File.Exists(appDataPath) && !File.Exists(userProfilePath) && !Migration.IsMigrationNeeded())
            {
                GtkDialog.CreateErrorDialog("Key file was not found. Please refer to `KEYS.md` for more info");
            }

            MainWindow mainWindow = new MainWindow();

            mainWindow.Show();

            if (args.Length == 1)
            {
                mainWindow.LoadApplication(args[0]);
            }

            Application.Run();
        }
 private void StartSelectSlots()
 {
     StopAllCoroutines();
     _signalBus.Fire(new SystemSignal.Ship.ConfigureSlots());
     _cycleAliens = true;
     _cycleSlots  = true;
     _state       = ConfigurationState.SelectControlSlot;
     StartCoroutine(CycleSlots());
 }
示例#18
0
        private void FTPConnection_Load(object sender, EventArgs e)
        {
            ConfigurationState state = new ConfigurationState();

            this.txtAddress.Text = state.Get(ftpAddressKey);
            this.txtPort.Text    = state.Get(ftpPortKey);
            this.txtUid.Text     = state.Get(ftpUidKey);
            this.txtPwd.Text     = state.Get(ftpPwdKey);
        }
示例#19
0
 private void ActivatePartSelection()
 {
     if (_activeListView != null)
     {
         _activeListView.Deactivate();
     }
     _state          = ConfigurationState.SelectItem;
     _activeListView = AvailableShipParts;
     _activeListView.Activate();
 }
示例#20
0
        private void StartWalkthrough()
        {
            nextBtn.Text      = "NEXT";
            nextBtn.BackColor = Color.LightSlateGray;

            CurrentStatePanel = null;

            ConfigWalkthroughState = 0;
            CurrentNextAction      = new Action(NextState);
        }
 private void StartSelectAliens()
 {
     StopAllCoroutines();
     _signalBus.Fire(new SystemSignal.Ship.ConfigureControls());
     ShipControls.ActivateSelectedSlot();
     _state       = ConfigurationState.SelectItem;
     _cycleSlots  = false;
     _cycleAliens = true;
     StartCoroutine(CycleAliens());
 }
示例#22
0
        /// <summary>
        /// 加载pdm文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="url"></param>
        private void selectDialog1_OnSelectDialogOk(object sender, string url)
        {
            if (!string.IsNullOrEmpty(url))
            {
                ConfigurationState state = new ConfigurationState();
                state.Set(StateKeys.ReadPdmPath, url);

                BindTables(url);
            }
        }
示例#23
0
        void CodeBuilder_FormClosing(object sender, FormClosingEventArgs e)
        {
            string path = this.selectDialog.Text;

            if (!string.IsNullOrEmpty(path))
            {
                ConfigurationState state = new ConfigurationState();
                state.Set("CodeBuilderPath", path);
            }
        }
示例#24
0
    private void ActivateShipSlots()
    {
        if (_activeListView != null)
        {
            _activeListView.Deactivate();
        }

        _state          = ConfigurationState.SelectControlSlot;
        _activeListView = ShipControls;
        _activeListView.Activate();
    }
示例#25
0
        private void CodeBuilder_Load(object sender, EventArgs e)
        {
            this.tables.DataBind(TableID);
            ProjectEntity project = Global.GetCurrentProject();

            this.template.TemplateID = project.TemplateID;
            this.template.DataBind();
            ConfigurationState state = new ConfigurationState();

            this.selectDialog.Text = state.Get("CodeBuilderPath");
        }
示例#26
0
        private void SelectStateComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (selectStateComboBox.SelectedIndex == -1)
            {
                return;
            }

            ConfigurationState configurationState = (ConfigurationState)selectStateComboBox.SelectedIndex + 3;

            ConfigWalkthroughState = configurationState;
        }
示例#27
0
        public void ShouldSaveUserSettings()
        {
            var state = new ConfigurationState();

            InitForSucces(state);
            config.Stub(x => x.SaveConfigurate(state)).Repeat.Once();
            mocks.ReplayAll();

            var controller = new WelcomeController(factory);

            controller.TryShow();
        }
示例#28
0
 public ReachableResult
 (
     VirtualNetworkService network,
     ConfigurationState configuration,
     ConnectionState connection,
     ReachableState reachable
 )
 {
     this._Network       = network;
     this._Configuration = configuration;
     this._Connection    = connection;
     this._Reachable     = reachable;
 }
示例#29
0
        internal static void Handle(JToken token, SubscribedResponse subscription, ConfigurationState config, Subject <ChecksumResponse> subject)
        {
            var checksum = token[2].Value <int>();
            var response = new ChecksumResponse()
            {
                Checksum = checksum,
                Pair     = subscription.Pair,
                ChanId   = subscription.ChanId
            };

            SetGlobalData(response, config, token, 2);
            subject.OnNext(response);
        }
        internal static void Handle(JToken token, Funding[] fundings, SubscribedResponse subscription,
                                    ConfigurationState config, Subject <Funding> subject)
        {
            var reversed = fundings.Reverse().ToArray(); // newest last

            foreach (var funding in reversed)
            {
                funding.Type   = FundingType.Executed;
                funding.Symbol = subscription.Symbol;
                funding.ChanId = subscription.ChanId;
                SetGlobalData(funding, config, token);
                subject.OnNext(funding);
            }
        }
示例#31
0
        private void TemplateExport_Load(object sender, EventArgs e)
        {
            this.template.IsShowExport   = false;
            this.template.IsShowCheckBox = true;
            if (!string.IsNullOrEmpty(TemplateTypeID))
            {
                template.TemplateID = Convert.ToInt32(TemplateTypeID);
            }
            this.template.DataBind();
            ConfigurationState state = new ConfigurationState();
            string             path  = state.Get(exportKey);

            this.selectDialog.Text = path;
        }
        public int Invoke(Dictionary<string, string> args)
        {
            var credentials = new Credentials(args[Arguments.Username], args[Arguments.Password]);
            var configId = args.ContainsKey(Arguments.ConfigId) ? args[Arguments.ConfigId] : null;
            var vpnId = args.ContainsKey(Arguments.VpnId) ? args[Arguments.VpnId] : null;
            var templateId = args[Arguments.TemplateId];
            var configName = args[Arguments.ConfigName];
            var configState = new ConfigurationState();

            var logger = LoggerFactory.GetLogger();

            // CreateConfiguration (returns ConfigID of the instantiated template)
            SkytapConfiguration newTargetConfig = SkytapApi.CreateConfiguration(credentials, templateId, configName);

            // Wait for Skytap to return the expected configuration state. Do this with a retry block
            // to test for the desired state every second for 5 minutes.
            Retry.Execute(() => SkytapApi.CheckConfigurationForDesiredState(credentials, newTargetConfig.ConfigurationUrl,
                                                                             new List<string> {ConfigurationStates.Suspended, ConfigurationStates.Stopped}),
                                                                             NumRetriesCheckConfigState,
                                                                             _retryIntervalCheckConfigState);

            // If VPNID supplied, make a VPN connection, if a configid, create ICNR Connection
            if (String.IsNullOrEmpty(vpnId))
            {
                // CreateIcnrConnection (between the TFSConfigNetwork and the newly instantiated config. Note that it
                // is important that the source network ID be the new configuration and the target network ID be
                // the (existing) TFS configuration. If the two are reversed, a 409 (conflict) error may occur.
                var tfsConfigNetworkId = SkytapApi.GetNetworkIdInConfiguration(credentials, configId);
                var icnrId = SkytapApi.CreateIcnrConnection(credentials, newTargetConfig.ConfigurationNetworkId, tfsConfigNetworkId );
                newTargetConfig.IcnrId = icnrId;
            }
            else
            {
                SkytapApi.AttachVpnConnection(credentials, newTargetConfig.ConfigurationUrl, newTargetConfig.ConfigurationNetworkId, vpnId);
                SkytapApi.ConnectVpn(credentials, newTargetConfig.ConfigurationUrl, newTargetConfig.ConfigurationNetworkId, vpnId);
                newTargetConfig.VpnId = vpnId;
            }

            // Need to wait again for ICNR or VPN to complete.
            //
            // Before starting the configuration, ensure that it is suspended. If it is not suspended (and perhaps stopped)
            // wait until it is in the desired state.
            var configurationState = SkytapApi.GetConfigurationState(credentials, newTargetConfig.ConfigurationUrl);

            if (configurationState != ConfigurationStates.Running)
            {
                // Attempt to start up the configuration using retry semantics just in case the first request doesn't work. This
                // could happen if the configuration tries to restart but the service is busy so the state is returned to
                // suspended and we need to retry the start-up.
                Retry.Execute(() =>
                    {
                        // Start up the configuration by changing its state to running. It is assumed there is a change to the
                        // runstate at this point, either to "busy" or "running". If the configuration ends up as "running",
                        // nothing else to do - just continue. If the state goes back to "suspended", need to retry the start
                        // logic a few more times until the number of retries is exhausted. If it never comes back from "busy" or
                        // enters some other unknown state, just exit once the retry threshold is reached.
                        SkytapApi.SetConfigurationState(credentials, newTargetConfig.ConfigurationUrl, ConfigurationStates.Running);

                        Retry.Execute(() => SkytapApi.CheckConfigurationForDesiredState(credentials, newTargetConfig.ConfigurationUrl,
                                                                            new List<string> { ConfigurationStates.Running, ConfigurationStates.Suspended }),
                                                                            NumRetriesCheckConfigState, _retryIntervalCheckConfigState);

                        // Re-get the configuration state so we can determine whether to give up attempting to start the
                        // configuration or try again. The exception will trigger a retry.
                        var currentConfigState = SkytapApi.GetConfigurationState(credentials, newTargetConfig.ConfigurationUrl);
                        if (currentConfigState == ConfigurationStates.Suspended)
                        {
                            throw new ApplicationException(Resources.TfsStartup_UnexpectedReversionToSuspended);
                        }
                    },
                    NumRetriesStartConfig, _retryIntervalStartConfig);
            }

            // Persist the log file path so that successive invocations of the EXE can use the
            // same log file.
            newTargetConfig.LogFilePath = ((TraceLogger) logger).LogFilePath;

            // Store Config Url so that we can run shutdown on it later since TFS isn't smart enough to do this for us
            var configStatePath = configState.Serialize(newTargetConfig);
            logger.LogInfo("Persisted configuration path: " + configStatePath);
            logger.LogInfo(newTargetConfig.ToString());

            return CommandResults.Success;
        }