Exemple #1
0
        public List <IResourceModel> FindResourcesByID(IServer targetEnvironment, IEnumerable <string> guids, ResourceType resourceType)
        {
            if (targetEnvironment == null || guids == null)
            {
                return(new List <IResourceModel>());
            }

            var comController = new CommunicationController {
                ServiceName = "FindResourcesByID"
            };

            comController.AddPayloadArgument("GuidCsv", string.Join(",", guids));
            comController.AddPayloadArgument("Type", Enum.GetName(typeof(ResourceType), resourceType));

            var models   = comController.ExecuteCompressedCommand <List <SerializableResource> >(targetEnvironment.Connection, GlobalConstants.ServerWorkspaceID);
            var serverId = targetEnvironment.Connection.ServerID;

            var result = new List <IResourceModel>();

            if (models != null)
            {
                result.AddRange(models.Select(model => HydrateResourceModel(model, serverId)));
            }

            return(result);
        }
Exemple #2
0
        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);
            }, () => { });
        }
        public void DeleteWorkflowSuccessCantDeleteDeletedWorkflow()
        {
            //---------Setup-------------------------------
            IEnvironmentConnection connection = new ServerProxy(new Uri(_webserverUri));

            connection.Connect(Guid.Empty);
            const string ServiceName  = "DeleteWorkflowTest2";
            const string ResourceType = "WorkflowService";
            //----------Execute-----------------------------

            var coms = new CommunicationController {
                ServiceName = "DeleteResourceService"
            };

            coms.AddPayloadArgument("ResourceName", ServiceName);
            coms.AddPayloadArgument("ResourceType", ResourceType);
            coms.AddPayloadArgument("ResourceID", "f2b78836-91dd-44f0-a43f-b3ecf4c53cd5");

            // Execute
            var result = coms.ExecuteCommand <ExecuteMessage>(connection, Guid.Empty);

            // Assert
            Assert.IsTrue(result.Message.Contains("Success"), "Got [ " + result.Message + " ]");

            result = coms.ExecuteCommand <ExecuteMessage>(connection, Guid.Empty);
            StringAssert.Contains(result.Message.ToString(), "WorkflowService 'f2b78836-91dd-44f0-a43f-b3ecf4c53cd5' was not found.");
        }
        public void DeleteWorkflowSuccessCantCallDeletedWorkflow()
        {
            //---------Setup-------------------------------
            IEnvironmentConnection connection = new ServerProxy(new Uri(_webserverUri));

            connection.Connect(Guid.Empty);
            const string ServiceName  = "DeleteWorkflowTest3";
            const string ResourceType = "WorkflowService";
            //----------Execute-----------------------------

            var coms = new CommunicationController {
                ServiceName = "DeleteResourceService"
            };

            coms.AddPayloadArgument("ResourceName", ServiceName);
            coms.AddPayloadArgument("ResourceType", ResourceType);

            var result = coms.ExecuteCommand <ExecuteMessage>(connection, Guid.Empty);

            //---------Call Workflow Failure-------
// ReSharper disable InconsistentNaming
            const string serviceName = "DeleteWorkflowTest3";
// ReSharper restore InconsistentNaming
            var servicecall = String.Format("{0}{1}", ServerSettings.WebserverURI, serviceName);
            var result2     = TestHelper.PostDataToWebserver(servicecall);

            Assert.IsTrue(result2.Contains("Service [ DeleteWorkflowTest3 ] not found."), "Got [ " + result + " ]");
        }
Exemple #5
0
        public virtual async Task ReadAsync()
        {
            if (EnvironmentConnection.IsConnected)
            {
                var communicationController = new CommunicationController
                {
                    ServiceName = "SecurityReadService"
                };
                Dev2Logger.Debug("Getting Permissions from Server", "Warewolf Debug");

                var securitySettingsTo = await communicationController.ExecuteCommandAsync <SecuritySettingsTO>(EnvironmentConnection, EnvironmentConnection.WorkspaceID).ConfigureAwait(true);

                List <WindowsGroupPermission> newPermissions = null;
                if (securitySettingsTo != null)
                {
                    Permissions    = securitySettingsTo.WindowsGroupPermissions;
                    newPermissions = securitySettingsTo.WindowsGroupPermissions;
                    Dev2Logger.Debug("Permissions from Server:" + Permissions, "Warewolf Debug");
                }
                if (newPermissions != null)
                {
                    RaisePermissionsModified(new PermissionsModifiedEventArgs(newPermissions));
                }
                RaisePermissionsChanged();
            }
        }
Exemple #6
0
        public SharepointServerSourceViewModel(SharepointServerSource serverSource, IEnvironmentModel environment)
        {
            IsLoading          = false;
            TestComplete       = false;
            _environment       = environment;
            ServerName         = "";
            AuthenticationType = AuthenticationType.Windows;
            IsWindows          = true;
            SaveCommand        = new RelayCommand(o =>
            {
                serverSource.DialogResult = true;
                serverSource.Close();
            }, o => TestComplete);

            CancelCommand = new RelayCommand(o =>
            {
                serverSource.DialogResult = false;
                serverSource.Close();
            });
            TestCommand = new RelayCommand(o =>
            {
                IsLoading = true;
                Dev2JsonSerializer serializer = new Dev2JsonSerializer();
                var source         = CreateSharepointServerSource();
                var comsController = new CommunicationController {
                    ServiceName = "TestSharepointServerService"
                };
                comsController.AddPayloadArgument("SharepointServer", serializer.SerializeToBuilder(source));
                TestResult = comsController.ExecuteCommand <string>(environment.Connection, GlobalConstants.ServerWorkspaceID);
                IsLoading  = false;
            }, o => !TestComplete);
        }
        public void ExecuteCommandAsync_GivenHasAuthorizationError_ShouldShowCorrectPopup_Aggregation()
        {
            //---------------Set up test pack-------------------
            var mock = new Mock <IPopupController>();

            mock.Setup(c => c.Show(It.IsAny <string>(), It.IsAny <string>(), MessageBoxButton.OK, MessageBoxImage.Error, "", false, false, true, false, false, false));
            CustomContainer.Register(mock.Object);
            var connection = new Mock <IEnvironmentConnection>();

            connection.Setup(environmentConnection => environmentConnection.IsConnected).Returns(true);
            var aggregateException = new AggregateException();

            connection.Setup(environmentConnection => environmentConnection.ExecuteCommandAsync(It.IsAny <StringBuilder>(), GlobalConstants.ServerWorkspaceID))
            .Throws(aggregateException);
            var controller = new CommunicationController();

            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------

            controller.ExecuteCommandAsync <ExecuteMessage>(connection.Object, GlobalConstants.ServerWorkspaceID).ContinueWith((d) =>
            {
                //---------------Test Result -----------------------
                Assert.IsNotNull(d);
                mock.Verify(c => c.Show(ErrorResource.NotAuthorizedToCreateException, "ServiceNotAuthorizedException", MessageBoxButton.OK, MessageBoxImage.Error, "", false, false, true, false, false, false), Times.Never);
            });
        }
        public void ExecuteCommandAsync_GivenReturnExploreAuthorizationError_ShouldShowCorrectPopup()
        {
            //---------------Set up test pack-------------------
            var mock = new Mock <IPopupController>();

            mock.Setup(c => c.Show(It.IsAny <string>(), It.IsAny <string>(), MessageBoxButton.OK, MessageBoxImage.Error, "", false, false, true, false, false, false));
            CustomContainer.Register(mock.Object);
            var connection = new Mock <IEnvironmentConnection>();

            connection.Setup(environmentConnection => environmentConnection.IsConnected).Returns(true);
            var serializer = new Dev2JsonSerializer();

            var message = new ExecuteMessage
            {
                HasError = true,
                Message  = new StringBuilder(ErrorResource.NotAuthorizedToExecuteException)
            };

            var serializeToBuilder = serializer.SerializeToBuilder(message);

            connection.Setup(environmentConnection => environmentConnection.ExecuteCommandAsync(It.IsAny <StringBuilder>(), GlobalConstants.ServerWorkspaceID))
            .Returns(Task.FromResult(serializeToBuilder));
            var controller = new CommunicationController();
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------

            var explorerRepositoryResult = controller.ExecuteCommandAsync <ExplorerRepositoryResult>(connection.Object, GlobalConstants.ServerWorkspaceID).Result;

            //---------------Test Result -----------------------
            mock.Verify(c => c.Show(It.IsAny <string>(), It.IsAny <string>(), MessageBoxButton.OK, MessageBoxImage.Error, "", false, false, true, false, false, false), Times.Once);
        }
        public SharepointServerSourceViewModel(SharepointServerSource serverSource, IEnvironmentModel environment)
        {
            IsLoading = false;
            TestComplete = false;
            _environment = environment;
            ServerName = "";
            AuthenticationType = AuthenticationType.Windows;
            IsWindows = true;
            SaveCommand = new RelayCommand(o =>
            {
                serverSource.DialogResult = true;
                serverSource.Close();
            }, o => TestComplete);

            CancelCommand = new RelayCommand(o =>
            {
                serverSource.DialogResult = false;
                serverSource.Close();
            });
            TestCommand = new RelayCommand(o =>
            {
                IsLoading = true;
                Dev2JsonSerializer serializer = new Dev2JsonSerializer();
                var source = CreateSharepointServerSource();
                var comsController = new CommunicationController { ServiceName = "TestSharepointServerService" };
                comsController.AddPayloadArgument("SharepointServer", serializer.SerializeToBuilder(source));
                TestResult = comsController.ExecuteCommand<string>(environment.Connection, GlobalConstants.ServerWorkspaceID);
                IsLoading = false;
            }, o => !TestComplete);
        }
Exemple #10
0
        public async Task <ExecuteMessage> GetDependenciesXmlAsync(IContextualResourceModel resourceModel, bool getDependsOnMe)
        {
            if (resourceModel == null)
            {
                return(new ExecuteMessage {
                    HasError = false
                });
            }

            var comsController = new CommunicationController {
                ServiceName = "FindDependencyService"
            };

            comsController.AddPayloadArgument("ResourceId", resourceModel.ID.ToString());
            comsController.AddPayloadArgument("GetDependsOnMe", getDependsOnMe.ToString());

            var workspaceId = resourceModel.Environment.Connection.WorkspaceID;
            var payload     = await comsController.ExecuteCommandAsync <ExecuteMessage>(resourceModel.Environment.Connection, workspaceId);

            if (payload == null)
            {
                throw new Exception(string.Format(GlobalConstants.NetworkCommunicationErrorTextFormat, "FindDependencyService"));
            }

            return(payload);
        }
Exemple #11
0
        public IServiceTestModelTO ExecuteTest(IContextualResourceModel resourceModel, string testName)
        {
            if (resourceModel?.Environment == null || !resourceModel.Environment.IsConnected)
            {
                var testRunReuslt = new ServiceTestModelTO {
                    TestFailing = true
                };
                return(testRunReuslt);
            }

            var clientContext = resourceModel.Environment.Connection;

            if (clientContext == null)
            {
                var testRunReuslt = new ServiceTestModelTO {
                    TestFailing = true
                };
                return(testRunReuslt);
            }
            var controller = new CommunicationController
            {
                ServiceName    = string.IsNullOrEmpty(resourceModel.Category) ? resourceModel.ResourceName : resourceModel.Category,
                ServicePayload = { ResourceID = resourceModel.ID }
            };

            controller.AddPayloadArgument("ResourceID", resourceModel.ID.ToString());
            controller.AddPayloadArgument("IsDebug", true.ToString());
            controller.ServicePayload.TestName = testName;
            var res = controller.ExecuteCommand <IServiceTestModelTO>(clientContext, GlobalConstants.ServerWorkspaceID);

            return(res);
        }
Exemple #12
0
        public void DeployResource(IResourceModel resource, string savePath)
        {
            if (resource == null)
            {
                throw new ArgumentNullException(nameof(resource));
            }
            Dev2Logger.Info($"Deploy Resource. Resource:{resource.DisplayName} Environment:{_server.Name}");
            var theResource = FindSingle(c => c.ResourceName.Equals(resource.ResourceName, StringComparison.CurrentCultureIgnoreCase));

            if (theResource != null)
            {
                _resourceModels.Remove(theResource);
            }
            theResource = new ResourceModel(_server);
            theResource.Update(resource);
            _resourceModels.Add(theResource);

            var comsController = new CommunicationController {
                ServiceName = "DeployResourceService"
            };

            comsController.AddPayloadArgument("savePath", savePath);
            comsController.AddPayloadArgument("ResourceDefinition", resource.ToServiceDefinition(true));
            comsController.AddPayloadArgument("Roles", "*");

            var con            = _server.Connection;
            var executeCommand = comsController.ExecuteCommand <ExecuteMessage>(con, GlobalConstants.ServerWorkspaceID);

            if (executeCommand != null && executeCommand.HasError)
            {
                throw new Exception(executeCommand.Message.ToString());
            }
        }
Exemple #13
0
        public void ShouldAddCommunication()
        {
            // Sample communications to test
            Communication comm = new Communication()
            {
                Text              = "Test communication",
                Subject           = "Testing communication",
                EffectiveDateTime = new DateTime(2020, 04, 04),
                ExpiryDateTime    = new DateTime(2020, 05, 13)
            };

            RequestResult <Communication> expected = new RequestResult <Communication>
            {
                ResourcePayload = comm,
                ResultStatus    = Common.Constants.ResultType.Success
            };

            Mock <ICommunicationService> mockCommunicationService = new Mock <ICommunicationService>();

            mockCommunicationService.Setup(s => s.Add(It.Is <Communication>(x => x.Text == comm.Text))).Returns(expected);

            // Initialize controller
            CommunicationController controller = new CommunicationController(
                mockCommunicationService.Object
                );

            // Test if controller adds communication properly
            IActionResult actualResult = controller.Add(comm);

            Assert.IsType <JsonResult>(actualResult);
            Assert.True(((JsonResult)actualResult).Value.IsDeepEqual(expected));
        }
Exemple #14
0
        /// <summary>
        /// Creates new instance of <see cref="DatabaseConnector.DatabaseConnectorManager"/>.
        /// New instance is created at every call becouse of concurent access to database.
        /// </summary>
        /// <returns>Created instance of <see cref="DatabaseConnector.DatabaseConnectorManager"/>.</returns>
        private static DatabaseConnector.DatabaseConnectorManager GetDatabaseConnector()
        {
            CommunicationController controller = new CommunicationController();

            controller.CreateCommunicationModules(controller.CreateConfigurations());
            DatabaseConnector.DatabaseConnectorManager dbm = controller.GetModule("fraktusek2") as DatabaseConnector.DatabaseConnectorManager;
            return(dbm);
        }
Exemple #15
0
        public ObservableCollection <IScheduledResource> GetScheduledResources()
        {
            var controller = new CommunicationController {
                ServiceName = "GetScheduledResources"
            };

            return(controller.ExecuteCommand <ObservableCollection <IScheduledResource> >(_model.Connection, _model.Connection.WorkspaceID));
        }
Exemple #16
0
        public Data.Settings.Settings ReadSettings(IServer currentEnv)
        {
            var comController = new CommunicationController {
                ServiceName = "SettingsReadService"
            };

            return(comController.ExecuteCommand <Data.Settings.Settings>(currentEnv.Connection, GlobalConstants.ServerWorkspaceID));
        }
 public void DeleteSchedule(IScheduledResource resource)
 {
     Dev2JsonSerializer jsonSerializer = new Dev2JsonSerializer();
     var builder = jsonSerializer.SerializeToBuilder(resource);
     var controller = new CommunicationController { ServiceName = "DeleteScheduledResourceService" };
     controller.AddPayloadArgument("Resource", builder);
     controller.ExecuteCommand<string>(_model.Connection, _model.Connection.WorkspaceID);
 }
Exemple #18
0
        public IList <T> GetResourceList <T>(IServer targetEnvironment) where T : new()
        {
            var comController = new CommunicationController {
                ServiceName = CreateServiceName(typeof(T))
            };
            var sources = comController.ExecuteCommand <List <T> >(targetEnvironment.Connection, GlobalConstants.ServerWorkspaceID);

            return(sources);
        }
        public SimulatedExchangeOrderExecutionProvider()
        {
            // Initialize
            _cancelOrdersMap         = new ConcurrentDictionary <string, Order>();
            _communicationController = new CommunicationController();

            //_communicationController.Connect();
            SubscribeRequiredEvents();
        }
Exemple #20
0
        public IResourceModel LoadResourceFromWorkspace(Guid resourceId, Guid?workspaceId)
        {
            if (!_server.Connection.IsConnected)
            {
                _server.Connection.Connect(_server.EnvironmentID);
                if (!_server.Connection.IsConnected)
                {
                    ShowServerDisconnectedPopup();
                    return(null);
                }
            }
            var con            = _server.Connection;
            var comsController = new CommunicationController {
                ServiceName = "FindResourcesByID"
            };

            comsController.AddPayloadArgument("GuidCsv", resourceId.ToString());
            comsController.AddPayloadArgument("ResourceType", Enum.GetName(typeof(ResourceType), ResourceType.WorkflowService));
            var workspaceIdToUse  = workspaceId ?? con.WorkspaceID;
            var toReloadResources = comsController.ExecuteCompressedCommand <List <SerializableResource> >(con, workspaceIdToUse);

            if (toReloadResources == null && !_server.Connection.IsConnected)
            {
                if (!_server.Connection.IsConnected)
                {
                    _server.Connection.Connect(_server.EnvironmentID);
                    if (!_server.Connection.IsConnected)
                    {
                        ShowServerDisconnectedPopup();
                        return(null);
                    }
                }
                else
                {
                    toReloadResources = comsController.ExecuteCompressedCommand <List <SerializableResource> >(con, workspaceIdToUse);
                }
            }
            if (toReloadResources != null)
            {
                foreach (var serializableResource in toReloadResources)
                {
                    var resource         = HydrateResourceModel(serializableResource, _server.Connection.ServerID, true);
                    var resourceToUpdate = _resourceModels.FirstOrDefault(r => ResourceModelEqualityComparer.Current.Equals(r, resource));

                    if (resourceToUpdate != null)
                    {
                        resourceToUpdate.Update(resource);
                    }
                    else
                    {
                        _resourceModels.Add(resource);
                    }
                    return(resource);
                }
            }
            return(null);
        }
Exemple #21
0
 public void Confirm()
 {
     if (city == null)
     {
         return;
     }
     city.production = selectedUnit;
     CommunicationController.SetProduction(city.ID, selectedUnit);
 }
        public void GivenSendEmailPostMethod_WhenReceivesCorrectEmailData_ThenShouldCallEmailSenderService()
        {
            var emailToSend              = new Email();
            var mockEmailSenderService   = Substitute.For <IEmailSender>();
            var communicationsController = new CommunicationController();

            communicationsController.SendEmail(emailToSend, mockEmailSenderService);

            mockEmailSenderService.Received().SendEmail(emailToSend);
        }
Exemple #23
0
        public ExecuteMessage WriteSettings(IServer currentEnv, Data.Settings.Settings settings)
        {
            var comController = new CommunicationController {
                ServiceName = "SettingsWriteService"
            };

            comController.AddPayloadArgument("Settings", settings.ToString());

            return(comController.ExecuteCommand <ExecuteMessage>(currentEnv.Connection, GlobalConstants.ServerWorkspaceID));
        }
Exemple #24
0
        /**
         * This method will not be used by our system but it is nice
         * to have in order to test that we can call our own service
         * through code.
         */
        public static TelstarResponse RequestRoute(TelstarRequest request)
        {
            string jsonString = JsonSerializer.Serialize(request);
            string response   = CommunicationController.Send(Config.TELSTAR_URL, jsonString);
            //Console.WriteLine(response);

            TelstarResponse telstarResponse = JsonSerializer.Deserialize <TelstarResponse>(response);

            return(telstarResponse);
        }
Exemple #25
0
        public IList <IResourceHistory> CreateHistory(IScheduledResource resource)
        {
            Dev2JsonSerializer jsonSerializer = new Dev2JsonSerializer();
            var builder    = jsonSerializer.SerializeToBuilder(resource);
            var controller = new CommunicationController {
                ServiceName = "GetScheduledResourceHistoryService"
            };

            controller.AddPayloadArgument("Resource", builder);
            return(controller.ExecuteCommand <IList <IResourceHistory> >(_model.Connection, _model.Connection.WorkspaceID));
        }
Exemple #26
0
        public void DeleteSchedule(IScheduledResource resource)
        {
            Dev2JsonSerializer jsonSerializer = new Dev2JsonSerializer();
            var builder    = jsonSerializer.SerializeToBuilder(resource);
            var controller = new CommunicationController {
                ServiceName = "DeleteScheduledResourceService"
            };

            controller.AddPayloadArgument("Resource", builder);
            controller.ExecuteCommand <string>(_model.Connection, _model.Connection.WorkspaceID);
        }
Exemple #27
0
        public DbTableList GetDatabaseTables(DbSource dbSource)
        {
            var comController = new CommunicationController {
                ServiceName = "GetDatabaseTablesService"
            };

            comController.AddPayloadArgument("Database", _serializer.Serialize(dbSource));

            var tables = comController.ExecuteCommand <DbTableList>(_server.Connection, GlobalConstants.ServerWorkspaceID);

            return(tables);
        }
Exemple #28
0
        public List <SharepointListTo> GetSharepointLists(SharepointSource source)
        {
            var comController = new CommunicationController {
                ServiceName = "GetSharepointListService"
            };

            comController.AddPayloadArgument("SharepointServer", _serializer.Serialize(source));

            var lists = comController.ExecuteCommand <List <SharepointListTo> >(_server.Connection, GlobalConstants.ServerWorkspaceID);

            return(lists);
        }
Exemple #29
0
 public override void DragEnd(int button)
 {
     if (button == 1)
     {
         Coords tile = InputController.GetCoordsUnderMouse();
         if (WorldGraphics.ValidCoords(tile))
         {
             CommunicationController.ExecuteCommand(ClientController.activePlayer, new CommandMove(tile));
         }
         InputController.ChangeState(new DefaultState());
     }
 }
Exemple #30
0
        public async Task <IContextualResourceModel> LoadContextualResourceModelAsync(Guid resourceId)
        {
            var con            = _server.Connection;
            var comsController = new CommunicationController {
                ServiceName = "FindResourcesByID"
            };

            comsController.AddPayloadArgument("GuidCsv", resourceId.ToString());
            var toReloadResources = await comsController.ExecuteCompressedCommandAsync <List <SerializableResource> >(con, GlobalConstants.ServerWorkspaceID);

            return(GetContextualResourceModel(resourceId, toReloadResources));
        }
Exemple #31
0
        private static CommunicationController GetCommunicationControllerForLoadResources()
        {
            Dev2Logger.Warn("Loading Resources - Start");
            var comsController = new CommunicationController {
                ServiceName = "FindResourceService"
            };

            comsController.AddPayloadArgument("ResourceName", "*");
            comsController.AddPayloadArgument("ResourceId", "*");
            comsController.AddPayloadArgument("ResourceType", string.Empty);
            return(comsController);
        }
Exemple #32
0
 public SimulatedExchangeMarketDataProvider()
 {
     try
     {
         _communicationController = new CommunicationController();
         SubscribeRequiredEvents();
     }
     catch (Exception exception)
     {
         Logger.Error(exception, _type.FullName, "SimulatedExchangeMarketDataProvider");
     }
 }
        public CompileMessageList GetCompileMessagesFromServer(IContextualResourceModel resourceModel)
        {
            var comsController = new CommunicationController { ServiceName = "FetchDependantCompileMessagesService" };

            var workspaceID = GlobalConstants.ServerWorkspaceID;

            comsController.AddPayloadArgument("ServiceID", resourceModel.ID.ToString());
            comsController.AddPayloadArgument("WorkspaceID", workspaceID.ToString());
            var con = resourceModel.Environment.Connection;
            var result = comsController.ExecuteCommand<CompileMessageList>(con, GlobalConstants.ServerWorkspaceID);

            return result;
        }
 public bool Save(IScheduledResource resource, out string errorMessage)
 {
     Dev2JsonSerializer jsonSerializer = new Dev2JsonSerializer();
     var builder = jsonSerializer.SerializeToBuilder(resource);
     var controller = new CommunicationController { ServiceName = "SaveScheduledResourceService" };
     controller.AddPayloadArgument("Resource", builder);
     controller.AddPayloadArgument("PreviousResource", resource.OldName);
     controller.AddPayloadArgument("UserName", resource.UserName);
     controller.AddPayloadArgument("Password", resource.Password);
     var executeCommand = controller.ExecuteCommand<ExecuteMessage>(_model.Connection, _model.Connection.WorkspaceID);
     errorMessage = "";
     if(executeCommand != null)
     {
         resource.IsDirty = executeCommand.HasError;
         errorMessage = executeCommand.Message.ToString();
         return !executeCommand.HasError;
     }
     return true;
 }
        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 virtual async Task ReadAsync()
 {
     var communicationController = new CommunicationController
     {
         ServiceName = "SecurityReadService"
     };
     Dev2Logger.Log.Debug("Getting Permissions from Server");
     SecuritySettingsTO securitySettingsTo = await communicationController.ExecuteCommandAsync<SecuritySettingsTO>(EnvironmentConnection, EnvironmentConnection.WorkspaceID);
     List<WindowsGroupPermission> newPermissions = null;
     if (securitySettingsTo != null)
     {
         Permissions = securitySettingsTo.WindowsGroupPermissions;
         newPermissions = securitySettingsTo.WindowsGroupPermissions;
         Dev2Logger.Log.Debug("Permissions from Server:" + Permissions);
     }
     if (newPermissions != null)
     {
         RaisePermissionsModified(new PermissionsModifiedEventArgs(newPermissions));
     }
     RaisePermissionsChanged();
 }
        public void AppServer_Update_Resource_Correctly()
        {
            CommunicationController coms = new CommunicationController { ServiceName = "SaveResourceService" };

            var tmp = new StringBuilder(TestResource.Service_Update_Request_String);
            var xe = tmp.ToXElement();
            var xml = xe.Element("ResourceXml");

            var wtf = xml.ToStringBuilder().Unescape();
            wtf = wtf.Replace("<XmlData>", "").Replace("</XmlData>", "").Replace("<ResourceXml>", "").Replace("</ResourceXml>", "");

            coms.AddPayloadArgument("ResourceXml", wtf);
            coms.AddPayloadArgument("WorkspaceID", Guid.Empty.ToString());

            const string expected = @"Updated WorkflowService 'ServiceToBindFrom'";

            var result = coms.ExecuteCommand<ExecuteMessage>(_connection, Guid.Empty);

            StringAssert.Contains(result.Message.ToString(), expected);

        }
        public void AppServer_SaveResource_WhenSavingWorkerService_ExpectSaved()
        {
            //------------Setup for test--------------------------
            CommunicationController coms = new CommunicationController { ServiceName = "SaveResourceService" };

            var id = Guid.NewGuid().ToString();
            var tmp = new StringBuilder(CreateService(id, "[[Id]]"));

            coms.AddPayloadArgument("ResourceXml", tmp);
            coms.AddPayloadArgument("WorkspaceID", Guid.Empty.ToString());

            string expected = string.Format("Added DbService '{0}'", id);

            //------------Execute Test---------------------------
            var result = coms.ExecuteCommand<ExecuteMessage>(_connection, Guid.Empty);

            //------------Assert Results-------------------------
            StringAssert.Contains(result.Message.ToString(), expected, "Got [ " + result.Message + " ]");

        }
 public IList<IResourceHistory> CreateHistory(IScheduledResource resource)
 {
     Dev2JsonSerializer jsonSerializer = new Dev2JsonSerializer();
     var builder = jsonSerializer.SerializeToBuilder(resource);
     var controller = new CommunicationController { ServiceName = "GetScheduledResourceHistoryService" };
     controller.AddPayloadArgument("Resource", builder);
     return controller.ExecuteCommand<IList<IResourceHistory>>(_model.Connection, _model.Connection.WorkspaceID);
 }
 public void Save(IScheduledResource resource, string userName, string password)
 {
     Dev2JsonSerializer jsonSerializer = new Dev2JsonSerializer();
     var builder = jsonSerializer.SerializeToBuilder(resource);
     var controller = new CommunicationController { ServiceName = "SaveScheduledResourceService" };
     controller.AddPayloadArgument("Resource", builder);
     controller.AddPayloadArgument("UserName", userName);
     controller.AddPayloadArgument("Password", password);
     controller.ExecuteCommand<string>(_model.Connection, _model.Connection.WorkspaceID);
     resource.IsDirty = false;
 }
 public ObservableCollection<IScheduledResource> GetScheduledResources()
 {
     var controller = new CommunicationController { ServiceName = "GetScheduledResources" };
     return controller.ExecuteCommand<ObservableCollection<IScheduledResource>>(_model.Connection, _model.Connection.WorkspaceID);
 }
        public ExecuteMessage UpdateWorkspaceItem(IContextualResourceModel resource, bool isLocalSave)
        {
            // BUG 9492 - 2013.06.08 - TWR : added null check
            if(resource == null)
            {
                throw new ArgumentNullException("resource");
            }
            var workspaceItem = WorkspaceItems.FirstOrDefault(wi => wi.ID == resource.ID && wi.EnvironmentID == resource.Environment.ID);

            if(workspaceItem == null)
            {
                var msg = new ExecuteMessage { HasError = false };
                msg.SetMessage(string.Empty);
                return msg;
            }

            workspaceItem.Action = WorkspaceItemAction.Commit;

            var comsController = new CommunicationController { ServiceName = "UpdateWorkspaceItemService" };
            comsController.AddPayloadArgument("Roles", String.Join(",", "Test"));
            var xml = workspaceItem.ToXml();

            comsController.AddPayloadArgument("ItemXml", xml.ToString(SaveOptions.DisableFormatting));
            comsController.AddPayloadArgument("IsLocalSave", isLocalSave.ToString());

            var con = resource.Environment.Connection;

            var result = comsController.ExecuteCommand<ExecuteMessage>(con, con.WorkspaceID);

            return result;
        }