public IRabbitMQServiceSourceDefinition FetchSource(Guid resourceID)
        {
            var xaml   = _queryManager.FetchResourceXaml(resourceID);
            var source = new RabbitMQSource(xaml.ToXElement());
            var def    = new RabbitMQServiceSourceDefinition(source);

            return(def);
        }
Beispiel #2
0
 void ToItem()
 {
     Item = new RabbitMQServiceSourceDefinition()
     {
         HostName     = _rabbitMQServiceSource.HostName,
         Password     = _rabbitMQServiceSource.Password,
         UserName     = _rabbitMQServiceSource.UserName,
         Port         = _rabbitMQServiceSource.Port,
         ResourceName = _rabbitMQServiceSource.ResourceName,
         ResourceID   = _rabbitMQServiceSource.ResourceID,
         VirtualHost  = _rabbitMQServiceSource.VirtualHost,
         ResourcePath = _rabbitMQServiceSource.ResourcePath,
     };
 }
Beispiel #3
0
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            ExecuteMessage     msg        = new ExecuteMessage();
            Dev2JsonSerializer serializer = new Dev2JsonSerializer();

            try
            {
                Dev2Logger.Info("Save RabbitMQ Service Source");
                StringBuilder resourceDefinition;
                msg.HasError = false;

                values.TryGetValue("RabbitMQServiceSource", out resourceDefinition);

                RabbitMQServiceSourceDefinition rabbitMQServiceSourceDefinition = serializer.Deserialize <RabbitMQServiceSourceDefinition>(resourceDefinition);
                if (rabbitMQServiceSourceDefinition.ResourcePath.EndsWith("\\"))
                {
                    rabbitMQServiceSourceDefinition.ResourcePath = rabbitMQServiceSourceDefinition.ResourcePath.Substring(0, rabbitMQServiceSourceDefinition.ResourcePath.LastIndexOf("\\", StringComparison.Ordinal));
                }

                RabbitMQSource rabbitMQSource = new RabbitMQSource
                {
                    ResourceID   = rabbitMQServiceSourceDefinition.ResourceID,
                    ResourceName = rabbitMQServiceSourceDefinition.ResourceName,
                    HostName     = rabbitMQServiceSourceDefinition.HostName,
                    Port         = rabbitMQServiceSourceDefinition.Port,
                    UserName     = rabbitMQServiceSourceDefinition.UserName,
                    Password     = rabbitMQServiceSourceDefinition.Password,
                    VirtualHost  = rabbitMQServiceSourceDefinition.VirtualHost
                };

                ResourceCatalog.Instance.SaveResource(GlobalConstants.ServerWorkspaceID, rabbitMQSource, rabbitMQServiceSourceDefinition.ResourcePath);
            }
            catch (Exception err)
            {
                msg.HasError = true;
                msg.Message  = new StringBuilder(err.Message);
                Dev2Logger.Error("Save RabbitMQ Service Source Failed: " + err.Message);
            }

            return(serializer.SerializeToBuilder(msg));
        }
Beispiel #4
0
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            ExecuteMessage     msg        = new ExecuteMessage();
            Dev2JsonSerializer serializer = new Dev2JsonSerializer();

            try
            {
                Dev2Logger.Info("Test RabbitMQ Service Source");
                StringBuilder resourceDefinition;
                msg.HasError = false;

                values.TryGetValue("RabbitMQServiceSource", out resourceDefinition);

                RabbitMQServiceSourceDefinition rabbitMQServiceSourceDefinition = serializer.Deserialize <RabbitMQServiceSourceDefinition>(resourceDefinition);
                RabbitMQSources  rabbitMQSources = new RabbitMQSources();
                ValidationResult result          = rabbitMQSources.Test(new RabbitMQSource
                {
                    ResourceID   = rabbitMQServiceSourceDefinition.ResourceID,
                    ResourceName = rabbitMQServiceSourceDefinition.ResourceName,
                    HostName     = rabbitMQServiceSourceDefinition.HostName,
                    Port         = rabbitMQServiceSourceDefinition.Port,
                    UserName     = rabbitMQServiceSourceDefinition.UserName,
                    Password     = rabbitMQServiceSourceDefinition.Password,
                    VirtualHost  = rabbitMQServiceSourceDefinition.VirtualHost
                });

                if (!result.IsValid)
                {
                    msg.HasError = true;
                    msg.Message  = new StringBuilder(result.ErrorMessage);
                }
            }
            catch (Exception err)
            {
                msg.HasError = true;
                msg.Message  = new StringBuilder(err.Message);
                Dev2Logger.Error(err);
            }
            return(serializer.SerializeToBuilder(msg));
        }
        public void RabbitMQPublishDesignerViewModel2_EditRabbitMQSourceCommand_ExistingSourceId()
        {
            //------------Setup for test--------------------------
            CustomContainer.LoadedTypes = new List <Type>
            {
                typeof(ManageRabbitMQSourceModel)
            };

            var mockHelpViewModel = new Mock <IHelpWindowViewModel>();

            mockHelpViewModel.Setup(model => model.UpdateHelpText(It.IsAny <string>())).Verifiable();

            var mockUpdateManager = new Mock <IStudioUpdateManager>();
            var mockQueryManager  = new Mock <IQueryManager>();

            var guidOne = Guid.NewGuid();
            var guidTwo = Guid.NewGuid();

            var rabbitMqSourceOne = new RabbitMQSource {
                ResourceID = guidOne, ResourceName = "ResourceOne", HostName = "HostOne"
            };
            var rabbitMqSourceTwo = new RabbitMQSource {
                ResourceID = guidTwo, ResourceName = "ResourceTwo", HostName = "HostTwo"
            };
            var rabbitMqServiceSourceDefinitionOne = new RabbitMQServiceSourceDefinition(rabbitMqSourceOne);
            var rabbitMqServiceSourceDefinitionTwo = new RabbitMQServiceSourceDefinition(rabbitMqSourceTwo);

            var rabbitMqServiceSourceDefinitions = new List <IRabbitMQServiceSourceDefinition>
            {
                rabbitMqServiceSourceDefinitionOne,
                rabbitMqServiceSourceDefinitionTwo,
            };

            mockQueryManager.Setup(o => o.FetchRabbitMQServiceSources()).Returns(rabbitMqServiceSourceDefinitions);

            var server = new Mock <IServer>();

            server.Setup(server1 => server1.UpdateRepository).Returns(mockUpdateManager.Object);
            server.Setup(server1 => server1.QueryProxy).Returns(mockQueryManager.Object);

            var mockMainViewModel = new Mock <IShellViewModel>();

            mockMainViewModel.Setup(model => model.HelpViewModel).Returns(mockHelpViewModel.Object);
            mockMainViewModel.Setup(model => model.ActiveServer).Returns(server.Object);
            CustomContainer.Register(mockMainViewModel.Object);

            var publishRabbitMqActivity = new PublishRabbitMQActivity();
            //------------Execute Test---------------------------
            var vm = new RabbitMQPublishDesignerViewModel2(ModelItemUtils.CreateModelItem(publishRabbitMqActivity));

            //------------Execute Test---------------------------

            vm.SelectedRabbitMQSource = rabbitMqServiceSourceDefinitionOne;

            Assert.IsTrue(vm.EditRabbitMQSourceCommand.CanExecute(null));

            vm.EditRabbitMQSourceCommand.Execute(null);

            //------------Assert Results-------------------------
            Assert.AreEqual(rabbitMqServiceSourceDefinitionOne, vm.SelectedRabbitMQSource);
        }