public StringBuilder Execute(Dictionary <string, StringBuilder> values, Workspaces.IWorkspace theWorkspace) { try { StringBuilder tmp; values.TryGetValue("Resource", out tmp); var serializer = new Dev2JsonSerializer(); if (tmp != null) { var res = serializer.Deserialize <IScheduledResource>(tmp); Dev2Logger.Log.Info("Get Scheduled History. " + tmp); IList <IResourceHistory> resources; using (var model = SchedulerFactory.CreateModel(GlobalConstants.SchedulerFolderId, SecurityWrapper)) { resources = model.CreateHistory(res); } return(serializer.SerializeToBuilder(resources)); } Dev2Logger.Log.Debug("No resource Provided"); return(serializer.SerializeToBuilder(new List <IResourceHistory>())); } catch (Exception e) { Dev2Logger.Log.Error(e); throw; } }
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)); }
public string Execute(IDictionary <string, string> values, Workspaces.IWorkspace theWorkspace) { string roles; string resourceDefinition; values.TryGetValue("Roles", out roles); values.TryGetValue("ResourceXml", out resourceDefinition); resourceDefinition = resourceDefinition.Unescape(); if (string.IsNullOrEmpty(roles) || string.IsNullOrEmpty(resourceDefinition)) { throw new InvalidDataContractException("Roles or ResourceXml is missing"); } var compiledResources = DynamicObjectHelper.GenerateObjectGraphFromString(resourceDefinition); if (compiledResources.Count == 0) { return(string.Format("<{0}>{1}</{0}>", "Result", Resources.CompilerError_TerminationFailed)); } var resource = compiledResources.First() as DynamicService; if (resource == null) { return(string.Format("<{0}>{1}</{0}>", "Result", Resources.CompilerError_TerminationFailed)); } var service = ExecutableServiceRepository.Instance.Get(theWorkspace.ID, resource.ID); if (service == null) { return(string.Format("<{0}>{1}</{0}>", "Result", Resources.CompilerError_TerminationFailed)); } var task = service.Terminate(); task.Wait(); return(string.Format("<{0}>{1}</{0}>", "Result", Resources.CompilerMessage_TerminationSuccess)); }
public StringBuilder Execute(Dictionary <string, StringBuilder> values, Workspaces.IWorkspace theWorkspace) { Dev2JsonSerializer serialiser = new Dev2JsonSerializer(); return(serialiser.SerializeToBuilder(GetVersion().ToString())); }