コード例 #1
0
ファイル: Services.cs プロジェクト: ndubul/Chillas
 public virtual RecordsetList FetchRecordset(PluginService pluginService, bool addFields)
 {
     if(pluginService == null)
     {
         throw new ArgumentNullException("pluginService");
     }
     var broker = new PluginBroker();
     var outputDescription = broker.TestPlugin(pluginService);
     return outputDescription.ToRecordsetList(pluginService.Recordsets, GlobalConstants.PrimitiveReturnValueTag);
 }
コード例 #2
0
        public virtual RecordsetList FetchRecordset(PluginService pluginService, bool addFields)
        {
            if (pluginService == null)
            {
                throw new ArgumentNullException(nameof(pluginService));
            }
            var broker            = new PluginBroker();
            var outputDescription = broker.TestPlugin(pluginService);
            var dataSourceShape   = outputDescription.DataSourceShapes[0];
            var recSet            = outputDescription.ToRecordsetList(pluginService.Recordsets, GlobalConstants.PrimitiveReturnValueTag);

            if (recSet != null)
            {
                foreach (var recordset in recSet)
                {
                    foreach (var field in recordset.Fields)
                    {
                        if (string.IsNullOrEmpty(field.Name))
                        {
                            continue;
                        }
                        var path    = field.Path;
                        var rsAlias = string.IsNullOrEmpty(field.RecordsetAlias) ? "" : field.RecordsetAlias.Replace("()", "");

                        var value = string.Empty;
                        if (!string.IsNullOrEmpty(field.Alias))
                        {
                            value = string.IsNullOrEmpty(rsAlias)
                                        ? $"[[{field.Alias}]]"
                                : $"[[{rsAlias}().{field.Alias}]]";
                        }

                        if (path != null)
                        {
                            path.OutputExpression = value;
                            var foundPath = dataSourceShape.Paths.FirstOrDefault(path1 => path1.OutputExpression == path.OutputExpression);
                            if (foundPath == null)
                            {
                                dataSourceShape.Paths.Add(path);
                            }
                            else
                            {
                                foundPath.OutputExpression = path.OutputExpression;
                            }
                        }
                    }
                }
            }
            return(recSet);
        }
コード例 #3
0
        public ServiceConstructorList Constructors(PluginService args, Guid workspaceId, Guid dataListId)
        {
            var result = new ServiceConstructorList();

            try
            {
                // BUG 9500 - 2013.05.31 - TWR : changed to use PluginService as args

                var broker = new PluginBroker();
                result = broker.GetConstructors(((PluginSource)args.Source).AssemblyLocation, ((PluginSource)args.Source).AssemblyName, args.Namespace);
                return(result);
            }
            catch (Exception ex)
            {
                RaiseError(ex);
            }
            return(result);
        }
コード例 #4
0
        // POST: Service/PluginServices/MethodsWithReturns
        public ServiceMethodList MethodsWithReturns(PluginService service, Guid workspaceId, Guid dataListId)
        {
            var result = new ServiceMethodList();

            try
            {
                // BUG 9500 - 2013.05.31 - TWR : changed to use PluginService as args

                var broker = new PluginBroker();
                result = broker.GetMethodsWithReturns(((PluginSource)service.Source).AssemblyLocation, ((PluginSource)service.Source).AssemblyName, service.Namespace);
                return(result);
            }
            catch (Exception ex)
            {
                RaiseError(ex);
            }
            return(result);
        }
コード例 #5
0
        // POST: Service/PluginServices/Methods
        public ServiceMethodList Methods(string args, Guid workspaceId, Guid dataListId)
        {
            var result = new ServiceMethodList();

            try
            {
                // BUG 9500 - 2013.05.31 - TWR : changed to use PluginService as args
                var service = JsonConvert.DeserializeObject <PluginService>(args);
                var broker  = new PluginBroker();
                result = broker.GetMethods(((PluginSource)service.Source).AssemblyLocation, ((PluginSource)service.Source).AssemblyName, service.Namespace);
                return(result);
            }
            catch (Exception ex)
            {
                RaiseError(ex);
            }
            return(result);
        }
コード例 #6
0
        // POST: Service/PluginServices/Methods
        public ServiceMethodList Methods(string args, Guid workspaceId, Guid dataListId)
        {
            var result = new ServiceMethodList();

            try
            {
                // BUG 9500 - 2013.05.31 - TWR : changed to use PluginService as args
                var service = JsonConvert.DeserializeObject <PluginService>(args);
                var pluginSourceFromCatalog = _resourceCatalog.GetResource <PluginSource>(workspaceId, service.Source.ResourceID);
                if (pluginSourceFromCatalog == null)
                {
                    try
                    {
                        var xmlStr = Resources.ReadXml(workspaceId, ResourceType.PluginSource, service.Source.ResourceID.ToString());
                        if (!string.IsNullOrEmpty(xmlStr))
                        {
                            var xml = XElement.Parse(xmlStr);
                            pluginSourceFromCatalog = new PluginSource(xml);
                        }
                    }
                    catch (Exception)
                    {
                        //ignore this
                    }
                }
                if (pluginSourceFromCatalog != null)
                {
                    service.Source = pluginSourceFromCatalog;
                }
                var broker       = new PluginBroker();
                var pluginSource = (PluginSource)service.Source;
                if (pluginSource != null)
                {
                    result = broker.GetMethods(pluginSource.AssemblyLocation, pluginSource.AssemblyName, service.Namespace);
                }
                return(result);
            }
            catch (Exception ex)
            {
                RaiseError(ex);
            }
            return(result);
        }
コード例 #7
0
        // POST: Service/PluginServices/Namespaces
        public virtual NamespaceList Namespaces(string args, Guid workspaceId, Guid dataListId)
        {
            var result = new NamespaceList();

            try
            {
                var pluginSource = JsonConvert.DeserializeObject <PluginSource>(args);
                if (pluginSource != null)
                {
                    var broker = new PluginBroker();
                    return(broker.GetNamespaces(pluginSource));
                }
            }
            catch (Exception ex)
            {
                RaiseError(ex);
            }
            return(result);
        }
コード例 #8
0
ファイル: Services.cs プロジェクト: tuga1975/Warewolf
        public virtual RecordsetList FetchRecordset(PluginService pluginService, bool addFields)
        {
            if (pluginService == null)
            {
                throw new ArgumentNullException(nameof(pluginService));
            }
            var broker            = new PluginBroker();
            var outputDescription = broker.TestPlugin(pluginService);
            var dataSourceShape   = outputDescription.DataSourceShapes[0];
            var recSet            = outputDescription.ToRecordsetList(pluginService.Recordsets, GlobalConstants.PrimitiveReturnValueTag);

            if (recSet != null)
            {
                foreach (var recordset in recSet)
                {
                    FetchRecordsetFields_PluginService(dataSourceShape, recordset);
                }
            }
            return(recSet);
        }
コード例 #9
0
        // POST: Service/PluginSources/ValidateAssemblyImageFormat
        public string ValidateAssemblyImageFormat(string args, Guid workspaceId, Guid dataListId)
        {
            // ReSharper disable RedundantAssignment
            var toJson = @"{""validationresult"":""failure""}";
            // ReSharper restore RedundantAssignment

            var broker = new PluginBroker();

            string errorMsg;

            if (broker.ValidatePlugin(args, out errorMsg))
            {
                toJson = @"{""validationresult"":""success""}";
            }
            else
            {
                toJson = @"{""validationresult"":""" + errorMsg + @"""}";
            }

            return(toJson);
        }
コード例 #10
0
        // POST: Service/PluginServices/Namespaces
        public virtual NamespaceList Namespaces(PluginSource args, Guid workspaceId, Guid dataListId)
        {
            var result = new NamespaceList();

            try
            {
                if (args != null)
                {
                    var broker = new PluginBroker();
                    return(broker.GetNamespaces(args));
                }
            }
            catch (BadImageFormatException e)
            {
                RaiseError(e);
                throw;
            }
            catch (Exception ex)
            {
                RaiseError(ex);
            }
            return(result);
        }