public override StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace) { try { string directory = null; var result = new StringBuilder(); if (values == null) { throw new InvalidDataContractException(ErrorResource.NoParameter); } values.TryGetValue("Directory", out StringBuilder tmp); if (tmp != null) { directory = tmp.ToString(); } if (string.IsNullOrEmpty(directory)) { throw new InvalidDataContractException(ErrorResource.DirectoryIsRequired); } Dev2Logger.Info("Get Directories Relative to Server. " + directory, GlobalConstants.WarewolfInfo); result.Append("<JSON>"); var explorerItem = ServerExplorerRepo.Load("Folder", string.Empty); var jsonTreeNode = new JsonTreeNode(explorerItem); var serializer = new Dev2JsonSerializer(); var directoryInfoAsJson = serializer.Serialize(jsonTreeNode); result.Append(directoryInfoAsJson); result.Append("</JSON>"); return(result); } catch (Exception e) { Dev2Logger.Error(e, GlobalConstants.WarewolfError); throw; } }
/// <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) { try { string directory = null; StringBuilder result = new StringBuilder(); if(values == null) { throw new InvalidDataContractException("No parameter values provided."); } StringBuilder tmp; values.TryGetValue("Directory", out tmp); if(tmp != null) { directory = tmp.ToString(); } if(String.IsNullOrEmpty(directory)) { throw new InvalidDataContractException("No value provided for Directory parameter."); } Dev2Logger.Log.Info("Get Directories Relative to Server. "+directory); result.Append("<JSON>"); var explorerItem = ServerExplorerRepo.Load(ResourceType.Folder, string.Empty); var jsonTreeNode = new JsonTreeNode(explorerItem); var serializer = new Dev2JsonSerializer(); var directoryInfoAsJson = serializer.Serialize(jsonTreeNode); result.Append(directoryInfoAsJson); result.Append("</JSON>"); return result; } catch (Exception e) { Dev2Logger.Log.Error(e); throw; } }
/// <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) { try { string directory = null; StringBuilder result = new StringBuilder(); if (values == null) { throw new InvalidDataContractException("No parameter values provided."); } StringBuilder tmp; values.TryGetValue("Directory", out tmp); if (tmp != null) { directory = tmp.ToString(); } if (String.IsNullOrEmpty(directory)) { throw new InvalidDataContractException("No value provided for Directory parameter."); } Dev2Logger.Log.Info("Get Directories Relative to Server. " + directory); result.Append("<JSON>"); var explorerItem = ServerExplorerRepo.Load(ResourceType.Folder, string.Empty); var jsonTreeNode = new JsonTreeNode(explorerItem); var serializer = new Dev2JsonSerializer(); var directoryInfoAsJson = serializer.Serialize(jsonTreeNode); result.Append(directoryInfoAsJson); result.Append("</JSON>"); return(result); } catch (Exception e) { Dev2Logger.Log.Error(e); throw; } }