private void DoWork(object state)
        {
            var e                    = new EnumerateWebAPI(api);
            var actionList           = e.CreateActionList();
            var blocklyFileGenerator = new BlocklyFileGenerator(actionList);

            BlocklyTypesDefinition           = blocklyFileGenerator.GenerateNewBlocklyTypesDefinition();
            BlocklyAPIFunctions              = blocklyFileGenerator.GenerateBlocklyAPIFunctions();
            BlocklyToolBoxValueDefinition    = blocklyFileGenerator.GenerateBlocklyToolBoxValueDefinitionFile();
            BlocklyToolBoxFunctionDefinition = blocklyFileGenerator.GenerateBlocklyToolBoxFunctionDefinitionFile();
            if (app == null)
            {
                return;
            }
            var serverAddresses = app.ServerFeatures.Get <IServerAddressesFeature>();

            if ((serverAddresses?.Addresses?.Count() ?? 0) == 0)
            {
                return;
            }

            lock (this)
                if (odataLater.Count > 0)
                {
                    _timer.Dispose();
                    var Host = "";
                    foreach (var item in serverAddresses.Addresses)
                    {
                        if (item.StartsWith("https"))
                        {
                            Host = item;
                        }
                        if (Host.Length == 0)
                        {
                            Host = item;
                        }
                    }
                    Host = Host.Replace("0.0.0.0", "localhost");
                    Host = Host.Replace("[::]", "localhost");
                    foreach (var item in odataLater)
                    {
                        var b = new UriBuilder(Host);
                        b.Path = item;
                        var x = AddOdata(item.Replace("/", ""), b.Uri.ToString(), true);
                        x.GetAwaiter().GetResult();
                    }
                    odataLater.Clear();
                    this._ODataBlocklyAPIFunctions = null;
                    this._ODataBlocklyToolBoxFunctionDefinition = null;
                    this._ODataBlocklyTypesDefinition           = null;
                    this._ODataBlocklyToolBoxValueDefinition    = null;
                }
            _timer.Dispose();
        }
Exemplo n.º 2
0
        private void DoWork(object state)
        {
            _timer.Dispose();
            var e                    = new EnumerateWebAPI(api);
            var actionList           = e.CreateActionList();
            var blocklyFileGenerator = new BlocklyFileGenerator(actionList);

            BlocklyTypesDefinition           = blocklyFileGenerator.GenerateNewBlocklyTypesDefinition();
            BlocklyAPIFunctions              = blocklyFileGenerator.GenerateBlocklyAPIFunctions();
            BlocklyToolBoxValueDefinition    = blocklyFileGenerator.GenerateBlocklyToolBoxValueDefinitionFile();
            BlocklyToolBoxFunctionDefinition = blocklyFileGenerator.GenerateBlocklyToolBoxFunctionDefinitionFile();
        }
        private void DoWork(object state)
        {
            var e          = new EnumerateWebAPI(api);
            var actionList = e.CreateActionList();

            if (!string.IsNullOrWhiteSpace(InternalSiteUrl))
            {
                actionList.ForEach(it => it.Site = InternalSiteUrl);
            }

            blocklyFileGeneratorWebAPI       = new BlocklyFileGenerator(actionList);
            BlocklyTypesDefinition           = blocklyFileGeneratorWebAPI.GenerateNewBlocklyTypesDefinition();
            BlocklyAPIFunctions              = blocklyFileGeneratorWebAPI.GenerateBlocklyAPIFunctions();
            BlocklyToolBoxValueDefinition    = blocklyFileGeneratorWebAPI.GenerateBlocklyToolBoxValueDefinitionFile();
            BlocklyToolBoxFunctionDefinition = blocklyFileGeneratorWebAPI.GenerateBlocklyToolBoxFunctionDefinitionFile();
            if (app == null)
            {
                return;
            }
            var serverAddresses = app.ServerFeatures.Get <IServerAddressesFeature>();

            if ((serverAddresses?.Addresses?.Count() ?? 0) == 0)
            {
                return;
            }

            lock (this)
            {
                var Host = "";
                if (odataLater.Count > 0 || graphQLLater.Count > 0)
                {
                    _timer.Dispose();

                    foreach (var item in serverAddresses.Addresses)
                    {
                        if (item.StartsWith("https"))
                        {
                            Host = item;
                        }
                        if (Host.Length == 0)
                        {
                            Host = item;
                        }
                    }
                    Host = Host.Replace("0.0.0.0", "localhost");
                    Host = Host.Replace("[::]", "localhost");
                }
                if (odataLater.Count > 0)
                {
                    foreach (var item in odataLater)
                    {
                        var b = new UriBuilder(Host);
                        b.Path = item;
                        var x = AddOdata(item.Replace("/", ""), b.Uri.ToString(), true);
                        x.GetAwaiter().GetResult();
                    }
                    odataLater.Clear();
                    this._ODataBlocklyAPIFunctions = null;
                    this._ODataBlocklyToolBoxFunctionDefinition = null;
                    this._ODataBlocklyTypesDefinition           = null;
                    this._ODataBlocklyToolBoxValueDefinition    = null;
                }
                if (graphQLLater.Count > 0)
                {
                    foreach (var item in graphQLLater)
                    {
                        var uri = new UriBuilder(Host);
                        uri.Path = item.Value;
                        InterpretSchemaGraphQl(item.Key, uri.Uri);
                    }
                }
                _timer.Dispose();
            }
        }