void LoadLists(System.Action continueWith = null) { Lists.Clear(); if (!IsSharepointServerSelected) { if (continueWith != null) { continueWith(); } return; } // Get Selected values on UI thread BEFORE starting asyncWorker var selectedDatabase = SelectedSharepointServer; _asyncWorker.Start(() => GetSharepointLists(selectedDatabase), tableList => { if (tableList != null) { foreach (var listTo in tableList.OrderBy(t => t.FullName)) { Lists.Add(listTo); } } if (continueWith != null) { continueWith(); } }); }
public void Load(Guid environmentId, IAsyncWorker asyncWorker, Action <Guid> onCompletion) { if (asyncWorker == null) { throw new ArgumentNullException("asyncWorker"); } var environmentRepository = GetEnvironmentRepository(); if (!_isRegistered) { _isRegistered = true; } // ReSharper disable ImplicitlyCapturedClosure IEnvironmentModel environmentModel = environmentRepository.FindSingle(c => c.ID == environmentId); // ReSharper restore ImplicitlyCapturedClosure if (environmentModel != null) { if (!environmentModel.IsConnected) { // ReSharper disable ImplicitlyCapturedClosure asyncWorker.Start(environmentModel.Connect, () => LoadEnvironmentTree(environmentId, onCompletion, environmentModel), e => onCompletion(environmentId)); // ReSharper restore ImplicitlyCapturedClosure } else { asyncWorker.Start(() => {}, () => LoadEnvironmentTree(environmentId, onCompletion, environmentModel), e => onCompletion(environmentId)); } } }
void LoadDatabases(System.Action continueWith = null) { Databases.Clear(); Databases.Add(NewDbSource); _asyncWorker.Start(() => GetDatabases().OrderBy(r => r.ResourceName), databases => { foreach (var database in databases) { Databases.Add(database); } continueWith?.Invoke(); }); }
public static void Send(IContextualResourceModel resourceModel, string payload, IAsyncWorker asyncWorker) { if (resourceModel?.Environment == null || !resourceModel.Environment.IsConnected) { return; } var clientContext = resourceModel.Environment.Connection; if (clientContext == null) { return; } asyncWorker.Start(() => { var controller = new CommunicationController { ServiceName = string.IsNullOrEmpty(resourceModel.Category) ? resourceModel.ResourceName : resourceModel.Category, ServicePayload = { ResourceID = resourceModel.ID }, }; controller.AddPayloadArgument("DebugPayload", payload); controller.ExecuteCommand <string>(clientContext, clientContext.WorkspaceID); }, () => { }); }
/// <exception cref="Exception">A delegate callback throws an exception.</exception> public ManageComPluginSourceViewModel(IManageComPluginSourceModel updateManager, Microsoft.Practices.Prism.PubSubEvents.IEventAggregator aggregator, IComPluginSource pluginSource, IAsyncWorker asyncWorker) : this(updateManager, aggregator, asyncWorker) { VerifyArgument.IsNotNull("compluginSource", pluginSource); asyncWorker.Start(() => { IsLoading = true; var comPluginSource = updateManager.FetchSource(pluginSource.Id); List<DllListingModel> names = updateManager.GetComDllListings(null)?.Select(input => new DllListingModel(updateManager, input)).ToList(); return new Tuple<IComPluginSource, List<DllListingModel>>(comPluginSource, names); }, tuple => { if (tuple.Item2 != null) { _originalDllListings = new AsyncObservableCollection<IDllListingModel>(tuple.Item2); DllListings = _originalDllListings; } _pluginSource = tuple.Item1; _pluginSource.ResourcePath = pluginSource.ResourcePath; SetupHeaderTextFromExisting(); FromModel(_pluginSource); Item = ToModel(); IsLoading = false; }); }
public ManageOAuthSourceViewModel(IManageOAuthSourceModel updateManager, IOAuthSource oAuthSource, IAsyncWorker asyncWorker) : base("OAuth") { if (updateManager == null) { throw new ArgumentNullException(nameof(updateManager)); } if (oAuthSource == null) { throw new ArgumentNullException(nameof(oAuthSource)); } _updateManager = updateManager; Types = new List <string> { "Dropbox" }; asyncWorker.Start(() => updateManager.FetchSource(oAuthSource.ResourceID), source => { _oAuthSource = source; _oAuthSource.ResourcePath = oAuthSource.ResourcePath; // ReSharper disable once VirtualMemberCallInContructor FromModel(_oAuthSource); SetupHeaderTextFromExisting(); SetupCommands(); SetupAuthorizeUri(); }); }
void LoadSettings() { ClearErrors(); IsSaved = false; IsDirty = false; IsLoading = true; _asyncWorker.Start(() => { Settings = CurrentEnvironment.IsConnected ? ReadSettings() : new Data.Settings.Settings { Security = new SecuritySettingsTO() }; }, () => { IsLoading = false; SecurityViewModel = CreateSecurityViewModel(); LogSettingsViewModel = CreateLoggingViewModel(); AddPropertyChangedHandlers(); if (Settings.HasError) { ShowError("Load Error", Settings.Error); } }); }
public void RunSelectedTest(IServiceTestModel selectedServiceTest, IContextualResourceModel resourceModel, IAsyncWorker asyncWorker) { selectedServiceTest = selectedServiceTest as ServiceTestModel; if (selectedServiceTest == null || resourceModel == null || asyncWorker == null || selectedServiceTest.IsNewTest) { return; } selectedServiceTest.IsTestLoading = true; selectedServiceTest.IsTestRunning = true; asyncWorker.Start(() => resourceModel.Environment.ResourceRepository.ExecuteTest(resourceModel, selectedServiceTest.TestName), res => { if (res?.Result != null) { if (res.Result.RunTestResult == RunResult.TestResourceDeleted) { selectedServiceTest.IsTestRunning = false; var popupController = CustomContainer.Get <IPopupController>(); popupController?.Show(Resources.Languages.Core.ServiceTestResourceDeletedMessage, Resources.Languages.Core.ServiceTestResourceDeletedHeader, MessageBoxButton.OK, MessageBoxImage.Error, null, false, true, false, false, false, false); var shellViewModel = CustomContainer.Get <IShellViewModel>(); shellViewModel.CloseResourceTestView(resourceModel.ID, resourceModel.ServerID, resourceModel.Environment.EnvironmentID); return; } UpdateTestStatus(selectedServiceTest, res); selectedServiceTest.Outputs = res.Outputs?.Select(output => { var serviceTestOutput = new ServiceTestOutput(output.Variable, output.Value, output.From, output.To) as IServiceTestOutput; serviceTestOutput.AssertOp = output.AssertOp; serviceTestOutput.Result = output.Result; return(serviceTestOutput); }).ToObservableCollection(); if (selectedServiceTest.TestSteps != null && res.TestSteps != null) { foreach (var resTestStep in res.TestSteps) { RunTestStep(selectedServiceTest, resTestStep); } } selectedServiceTest.DebugForTest = res.Result.DebugForTest; selectedServiceTest.LastRunDate = DateTime.Now; selectedServiceTest.LastRunDateVisibility = true; } else { selectedServiceTest.TestPassed = false; selectedServiceTest.TestFailing = false; selectedServiceTest.TestInvalid = true; } selectedServiceTest.IsTestRunning = false; selectedServiceTest.IsTestLoading = false; }); }
public ManageRabbitMQSourceViewModel(IRabbitMQSourceModel rabbitMQSourceModel, IRabbitMQServiceSourceDefinition rabbitMQServiceSource, IAsyncWorker asyncWorker) : this(rabbitMQSourceModel) { VerifyArgument.IsNotNull("rabbitMQServiceSource", rabbitMQServiceSource); asyncWorker.Start(() => rabbitMQSourceModel.FetchSource(rabbitMQServiceSource.ResourceID), source => { _rabbitMQServiceSource = source; _rabbitMQServiceSource.ResourcePath = rabbitMQServiceSource.ResourcePath; SetupHeaderTextFromExisting(); FromModel(source); }); }
public ManageExchangeSourceViewModel(IManageExchangeSourceModel updateManager, IEventAggregator aggregator, IExchangeSource exchangeSource, IAsyncWorker AsyncWorker) : this(updateManager, aggregator) { VerifyArgument.IsNotNull("exchangeSource", exchangeSource); AsyncWorker.Start(() => updateManager.FetchSource(exchangeSource.ResourceID), source => { _emailServiceSource = source; _emailServiceSource.Path = exchangeSource.Path; FromModel(_emailServiceSource); SetupHeaderTextFromExisting(); }); }
public ManageWcfSourceViewModel(IWcfSourceModel updateManager, IEventAggregator aggregator, IWcfServerSource wcfSource, IAsyncWorker asyncWorker, IServer environment) : this(updateManager, aggregator, asyncWorker, environment) { VerifyArgument.IsNotNull("source", wcfSource); asyncWorker.Start(() => updateManager.FetchSource(wcfSource.Id), source => { _wcfServerSource = source; _wcfServerSource.Path = wcfSource.Path; SetupHeaderTextFromExisting(); FromModel(source); }); }
public ManagePluginSourceViewModel(IManagePluginSourceModel updateManager, IEventAggregator aggregator, IPluginSource pluginSource, IAsyncWorker asyncWorker) : this(updateManager, aggregator, asyncWorker) { VerifyArgument.IsNotNull("pluginSource", pluginSource); asyncWorker.Start(() => updateManager.FetchSource(pluginSource.Id), source => { _pluginSource = source; _pluginSource.Path = pluginSource.Path; ToItem(); FromModel(_pluginSource); SetupHeaderTextFromExisting(); }); }
public ManageEmailSourceViewModel(IManageEmailSourceModel updateManager, IEventAggregator aggregator, IEmailServiceSource emailServiceSource, IAsyncWorker asyncWorker) : this(updateManager, aggregator) { VerifyArgument.IsNotNull("emailServiceSource", emailServiceSource); asyncWorker.Start(() => updateManager.FetchSource(emailServiceSource.Id), source => { _emailServiceSource = source; _emailServiceSource.Path = emailServiceSource.Path; FromModel(_emailServiceSource); Item = ToModel(); SetupHeaderTextFromExisting(); }); }
public SharepointServerSourceViewModel(ISharePointSourceModel updateManager, IEventAggregator aggregator, ISharepointServerSource sharePointServiceSource, IAsyncWorker asyncWorker, IServer environment) : this(updateManager, aggregator, asyncWorker, environment) { VerifyArgument.IsNotNull("sharePointServiceSource", sharePointServiceSource); asyncWorker.Start(() => updateManager.FetchSource(sharePointServiceSource.Id), source => { _sharePointServiceSource = source; _sharePointServiceSource.Path = sharePointServiceSource.Path; SetupHeaderTextFromExisting(); FromModel(source); }); }
void LoadSources(System.Action continueWith = null) { EmailSources.Clear(); EmailSources.Add(NewEmailSource); _asyncWorker.Start(() => GetEmailSources().OrderBy(r => r.ResourceName), sources => { foreach (var source in sources) { EmailSources.Add(source); } continueWith?.Invoke(); }); }
public void RunSelectedTest(IServiceTestModel selectedServiceTest, IContextualResourceModel resourceModel, IAsyncWorker asyncWorker) { var model = selectedServiceTest.As <ServiceTestModel>(); if (model == null || resourceModel == null || asyncWorker == null || model.IsNewTest) { return; } model.IsTestLoading = true; model.IsTestRunning = true; asyncWorker.Start(() => BackgroundAction(model, resourceModel), res => UiAction(model, resourceModel, res)); }
public ElasticsearchSourceViewModel(IElasticsearchSourceModel elasticsearchSourceModel, IElasticsearchSourceDefinition elasticsearchServiceSource, IAsyncWorker asyncWorker, IServer currentEnvironment) : this(elasticsearchSourceModel) { VerifyArgument.IsNotNull(nameof(elasticsearchServiceSource), elasticsearchServiceSource); CurrentEnvironment = currentEnvironment ?? throw new ArgumentNullException(nameof(currentEnvironment)); asyncWorker.Start(() => elasticsearchSourceModel.FetchSource(elasticsearchServiceSource.Id), source => { _elasticsearchServiceSource = source; _elasticsearchServiceSource.Path = elasticsearchServiceSource.Path; SetupHeaderTextFromExisting(); ToItem(); FromModel(elasticsearchServiceSource); }); }
void OnServerChanged(object obj) { var tmpEnv = obj as IEnvironmentModel; if (!DoDeactivate()) { return; } CurrentEnvironment = tmpEnv; if (CurrentEnvironment != null && CurrentEnvironment.AuthorizationService != null && CurrentEnvironment.IsConnected) { if (CurrentEnvironment.AuthorizationService.IsAuthorized(AuthorizationContext.Administrator, null)) { ClearConnectionError(); _resourcePicker = new ResourcePickerDialog(enDsfActivityType.Workflow, CurrentEnvironment); ScheduledResourceModel = new ClientScheduledResourceModel(CurrentEnvironment); IsLoading = true; _asyncWorker.Start( () => ScheduledResourceModel.ScheduledResources = ScheduledResourceModel.GetScheduledResources(), () => { foreach (var scheduledResource in ScheduledResourceModel.ScheduledResources) { scheduledResource.NextRunDate = scheduledResource.Trigger.Trigger.StartBoundary; scheduledResource.OldName = scheduledResource.Name; } NotifyOfPropertyChange(() => TaskList); if (TaskList.Count > 0) { SelectedTask = TaskList[0]; } IsLoading = false; }); } else { SetConnectionError(); ClearViewModel(); } } else { ClearConnectionError(); ClearViewModel(); } }
private void SendEmail(ExchangeSource testSource, ExchangeTestMessage testMessage) { _asyncWorker.Start(() => { try { testSource.Send(new ExchangeEmailSender(testSource), testMessage); } catch (Exception) { SetStatusMessage("One or more errors occured"); } finally { Testing = false; } }); }
private void LoadActions(IDbServiceModel model) { IsRefreshing = true; SelectedAction = null; IsActionEnabled = false; IsEnabled = false; _worker.Start(() => model.GetActions(_source.SelectedSource), delegate(ICollection <IDbAction> actions) { Actions = actions; IsRefreshing = false; IsActionEnabled = true; IsEnabled = true; if (!string.IsNullOrEmpty(ProcedureName)) { SelectedAction = Actions.FirstOrDefault(action => action.Name == ProcedureName); } }); }
public ManageNewServerViewModel(IManageServerSourceModel updateManager, IEventAggregator aggregator, IServerSource serverSource, IAsyncWorker asyncWorker, IExternalProcessExecutor executor) : this(updateManager, aggregator, asyncWorker, executor) { VerifyArgument.IsNotNull("serverSource", serverSource); _warewolfserverName = updateManager.ServerName; AsyncWorker.Start(() => updateManager.FetchSource(serverSource.ID), source => { _serverSource = source; _serverSource.ResourcePath = serverSource.ResourcePath; GetLoadComputerNamesTask(() => { FromModel(_serverSource); Item = ToModel(); SetupHeaderTextFromExisting(); } ); }); }
public static void Send(WebServerMethod method, IContextualResourceModel resourceModel, string payload, IAsyncWorker asyncWorker) { if(resourceModel == null || resourceModel.Environment == null || !resourceModel.Environment.IsConnected) { return; } var clientContext = resourceModel.Environment.Connection; if(clientContext == null) { return; } asyncWorker.Start(() => { var controller = new CommunicationController { ServiceName = resourceModel.Category }; controller.AddPayloadArgument("DebugPayload", payload); controller.ExecuteCommand<string>(clientContext, clientContext.WorkspaceID); }, () => { }); }
internal Task LoadResourcesAsync(IEnvironmentModel environment, List <IExplorerItemModel> expandedList = null, IExplorerItemModel selectedItem = null) { Task task = null; if (AsyncWorker != null) { // ReSharper disable ImplicitlyCapturedClosure task = AsyncWorker.Start(() => // ReSharper restore ImplicitlyCapturedClosure { if (!environment.IsConnected) { Connect(environment); } environment.LoadResources(); }, () => { try { if (environment.IsConnected && environment.CanStudioExecute) { UpdateNavigationView(expandedList, selectedItem); } } catch (Exception ex) { Dev2Logger.Log.Error(ex); } finally { if (UpdateWorkSpaceItems != null) { UpdateWorkSpaceItems(); } environment.RaiseResourcesLoaded(); } }); } return(task); }
public static void Send(WebServerMethod method, IContextualResourceModel resourceModel, string payload, IAsyncWorker asyncWorker) { if (resourceModel == null || resourceModel.Environment == null || !resourceModel.Environment.IsConnected) { return; } var clientContext = resourceModel.Environment.Connection; if (clientContext == null) { return; } asyncWorker.Start(() => { var controller = new CommunicationController { ServiceName = resourceModel.Category }; controller.AddPayloadArgument("DebugPayload", payload); controller.ExecuteCommand <string>(clientContext, clientContext.WorkspaceID); }, () => { }); }
public void Load(Guid environmentId, IAsyncWorker asyncWorker, Action<Guid> onCompletion) { if(asyncWorker == null) { throw new ArgumentNullException("asyncWorker"); } var environmentRepository = GetEnvironmentRepository(); if(!_isRegistered) { _isRegistered = true; } // ReSharper disable ImplicitlyCapturedClosure IEnvironmentModel environmentModel = environmentRepository.FindSingle(c => c.ID == environmentId); // ReSharper restore ImplicitlyCapturedClosure if(environmentModel != null) { if(!environmentModel.IsConnected) { // ReSharper disable ImplicitlyCapturedClosure asyncWorker.Start(environmentModel.Connect, () => LoadEnvironmentTree(environmentId, onCompletion, environmentModel), e => onCompletion(environmentId)); // ReSharper restore ImplicitlyCapturedClosure } else { asyncWorker.Start(()=>{}, () => LoadEnvironmentTree(environmentId, onCompletion, environmentModel), e => onCompletion(environmentId)); } } }
// ReSharper disable InconsistentNaming void OnEnvironmentModel_ResourcesLoaded(object sender, ResourcesLoadedEventArgs e) // ReSharper restore InconsistentNaming { _worker.Start(() => GetResourceModel(e.Model), CheckVersions); e.Model.ResourcesLoaded -= OnEnvironmentModel_ResourcesLoaded; }
public ServiceDesignerViewModel(ModelItem modelItem, IContextualResourceModel rootModel, IServerRepository serverRepository, IEventAggregator eventPublisher, IAsyncWorker asyncWorker) : base(modelItem) { ValidationMemoManager = new ValidationMemoManager(this); MappingManager = new MappingManager(this); if (modelItem.ItemType != typeof(DsfDatabaseActivity) && modelItem.ItemType != typeof(DsfPluginActivity) && modelItem.ItemType != typeof(DsfWebserviceActivity)) { AddTitleBarEditToggle(); } AddTitleBarMappingToggle(); VerifyArgument.IsNotNull("rootModel", rootModel); VerifyArgument.IsNotNull("environmentRepository", serverRepository); VerifyArgument.IsNotNull("eventPublisher", eventPublisher); VerifyArgument.IsNotNull("asyncWorker", asyncWorker); _worker = asyncWorker; _eventPublisher = eventPublisher; eventPublisher.Subscribe(this); ButtonDisplayValue = DoneText; ShowExampleWorkflowLink = Visibility.Collapsed; RootModel = rootModel; ValidationMemoManager.DesignValidationErrors = new ObservableCollection <IErrorInfo>(); FixErrorsCommand = new DelegateCommand(o => { ValidationMemoManager.FixErrors(); IsFixed = IsWorstErrorReadOnly; }); DoneCommand = new DelegateCommand(o => Done()); DoneCompletedCommand = new DelegateCommand(o => DoneCompleted()); InitializeDisplayName(); InitializeImageSource(); IsAsyncVisible = ActivityTypeToActionTypeConverter.ConvertToActionType(Type) == Common.Interfaces.Core.DynamicServices.enActionType.Workflow; OutputMappingEnabled = !RunWorkflowAsync; var activeEnvironment = serverRepository.ActiveServer; if (EnvironmentID == Guid.Empty && !activeEnvironment.IsLocalHostCheck()) { _environment = activeEnvironment; } else { var environment = serverRepository.FindSingle(c => c.EnvironmentID == EnvironmentID); if (environment == null) { IList <IServer> environments = ServerRepository.Instance.LookupEnvironments(activeEnvironment); environment = environments.FirstOrDefault(model => model.EnvironmentID == EnvironmentID); } _environment = environment; } ValidationMemoManager.InitializeValidationService(_environment); IsLoading = true; _worker.Start(() => InitializeResourceModel(_environment), b => { if (b) { UpdateDesignerAfterResourceLoad(serverRepository); } }); ViewComplexObjectsCommand = new RelayCommand(item => { ViewJsonObjects(item as IComplexObjectItemModel); }, CanViewComplexObjects); }