static private int GetReportNumber(ApplicationSettings applicationSettings, string fileName) { int dataIndex = 0, refIndex = 0; for (; ; ) { char token; int refStart = refIndex; if (!GetNextToken(applicationSettings, ref refIndex, out token)) break; int length = refIndex - refStart; if (token == 'n' || token == 't') length -= 2; else length -= 1; dataIndex += length; if (token == 'n' || token == 't') { int dataStart = dataIndex; while (dataIndex < fileName.Length && char.IsDigit(fileName[dataIndex])) ++dataIndex; if (token == 'n') { int dataLength = dataIndex - dataStart; if (dataLength > 0) return int.Parse(fileName.Substring(dataStart, dataLength)); } } } return -1; }
public PreferencesViewModel(ApplicationSettings settings) { _settings = settings; ImageResultSize = _settings.ImageResultSize; Rating = _settings.Rating; ResetHistoryCommand = new AsyncDelegateCommand(ResetHistory); }
protected override void ConfigureSettings(ApplicationSettings settings) { base.ConfigureSettings(settings); #if DEBUG settings.IsSingleProcess = true; #endif }
public SearchResultsPageViewModel(ApplicationSettings settings, INavigationService navigationService, IImageSearchService imageSearchService, IHub hub, IAccelerometer accelerometer, IStatusService statusService, IShareDataRequestedPump shareMessagePump) { _settings = settings; _navigationService = navigationService; _imageSearchService = imageSearchService; _hub = hub; _accelerometer = accelerometer; _statusService = statusService; HomeCommand = _navigationService.GoBackCommand; ViewDetailsCommand = new DelegateCommand(ViewDetails, () => SelectedImage != null); LoadMoreCommand = new AsyncDelegateCommand(LoadMore); ThumbnailViewCommand = new DelegateCommand(ThumbnailView); ListViewCommand = new DelegateCommand(ListView); SplitViewCommand = new DelegateCommand(SplitView); SettingsCommand = new DelegateCommand(Settings); AddImages(_settings.SelectedInstance.Images); shareMessagePump.DataToShare = _settings.SelectedInstance.QueryLink; _statusService.Title = _settings.SelectedInstance.Query; _accelerometer.Shaken += accelerometer_Shaken; _navigationService.Navigating += NavigatingFrom; UpdateCurrentView(CurrentView); _hub.Send(new UpdateTileImageCollectionMessage(_settings.SelectedInstance)); }
public ApplicationStartResponse StartApplication(ApplicationSettings settings, ManualResetEvent reset) { var response = new ApplicationStartResponse(); try { var source = _sourceFinder.FindSource(settings, response); if (source == null) { response.Status = ApplicationStartStatus.CouldNotResolveApplicationSource; } else { StartApplication(source, settings, reset); response.ApplicationSourceName = source.GetType().AssemblyQualifiedName; reset.WaitOne(); determineBottleFolders(response); } } catch (Exception ex) { response.ErrorMessage = ex.ToString(); response.Status = ApplicationStartStatus.ApplicationSourceFailure; } return response; }
public CalculateAnticipatedFeesStrategy(CreditContractOptions pCCO,Loan pContract, ApplicationSettings pGeneralSettings) { if(pCCO.CancelFees || pCCO.KeepExpectedInstallments) _cFfar = new AnticipatedFeesNotCalculate(); else _cFfar = new AnticipatedFeesCalculate(pCCO,pContract); }
private static void CreateDatabaseSchemaAndDemoData() { CreateDatabaseSchema(); var session = NHibernateHelper.SessionFactory.OpenSession(); var passwordPolicy = new RegularExpressionPasswordPolicy(".{5,}$"); var translationsRepository = new TranslationRepository(session, new InMemoryKeyValueCache()); var applicationSettings = new ApplicationSettings(); var encryptor = new DefaultEncryptor(); var userRepository = new UserRepository(session, passwordPolicy, applicationSettings, encryptor); // Create administrators PocoGenerator.CreateAdministrators(userRepository); // Create users PocoGenerator.CreateUsers(100, userRepository); session.Transaction.Begin(); // Create translations PocoGenerator.CreateTranslations(translationsRepository); session.Transaction.Commit(); // Create logitems PocoGenerator.CreateLogItems(new NLogLogger(applicationSettings, "Console.Admin")); }
public static void Main() { var applicationSettings = new ApplicationSettings(); // Use topshelf for installing and activating the Windows service // http://topshelf-project.com/ HostFactory.Run(x => { x.Service<MailSenderService>(s => { s.ConstructUsing(name => new MailSenderService()); s.WhenStarted(tc => tc.Start()); s.WhenStopped(tc => tc.Stop()); }); // http://4sysops.com/archives/service-account-best-practices-part-1-choosing-a-service-account/ x.RunAsLocalSystem(); x.SetServiceName(applicationSettings.WindowsServiceMailSenderName); x.SetDisplayName(applicationSettings.WindowsServiceMailSenderName); x.SetDescription("Service for sending email"); x.EnableServiceRecovery(rc => rc.RestartService(1)); }); }
/// <summary> /// Initializes a new instance of the BallerburgGame class /// </summary> public BallerburgGame() { Instance = this; gameSettings = new GameSettings(); playerSettings = new PlayerSettings[4]; applicationSettings = new ApplicationSettings(); graphics = new GraphicsDeviceManager(this) { PreferredBackBufferWidth = 640, PreferredBackBufferHeight = 480 }; graphicsManager = new BallerburgGraphicsManager(); contentManager = new ContentManager(); shaderManager = new ShaderManager(); audioManager = new AudioManager(applicationSettings, contentManager); gameObjectManager = new GameObjectManager(contentManager, this.audioManager, this.graphicsManager); MousePointer = new MousePointer(this) { DrawOrder = 1000, RestrictZone = new Rectangle(0, 0, 640, 480) }; Components.Add(MousePointer); // Create the screen manager component. screenManager = new ScreenManager(graphicsManager, contentManager, gameObjectManager, applicationSettings, gameSettings, shaderManager, audioManager, playerSettings) { GameMousePointer = MousePointer }; }
public CalculateInstallmentsStrategy(CalculateInstallmentsOptions pCio, int pStartInstallment, OCurrency pStartAmount, int pNumberOfInstallments, ApplicationSettings pGeneralSettings) { _generalSettings = pGeneralSettings; OCurrency initialOLBOfContractBeforeRescheduling = Loan.InitialOlbOfContractBeforeRescheduling; if (pCio.IsExotic) { if (pCio.LoanType == OLoanTypes.Flat) _iCi = new Flat.ExoticStrategy(pCio.StartDate, pCio.Contract, _generalSettings); else _iCi = new Declining.ExoticStrategy(pCio.StartDate, pCio.Contract, _generalSettings); } else { if (pCio.LoanType == OLoanTypes.Flat) _iCi = new FlatStrategy(pCio.StartDate, pCio.Contract, _generalSettings, initialOLBOfContractBeforeRescheduling); else if (pCio.LoanType == OLoanTypes.DecliningFixedInstallments) { if (pCio.Contract.InterestRate == 0) _iCi = new FlatStrategy(pCio.StartDate, pCio.Contract, _generalSettings, initialOLBOfContractBeforeRescheduling); else _iCi = new FixedInstallmentStrategy(pCio.StartDate, pCio.Contract, pStartInstallment, pStartAmount, pNumberOfInstallments, _generalSettings); } else { if (pCio.Contract.InterestRate == 0) _iCi = new FlatStrategy(pCio.StartDate, pCio.Contract, _generalSettings, initialOLBOfContractBeforeRescheduling); else _iCi = new FixedPrincipalStrategy(pCio.StartDate, pCio.Contract, _generalSettings); } } }
public SavingDeposit(ApplicationSettings pApplicationSettings, ChartOfAccounts pChartOfAccounts, User pUser) { _events = new List<SavingEvent>(); _chartOfAccounts = _FillChartOfAccounts(pChartOfAccounts); _applicationSettings = pApplicationSettings; _user = pUser; }
public DecliningKeepNotExpectedInstallments(Loan contract, User pUser, ApplicationSettings pGeneralSettings) { _user = pUser; _generalSettings = pGeneralSettings; _contract = contract; _paidInstallments = new List<Installment>(); }
public void listens_and_finishes_after_receiving_the_all_clear() { // trying to get the asset pipeline to shut up about // non-existent assets var settings = new ApplicationSettings { PhysicalPath = Environment.CurrentDirectory .ParentDirectory().ParentDirectory().ParentDirectory() .AppendPath("RemoteService") }; var system = new FubuMvcSystem(settings, () => FubuApplication.DefaultPolicies().StructureMap().Bootstrap()); system.AddRemoteSubSystem("Remote", x => { x.UseParallelServiceDirectory("RemoteService"); }); using (var context = system.CreateContext()) { system.StartListeningForMessages(); var message = new RemoteGo(); MessageHistory.Record(MessageTrack.ForSent(message)); var waitForWorkToFinish = MessageHistory.WaitForWorkToFinish(() => { system.RemoteSubSystemFor("Remote").Runner.SendRemotely(message); }, timeoutMilliseconds:30000); waitForWorkToFinish.ShouldBeTrue(); } }
public static string GetPreferenceFormattedText(this string text, ApplicationSettings applicationSettings, bool pluralize) { string formattedText = text.Replace('_', ' '); formattedText = formattedText.MakeTitleCase(); formattedText = formattedText.Replace(" ", ""); return formattedText; }
public FlatStrategy(DateTime pStartDate, Loan pContract, ApplicationSettings pGeneralSettings, OCurrency pInitialOLBOfContractBeforeRescheduling) { RoundingPoint = pContract.UseCents ? 2 : 0; _initialOLBOfContractBeforeRescheduling = pInitialOLBOfContractBeforeRescheduling; _contract = pContract; GeneralSettings = pGeneralSettings; }
public SavingDeposit(ApplicationSettings pApplicationSettings, ChartOfAccounts pChartOfAccounts, User pUser, TermDepositProduct pProduct) { _events = new List<SavingEvent>(); base.Product = pProduct; _chartOfAccounts = _FillChartOfAccounts(pChartOfAccounts); _applicationSettings = pApplicationSettings; _user = pUser; }
protected override void ConfigureSettings(ApplicationSettings settings) { base.ConfigureSettings (settings); #if DEBUG settings.IsSingleProcess = true; #endif settings.LogSeverity = LogSeverity.LogseverityVerbose; }
public FileOpenPickerPageViewModel(ApplicationSettings settings, IImageSearchService imageSearchService, IFileOpenPickerUiManager fileOpenPicker) { _settings = settings; _imageSearchService = imageSearchService; _fileOpenPicker = fileOpenPicker; SearchCommand = new AsyncDelegateCommand(Search); }
public void get_the_application_folder_with_a_file_but_no_physical_path() { var settings = new ApplicationSettings{ PhysicalPath = null, ParentFolder = ".".ToFullPath() }; settings.GetApplicationFolder().ShouldEqual(settings.ParentFolder); }
public CalculateAmountToRepaySpecifiedInstallmentStrategy(CreditContractOptions pCCo,Loan pContract, User pUser, ApplicationSettings pGeneralSettings,NonWorkingDateSingleton pNonWorkingDate) { _user = pUser; _generalSettings = pGeneralSettings; _nWds = pNonWorkingDate; _contract = pContract; _cCo = pCCo; }
public void get_the_application_folder_when_the_physical_path_is_relative() { var settings = new ApplicationSettings{ ParentFolder = ".".ToFullPath(), PhysicalPath = "app1" }; settings.GetApplicationFolder().ShouldEqual(settings.ParentFolder.AppendPath(settings.PhysicalPath)); }
public void StartWatching(ApplicationSettings settings, IEnumerable<string> folders) { cleanUpWatchers(); Console.WriteLine("Listening for file changes at"); addDirectory(settings.PhysicalPath); folders.Each(addDirectory); }
public IssueViewModel(IHub messageHub, ISettings settings, IDialogService dialogService, IJiraService service) : base(messageHub) { _dialogService = dialogService; _settings = (ApplicationSettings)settings; _service = service; LoadIssueComments(); }
public Saving(ApplicationSettings pApplicationSettings, ChartOfAccounts pChartOfAccounts, User pUser, SavingBookProduct pProduct) { base.Product = pProduct; _events = new List<SavingEvent>(); _chartOfAccounts = _FillChartOfAccounts(pChartOfAccounts); _applicationSettings = pApplicationSettings; _user = pUser; _loans = new List<Loan>(); }
public ApplicationSettingsViewModel(ApplicationSettings settings, DropboxService dropBoxService) { _settings = settings; _dropBoxService = dropBoxService; BroadcastSettingsChanged = new RelayCommand(() => Messenger.Default.Send(new ApplicationSettingsChangedMessage(_settings))); DisconnectCommand = new RelayCommand(Disconnect); ResetColorsCommand = new RelayCommand(ResetColors); }
public CalculateMaximumAmountToRegradingLoanStrategy(CreditContractOptions pCCo,Loan pContract, User pUser, ApplicationSettings pGeneralSettings,NonWorkingDateSingleton pNonWorkingDate) { _user = pUser; _generalSettings = pGeneralSettings; _nWDS = pNonWorkingDate; _contract = pContract; _cCo = pCCo; }
public SavingDeposit(ApplicationSettings pApplicationSettings, ChartOfAccounts pChartOfAccounts, User pUser, DateTime pCreationDate, IClient pClient) { Client = pClient; CreationDate = pCreationDate; _events = new List<SavingEvent>(); _chartOfAccounts = _FillChartOfAccounts(pChartOfAccounts); _applicationSettings = pApplicationSettings; _user = pUser; }
private bool UnsetVariable(string varName, ApplicationSettings settings) { if (!settings.HasVariable(varName)) { Application.Error.WriteLine("unknown variable {0}", varName); return false; } settings.RemoveVariable(varName); return true; }
protected override void ConfigureSettings(ApplicationSettings settings) { base.ConfigureSettings(settings); //settings.IsSingleProcess = true; //settings.ProductVersion = "1.0.0.0"; //settings.UserAgent = "Spectre"; //settings.CacheDirectory = "CacheDir"; //settings.ResourceDirectory = "ResourceDir"; //settings.BrowserSubprocessPath = "mono.exe"; }
public CalculateInstallments(CreditContractOptions pCCO, Loan pContract, User pUser, ApplicationSettings pGeneralSettings,NonWorkingDateSingleton pNonWorkingDate) { _generalSettings = pGeneralSettings; _nWds = pNonWorkingDate; _contract = pContract; _cCo = pCCO; _methodToRepayFees = new RepayFeesStrategy(pCCO); _methodToRepayInterest = new RepayInterestStrategy(pCCO); _methodToRepayCommission = new RepayCommisionStrategy(pCCO); PaidIstallments = new List<Installment>(); }
public ReportingManager(ApplicationSettings applicationSettings, WebSettings webSettings, ConsoleManager <TArachnodeDAO> consoleManager) : base(applicationSettings, webSettings, consoleManager) { }
/// <summary> /// 创建金币库对象实例 /// </summary> /// <returns></returns> public static ITreasureDataProvider GetITreasureDataProvider() { return(ProxyFactory.CreateInstance <TreasureDataProvider>(ApplicationSettings.Get("DBTreasure"))); }
/// <summary> /// 创建帐号库对象实例 /// </summary> /// <returns></returns> public static IAccountsDataProvider GetIAccountsDataProvider() { return(ProxyFactory.CreateInstance <AccountsDataProvider>(ApplicationSettings.Get("DBAccounts"))); }
/// <summary> /// 创建金币库对象实例 /// </summary> /// <returns></returns> public static INativeWebDataProvider GetINativeWebDataProvider() { return(ProxyFactory.CreateInstance <NativeWebDataProvider>(ApplicationSettings.Get("DBNativeWeb"))); }
public ApplicationUserController(UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, IOptions <ApplicationSettings> appSettings) { _userManager = userManager; _singInManager = signInManager; _appSettings = appSettings.Value; }
private void FillLocalSettings(ApplicationSettings settings) { DurationOfRecordedVideoChunk = settings.DurationOfRecordedVideoChunk; }
/// <summary> /// Form load /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SaveForm_Load(object sender, EventArgs e) { ApplicationSettings appSettings = Program.ConfigurationManager.ApplicationSettings; // AES IV string storedCustomEnc = appSettings.MapleVersion_CustomEncryptionBytes; string[] splitBytes = storedCustomEnc.Split(' '); bool parsed = true; if (splitBytes.Length == 4) { foreach (string byte_ in splitBytes) { if (!CheckHexDigits(byte_)) { parsed = false; break; } } } else { parsed = false; } if (!parsed) { // do nothing.. default, could be corrupted anyway appSettings.MapleVersion_CustomEncryptionBytes = "00 00 00 00"; Program.ConfigurationManager.Save(); } else { int i = 0; foreach (string byte_ in splitBytes) { switch (i) { case 0: textBox_byte0.Text = byte_; break; case 1: textBox_byte1.Text = byte_; break; case 2: textBox_byte2.Text = byte_; break; case 3: textBox_byte3.Text = byte_; break; } i++; } } // AES User key if (appSettings.MapleVersion_CustomAESUserKey == string.Empty) // set default if there's none { SetDefaultTextBoxAESUserKey(); } else { string storedCustomAESKey = appSettings.MapleVersion_CustomAESUserKey; string[] splitAESKeyBytes = storedCustomAESKey.Split(' '); bool parsed2 = true; if (splitAESKeyBytes.Length == 32) { foreach (string byte_ in splitAESKeyBytes) { if (!CheckHexDigits(byte_)) { parsed2 = false; break; } } } else { parsed2 = false; } if (!parsed2) { // do nothing.. default, could be corrupted anyway appSettings.MapleVersion_CustomAESUserKey = string.Empty; Program.ConfigurationManager.Save(); } else { int i = 0; foreach (string byte_ in splitAESKeyBytes) { switch (i) { case 0: textBox_AESUserKey1.Text = byte_; break; case 1: textBox_AESUserKey2.Text = byte_; break; case 2: textBox_AESUserKey3.Text = byte_; break; case 3: textBox_AESUserKey4.Text = byte_; break; case 4: textBox_AESUserKey5.Text = byte_; break; case 5: textBox_AESUserKey6.Text = byte_; break; case 6: textBox_AESUserKey7.Text = byte_; break; case 7: textBox_AESUserKey8.Text = byte_; break; case 8: textBox_AESUserKey9.Text = byte_; break; case 9: textBox_AESUserKey10.Text = byte_; break; case 10: textBox_AESUserKey11.Text = byte_; break; case 11: textBox_AESUserKey12.Text = byte_; break; case 12: textBox_AESUserKey13.Text = byte_; break; case 13: textBox_AESUserKey14.Text = byte_; break; case 14: textBox_AESUserKey15.Text = byte_; break; case 15: textBox_AESUserKey16.Text = byte_; break; case 16: textBox_AESUserKey17.Text = byte_; break; case 17: textBox_AESUserKey18.Text = byte_; break; case 18: textBox_AESUserKey19.Text = byte_; break; case 19: textBox_AESUserKey20.Text = byte_; break; case 20: textBox_AESUserKey21.Text = byte_; break; case 21: textBox_AESUserKey22.Text = byte_; break; case 22: textBox_AESUserKey23.Text = byte_; break; case 23: textBox_AESUserKey24.Text = byte_; break; case 24: textBox_AESUserKey25.Text = byte_; break; case 25: textBox_AESUserKey26.Text = byte_; break; case 26: textBox_AESUserKey27.Text = byte_; break; case 27: textBox_AESUserKey28.Text = byte_; break; case 28: textBox_AESUserKey29.Text = byte_; break; case 29: textBox_AESUserKey30.Text = byte_; break; case 30: textBox_AESUserKey31.Text = byte_; break; case 31: textBox_AESUserKey32.Text = byte_; break; } i++; } } } }
public CommandContext(TwitchClient botClient, TwitchClient userClient, TwitchAPI twitchApi, ChatCommand context, CommandFactory factory, ApplicationSettings settings, bool fromConsole = false) { BotClient = botClient; UserClient = userClient; TwitchApi = twitchApi; Context = context; Settings = settings; FromConsole = fromConsole; Commands = factory.ToList(); // Provide information to the ChatMessageContext ChatMessage = new ChatMessageContext(); if (context != null) { ChatMessage.Bits = context.ChatMessage.Bits; ChatMessage.IsChatBot = fromConsole; ChatMessage.DisplayName = context.ChatMessage.DisplayName; ChatMessage.IsBroadcaster = context.ChatMessage.IsBroadcaster; ChatMessage.IsModerator = context.ChatMessage.IsModerator; ChatMessage.IsModeratorOrBroadcaster = context.ChatMessage.IsBroadcaster || context.ChatMessage.IsModerator; ChatMessage.IsSubscriber = context.ChatMessage.IsSubscriber; ChatMessage.Message = context.ChatMessage.Message; } // Provide information to the TwitchStreamContext TwitchStream = new TwitchStreamContext(); var channel = TwitchApi.Channels.v3.GetChannelByNameAsync(UserClient.TwitchUsername).ConfigureAwait(false).GetAwaiter().GetResult(); TwitchStream.Game = channel.Game; TwitchStream.Title = channel.Status; TwitchStream.Username = UserClient.TwitchUsername; }
/// <summary> /// 增加页面标题 /// </summary> protected override void AddHeaderTitle() { AddMetaTitle("比赛排名 - " + ApplicationSettings.Get("title")); AddMetaKeywords(ApplicationSettings.Get("keywords")); AddMetaDescription(ApplicationSettings.Get("description")); }
public void Run(IBackgroundTaskInstance taskInstance) { StorageFolder localFolder = ApplicationData.Current.LocalFolder; try { // see if the configuration file is present if not copy minimal sample one from application directory if (localFolder.TryGetItemAsync(ConfigurationFilename).AsTask().Result == null) { StorageFile templateConfigurationfile = Package.Current.InstalledLocation.GetFileAsync(ConfigurationFilename).AsTask().Result; templateConfigurationfile.CopyAsync(localFolder, ConfigurationFilename).AsTask(); } // Load the settings from configuration file exit application if missing or invalid StorageFile file = localFolder.GetFileAsync(ConfigurationFilename).AsTask().Result; this.applicationSettings = JsonConvert.DeserializeObject <ApplicationSettings>(FileIO.ReadTextAsync(file).AsTask().Result); } catch (Exception ex) { this.logging.LogMessage("JSON configuration file load failed " + ex.Message, LoggingLevel.Error); return; } #if CEECH_NRF24L01P_SHIELD // Disable the onboard beeper so it doesn't whine so much GpioController gpioController = GpioController.GetDefault(); GpioPin buzzer = gpioController.OpenPin(4); buzzer.SetDriveMode(GpioPinDriveMode.Output); buzzer.Write(GpioPinValue.Low); #endif // Log the Application build, shield information etc. LoggingFields applicationBuildInformation = new LoggingFields(); #if CEECH_NRF24L01P_SHIELD applicationBuildInformation.AddString("Shield", "CeechnRF24L01P"); #endif #if BOROS_RF2_SHIELD_RADIO_0 appllcationBuildInformation.AddString("Shield", "BorosRF2Port0"); #endif #if BOROS_RF2_SHIELD_RADIO_1 applicationBuildInformation.AddString("Shield", "BorosRF2Port1"); #endif #if CLOUD_DEVICE_BOND applicationBuildInformation.AddString("Bond", "Supported"); #else applicationBuildInformation.AddString("Bond", "NotSupported"); #endif #if CLOUD_DEVICE_PUSH applicationBuildInformation.AddString("Push", "Supported"); #else applicationBuildInformation.AddString("Push", "NotSupported"); #endif #if CLOUD_DEVICE_SEND applicationBuildInformation.AddString("Send", "Supported"); #else applicationBuildInformation.AddString("Send", "NotSupported"); #endif applicationBuildInformation.AddString("Timezone", TimeZoneSettings.CurrentTimeZoneDisplayName); applicationBuildInformation.AddString("OSVersion", Environment.OSVersion.VersionString); applicationBuildInformation.AddString("MachineName", Environment.MachineName); // This is from the application manifest Package package = Package.Current; PackageId packageId = package.Id; PackageVersion version = packageId.Version; applicationBuildInformation.AddString("ApplicationVersion", string.Format($"{version.Major}.{version.Minor}.{version.Build}.{version.Revision}")); this.logging.LogEvent("Application starting", applicationBuildInformation, LoggingLevel.Information); // Connect the IoT hub first so we are ready for any messages LoggingFields azureIoTHubSettings = new LoggingFields(); azureIoTHubSettings.AddString("DeviceConnectionString", this.applicationSettings.AzureIoTHubDeviceConnectionString); azureIoTHubSettings.AddString("TransportType", this.applicationSettings.AzureIoTHubTransportType.ToString()); azureIoTHubSettings.AddString("SensorIDIsDeviceIDSensorID", this.applicationSettings.SensorIDIsDeviceIDSensorID.ToString()); this.logging.LogEvent("AzureIoTHub configuration", azureIoTHubSettings, LoggingLevel.Information); try { this.azureIoTHubClient = DeviceClient.CreateFromConnectionString(this.applicationSettings.AzureIoTHubDeviceConnectionString, this.applicationSettings.AzureIoTHubTransportType); } catch (Exception ex) { this.logging.LogMessage("IoT Hub connection failed " + ex.Message, LoggingLevel.Error); return; } // Wire up the field gateway restart method handler try { this.azureIoTHubClient.SetMethodHandlerAsync("Restart", this.RestartAsync, null); } catch (Exception ex) { this.logging.LogMessage("Azure IoT Hub client Restart method handler setup failed " + ex.Message, LoggingLevel.Error); return; } #if CLOUD_DEVICE_BOND // Wire up the bond device method handler try { this.azureIoTHubClient.SetMethodHandlerAsync("DeviceBond", this.DeviceBondAsync, null); } catch (Exception ex) { this.logging.LogMessage("Azure IoT Hub Device Bond method handler setup failed " + ex.Message, LoggingLevel.Error); return; } #endif #if CLOUD_DEVICE_PUSH // Wire up the push message to device method handler try { this.azureIoTHubClient.SetMethodHandlerAsync("DevicePush", this.DevicePushAsync, null); } catch (Exception ex) { this.logging.LogMessage("Azure IoT Hub client DevicePush SetMethodHandlerAsync failed " + ex.Message, LoggingLevel.Error); return; } #endif #if CLOUD_DEVICE_SEND // Wire up the send message to device method handler try { this.azureIoTHubClient.SetMethodHandlerAsync("DeviceSend", this.DeviceSendAsync, null); } catch (Exception ex) { this.logging.LogMessage("Azure IoT Hub client DeviceSend SetMethodHandlerAsync failed " + ex.Message, LoggingLevel.Error); return; } #endif // Configure the nRF24L01 module this.rf24.OnDataReceived += this.Radio_OnDataReceived; this.rf24.OnTransmitFailed += this.Radio_OnTransmitFailed; this.rf24.OnTransmitSuccess += this.Radio_OnTransmitSuccess; this.rf24.Initialize(RF24ModuleChipEnablePin, RF24ModuleChipSelectPin, RF24ModuleInterruptPin); this.rf24.Address = Encoding.UTF8.GetBytes(this.applicationSettings.RF24Address); this.rf24.Channel = this.applicationSettings.RF24Channel; // The order of setting the power level and Data rate appears to be important, most probably register masking issue in NRF24 library which needs some investigation this.rf24.PowerLevel = this.applicationSettings.RF24PowerLevel; this.rf24.DataRate = this.applicationSettings.RF24DataRate; this.rf24.IsAutoAcknowledge = this.applicationSettings.IsRF24AutoAcknowledge; this.rf24.IsDyanmicAcknowledge = this.applicationSettings.IsRF24DynamicAcknowledge; this.rf24.IsDynamicPayload = this.applicationSettings.IsRF24DynamicPayload; this.rf24.IsEnabled = true; LoggingFields rf24Settings = new LoggingFields(); rf24Settings.AddUInt8("Channel", this.applicationSettings.RF24Channel); rf24Settings.AddString("Address", this.applicationSettings.RF24Address); rf24Settings.AddString("DataRate", this.applicationSettings.RF24DataRate.ToString()); rf24Settings.AddString("PowerLevel", this.applicationSettings.RF24PowerLevel.ToString()); rf24Settings.AddBoolean("AutoAcknowledge", this.applicationSettings.IsRF24AutoAcknowledge); rf24Settings.AddBoolean("DynamicAcknowledge", this.applicationSettings.IsRF24DynamicAcknowledge); rf24Settings.AddBoolean("DynamicPayload", this.applicationSettings.IsRF24DynamicPayload); this.logging.LogEvent("nRF24L01 configuration", rf24Settings, LoggingLevel.Information); this.deferral = taskInstance.GetDeferral(); }
private void InitializeControls() { lvMembers.Items.Clear(); _fLServices.EmptyTemporaryFLAmountsStorage(); ApplicationSettings dataParam = ApplicationSettings.GetInstance(string.Empty); int decimalPlaces = dataParam.InterestRateDecimalPlaces; foreach (VillageMember member in _village.NonDisbursedMembers) { foreach (Loan loan in member.ActiveLoans) { if (loan.ContractStatus == OContractStatus.Active || loan.ContractStatus == OContractStatus.Refused || loan.ContractStatus == OContractStatus.Abandoned ) { continue; } _hasMember = true; Person person = member.Tiers as Person; ListViewItem item = new ListViewItem(person.Name) { Tag = loan }; item.UseItemStyleForSubItems = true; item.SubItems.Add(person.IdentificationData); ListViewItem.ListViewSubItem subitem = new ListViewItem.ListViewSubItem { Text = TimeProvider.Today.ToShortDateString(), Tag = TimeProvider.Today }; item.SubItems.Add(subitem); item.SubItems.Add(loan.FirstInstallmentDate.ToShortDateString()); item.SubItems.Add(loan.Amount.GetFormatedValue(loan.UseCents)); item.SubItems.Add(loan.Product.Currency.Code); item.SubItems.Add(Math.Round(loan.InterestRate * 100, decimalPlaces).ToString()); item.SubItems.Add(loan.GracePeriod.ToString()); item.SubItems.Add(loan.NbOfInstallments.ToString()); item.SubItems.Add(loan.LoanOfficer.Name); item.SubItems.Add(loan.FundingLine.Name); _accumulatedAmount = _fLServices.CheckIfAmountIsEnough(loan.FundingLine, loan.Amount.Value); if (_accumulatedAmount <= 0) { item.BackColor = Color.Red; } item.SubItems.Add(_accumulatedAmount.ToString()); cbPaymentMethods.Items.Clear(); List <PaymentMethod> methods = ServicesProvider.GetInstance().GetPaymentMethodServices().GetAllPaymentMethods(); item.SubItems.Add(methods[0].Name); lvMembers.Items.Add(item); item.SubItems[IdxAmount].Tag = loan.Amount.GetFormatedValue(loan.UseCents); item.SubItems[IdxCurrency].Tag = loan.Product.Currency; } } if (_hasMember) { OCurrency zero = 0m; _itemTotal.Text = GetString("total"); _itemTotal.SubItems.Add(""); _itemTotal.SubItems.Add(""); _itemTotal.SubItems.Add(""); _itemTotal.SubItems.Add(zero.GetFormatedValue(true)); _itemTotal.SubItems.Add(""); lvMembers.Items.Add(_itemTotal); } lvMembers.SubItemClicked += lvMembers_SubItemClicked; lvMembers.DoubleClickActivation = true; }
public void Get_Set_CreationDate() { CompulsorySavings CompulsorySavings = new CompulsorySavings(ApplicationSettings.GetInstance(""), ChartOfAccounts.GetInstance(new User()), new User(), 12m, new DateTime(2008, 10, 21), null); Assert.AreEqual(new DateTime(2008, 10, 21), CompulsorySavings.CreationDate); }
public string GetPhysicalBasePath(string ParameterName, string basePathID) { return(ApplicationSettings.GetPhysicalBasePath(ParameterName, basePathID)); }
protected AActionManager(ApplicationSettings applicationSettings, WebSettings webSettings, ConsoleManager <TArachnodeDAO> consoleManager) : base(applicationSettings, webSettings) { _consoleManager = consoleManager; }
public static void SaveSettings(ApplicationSettings s) { CommonUtil.SerializeToFile(s, SettingsFileName); }
public const int DEFENSE_STATUS_ON = 1; // 安防状态:开 public static void Initialize() { Store.Set(API_HOST, ApplicationSettings.Get(CFG_.API_HOST)); Store.Set(NLE_API, new NLECloudAPI(Store.Get <String>(API_HOST))); Store.Set <object>(ACCESS_TOKEN, null); }
public BackupService(IOptions <ApplicationSettings> options, ConsoleApplicationWrapper <MinecraftMessageParser> wrapper, ScheduledTaskService scheduledTaskService) { _applicationSettings = options.Value; _wrapper = wrapper; _scheduledTaskService = scheduledTaskService; }
/// <summary> /// 创建本地库对象实例 /// </summary> /// <returns></returns> public static IPlatformDataProvider GetIPlatformDataProvider() { return(ProxyFactory.CreateInstance <PlatformDataProvider>(ApplicationSettings.Get("DBPlatform"))); }
/// <summary> /// 数据保存 /// </summary> protected void btnSave_Click(object sender, EventArgs e) { AuthUserOperationPermission(Permission.Edit); try { int typeID = Convert.ToInt32(ddlType.SelectedValue); string content = CtrlHelper.GetText(txtContent); DateTime time = Convert.ToDateTime(txtTime.Text); if (string.IsNullOrEmpty(content)) { MessageBox("消息内容不能为空"); return; } if (DateTime.Now > time) { MessageBox("推送时间不能小于或等于当前时间"); return; } DateTime endTime = time.AddHours(5); IList <AccountsUmeng> list = new List <AccountsUmeng>(); if (typeID == 0) { bool flag = false; flag = Umeng.SendMessage(0, content, "broadcast", time.ToString("yyyy-MM-dd HH:mm:ss"), endTime.ToString("yyyy-MM-dd HH:mm:ss"), ""); if (!flag) { MessageBox("推送消息失败,请前往友盟后台绑定系统后台ip"); return; } flag = Umeng.SendMessage(1, content, "broadcast", time.ToString("yyyy-MM-dd HH:mm:ss"), endTime.ToString("yyyy-MM-dd HH:mm:ss"), ""); if (!flag) { MessageBox("推送消息失败,请前往友盟后台绑定系统后台ip"); return; } list = FacadeManage.aideAccountsFacade.GetAccountsUmengList(""); } else { bool flag = false; string where = string.Empty; switch (typeID) { case 1: int gameid = CtrlHelper.GetInt(txtGameID, 0); if (gameid != 0) { AccountsInfo info = FacadeManage.aideAccountsFacade.GetAccountInfoByGameId(gameid); if (info == null) { MessageBox("推送消息失败,代理商游戏id不存在"); return; } if (info.AgentID <= 0) { MessageBox("推送消息失败,游戏id为非代理商"); return; } where = "WHERE UserID IN(SELECT UserID FROM AccountsInfo WHERE SpreaderID=" + info.UserID.ToString() + ")"; } else { where = "WHERE UserID IN(SELECT UserID FROM AccountsInfo WHERE AgentID>0)"; } break; case 2: where = "WHERE UserID IN(SELECT UserID FROM AccountsInfo WHERE AgentID=0)"; break; case 3: where = "WHERE DeviceType=0"; break; case 4: where = "WHERE DeviceType=1"; break; case 5: string start = CtrlHelper.GetText(txtStartDate); string end = CtrlHelper.GetText(txtEndDate); if (!string.IsNullOrEmpty(start) && !string.IsNullOrEmpty(end)) { where = "WHERE UserID IN(SELECT UserID FROM AccountsInfo WHERE RegisterDate BETWEEN '" + start + "' AND '" + end + "')"; } else { where = "WHERE 1=1"; } break; case 6: int nologin = CtrlHelper.GetInt(txtNoLoginDay, 0); if (nologin > 0) { where = "WHERE DATEDIFF(DAY,UpdateTime,GETDATE())>=" + nologin.ToString(); } else { where = "WHERE 1=1"; } break; default: break; } list = FacadeManage.aideAccountsFacade.GetAccountsUmengList(where); if (list == null || list.Count <= 0) { MessageBox("推送用户未绑定设备,无法推送"); return; } //获取安卓用户 IList <AccountsUmeng> android = list.Where(a => a.DeviceType == 0).ToList <AccountsUmeng>(); if (android != null && android.Count > 0) { StringBuilder android_sb = new StringBuilder(); int i = 1, j = 1; string android_tokens = string.Empty; foreach (AccountsUmeng item in android) { if (!string.IsNullOrEmpty(item.DeviceToken)) { android_sb.AppendFormat("{0},", item.DeviceToken); } if (i == 400 || j == android.Count) { android_tokens = android_sb.ToString(); android_tokens = android_tokens.Substring(0, (android_tokens.Length - 1)); flag = Umeng.SendMessage(0, content, "listcast", time.ToString("yyyy-MM-dd HH:mm:ss"), endTime.ToString("yyyy-MM-dd HH:mm:ss"), android_tokens); if (!flag) { MessageBox("推送消息失败,请前往友盟后台绑定系统后台ip"); return; } i = 0; android_sb = new StringBuilder(); android_tokens = string.Empty; } i++; j++; } } //获取苹果用户 IList <AccountsUmeng> iphone = list.Where(a => a.DeviceType == 1).ToList <AccountsUmeng>(); if (iphone != null & iphone.Count > 0) { StringBuilder iphone_sb = new StringBuilder(); int i = 1, j = 1; string iphone_tokens = string.Empty; foreach (AccountsUmeng item in iphone) { if (!string.IsNullOrEmpty(item.DeviceToken)) { iphone_sb.AppendFormat("{0},", item.DeviceToken); } if (i == 500 || j == iphone.Count) { iphone_tokens = iphone_sb.ToString(); iphone_tokens = iphone_tokens.Substring(0, (iphone_tokens.Length - 1)); flag = Umeng.SendMessage(1, content, "listcast", time.ToString("yyyy-MM-dd HH:mm:ss"), endTime.ToString("yyyy-MM-dd HH:mm:ss"), iphone_tokens); if (!flag) { MessageBox("推送消息失败,请前往友盟后台绑定系统后台ip"); return; } i = 0; iphone_sb = new StringBuilder(); iphone_tokens = string.Empty; } i++; j++; } } } //批量写入记录 DataTable table = new DataTable(); table.Columns.AddRange(new DataColumn[] { new DataColumn("RecordID", typeof(int)), new DataColumn("MasterID", typeof(int)), new DataColumn("UserID", typeof(int)), new DataColumn("PushType", typeof(byte)), new DataColumn("PushContent", typeof(string)), new DataColumn("PushTime", typeof(DateTime)), new DataColumn("PushIP", typeof(string)) }); int masterid = userExt.UserID; DateTime addTime = DateTime.Now; string ip = GameRequest.GetUserIP(); string connStr = ApplicationSettings.Get("DBRecord"); for (int i = 0; i < list.Count; i++) { DataRow dr = table.NewRow(); dr[0] = 0; dr[1] = masterid; dr[2] = list[i].UserID; dr[3] = list[i].DeviceType; dr[4] = content; dr[5] = addTime; dr[6] = ip; table.Rows.Add(dr); } int result = FacadeManage.aideRecordFacade.AddRecordAccountsUmeng(table, connStr); if (result > 0) { MessageBox("推送消息成功"); } else { MessageBox("推送消息成功,但推送记录写入失败"); } } catch (Exception) { MessageBox("推送消息异常,请稍后重试"); } }
public ApplicationSettingsController(IOptionsSnapshot <ApplicationSettings> applicationSettingsAccessor) { _applicationSettings = applicationSettingsAccessor.Value; }
protected override void OnLoad(EventArgs e) { if (!SecurityHelper.CanRunApplication("PowerShell/PowerShellIse") || ServiceAuthorizationManager.TerminateUnauthorizedRequest(WebServiceSettings.ServiceClient, Context.User.Name)) { PowerShellLog.Warn($"User {Context.User?.Name} attempt to access PowerShell ISE - denied."); return; } base.OnLoad(e); if (Monitor == null) { if (!Context.ClientPage.IsEvent) { Monitor = new SpeJobMonitor { ID = "Monitor" }; Context.ClientPage.Controls.Add(Monitor); } else { Monitor = (SpeJobMonitor)Context.ClientPage.FindControl("Monitor"); } } Monitor.JobFinished += MonitorOnJobFinished; if (Context.ClientPage.IsEvent) { return; } var settings = ApplicationSettings.GetInstance(ApplicationNames.ISE); if (settings.SaveLastScript) { Editor.Value = settings.LastScript; } var itemId = WebUtil.GetQueryString("id"); var itemDb = WebUtil.GetQueryString("db"); if (itemId.Length > 0) { ScriptItemId = itemId; ScriptItemDb = itemDb; LoadItem(itemDb, itemId); } ContextItemDb = Context.ContentDatabase.Name; var contextItem = Context.ContentDatabase.GetItem(Context.Site.ContentStartPath) ?? UIUtil.GetHomeItem(Context.User); ContextItemId = contextItem?.ID.ToString() ?? String.Empty; CurrentSessionId = DefaultSessionName; CurrentUser = DefaultUser; CurrentLanguage = DefaultLanguage; ParentFrameName = WebUtil.GetQueryString("pfn"); UpdateRibbon(); }
public string GetParameterValue(string ParameterName) { return(ApplicationSettings.GetParameterValue(ParameterName)); }
public DoctorController(UserManager <ApplicationUsers> userManager, IOptions <ApplicationSettings> appSettings, IDoctorService doctorService) { _userManager = userManager; _appSettings = appSettings.Value; _doctorService = doctorService; }
private static KernelBase SetupNinject(ApplicationSettings settings) { var kernel = new StandardKernel(new[] { new FactoryModule() }); kernel.Bind <JabbrContext>() .To <JabbrContext>(); kernel.Bind <IJabbrRepository>() .To <PersistedRepository>(); kernel.Bind <IChatService>() .To <ChatService>(); kernel.Bind <IDataProtection>() .To <JabbRDataProtection>(); kernel.Bind <IFormsAuthenticationProvider>() .To <JabbRFormsAuthenticationProvider>(); kernel.Bind <ILogger>() .To <RealtimeLogger>(); // We're doing this manually since we want the chat repository to be shared // between the chat service and the chat hub itself kernel.Bind <Chat>() .ToMethod(context => { var resourceProcessor = context.Kernel.Get <ContentProviderProcessor>(); var repository = context.Kernel.Get <IJabbrRepository>(); var cache = context.Kernel.Get <ICache>(); var service = new ChatService(cache, repository); return(new Chat(resourceProcessor, service, repository, cache)); }); kernel.Bind <ICryptoService>() .To <CryptoService>() .InSingletonScope(); kernel.Bind <IResourceProcessor>() .To <ResourceProcessor>() .InSingletonScope(); kernel.Bind <IApplicationSettings>() .ToConstant(settings); kernel.Bind <IJavaScriptMinifier>() .To <AjaxMinMinifier>() .InSingletonScope(); kernel.Bind <IMembershipService>() .To <MembershipService>(); kernel.Bind <IAuthenticationService>() .ToConstant(new AuthenticationService()); kernel.Bind <IAuthenticationCallbackProvider>() .To <JabbRAuthenticationCallbackProvider>(); kernel.Bind <ICache>() .To <DefaultCache>() .InSingletonScope(); kernel.Bind <IChatNotificationService>() .To <ChatNotificationService>(); if (String.IsNullOrEmpty(settings.VerificationKey) || String.IsNullOrEmpty(settings.EncryptionKey)) { kernel.Bind <IKeyProvider>() .ToConstant(new FileBasedKeyProvider()); } else { kernel.Bind <IKeyProvider>() .To <AppSettingKeyProvider>() .InSingletonScope(); } var serializer = new JsonNetSerializer(new JsonSerializerSettings() { DateFormatHandling = DateFormatHandling.IsoDateFormat }); kernel.Bind <IJsonSerializer>() .ToConstant(serializer); kernel.Bind <UploadCallbackHandler>() .ToSelf() .InSingletonScope(); kernel.Bind <UploadProcessor>() .ToSelf() .InSingletonScope(); kernel.Bind <ContentProviderProcessor>() .ToConstant(new ContentProviderProcessor(kernel)); return(kernel); }
public JwtTokenGenerator(UserManager <ApplicationUser> userManager, IOptions <ApplicationSettings> applicationSettings) { _userManager = userManager; _applicationSettings = applicationSettings.Value; }
public static void AddInfrastructure(this IServiceCollection services, ApplicationSettings appSettings) { services.AddInfrastructureForLiteDb(appSettings); services.AddInfrastructureForTwitch(); }
protected void Page_Load(object sender, EventArgs e) { var tradeno = Serializer.DeserializeJsonToObject <EntityAddOrder>(AddOrder()); Logger.Info(JsonHelper.SerializeObject(tradeno)); if (tradeno.errorcode.ToInt(0) > 0) { Logger.Info("2"); string tradeno1 = tradeno.errormsg; if (tradeno1.IndexOf("YB") > -1) { string apiurl = ApplicationSettings.Get("bankurl_yifu").ToStringOrEmpty(); string payKey = ApplicationSettings.Get("payKey_yifu").ToStringOrEmpty(); string paySecret = ApplicationSettings.Get("paySecret_yifu").ToStringOrEmpty(); string orderPrice = Request["money"].ToStringOrEmpty(); string outTradeNo = tradeno1; string productType = Request["banktype"].ToStringOrEmpty(); string orderTime = DateTime.Now.ToString("yyyyMMddHHmmss"); string productName = "1"; string orderIp = Request["ip"].ToStringOrEmpty(); string bankCode = Request["bankcode"].ToStringOrEmpty(); string bankAccountType = Request["bankAccountType"].ToStringOrEmpty(); string returnUrl = ApplicationSettings.Get("url").ToStringOrEmpty() + "Pay/yifu/return_urlbank.aspx"; string notifyUrl = ApplicationSettings.Get("url").ToStringOrEmpty() + "Pay/yifu/notify_urlbank.aspx"; string remark = "1"; SortedDictionary <string, string> sortedDictionary = new SortedDictionary <string, string>(); sortedDictionary.Add("payKey", payKey); sortedDictionary.Add("orderPrice", orderPrice); sortedDictionary.Add("outTradeNo", outTradeNo); sortedDictionary.Add("productType", productType); sortedDictionary.Add("orderTime", orderTime); sortedDictionary.Add("productName", productName); sortedDictionary.Add("orderIp", orderIp); sortedDictionary.Add("bankCode", bankCode); sortedDictionary.Add("bankAccountType", bankAccountType); sortedDictionary.Add("returnUrl", returnUrl); sortedDictionary.Add("notifyUrl", notifyUrl); sortedDictionary.Add("remark", remark); string str = ""; foreach (System.Collections.Generic.KeyValuePair <string, string> current in sortedDictionary) { if (current.Value != "") { string text3 = str; str = string.Concat(new string[] { text3, current.Key, "=", current.Value, "&" }); } } str = str + "paySecret=" + paySecret; //byte[] result = Encoding.Default.GetBytes(str); //MD5 md5 = new MD5CryptoServiceProvider(); //byte[] output = md5.ComputeHash(result); //string sign = BitConverter.ToString(output).Replace("-", ""); //string md5sign = sign.ToUpper(); MD5 md = new MD5CryptoServiceProvider(); byte[] ss = md.ComputeHash(UnicodeEncoding.UTF8.GetBytes(str)); string sign = byteArrayToHexString(ss).ToUpper(); sortedDictionary.Add("sign", sign); str = ""; foreach (System.Collections.Generic.KeyValuePair <string, string> current in sortedDictionary) { if (current.Value != "") { string text3 = str; str = string.Concat(new string[] { text3, current.Key, "=", current.Value, "&" }); } } str = str.TrimEnd('&'); var ret = HttpHelper.PostWebRequest(apiurl, str); ResponseToEnd(ret); //var retObj = JsonHelper.DeserializeJsonToObject<dynamic>(ret); //if (retObj.resultCode.Value == "0000") //{ // Response.Redirect(retObj.payMessage.Value, true); //} //else //{ // ResponseToEnd(JsonHelper.SerializeObject(ret)); //} } else { ResponseToEnd(tradeno1); } } }
/// <summary> /// 创建本地库对象实例 /// </summary> /// <returns></returns> public static IRecordDataProvider GetIRecordDataProvider() { return(ProxyFactory.CreateInstance <RecordDataProvider>(ApplicationSettings.Get("DBRecord"))); }
public MainViewModel(ISettingsService settingsService, ITrayProcessCommunicationService trayProcessCommunicationService, IDialogService dialogService, IKeyboardCommandService keyboardCommandService, IApplicationView applicationView, IClipboardService clipboardService, ICommandHistoryService commandHistoryService, IAcceleratorKeyValidator acceleratorKeyValidator) { MessengerInstance.Register <ApplicationSettingsChangedMessage>(this, OnApplicationSettingsChanged); MessengerInstance.Register <ShellProfileAddedMessage>(this, OnShellProfileAdded); MessengerInstance.Register <ShellProfileDeletedMessage>(this, OnShellProfileDeleted); MessengerInstance.Register <ShellProfileChangedMessage>(this, OnShellProfileChanged); MessengerInstance.Register <DefaultShellProfileChangedMessage>(this, OnDefaultShellProfileChanged); MessengerInstance.Register <TerminalOptionsChangedMessage>(this, OnTerminalOptionsChanged); MessengerInstance.Register <CommandHistoryChangedMessage>(this, OnCommandHistoryChanged); MessengerInstance.Register <KeyBindingsChangedMessage>(this, OnKeyBindingChanged); _settingsService = settingsService; _trayProcessCommunicationService = trayProcessCommunicationService; _dialogService = dialogService; ApplicationView = applicationView; _clipboardService = clipboardService; _keyboardCommandService = keyboardCommandService; _commandHistoryService = commandHistoryService; _acceleratorKeyValidator = acceleratorKeyValidator; _keyboardCommandService.RegisterCommandHandler(nameof(Command.NewTab), async() => await AddDefaultProfileAsync(NewTerminalLocation.Tab)); _keyboardCommandService.RegisterCommandHandler(nameof(Command.NewWindow), async() => await AddDefaultProfileAsync(NewTerminalLocation.Window)); _keyboardCommandService.RegisterCommandHandler(nameof(Command.NewSshTab), async() => await AddSshProfileAsync(NewTerminalLocation.Tab)); _keyboardCommandService.RegisterCommandHandler(nameof(Command.NewSshWindow), async() => await AddSshProfileAsync(NewTerminalLocation.Window)); _keyboardCommandService.RegisterCommandHandler(nameof(Command.NewCustomCommandTab), async() => await AddQuickLaunchProfileAsync(NewTerminalLocation.Tab)); _keyboardCommandService.RegisterCommandHandler(nameof(Command.NewCustomCommandWindow), async() => await AddQuickLaunchProfileAsync(NewTerminalLocation.Window)); _keyboardCommandService.RegisterCommandHandler(nameof(Command.ChangeTabTitle), async() => await SelectedTerminal.EditTitleAsync()); _keyboardCommandService.RegisterCommandHandler(nameof(Command.CloseTab), CloseCurrentTab); _keyboardCommandService.RegisterCommandHandler(nameof(Command.DuplicateTab), async() => await AddTabAsync(SelectedTerminal.ShellProfile.Clone())); // Add all of the commands for switching to a tab of a given ID, if there's one open there for (int i = 0; i < 9; i++) { var switchCmd = Command.SwitchToTerm1 + i; int tabNumber = i; // ReSharper disable once InconsistentNaming void handler() => SelectTabNumber(tabNumber); _keyboardCommandService.RegisterCommandHandler(switchCmd.ToString(), handler); } _keyboardCommandService.RegisterCommandHandler(nameof(Command.NextTab), SelectNextTab); _keyboardCommandService.RegisterCommandHandler(nameof(Command.PreviousTab), SelectPreviousTab); _keyboardCommandService.RegisterCommandHandler(nameof(Command.ShowSettings), ShowSettings); _keyboardCommandService.RegisterCommandHandler(nameof(Command.ToggleFullScreen), ToggleFullScreen); foreach (ShellProfile profile in _settingsService.GetShellProfiles()) { _keyboardCommandService.RegisterCommandHandler(profile.Id.ToString(), async() => await AddProfileByGuidAsync(profile.Id)); } foreach (SshProfile profile in _settingsService.GetSshProfiles()) { _keyboardCommandService.RegisterCommandHandler(profile.Id.ToString(), async() => await AddProfileByGuidAsync(profile.Id)); } var currentTheme = _settingsService.GetCurrentTheme(); var options = _settingsService.GetTerminalOptions(); UseAcrylicBackground = options.UseAcrylicBackground; BackgroundOpacity = options.BackgroundOpacity; _applicationSettings = _settingsService.GetApplicationSettings(); TabsPosition = _applicationSettings.TabsPosition; AddDefaultTabCommand = new RelayCommand(async() => await AddDefaultProfileAsync(NewTerminalLocation.Tab)); ApplicationView.CloseRequested += OnCloseRequest; ApplicationView.Closed += OnClosed; Terminals.CollectionChanged += OnTerminalsCollectionChanged; LoadKeyBindings(); _newDefaultTabCommand = new RelayCommand(async() => await AddDefaultProfileAsync(NewTerminalLocation.Tab)); _newDefaultWindowCommand = new RelayCommand(async() => await AddDefaultProfileAsync(NewTerminalLocation.Window)); _newRemoteTabCommand = new RelayCommand(async() => await AddSshProfileAsync(NewTerminalLocation.Tab)); _newRemoteWindowCommand = new RelayCommand(async() => await AddSshProfileAsync(NewTerminalLocation.Window)); _newQuickLaunchTabCommand = new RelayCommand(async() => await AddQuickLaunchProfileAsync(NewTerminalLocation.Tab)); _newQuickLaunchWindowCommand = new RelayCommand(async() => await AddQuickLaunchProfileAsync(NewTerminalLocation.Window)); _settingsCommand = new RelayCommand(ShowSettings); _aboutCommand = new RelayCommand(async() => await _dialogService.ShowAboutDialogAsync()); _quitCommand = new AsyncCommand(() => _trayProcessCommunicationService.QuitApplicationAsync()); _defaultProfile = _settingsService.GetDefaultShellProfile(); CreateMenuViewModel(); }
public UserController(IOptions <ApplicationSettings> settings, IOptions <ConfigOptions> config) { _settings = settings.Value; _config = config.Value; }