当前位置: 首页>>代码示例>>C#>>正文


C# ExecuteMessage.SetMessage方法代码示例

本文整理汇总了C#中Dev2.Communication.ExecuteMessage.SetMessage方法的典型用法代码示例。如果您正苦于以下问题:C# ExecuteMessage.SetMessage方法的具体用法?C# ExecuteMessage.SetMessage怎么用?C# ExecuteMessage.SetMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dev2.Communication.ExecuteMessage的用法示例。


在下文中一共展示了ExecuteMessage.SetMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

        public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
        {
            string domain = null;
            string username = null;
            string password = null;

            StringBuilder tmp;
            values.TryGetValue("Domain", out tmp);
            if(tmp != null)
            {
                domain = tmp.ToString();
            }

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

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

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

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


            if(string.IsNullOrEmpty(domain) || string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
            {
                throw new InvalidDataContractException("Domain or Username or Password is missing");
            }

            var result = new ExecuteMessage { HasError = false };

            try
            {
                if(domain.Equals("."))
                {
                    domain = Environment.UserDomainName;
                }
                bool isValid;
                using(var context = new PrincipalContext(ContextType.Domain, domain))
                {
                    isValid = context.ValidateCredentials(username, password);

                    context.Dispose();
                }
                result.SetMessage(isValid ? "<result>Connection successful!</result>" : "<result>Connection failed. Ensure your username and password are valid</result>");
            }
            catch
            {
                result.SetMessage("<result>Connection failed. Ensure your username and password are valid</result>");
            }

            Dev2JsonSerializer serializer = new Dev2JsonSerializer();

            return serializer.SerializeToBuilder(result);
        }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:59,代码来源:CheckCredentials.cs

示例2: Execute

        public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
        {
            string type = null;
            Dev2JsonSerializer serializer = new Dev2JsonSerializer();
            StringBuilder tmp;
            values.TryGetValue("ResourceID", out tmp);
            Guid resourceId = Guid.Empty;
            if(tmp != null)
            {
                if(!Guid.TryParse(tmp.ToString(), out resourceId))
                {
                    Dev2Logger.Log.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.Log.Info("Delete Resource Service. Resource:" + resourceId);
            // BUG 7850 - TWR - 2013.03.11 - ResourceCatalog refactor
            var msg = ResourceCatalog.Instance.DeleteResource(theWorkspace.ID, resourceId, type);

            var result = new ExecuteMessage { HasError = false };
            result.SetMessage(msg.Message);
            result.HasError = msg.Status != ExecStatus.Success;
            return serializer.SerializeToBuilder(result);
        }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:32,代码来源:DeleteResource.cs

示例3: MakeMessage

        public static ExecuteMessage MakeMessage(string msg)
        {
            var result = new ExecuteMessage { HasError = false };
            result.SetMessage(msg);

            return result;
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:7,代码来源:ResourceModelTest.cs

示例4: WorkspaceItemRepositoryWorkspaceItemsExpectedInvokesReadFirstTime

        public void WorkspaceItemRepositoryWorkspaceItemsExpectedInvokesReadFirstTime()
        {
            string resourceName;
            Guid workspaceID;
            Guid serverID;

            var mockConn = new Mock<IEnvironmentConnection>();
            mockConn.Setup(c => c.IsConnected).Returns(true);
            ExecuteMessage msg = new ExecuteMessage { HasError = false };
            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 repositoryPath = GetUniqueRepositoryPath();

            // Create repository file with one item in it
            var repository = new WorkspaceItemRepository(repositoryPath);
            repository.AddWorkspaceItem(model.Object);

            // Now create a new repository from the previous file
            repository = new WorkspaceItemRepository(repositoryPath);

            // Access items for the first time
            var items = repository.WorkspaceItems;

            Assert.AreEqual(1, items.Count);
            Assert.AreEqual(workspaceID, items[0].WorkspaceID);
            Assert.AreEqual(serverID, items[0].ServerID);
            Assert.AreEqual(resourceName, items[0].ServiceName);
            Assert.AreEqual(WorkspaceItem.ServiceServiceType, items[0].ServiceType);
        }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:34,代码来源:WorkspaceItemRepositoryTests.cs

示例5: JsonSerializer_Deserializer_WhenUsingStream_ExpectValidObject

        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());
        }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:25,代码来源:JsonSerializerTest.cs

示例6: ExecuteMessage_Constructor_WhenSettingHasErrors_ExpectHasErrorsTrue

        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);
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:10,代码来源:ExecuteMessageTest.cs

示例7: ExecuteMessage_Constructor_WhenSettingMessage_ExpectMessageWithNoErrors

        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());
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:10,代码来源:ExecuteMessageTest.cs

示例8: Execute

        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);
        }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:10,代码来源:TestNetworkService.cs

示例9: Execute

        public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
        {
            ExecuteMessage msg = new ExecuteMessage {HasError = false};

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

            Dev2JsonSerializer serializer = new Dev2JsonSerializer();

            return serializer.SerializeToBuilder(msg);
        }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:10,代码来源:Ping.cs

示例10: Execute

        public StringBuilder Execute(Dictionary<string, StringBuilder> values, Workspaces.IWorkspace theWorkspace)
        {
            string resourceIdString = null;

            StringBuilder tmp;
            values.TryGetValue("ResourceID", out tmp);
            
            if (tmp != null)
            {
                resourceIdString = tmp.ToString();
            }

            if(resourceIdString == null)
            {
                throw new InvalidDataContractException("ResourceID is missing");
            }

            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);
        }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:42,代码来源:TerminateExecution.cs

示例11: Execute

        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);
        }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:49,代码来源:RenameCategoryResource.cs

示例12: Execute

        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);
        }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:36,代码来源:GetLatest.cs

示例13: Execute

        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);
        }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:55,代码来源:UpdateWorkspaceItem.cs

示例14: Execute

        /// <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("No parameter values provided.");
            }
            string serializedSource = null;
            StringBuilder tmp;
            values.TryGetValue("SharepointServer", out tmp);
            if(tmp != null)
            {
                serializedSource = tmp.ToString();
            }
            
            Dev2JsonSerializer serializer = new Dev2JsonSerializer();

            if(string.IsNullOrEmpty(serializedSource))
            {
                var res = new ExecuteMessage();
                res.HasError = true;
                res.SetMessage("No sharepoint server set");
                Dev2Logger.Log.Debug("No sharepoint server set.");
                return serializer.SerializeToBuilder(res);
            }
            try
            {
                var sharepointSource = serializer.Deserialize<SharepointSource>(serializedSource);
                var result = sharepointSource.TestConnection();
                var sharepointSourceTo = new SharepointSourceTo
                {
                    TestMessage = result,
                    IsSharepointOnline = sharepointSource.IsSharepointOnline
                };
                return serializer.SerializeToBuilder(sharepointSourceTo);
            }
            catch(Exception ex)
            {
                Dev2Logger.Log.Error(ex);
                var res = new DbColumnList(ex);
                return serializer.SerializeToBuilder(res);
            }
        }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:48,代码来源:TestSharepointServerService.cs

示例15: Execute

        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);
        }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:20,代码来源:DeployResource.cs


注:本文中的Dev2.Communication.ExecuteMessage.SetMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。