/// <summary>
        /// Executes the service
        /// </summary>
        /// <param name="values">The values.</param>
        /// <param name="theWorkspace">The workspace.</param>
        /// <returns></returns>
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            var msg        = new ExecuteMessage();
            var serializer = new Dev2JsonSerializer();

            Dev2Logger.Info("Get COMDll Listings");

            try
            {
                List <DllListing> dllListings;
                using (Isolated <ComDllLoaderHandler> isolated = new Isolated <ComDllLoaderHandler>())
                {
                    var openBaseKey = RegistryKey.OpenBaseKey(RegistryHive.ClassesRoot, RegistryView.Registry32);
                    dllListings = isolated.Value.GetListings(openBaseKey);
                    openBaseKey = RegistryKey.OpenBaseKey(RegistryHive.ClassesRoot, RegistryView.Registry64);
                    dllListings.AddRange(isolated.Value.GetListings(openBaseKey));
                }
                msg.Message = serializer.SerializeToBuilder(dllListings);
            }
            catch (COMException ex)
            {
                msg.HasError = true;
                msg.SetMessage(ex.Message);
            }
            catch (Exception ex)
            {
                Dev2Logger.Error(ex);
                msg.HasError = true;
                msg.SetMessage(ex.Message);
            }

            return(serializer.SerializeToBuilder(msg));
        }
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            string resourceIdString = null;

            StringBuilder tmp;

            values.TryGetValue("ResourceID", out tmp);

            if (tmp != null)
            {
                resourceIdString = tmp.ToString();
            }

            if (resourceIdString == null)
            {
                throw new InvalidDataContractException(ErrorResource.ResourceIdIsNull);
            }

            var res = new ExecuteMessage {
                HasError = false
            };

            Guid resourceId;
            var  hasResourceId = Guid.TryParse(resourceIdString, out resourceId);

            if (!hasResourceId)
            {
                res.SetMessage(Resources.CompilerError_TerminationFailed);
                res.HasError = true;
            }
            var service = ExecutableServiceRepository.Instance.Get(theWorkspace.ID, resourceId);

            if (service == null)
            {
                res.SetMessage(Resources.CompilerError_TerminationFailed);
                res.HasError = true;
            }

            if (service != null)
            {
                service.Terminate();
                res.SetMessage(Resources.CompilerMessage_TerminationSuccess);
            }

            Dev2JsonSerializer serializer = new Dev2JsonSerializer();

            return(serializer.SerializeToBuilder(res));
        }
Ejemplo n.º 3
0
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            if (values == null)
            {
                throw new InvalidDataContractException(ErrorResource.NoParameter);
            }

            var msg        = new ExecuteMessage();
            var serializer = new Dev2JsonSerializer();

            try
            {
                Dev2Logger.Info("Save Trigger Queue Service", GlobalConstants.WarewolfInfo);
                msg.HasError = false;

                values.TryGetValue("TriggerQueue", out StringBuilder resourceDefinition);

                var triggerQueue = serializer.Deserialize <ITriggerQueue>(resourceDefinition);

                TriggersCatalog.Instance.SaveTriggerQueue(triggerQueue);
                msg.SetMessage(triggerQueue.TriggerId.ToString());
                return(serializer.SerializeToBuilder(msg));
            }
            catch (Exception err)
            {
                msg.HasError = true;
                msg.Message  = new StringBuilder(err.Message);
                Dev2Logger.Error("Save Queue Service Failed: " + err.Message, GlobalConstants.WarewolfError);
                return(serializer.SerializeToBuilder(msg));
            }
        }
Ejemplo n.º 4
0
        public override StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            var msg        = new ExecuteMessage();
            var serializer = new Dev2JsonSerializer();

            Dev2Logger.Info("Get Files", GlobalConstants.WarewolfInfo);

            values.TryGetValue("fileListing", out StringBuilder currentFolder);
            if (currentFolder != null)
            {
                var src = serializer.Deserialize(currentFolder.ToString(), typeof(IFileListing)) as IFileListing;
                try
                {
                    msg.HasError = false;
                    var filesAndFolders = GetFilesAndFolders(src);
                    msg.Message = serializer.SerializeToBuilder(filesAndFolders);
                }
                catch (Exception ex)
                {
                    Dev2Logger.Error(ex, GlobalConstants.WarewolfError);
                    msg.HasError = true;
                    msg.SetMessage(ex.Message);
                }
            }
            else
            {
                msg.HasError = false;
                msg.Message  = serializer.SerializeToBuilder(GetFilesAndFolders(null));
            }

            return(serializer.SerializeToBuilder(msg));
        }
Ejemplo n.º 5
0
        public void JsonSerializer_Deserializer_WhenUsingStream_ExpectValidObject()
        {
            //------------Setup for test--------------------------
            var theMessage =
                @"Much evil soon high in hope do view. Out may few northward believing attempted. Yet timed being songs marry one defer men our. Although finished blessing do of. Consider speaking me prospect whatever if. Ten nearer rather hunted six parish indeed number. Allowance repulsive sex may contained can set suspected abilities cordially. Do part am he high rest that. So fruit to ready it being views match. 

Knowledge nay estimable questions repulsive daughters boy. Solicitude gay way unaffected expression for. His mistress ladyship required off horrible disposed rejoiced. Unpleasing pianoforte unreserved as oh he unpleasant no inquietude insipidity. Advantages can discretion possession add favourable cultivated admiration far. Why rather assure how esteem end hunted nearer and before. By an truth after heard going early given he. Charmed to it excited females whether at examine. Him abilities suffering may are yet dependent. 

Why end might ask civil again spoil.";

            ExecuteMessage msg = new ExecuteMessage {
                HasError = false
            };

            msg.SetMessage(theMessage);

            StringBuilder buffer = new StringBuilder(JsonConvert.SerializeObject(msg));

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

            Dev2JsonSerializer js = new Dev2JsonSerializer();

            var result = js.Deserialize <ExecuteMessage>(buffer);

            //------------Assert Results-------------------------

            Assert.AreEqual(theMessage, result.Message.ToString());
        }
Ejemplo n.º 6
0
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            StringBuilder resourceDefinition;

            values.TryGetValue("ResourceDefinition", out resourceDefinition);
            Dev2Logger.Log.Info(String.Format("Deploy Resource."));
            if (resourceDefinition == null || resourceDefinition.Length == 0)
            {
                Dev2Logger.Log.Info(String.Format("Roles or ResourceDefinition missing"));
                throw new InvalidDataContractException("Roles or ResourceDefinition missing");
            }

            var msg = ResourceCatalog.Instance.SaveResource(WorkspaceRepository.ServerWorkspaceID, resourceDefinition, null, "Deploy", "unknown");

            WorkspaceRepository.Instance.RefreshWorkspaces();

            var result = new ExecuteMessage {
                HasError = false
            };

            result.SetMessage(msg.Message);
            Dev2JsonSerializer serializer = new Dev2JsonSerializer();

            return(serializer.SerializeToBuilder(result));
        }
Ejemplo n.º 7
0
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            if (values == null)
            {
                throw new InvalidDataException("Empty values passed.");
            }

            StringBuilder settingsJson;

            values.TryGetValue("Settings", out settingsJson);
            if (settingsJson == null || settingsJson.Length == 0)
            {
                throw new InvalidDataException("Error: Unable to parse values.");
            }

            var            serializer = new Dev2JsonSerializer();
            ExecuteMessage result;

            try
            {
                var settings = serializer.Deserialize <Settings>(settingsJson.ToString());

                result = ExecuteService(theWorkspace, new SecurityWrite(), "SecuritySettings", settings.Security);
            }
            catch (Exception ex)
            {
                Dev2Logger.Log.Error(ex);
                result = new ExecuteMessage {
                    HasError = true
                };
                result.SetMessage("Error writing settings configuration.");
            }

            return(serializer.SerializeToBuilder(result));
        }
Ejemplo n.º 8
0
        public void WorkspaceItemRepositoryRemoveWithNonExistingModelExpectedDoesNothing()
        {
            string resourceName;
            Guid   workspaceID;
            Guid   serverID;

            var mockConn = new Mock <IEnvironmentConnection>();

            mockConn.Setup(c => c.IsConnected).Returns(true);
            ExecuteMessage msg = new ExecuteMessage();

            msg.SetMessage("Workspace item updated");
            var payload = JsonConvert.SerializeObject(msg);

            mockConn.Setup(c => c.ExecuteCommand(It.IsAny <StringBuilder>(), It.IsAny <Guid>())).Returns(new StringBuilder(payload)).Verifiable();

            var model = CreateModel(ResourceType.Service, mockConn, out resourceName, out workspaceID, out serverID);

            var repository = new WorkspaceItemRepository(GetUniqueRepositoryPath());

            repository.AddWorkspaceItem(model.Object);
            Assert.AreEqual(1, repository.WorkspaceItems.Count);

            model.Setup(m => m.ResourceName).Returns("Test_" + Guid.NewGuid());

            repository.Remove(model.Object);
            Assert.AreEqual(1, repository.WorkspaceItems.Count);
        }
Ejemplo n.º 9
0
        public void WorkspaceItemRepositoryAddWorkspaceItemWithNewModelWithSameNameExpectedInvokesWrite()
        {
            Guid workspaceID = Guid.NewGuid();
            Guid serverID    = Guid.NewGuid();
            Guid envID       = Guid.NewGuid();

            var mockConn = new Mock <IEnvironmentConnection>();

            mockConn.Setup(c => c.IsConnected).Returns(true);
            ExecuteMessage msg = new ExecuteMessage();

            msg.SetMessage("Workspace item updated");
            var payload = JsonConvert.SerializeObject(msg);

            mockConn.Setup(c => c.ExecuteCommand(It.IsAny <StringBuilder>(), It.IsAny <Guid>())).Returns(new StringBuilder(payload)).Verifiable();

            var model1 = CreateModel(ResourceType.Service, mockConn, workspaceID, serverID, envID);

            workspaceID = Guid.NewGuid();
            serverID    = Guid.NewGuid();
            envID       = Guid.NewGuid();
            var model2 = CreateModel(ResourceType.Service, mockConn, workspaceID, serverID, envID);

            var repositoryPath = GetUniqueRepositoryPath();

            Assert.IsFalse(File.Exists(repositoryPath));

            var repository = new WorkspaceItemRepository(repositoryPath);

            repository.AddWorkspaceItem(model1.Object);
            repository.AddWorkspaceItem(model2.Object);
            Assert.IsTrue(repository.WorkspaceItems.Count == 2);
            Assert.IsTrue(File.Exists(repositoryPath));
        }
Ejemplo n.º 10
0
        public void WorkspaceItemRepositoryUpdateWorkspaceItemWithExistingModelExpectedInvokesExecuteCommand()
        {
            const string ExpectedResult = "Workspace item updated";
            string       resourceName;
            Guid         workspaceID;
            Guid         serverID;

            var mockConn = new Mock <IEnvironmentConnection>();

            mockConn.Setup(c => c.IsConnected).Returns(true);
            ExecuteMessage msg = new ExecuteMessage();

            msg.SetMessage("Workspace item updated");
            var payload = JsonConvert.SerializeObject(msg);

            mockConn.Setup(c => c.ExecuteCommand(It.IsAny <StringBuilder>(), It.IsAny <Guid>())).Returns(new StringBuilder(payload)).Verifiable();

            var model = CreateModel(ResourceType.Service, mockConn, out resourceName, out workspaceID, out serverID);

            #region Setup ImportService - GRRR!


            #endregion

            var repository = new WorkspaceItemRepository(GetUniqueRepositoryPath());
            repository.AddWorkspaceItem(model.Object);

            var result = repository.UpdateWorkspaceItem(model.Object, true);
            mockConn.Verify(c => c.ExecuteCommand(It.IsAny <StringBuilder>(), It.IsAny <Guid>()), Times.Once());
            Assert.AreEqual(ExpectedResult, result.Message.ToString());
        }
Ejemplo n.º 11
0
        public void WorkspaceItemRepositoryRemoveWithExistingModelExpectedInvokesWrite()
        {
            string resourceName;
            Guid   workspaceID;
            Guid   serverID;

            var mockConn = new Mock <IEnvironmentConnection>();

            mockConn.Setup(c => c.IsConnected).Returns(true);
            ExecuteMessage msg = new ExecuteMessage();

            msg.SetMessage("Workspace item updated");
            var payload = JsonConvert.SerializeObject(msg);

            mockConn.Setup(c => c.ExecuteCommand(It.IsAny <StringBuilder>(), It.IsAny <Guid>())).Returns(new StringBuilder(payload)).Verifiable();
            var mockResourceRepo = new Mock <IResourceRepository>();

            mockResourceRepo.Setup(resourceRepository => resourceRepository.DeleteResourceFromWorkspaceAsync(It.IsAny <IContextualResourceModel>()));
            var model = CreateModel(ResourceType.Service, mockConn, out resourceName, out workspaceID, out serverID, mockResourceRepo);

            var repositoryPath = GetUniqueRepositoryPath();

            Assert.IsFalse(File.Exists(repositoryPath));

            var repository = new WorkspaceItemRepository(repositoryPath);

            repository.AddWorkspaceItem(model.Object);
            if (File.Exists(repositoryPath))
            {
                File.Delete(repositoryPath);
            }
            repository.Remove(model.Object);
            Assert.IsTrue(File.Exists(repositoryPath));
            mockResourceRepo.Verify(resourceRepository => resourceRepository.DeleteResourceFromWorkspaceAsync(It.IsAny <IContextualResourceModel>()), Times.Once());
        }
Ejemplo n.º 12
0
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            values.TryGetValue("savePath", out StringBuilder savePathValue);
            if (savePathValue == null)
            {
                throw new InvalidDataContractException("SavePath is missing");
            }
            values.TryGetValue("ResourceDefinition", out StringBuilder resourceDefinition);
            Dev2Logger.Info("Deploy Resource.", GlobalConstants.WarewolfInfo);
            if (resourceDefinition == null || resourceDefinition.Length == 0)
            {
                Dev2Logger.Info("Roles or ResourceDefinition missing", GlobalConstants.WarewolfInfo);
                throw new InvalidDataContractException("Roles or ResourceDefinition missing");
            }

            var msg = ResourceCatalog.Instance.SaveResource(WorkspaceRepository.ServerWorkspaceID, resourceDefinition, savePathValue.ToString(), GlobalConstants.SaveReasonForDeploy, "unknown");

            WorkspaceRepository.Instance.RefreshWorkspaces();

            var result = new ExecuteMessage {
                HasError = msg.Status != ExecStatus.Success
            };

            result.SetMessage(msg.Message);
            var serializer = new Dev2JsonSerializer();

            return(serializer.SerializeToBuilder(result));
        }
Ejemplo n.º 13
0
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            ExecuteMessage     msg        = new ExecuteMessage();
            Dev2JsonSerializer serializer = new Dev2JsonSerializer();

            Dev2Logger.Info("Get Dll Listings");
            StringBuilder dllListing;

            values.TryGetValue("currentDllListing", out dllListing);
            if (dllListing != null)
            {
                var src = serializer.Deserialize(dllListing.ToString(), typeof(IFileListing)) as IFileListing;
                try
                {
                    msg.HasError = false;
                    var fileListings = GetDllListing(src);
                    msg.Message = serializer.SerializeToBuilder(fileListings);
                }
                catch (Exception ex)
                {
                    Dev2Logger.Error(ex);
                    msg.HasError = true;
                    msg.SetMessage(ex.Message);
                }
            }

            return(serializer.SerializeToBuilder(msg));
        }
Ejemplo n.º 14
0
        protected void SetupForDelete()
        {
            _popupController.Setup(c => c.Show()).Verifiable();
            _popupController.Setup(s => s.Show()).Returns(MessageBoxResult.Yes);
            _resourceRepo.Setup(c => c.HasDependencies(_firstResource.Object)).Returns(false).Verifiable();
            var succesResponse = new ExecuteMessage();

            succesResponse.SetMessage(@"<DataList>Success</DataList>");
            _resourceRepo.Setup(s => s.DeleteResource(_firstResource.Object)).Returns(succesResponse);
        }
        public static ExecuteMessage MakeMessage(string msg)
        {
            var result = new ExecuteMessage {
                HasError = false
            };

            result.SetMessage(msg);

            return(result);
        }
Ejemplo n.º 16
0
        public override StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            var msg = new ExecuteMessage {
                HasError = false
            };

            msg.SetMessage("Pong @ " + Now.Invoke().ToString("yyyy-MM-dd hh:mm:ss.fff"));
            var serializer = new Dev2JsonSerializer();

            return(serializer.SerializeToBuilder(msg));
        }
Ejemplo n.º 17
0
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            ExecuteMessage msg = new ExecuteMessage {
                HasError = false
            };

            msg.SetMessage(values["payload"].ToString());

            Dev2JsonSerializer serializer = new Dev2JsonSerializer();

            return(serializer.SerializeToBuilder(msg));
        }
        /// <summary>
        /// Executes the service
        /// </summary>
        /// <param name="values">The values.</param>
        /// <param name="theWorkspace">The workspace.</param>
        /// <returns></returns>
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            if (values == null)
            {
                throw new InvalidDataContractException(ErrorResource.NoParameter);
            }
            string         serializedSource = null;
            StringBuilder  tmp;
            ExecuteMessage msg = new ExecuteMessage();

            values.TryGetValue("SharepointServer", out tmp);
            if (tmp != null)
            {
                serializedSource = tmp.ToString();
            }

            Dev2JsonSerializer serializer = new Dev2JsonSerializer();

            if (string.IsNullOrEmpty(serializedSource))
            {
                var res = new ExecuteMessage {
                    HasError = true
                };
                res.SetMessage(ErrorResource.NoSharepointServerSet);
                Dev2Logger.Debug(ErrorResource.NoSharepointServerSet);
                return(serializer.SerializeToBuilder(res));
            }
            try
            {
                msg.HasError = false;
                var sharepointSource = serializer.Deserialize <SharepointSource>(serializedSource);
                var result           = sharepointSource.TestConnection();

                if (result.Contains("Failed"))
                {
                    msg.HasError = true;
                }
                msg.Message = serializer.SerializeToBuilder(result);

                var sharepointSourceTo = new SharepointSourceTo
                {
                    TestMessage        = result,
                    IsSharepointOnline = sharepointSource.IsSharepointOnline
                };
                return(serializer.SerializeToBuilder(sharepointSourceTo));
            }
            catch (Exception ex)
            {
                Dev2Logger.Error(ex);
                msg.Message = serializer.SerializeToBuilder(ex.Message);
            }
            return(serializer.SerializeToBuilder(msg));
        }
Ejemplo n.º 19
0
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            Dev2JsonSerializer serializer = new Dev2JsonSerializer();

            try
            {
                string type = null;

                StringBuilder tmp;
                values.TryGetValue("ResourceID", out tmp);
                Guid resourceId = Guid.Empty;
                if (tmp != null)
                {
                    if (!Guid.TryParse(tmp.ToString(), out resourceId))
                    {
                        Dev2Logger.Info("Delete Resource Service. Invalid Parameter Guid:");
                        var failureResult = new ExecuteMessage {
                            HasError = true
                        };
                        failureResult.SetMessage("Invalid guid passed for ResourceID");
                        return(serializer.SerializeToBuilder(failureResult));
                    }
                }
                values.TryGetValue("ResourceType", out tmp);
                if (tmp != null)
                {
                    type = tmp.ToString();
                }
                Dev2Logger.Info("Delete Resource Service. Resource:" + resourceId);

                var msg = MyResourceCatalog.DeleteResource(theWorkspace.ID, resourceId, type);
                if (theWorkspace.ID == GlobalConstants.ServerWorkspaceID)
                {
                    MyTestCatalog.DeleteAllTests(resourceId);
                    MyTestCatalog.Load();
                }

                var result = new ExecuteMessage {
                    HasError = false
                };
                result.SetMessage(msg.Message);
                result.HasError = msg.Status != ExecStatus.Success;
                return(serializer.SerializeToBuilder(result));
            }
            catch (ServiceNotAuthorizedException ex)
            {
                var result = new ExecuteMessage {
                    HasError = true
                };
                result.SetMessage(ex.Message);
                return(serializer.SerializeToBuilder(result));
            }
        }
Ejemplo n.º 20
0
        public override StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            var serializer = new Dev2JsonSerializer();

            try
            {
                if (values == null)
                {
                    throw new InvalidDataContractException(ErrorResource.NoParameter);
                }
                string serializedSource = null;
                values.TryGetValue("Search", out StringBuilder searchValueSB);
                values.TryGetValue("SearchInput", out StringBuilder searchInputSB);
                if (searchValueSB != null)
                {
                    serializedSource = searchValueSB.ToString();
                }

                if (string.IsNullOrEmpty(serializedSource))
                {
                    var message = new ExecuteMessage();
                    message.HasError = true;
                    message.SetMessage("No Search found");
                    Dev2Logger.Debug("No Search found", GlobalConstants.WarewolfDebug);
                    return(serializer.SerializeToBuilder(message));
                }

                var searchResults = new List <ISearchResult>();

                var searchValue = serializer.Deserialize <ISearch>(serializedSource);
                if (searchValue != null)
                {
                    var searchers = new List <ISearcher>
                    {
                        new ActivitySearcher(ResourceCatalog.Instance),
                        new TestSearcher(ResourceCatalog.Instance, TestCatalog.Instance),
                        new VariableListSearcher(ResourceCatalog.Instance),
                        new ResourceSearcher(ResourceCatalog.Instance)
                    };
                    searchResults = searchValue.GetSearchResults(searchers);
                }

                return(serializer.SerializeToBuilder(searchResults));
            }
            catch (Exception err)
            {
                Dev2Logger.Error(err, GlobalConstants.WarewolfError);
                var res = new CompressedExecuteMessage {
                    HasError = true, Message = new StringBuilder(err.Message)
                };
                return(serializer.SerializeToBuilder(res));
            }
        }
Ejemplo n.º 21
0
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            ExecuteMessage res = new ExecuteMessage {
                HasError = false
            };

            string editedItemsXml = null;

            StringBuilder tmp;

            values.TryGetValue("EditedItemsXml", out tmp);
            if (tmp != null)
            {
                editedItemsXml = tmp.ToString();
            }

            try
            {
                var editedItems = new List <string>();

                if (!string.IsNullOrWhiteSpace(editedItemsXml))
                {
                    editedItems.AddRange(XElement.Parse(editedItemsXml)
                                         .Elements()
                                         .Select(x => x.Attribute("ServiceName").Value));
                }

                WorkspaceRepository.Instance.GetLatest(theWorkspace, editedItems);
                res.SetMessage("Workspace updated " + DateTime.Now);
            }
            catch (Exception ex)
            {
                res.SetMessage("Error updating workspace " + DateTime.Now);
                Dev2Logger.Log.Error(ex);
            }

            Dev2JsonSerializer serializer = new Dev2JsonSerializer();

            return(serializer.SerializeToBuilder(res));
        }
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            string oldCategory  = null;
            string newCategory  = null;
            string resourceType = null;

            if (values == null)
            {
                throw new InvalidDataContractException("No parameter values provided.");
            }
            StringBuilder tmp;

            values.TryGetValue("OldCategory", out tmp);
            if (tmp != null)
            {
                oldCategory = tmp.ToString();
            }
            values.TryGetValue("NewCategory", out tmp);
            if (tmp != null)
            {
                newCategory = tmp.ToString();
            }
            values.TryGetValue("ResourceType", out tmp);
            if (tmp != null)
            {
                resourceType = tmp.ToString();
            }

            if (oldCategory == null)
            {
                throw new InvalidDataContractException("No value provided for OldCategory parameter.");
            }
            if (String.IsNullOrEmpty(newCategory))
            {
                throw new InvalidDataContractException("No value provided for NewCategory parameter.");
            }
            if (String.IsNullOrEmpty(resourceType))
            {
                throw new InvalidDataContractException("No value provided for ResourceType parameter.");
            }
            Dev2Logger.Log.Info(String.Format("Rename Category. Old {0} New {1} Type{2}", oldCategory, newCategory, resourceType));
            var saveResult = ResourceCatalog.Instance.RenameCategory(Guid.Empty, oldCategory, newCategory);

            ExecuteMessage msg = new ExecuteMessage {
                HasError = false
            };

            msg.SetMessage(saveResult.Message);
            Dev2JsonSerializer serializer = new Dev2JsonSerializer();

            return(serializer.SerializeToBuilder(msg));
        }
Ejemplo n.º 23
0
        public void ExecuteMessage_Constructor_WhenSettingHasErrors_ExpectHasErrorsTrue()
        {
            //------------Setup for test--------------------------
            var executeMessage = new ExecuteMessage {
                HasError = true
            };

            executeMessage.SetMessage("the message");

            //------------Assert Results-------------------------

            Assert.IsTrue(executeMessage.HasError);
        }
Ejemplo n.º 24
0
        public void ExecuteMessage_Constructor_WhenSettingMessage_ExpectMessageWithNoErrors()
        {
            //------------Setup for test--------------------------
            var executeMessage = new ExecuteMessage {
                HasError = false
            };

            executeMessage.SetMessage("the message");

            //------------Assert Results-------------------------

            Assert.AreEqual("the message", executeMessage.Message.ToString());
        }
Ejemplo n.º 25
0
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            try
            {
                Dev2Logger.Info("Save Resource Service");
                StringBuilder resourceDefinition;

                string        workspaceIdString = string.Empty;
                StringBuilder savePathValue;
                values.TryGetValue("savePath", out savePathValue);
                if (savePathValue == null)
                {
                    throw new InvalidDataContractException("SavePath is missing");
                }
                values.TryGetValue("ResourceXml", out resourceDefinition);
                StringBuilder tmp;
                values.TryGetValue("WorkspaceID", out tmp);
                if (tmp != null)
                {
                    workspaceIdString = tmp.ToString();
                }
                Guid workspaceId;
                if (!Guid.TryParse(workspaceIdString, out workspaceId))
                {
                    workspaceId = theWorkspace.ID;
                }

                if (resourceDefinition == null || resourceDefinition.Length == 0)
                {
                    throw new InvalidDataContractException("ResourceXml is missing");
                }
                Dev2JsonSerializer serializer = new Dev2JsonSerializer();
                resourceDefinition = new StringBuilder(serializer.Deserialize <CompressedExecuteMessage>(resourceDefinition).GetDecompressedMessage());
                var res = new ExecuteMessage {
                    HasError = false
                };
                var saveResult = ResourceCatalog.Instance.SaveResource(workspaceId, resourceDefinition, savePathValue.ToString(), "Save");
                if (workspaceId == GlobalConstants.ServerWorkspaceID)
                {
                    ResourceCatalog.Instance.SaveResource(theWorkspace.ID, resourceDefinition, savePathValue.ToString(), "Save");
                }
                res.SetMessage(saveResult.Message + " " + DateTime.Now);

                return(serializer.SerializeToBuilder(res));
            }
            catch (Exception err)
            {
                Dev2Logger.Error(err);
                throw;
            }
        }
Ejemplo n.º 26
0
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            StringBuilder itemXml;
            string        isLocal = string.Empty;

            StringBuilder tmp;

            values.TryGetValue("ItemXml", out itemXml);
            values.TryGetValue("IsLocalSave", out tmp);
            if (tmp != null)
            {
                isLocal = tmp.ToString();
            }

            bool isLocalSave;

            bool.TryParse(isLocal, out isLocalSave);

            var res = new ExecuteMessage {
                HasError = false
            };

            if (itemXml == null || itemXml.Length == 0)
            {
                res.SetMessage("Invalid workspace item definition " + DateTime.Now);
                res.HasError = true;
            }
            else
            {
                try
                {
                    XElement xe = itemXml.ToXElement();

                    var workspaceItem = new WorkspaceItem(xe);
                    if (workspaceItem.WorkspaceID != theWorkspace.ID)
                    {
                        res.SetMessage("Cannot update a workspace item from another workspace " + DateTime.Now);
                        res.HasError = true;
                    }
                    else
                    {
                        theWorkspace.Update(workspaceItem, isLocalSave);
                        res.SetMessage("Workspace item updated " + DateTime.Now);
                    }
                }
                catch (Exception ex)
                {
                    res.SetMessage("Error updating workspace item " + DateTime.Now);
                    res.SetMessage(ex.Message);
                    res.SetMessage(ex.StackTrace);
                    res.HasError = true;
                }
            }

            Dev2JsonSerializer serializer = new Dev2JsonSerializer();

            return(serializer.SerializeToBuilder(res));
        }
        public void Dev2JsonSerializer_Serialize_Formatting()
        {
            var theMessage = "testingtesting123";
            var msg        = new ExecuteMessage {
                HasError = false
            };

            msg.SetMessage(theMessage);
            var buffer = JsonConvert.SerializeObject(msg);

            var json    = new Dev2JsonSerializer();
            var resultA = JsonConvert.SerializeObject(buffer, Formatting.None, _serializerSettings);
            var resultB = json.Serialize(buffer, Formatting.None);

            Assert.AreEqual(resultA.ToString(), resultB.ToString());
        }
Ejemplo n.º 28
0
        public ExecuteMessage DeleteResource(IResourceModel resource)
        {
            Dev2Logger.Info($"DeleteResource Resource: {resource.DisplayName}  Environment:{_server.Name}");
            IResourceModel res = _resourceModels.FirstOrDefault(c => c.ID == resource.ID);

            if (res == null)
            {
                var msg = new ExecuteMessage {
                    HasError = true
                };
                msg.SetMessage("Failure");
                return(msg);
            }

            int index = _resourceModels.IndexOf(res);

            if (index != -1)
            {
                _resourceModels.RemoveAt(index);
            }
            else
            {
                throw new KeyNotFoundException();
            }
            var comsController = new CommunicationController {
                ServiceName = "DeleteResourceService"
            };

            if (resource.ResourceName.Contains("Unsaved"))
            {
                comsController.AddPayloadArgument("ResourceID", resource.ID.ToString());
                comsController.AddPayloadArgument("ResourceType", resource.ResourceType.ToString());
                return(comsController.ExecuteCommand <ExecuteMessage>(_server.Connection, _server.Connection.WorkspaceID));
            }

            comsController.AddPayloadArgument("ResourceID", resource.ID.ToString());
            comsController.AddPayloadArgument("ResourceType", resource.ResourceType.ToString());

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

            if (result.HasError)
            {
                HandleDeleteResourceError(result, resource);
                return(null);
            }
            return(result);
        }
        public void Dev2JsonSerializer_Deserialize_String()
        {
            var theMessage = "testingtesting123";
            var js         = new Dev2JsonSerializer();
            var msg        = new ExecuteMessage {
                HasError = false
            };

            msg.SetMessage(theMessage);
            var buffer = JsonConvert.SerializeObject(msg);

            var resultA = JsonConvert.DeserializeObject <ExecuteMessage>(buffer.ToString(), _deSerializerSettings);

            var resultB = js.Deserialize <ExecuteMessage>(buffer.ToString());

            Assert.AreEqual(resultA.Message.ToString(), resultB.Message.ToString());
        }
Ejemplo n.º 30
0
        public void JsonSerializer_Deserializer_WhenUsingStreamWithLargePayload_ExpectValidObject()
        {
            //------------Setup for test--------------------------
            var theMessage =
                @"Much evil soon high in hope do view. Out may few northward believing attempted. Yet timed being songs marry one defer men our. Although finished blessing do of. Consider speaking me prospect whatever if. Ten nearer rather hunted six parish indeed number. Allowance repulsive sex may contained can set suspected abilities cordially. Do part am he high rest that. So fruit to ready it being views match. 

Knowledge nay estimable questions repulsive daughters boy. Solicitude gay way unaffected expression for. His mistress ladyship required off horrible disposed rejoiced. Unpleasing pianoforte unreserved as oh he unpleasant no inquietude insipidity. Advantages can discretion possession add favourable cultivated admiration far. Why rather assure how esteem end hunted nearer and before. By an truth after heard going early given he. Charmed to it excited females whether at examine. Him abilities suffering may are yet dependent. 

Why end might ask civil again spoil. She dinner she our horses depend. Remember at children by reserved to vicinity. In affronting unreserved delightful simplicity ye. Law own advantage furniture continual sweetness bed agreeable perpetual. Oh song well four only head busy it. Afford son she had lively living. Tastes lovers myself too formal season our valley boy. Lived it their their walls might to by young. 

On insensible possession oh particular attachment at excellence in. The books arose but miles happy she. It building contempt or interest children mistress of unlocked no. Offending she contained mrs led listening resembled. Delicate marianne absolute men dashwood landlord and offended. Suppose cottage between and way. Minuter him own clothes but observe country. Agreement far boy otherwise rapturous incommode favourite. 

Inquietude simplicity terminated she compliment remarkably few her nay. The weeks are ham asked jokes. Neglected perceived shy nay concluded. Not mile draw plan snug next all. Houses latter an valley be indeed wished merely in my. Money doubt oh drawn every or an china. Visited out friends for expense message set eat. 

By so delight of showing neither believe he present. Deal sigh up in shew away when. Pursuit express no or prepare replied. Wholly formed old latter future but way she. Day her likewise smallest expenses judgment building man carriage gay. Considered introduced themselves mr to discretion at. Means among saw hopes for. Death mirth in oh learn he equal on. 

Exquisite cordially mr happiness of neglected distrusts. Boisterous impossible unaffected he me everything. Is fine loud deal an rent open give. Find upon and sent spot song son eyes. Do endeavor he differed carriage is learning my graceful. Feel plan know is he like on pure. See burst found sir met think hopes are marry among. Delightful remarkably new assistance saw literature mrs favourable. 

Behind sooner dining so window excuse he summer. Breakfast met certainty and fulfilled propriety led. Waited get either are wooded little her. Contrasted unreserved as mr particular collecting it everything as indulgence. Seems ask meant merry could put. Age old begin had boy noisy table front whole given. 

Boy favourable day can introduced sentiments entreaties. Noisier carried of in warrant because. So mr plate seems cause chief widen first. Two differed husbands met screened his. Bed was form wife out ask draw. Wholly coming at we no enable. Offending sir delivered questions now new met. Acceptance she interested new boisterous day discretion celebrated. 

That know ask case sex ham dear her spot. Weddings followed the all marianne nor whatever settling. Perhaps six prudent several her had offence. Did had way law dinner square tastes. Recommend concealed yet her procuring see consulted depending. Adieus hunted end plenty are his she afraid. Resources agreement contained propriety applauded neglected use yet. 

Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean. A small river named Duden flows by their place and supplies it with the necessary regelialia. It is a paradisematic country, in which roasted parts of sentences fly into your mouth. Even the all-powerful 

Pointing has no control about the blind texts it is an almost unorthographic life One day however a small line of blind text by the name of Lorem Ipsum decided to leave for the far World of Grammar. The Big Oxmox advised her not to do so, because there were thousands of bad Commas, wild Question Marks and devious Semikoli, but the Little Blind Text didn’t listen. She packed her seven versalia, put her initial into the belt and made herself on the way. When she reached the first hills of the Italic Mountains, she had a last view back on the skyline of her hometown Bookmarksgrove, the headline of ";

            ExecuteMessage msg = new ExecuteMessage {
                HasError = false
            };

            msg.SetMessage(theMessage);

            StringBuilder buffer = new StringBuilder(JsonConvert.SerializeObject(msg));

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

            Dev2JsonSerializer js = new Dev2JsonSerializer();

            var result = js.Deserialize <ExecuteMessage>(buffer);

            //------------Assert Results-------------------------

            Assert.AreEqual(theMessage, result.Message.ToString());
        }