public void InitializeSettings(string settingsFolderPath) { var tradingSettingsFilePath = Path.Combine(settingsFolderPath, TradingSettingsFileName); if (File.Exists(tradingSettingsFilePath)) { _tradingSettings = JsonConvert.DeserializeObject <TradingSettings>(File.ReadAllText(tradingSettingsFilePath)); } var analysisSettingsFilePath = Path.Combine(settingsFolderPath, AnalysisSettingsFileName); if (File.Exists(analysisSettingsFilePath)) { _analysisSettings = JsonConvert.DeserializeObject <AnalysisSettings>(File.ReadAllText(analysisSettingsFilePath)); } var exchangeConnectionSettingsFilePath = Path.Combine(settingsFolderPath, ExchangeConnectionSettingsFileName); if (File.Exists(exchangeConnectionSettingsFilePath)) { _exchangeConnectionSettings = JsonConvert.DeserializeObject <ExchangeConnectionSettings>(File.ReadAllText(exchangeConnectionSettingsFilePath)); } var databaseConnectionSettingsFilePath = Path.Combine(settingsFolderPath, DatabaseConnectionSettingsFileName); if (File.Exists(databaseConnectionSettingsFilePath)) { _databaseConnectionSettings = JsonConvert.DeserializeObject <DatabaseConnectionSettings>(File.ReadAllText(databaseConnectionSettingsFilePath)); } }
public PluginExecutionResult Execute(PluginExecutionData executionData) { try { ServerInfo exchangeServerInfo = executionData.Servers.First(); if (!_controllerConfigured) { // Alan Andrews 7/9/2010: // For some reason, Autodiscover hangs when we do not have this VMLevelLock in place. // Putting the lock in, then Autodiscover no longer hangs. I don't quite understand why, but // this is how automation goes sometimes. var action = new Action(() => { ExecutionServices.SystemTrace.LogDebug("Autodiscover lock acquired"); ExchangeConnectionSettings settings = new ExchangeConnectionSettings(exchangeServerInfo); _emailController = new ExchangeEmailController(executionData.Credential, settings); }); ExecutionServices.CriticalSection.Run(new ExchangeAutodiscoverLockToken(new TimeSpan(0, 5, 0), new TimeSpan(0, 5, 0)), action); if (InvokeRequired) { ExecutionServices.SystemTrace.LogDebug("Invoking Load Inbox activity"); Invoke(new Action(LoadInbox)); } _controllerConfigured = true; } LogUsageData(executionData, exchangeServerInfo); _sendActivity = executionData.GetMetadata <EmailActivityData>(); ExecutionServices.SystemTrace.LogDebug("Activity deserialized, Preparing to send an email"); var allRecipients = ExecutionServices.SessionRuntime.AsInternal().GetOfficeWorkerEmailAddresses(_sendActivity.ToRandomCount + _sendActivity.CCRandomCount); ExecutionServices.SystemTrace.LogDebug("Adding To: recipients"); var toRecipients = allRecipients.Take(_sendActivity.ToRandomCount); ExecutionServices.SystemTrace.LogDebug("Adding CC: recipients"); var ccRecipients = allRecipients.Skip(_sendActivity.ToRandomCount).Take(_sendActivity.CCRandomCount); PopulateControl(_sendActivity, executionData.Documents, toRecipients, ccRecipients); SendEmail(); ExecutionServices.SystemTrace.LogDebug("Email sent, now sleeping 1 second"); Thread.Sleep(TimeSpan.FromSeconds(1)); } finally { // We want to attempt an email receive, even if something goes wrong with the send if (_exchangeInboxControl != null) { _exchangeInboxControl.LoadInbox(); } } return(new PluginExecutionResult(PluginResult.Passed)); }
private void ConfigureEmailController(ServerInfo serverInfo, NetworkCredential credential) { Action action = new Action(() => { ExchangeConnectionSettings settings = new ExchangeConnectionSettings(serverInfo); _emailController = new ExchangeEmailController(credential, settings); }); // For some reason, Autodiscover hangs when we do not have this local lock in place. // Putting the lock in, then Autodiscover no longer hangs. ExecutionServices.CriticalSection.Run(new ExchangeAutodiscoverLockToken(new TimeSpan(0, 8, 0), new TimeSpan(0, 5, 0)), action); }
private void InternalProcessPublicFolder() { TestMigrationServerAvailabilityOutcome sendToPipeline; try { TestMigrationServerAvailability.VerifyPublicFolderConnection(base.DataProvider, (PublicFolderEndpoint)this.endpoint, this.SourceMailboxLegacyDN, this.PublicFolderDatabaseServerLegacyDN, this.targetMailbox); ExchangeConnectionSettings connectionSettings = this.endpoint.ConnectionSettings as ExchangeConnectionSettings; sendToPipeline = TestMigrationServerAvailabilityOutcome.Create(TestMigrationServerAvailabilityResult.Success, this.SupportsCutover, connectionSettings); } catch (LocalizedException ex) { sendToPipeline = TestMigrationServerAvailabilityOutcome.Create(TestMigrationServerAvailabilityResult.Failed, this.SupportsCutover, ex.LocalizedString, ex.ToString()); } base.WriteObject(sendToPipeline); }
private void InternalProcessEndpoint(bool fromAutoDiscover) { TestMigrationServerAvailabilityOutcome sendToPipeline; try { this.endpoint.VerifyConnectivity(); ExchangeConnectionSettings connectionSettings = this.endpoint.ConnectionSettings as ExchangeConnectionSettings; sendToPipeline = TestMigrationServerAvailabilityOutcome.Create(TestMigrationServerAvailabilityResult.Success, this.SupportsCutover, connectionSettings); } catch (LocalizedException ex) { if (fromAutoDiscover) { ex = new MigrationRemoteEndpointSettingsCouldNotBeAutodiscoveredException(this.endpoint.RemoteServer.ToString(), ex); } sendToPipeline = TestMigrationServerAvailabilityOutcome.Create(TestMigrationServerAvailabilityResult.Failed, this.SupportsCutover, ex.LocalizedString, ex.ToString()); } base.WriteObject(sendToPipeline); }
/// <summary> /// Initializes the Exchange version and the URL so we don't have to use autodiscover for all the subscribers. /// </summary> /// <param name="credential"></param> private static void Initialize(NetworkCredential credential) { ExchangeConnectionSettings settings = new ExchangeConnectionSettings(_exchangeServerSettings); if (settings.AutodiscoverEnabled) { Action action = new Action(() => { TraceFactory.Logger.Debug("Autodiscover lock acquired. Autodiscovering the Exchange Server."); MailAddress autodiscoverAddress = ExchangeEmailController.GetLdapEmailAddress(credential); _exchangeUrl = ExchangeEmailController.AutodiscoverExchangeUrl(autodiscoverAddress); }); TraceFactory.Logger.Debug("Attempting to autodiscover against Exchange"); CriticalSection criticalSection = new CriticalSection(new DistributedLockManager(GlobalSettings.WcfHosts["Lock"])); criticalSection.Run(new LocalLockToken("ExchangeAutodiscover", new TimeSpan(0, 5, 0), new TimeSpan(0, 5, 0)), action); } else { TraceFactory.Logger.Debug("Configuring exchange service using Exchange Web Services URL."); _exchangeUrl = settings.EwsUrl; } }
private void ConfigureEmailController() { SettingsDictionary exchangeServerSettings = null; using (AssetInventoryContext aiContext = DbConnect.AssetInventoryContext()) { string serverType = ServerType.Exchange.ToString(); FrameworkServer server = aiContext.FrameworkServers.FirstOrDefault(n => n.ServerTypes.Any(m => m.Name == serverType) && n.Active); exchangeServerSettings = new SettingsDictionary(server.ServerSettings.ToDictionary(n => n.Name, n => n.Value)); } ExchangeConnectionSettings settings = new ExchangeConnectionSettings(exchangeServerSettings); if (settings.AutodiscoverEnabled) { TraceFactory.Logger.Debug("Configuring exchange service using Autodiscover."); _controller = new ExchangeEmailController(_credential, _emailAddress); } else { TraceFactory.Logger.Debug("Configuring exchange service using FrameworkServerSetting URL."); _controller = new ExchangeEmailController(_credential, settings.EwsUrl); } }
public ApiConnection(ExchangeConnectionSettings connectionSettings) { _baseUrl = "wss://api.hitbtc.com/api/2/ws"; _connectionSettings = connectionSettings; }