本文整理汇总了C#中Dev2.Communication.ExecuteMessage类的典型用法代码示例。如果您正苦于以下问题:C# ExecuteMessage类的具体用法?C# ExecuteMessage怎么用?C# ExecuteMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExecuteMessage类属于Dev2.Communication命名空间,在下文中一共展示了ExecuteMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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)
{
Dev2JsonSerializer serializer = new Dev2JsonSerializer();
var execMessage = new ExecuteMessage { HasError = false };
if(!values.ContainsKey("resourceId"))
{
Dev2Logger.Log.Info("Delete Version. Invalid Resource Id");
execMessage.HasError = true;
execMessage.Message = new StringBuilder( "No resourceId sent to server");
}
else if(!values.ContainsKey("versionNumber") )
{
Dev2Logger.Log.Info("Delete Version. Invalid Version number");
execMessage.HasError = true;
execMessage.Message = new StringBuilder("No versionNumber sent to server");
}
else
{
try
{
var guid = Guid.Parse(values["resourceId"].ToString());
var version = values["versionNumber"].ToString();
Dev2Logger.Log.Info(String.Format("Delete Version. ResourceId:{0} VersionNumber{1}",guid,version));
var res = ServerVersionRepo.DeleteVersion(guid,version);
execMessage.Message = serializer.SerializeToBuilder(res);
}
catch (Exception e)
{
Dev2Logger.Log.Error(String.Format("Delete Version Error."),e);
execMessage.HasError = true;
execMessage.Message = new StringBuilder( e.Message);
}
}
return serializer.SerializeToBuilder(execMessage);
}
示例2: Execute
public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
{
var result = new ExecuteMessage { HasError = false };
Dev2Logger.Log.Info("Find Log Directory");
try
{
var logdir = WorkflowLoggger.GetDirectoryPath(SettingsProvider.Instance.Configuration.Logging);
var cleanedDir = CleanUp(logdir);
result.Message.Append("<JSON>");
result.Message.Append(@"{""PathToSerialize"":""");
result.Message.Append(cleanedDir);
result.Message.Append(@"""}");
result.Message.Append("</JSON>");
}
catch (Exception ex)
{
Dev2Logger.Log.Error(ex);
result.Message.Append(ex.Message);
result.HasError = true;
}
Dev2JsonSerializer serializer = new Dev2JsonSerializer();
return serializer.SerializeToBuilder(result);
}
示例3: Execute
public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
{
var result = new ExecuteMessage { HasError = false };
Dev2Logger.Log.Info("Delete Scheduled Resource Service");
StringBuilder tmp;
values.TryGetValue("Resource", out tmp);
var serializer = new Dev2JsonSerializer();
if (tmp != null)
{
var res = serializer.Deserialize<IScheduledResource>(tmp);
Dev2Logger.Log.Info("Delete Scheduled Resource Service." +res);
using(var model = SchedulerFactory.CreateModel(GlobalConstants.SchedulerFolderId, SecurityWrapper))
{
model.DeleteSchedule(res);
}
}
else
{
Dev2Logger.Log.Info("Delete Scheduled Resource Service. No Resource Selected");
result.Message.Append("No Resource Selected");
result.HasError = true;
}
return serializer.SerializeToBuilder(result);
}
示例4: Execute
public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
{
try
{
Dev2Logger.Log.Info("Fetch Server Log Started");
var result = new ExecuteMessage { HasError = false };
if (File.Exists(_serverLogPath))
{
var fileStream = File.Open(_serverLogPath, FileMode.Open, FileAccess.Read,FileShare.Read);
using (var streamReader = new StreamReader(fileStream))
{
while(!streamReader.EndOfStream)
{
result.Message.Append(streamReader.ReadLine());
}
}
}
Dev2JsonSerializer serializer = new Dev2JsonSerializer();
return serializer.SerializeToBuilder(result);
}
catch (Exception err)
{
Dev2Logger.Log.Error("Fetch Server Log Error", err);
throw;
}
}
示例5: 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);
}
示例6: 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);
}
示例7: 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)
{
var serializer = new Dev2JsonSerializer();
try
{
var res = new ExecuteMessage { HasError = false };
if (values == null)
{
throw new ArgumentNullException("values");
}
if (!values.ContainsKey("versionInfo"))
{
// ReSharper disable NotResolvedInText
throw new ArgumentNullException("No resourceId was found in the incoming data");
// ReSharper restore NotResolvedInText
}
var version = serializer.Deserialize<IVersionInfo>(values["versionInfo"]);
Dev2Logger.Log.Info("Get Version. " + version);
var result = ServerVersionRepo.GetVersion(version);
res.Message.Append(result);
Dev2XamlCleaner dev2XamlCleaner = new Dev2XamlCleaner();
res.Message = dev2XamlCleaner.StripNaughtyNamespaces(res.Message);
return serializer.SerializeToBuilder(res);
}
catch (Exception e)
{
Dev2Logger.Log.Error(e);
IExplorerRepositoryResult error = new ExplorerRepositoryResult(ExecStatus.Fail, e.Message);
return serializer.SerializeToBuilder(error);
}
}
示例8: 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());
}
示例9: MakeMessage
public static ExecuteMessage MakeMessage(string msg)
{
var result = new ExecuteMessage { HasError = false };
result.SetMessage(msg);
return result;
}
示例10: Execute
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();
var result = new ExecuteMessage { HasError = false, Message = new StringBuilder() };
try
{
var settings = serializer.Deserialize<Settings>(settingsJson.ToString());
WriteSecuritySettings(theWorkspace, settings, result);
WriteLoggingSettings(theWorkspace, settings, result);
}
catch (Exception ex)
{
Dev2Logger.Log.Error("Error writing settings.", ex);
result.HasError = true;
result.Message.AppendLine("Error writing settings.");
}
return serializer.SerializeToBuilder(result);
}
示例11: 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);
}
示例12: Execute
public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
{
try
{
Dev2Logger.Log.Info("Find Dependencies");
var result = new ExecuteMessage { HasError = false };
string resourceId = null;
string dependsOnMeString = null;
bool dependsOnMe = false;
StringBuilder tmp;
values.TryGetValue("ResourceId", out tmp);
if(tmp != null)
{
resourceId = tmp.ToString();
}
values.TryGetValue("GetDependsOnMe", out tmp);
if(tmp != null)
{
dependsOnMeString = tmp.ToString();
}
if (string.IsNullOrEmpty(resourceId))
{
throw new InvalidDataContractException("ResourceName is empty or null");
}
var resource= ResourceCatalog.Instance.GetResource(theWorkspace.ID, Guid.Parse(resourceId));
var resourceName = resource.ResourcePath;
if(!string.IsNullOrEmpty(dependsOnMeString))
{
if(!bool.TryParse(dependsOnMeString, out dependsOnMe))
{
dependsOnMe = false;
}
}
if(dependsOnMe)
{
result.Message.Append(string.Format("<graph title=\"Local Dependants Graph: {0}\">", resourceName));
result.Message.Append(FindWhatDependsOnMe(resource, theWorkspace.ID));
result.Message.Append("</graph>");
}
else
{
result.Message.Append(string.Format("<graph title=\"Dependency Graph Of {0}\">", resourceName));
result.Message.Append(FindDependenciesRecursive(resource.ResourceID, theWorkspace.ID));
result.Message.Append("</graph>");
}
Dev2JsonSerializer serializer = new Dev2JsonSerializer();
return serializer.SerializeToBuilder(result);
}
catch (Exception e)
{
Dev2Logger.Log.Error(e);
throw;
}
}
示例13: Execute
public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
{
string serviceId = null;
string workspaceId = null;
Dev2JsonSerializer serializer = new Dev2JsonSerializer();
var result = new ExecuteMessage { HasError = false };
StringBuilder tmp;
values.TryGetValue("ServiceID", out tmp);
if(tmp != null)
{
serviceId = tmp.ToString();
}
values.TryGetValue("WorkspaceID", out tmp);
if(tmp != null)
{
workspaceId = tmp.ToString();
}
values.TryGetValue("FilterList", out tmp);
if(tmp != null)
{
}
if(string.IsNullOrEmpty(serviceId) || string.IsNullOrEmpty(workspaceId))
{
throw new InvalidDataContractException("Null or empty ServiceID or WorkspaceID");
}
Guid wGuid;
Guid sGuid;
Guid.TryParse(workspaceId, out wGuid);
Guid.TryParse(serviceId, out sGuid);
var thisService = ResourceCatalog.Instance.GetResource(wGuid, sGuid);
if(thisService != null)
{
var deps = thisService.Dependencies;
CompileMessageType[] filters = null; // TODO : Convert string list to enum array ;)
// ReSharper disable ExpressionIsAlwaysNull
CompileMessageList msgs = CompileMessageRepo.Instance.FetchMessages(wGuid, sGuid, deps, filters);
// ReSharper restore ExpressionIsAlwaysNull
result.Message.Append(serializer.SerializeToBuilder(msgs));
}
else
{
result.Message.Append("Could not locate service with ID [ " + sGuid + " ]");
result.HasError = true;
}
return serializer.SerializeToBuilder(result);
}
示例14: 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);
}
示例15: 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());
}