/// <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)); } }
/// <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); var resource = Resources.GetResource(theWorkspace.ID, version.ResourceId); if (resource != null && resource.ResourceType == ResourceType.DbSource) { res.Message.Append(result); } else { var startIdx = result.IndexOf(PayloadStart, 0, false); if (startIdx >= 0) { // remove beginning junk startIdx += PayloadStart.Length; result = result.Remove(0, startIdx); startIdx = result.IndexOf(PayloadEnd, 0, false); if (startIdx > 0) { var len = result.Length - startIdx; result = result.Remove(startIdx, len); res.Message.Append(result.Unescape()); } } else { // handle services ;) startIdx = result.IndexOf(AltPayloadStart, 0, false); if (startIdx >= 0) { // remove begging junk startIdx += AltPayloadStart.Length; result = result.Remove(0, startIdx); startIdx = result.IndexOf(AltPayloadEnd, 0, false); if (startIdx > 0) { var len = result.Length - startIdx; result = result.Remove(startIdx, len); res.Message.Append(result.Unescape()); } } else { // send the entire thing ;) 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)); } }