public IList <IDbSource> FetchDbSources() { var comsController = CommunicationControllerFactory.CreateController("FetchDbSources"); var workspaceId = Connection.WorkspaceID; var result = comsController.ExecuteCommand <ExecuteMessage>(Connection, workspaceId); if (result == null || result.HasError) { if (!Connection.IsConnected) { ShowServerDisconnectedPopup(); return(new List <IDbSource>()); } if (result != null) { throw new WarewolfSupportServiceException(result.Message.ToString(), null); } throw new WarewolfSupportServiceException(ErrorResource.ServiceDoesNotExist, null); } Dev2JsonSerializer serializer = new Dev2JsonSerializer(); return(serializer.Deserialize <IList <IDbSource> >(result.Message.ToString())); }
public ICollection <INamespaceItem> FetchNamespaces(IComPluginSource source) { var serializer = new Dev2JsonSerializer(); var comsController = CommunicationControllerFactory.CreateController("FetchComPluginNameSpaces"); comsController.AddPayloadArgument(nameof(source), serializer.SerializeToBuilder(source)); var workspaceId = Connection.WorkspaceID; var payload = comsController.ExecuteCommand <ExecuteMessage>(Connection, workspaceId); if (payload == null || payload.HasError) { if (!Connection.IsConnected) { ShowServerDisconnectedPopup(); return(new List <INamespaceItem>()); } if (payload != null) { throw new WarewolfSupportServiceException(payload.Message.ToString(), null); } throw new WarewolfSupportServiceException(ErrorResource.ServiceDoesNotExist, null); } return(serializer.Deserialize <List <INamespaceItem> >(payload.Message)); }
/// <summary> /// Get the list of dependencies for the deploy screen /// </summary> /// <param name="values"></param> /// <returns></returns> public IList <Guid> FetchDependenciesOnList(IEnumerable <Guid> values) { if (!Connection.IsConnected) { ShowServerDisconnectedPopup(); return(new List <Guid>()); } var enumerable = values as Guid[] ?? values.ToArray(); if (!enumerable.Any()) { return(new List <Guid>()); } Dev2JsonSerializer serializer = new Dev2JsonSerializer(); var comsController = CommunicationControllerFactory.CreateController("GetDependanciesOnListService"); comsController.AddPayloadArgument("ResourceIds", serializer.SerializeToBuilder(enumerable.Select(a => a.ToString()).ToList())); comsController.AddPayloadArgument("GetDependsOnMe", "false"); var res = comsController.ExecuteCommand <List <string> >(Connection, GlobalConstants.ServerWorkspaceID).Where(a => { Guid b; Guid.TryParse(a, out b); return(b != Guid.Empty); }); var result = res.Select(Guid.Parse).ToList(); if (result == null) { throw new Exception(string.Format(GlobalConstants.NetworkCommunicationErrorTextFormat, "GetDependanciesOnListService")); } return(result); }
public IExplorerItem Load(Guid workSpaceId) { var controller = CommunicationControllerFactory.CreateController("FetchExplorerItemsService"); return(controller.ExecuteCommand <IExplorerItem>(Connection, workSpaceId)); }
public void Add_A_New_InputOnSqlProcedure_Expect_New_IS_InputAdded() { var newName = Guid.NewGuid().ToString(); var cleanProcName = newName.Replace("-", "").Replace(" ", ""); var dropProcedure = "USE [Dev2TestingDB] DROP PROCEDURE [dbo].[" + cleanProcName + "]"; var createProcedure = "CREATE procedure [dbo].[" + cleanProcName + "](@ProductId int) as Begin select * from Country select * from City end"; var result = SqlHelper.RunSqlCommand(createProcedure); Assert.AreEqual(-1, result); var inputs = new List <IServiceInput>() { new ServiceInput("ProductId", "[[ProductId]]") { ActionName = "dbo." + cleanProcName } }; var sqlActivity = new DsfSqlServerDatabaseActivity() { Inputs = inputs, ActionName = "dbo." + cleanProcName, ProcedureName = "dbo." + cleanProcName, SourceId = new Guid("b9184f70-64ea-4dc5-b23b-02fcd5f91082") }; var modelItem = ModelItemUtils.CreateModelItem(sqlActivity); var environmentModel = ServerRepository.Instance.Source; environmentModel.Connect(); var environmentConnection = environmentModel.Connection; var controllerFactory = new CommunicationControllerFactory(); var _proxyLayer = new StudioServerProxy(controllerFactory, environmentConnection); var mock = new Mock <IShellViewModel>(); var dbServiceModel = new ManageDbServiceModel(new StudioResourceUpdateManager(controllerFactory, environmentConnection) , _proxyLayer.QueryManagerProxy , mock.Object , environmentModel); var source = new DatabaseSourceRegion(dbServiceModel, modelItem, Common.Interfaces.Core.DynamicServices.enSourceType.SqlDatabase); var selectedSource = source.Sources.Single(a => a.Id == sqlActivity.SourceId); source.SelectedSource = selectedSource; var actionRegion = new DbActionRegion(dbServiceModel, modelItem, source, new SynchronousAsyncWorker()); var diffAction = actionRegion.Actions.First(p => p.Name != sqlActivity.ProcedureName); IDatabaseInputRegion databaseInputRegion = new DatabaseInputRegion(modelItem, actionRegion); Assert.AreEqual(1, databaseInputRegion.Inputs.Count); Assert.AreEqual("ProductId", databaseInputRegion.Inputs.Single().Name); Assert.AreEqual("[[ProductId]]", databaseInputRegion.Inputs.Single().Value); //add testing here var alterProcedure = "ALTER procedure [dbo].[" + cleanProcName + "](@ProductId int,@ProductId1 int,@ProductId2 int) as Begin select * from Country select * from City end"; //actionRegion.SelectedAction = diffAction;//trigger action changes var alterTableResults = SqlHelper.RunSqlCommand(alterProcedure); actionRegion.RefreshActionsCommand.Execute(null); var underTest = actionRegion.Actions.Single(p => p.Name.EndsWith(cleanProcName)); Assert.AreEqual(3, databaseInputRegion.Inputs.Count); Assert.AreEqual("ProductId", underTest.Inputs.ToList()[0].Name); Assert.AreEqual("ProductId1", underTest.Inputs.ToList()[1].Name); Assert.AreEqual("ProductId2", underTest.Inputs.ToList()[2].Name); Assert.AreEqual("ProductId", databaseInputRegion.Inputs.ToList()[0].Name); Assert.AreEqual("[[ProductId]]", databaseInputRegion.Inputs.ToList()[0].Value); Assert.AreEqual("ProductId1", databaseInputRegion.Inputs.ToList()[1].Name); Assert.AreEqual("[[ProductId1]]", databaseInputRegion.Inputs.ToList()[1].Value); Assert.AreEqual("ProductId2", databaseInputRegion.Inputs.ToList()[2].Name); Assert.AreEqual("[[ProductId2]]", databaseInputRegion.Inputs.ToList()[2].Value); Assert.AreEqual(-1, alterTableResults); var resultForDrop = SqlHelper.RunSqlCommand(dropProcedure); Assert.AreEqual(-1, resultForDrop); }