public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace) { ExecuteMessage msg = new ExecuteMessage(); Dev2JsonSerializer serializer = new Dev2JsonSerializer(); try { Dev2Logger.Info("Save Com Plugin Source"); StringBuilder resourceDefinition; values.TryGetValue("ComPluginSource", out resourceDefinition); var src = serializer.Deserialize <ComPluginSourceDefinition>(resourceDefinition); if (src.ResourcePath == null) { src.ResourcePath = string.Empty; } if (src.ResourcePath.EndsWith("\\")) { src.ResourcePath = src.ResourcePath.Substring(0, src.ResourcePath.LastIndexOf("\\", StringComparison.Ordinal)); } ComPluginSource res1; var existingSource = ResourceCat.GetResource(GlobalConstants.ServerWorkspaceID, src.Name); if (existingSource != null) { res1 = existingSource as ComPluginSource; } else { res1 = new ComPluginSource { ResourceID = src.Id, ClsId = src.ClsId, Is32Bit = src.Is32Bit, ComName = src.SelectedDll.Name, ResourceName = src.ResourceName }; } ResourceCat.SaveResource(GlobalConstants.ServerWorkspaceID, res1, src.ResourcePath); msg.HasError = false; } catch (Exception err) { msg.HasError = true; msg.Message = new StringBuilder(err.Message); Dev2Logger.Error(err); } return(serializer.SerializeToBuilder(msg)); }
public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace) { var msg = new ExecuteMessage(); var serializer = new Dev2JsonSerializer(); try { Dev2Logger.Info("Save Elasticsearch Resource Service", GlobalConstants.WarewolfInfo); values.TryGetValue(Warewolf.Service.SaveElasticsearchSource.ElasticsearchSource, out StringBuilder resourceDefinition); IElasticsearchSourceDefinition elasticsearchSourceDef = serializer.Deserialize <ElasticsearchSourceDefinition>(resourceDefinition); if (elasticsearchSourceDef.Path == null) { elasticsearchSourceDef.Path = string.Empty; } if (elasticsearchSourceDef.Path.EndsWith("\\")) { elasticsearchSourceDef.Path = elasticsearchSourceDef.Path.Substring(0, elasticsearchSourceDef.Path.LastIndexOf("\\", StringComparison.Ordinal)); } var elasticsearchSource = new ElasticsearchSource { ResourceID = elasticsearchSourceDef.Id, HostName = elasticsearchSourceDef.HostName, Port = elasticsearchSourceDef.Port, SearchIndex = elasticsearchSourceDef.SearchIndex, AuthenticationType = elasticsearchSourceDef.AuthenticationType, Password = elasticsearchSourceDef.Password, Username = elasticsearchSourceDef.Username, ResourceName = elasticsearchSourceDef.Name }; ResourceCat.SaveResource(GlobalConstants.ServerWorkspaceID, elasticsearchSource, elasticsearchSourceDef.Path); msg.HasError = false; } catch (Exception err) { msg.HasError = true; msg.Message = new StringBuilder(err.Message); Dev2Logger.Error(err, GlobalConstants.WarewolfError); } return(serializer.SerializeToBuilder(msg)); }