public void Execute(StringBuilder sb, string value)
        {
            string[]      properties = value.Split('/');
            StringBuilder key        = new StringBuilder();

            string[] items = RuleAnalysis.Execute(properties[0]);
            foreach (string p in items)
            {
                string[]          sps     = RuleAnalysis.GetProperties(p);
                IParameterHandler handler = null;
                if (Factory.Handlers.TryGetValue(sps[0], out handler))
                {
                    handler.Execute(key, sps[1]);
                }
            }

            SequenceItem item = GetSequenceItem(key.ToString());

            lock (item)
            {
                item.Value++;
                sb.Append(item.Value.ToString(properties[1]));
            }
            Save(item);
        }
 public StoredProcedureService(
     ConnectionPool connpool,
     IParameterHandler parameterHandler)
 {
     _dbconn           = connpool.MsSqlConnection;
     _parameterHandler = parameterHandler;
 }
        }                                           // The subroutine's return handler.

        public SubroutineCatalogItem(Subroutine subroutine, IParameterHandler parameterHandler, IndexReference objectStack, ReturnHandler returnHandler)
        {
            Subroutine       = subroutine;
            ParameterHandler = parameterHandler;
            ObjectStack      = objectStack;
            ReturnHandler    = returnHandler;
        }
        public SubroutineCatalogItem Initiate()
        {
            // Setup the subroutine element.
            Subroutine subroutine = _deltinScript.SubroutineCollection.NewSubroutine(_context.ElementName);

            // Create the rule.
            _subroutineRule = new TranslateRule(_deltinScript, subroutine, _context.RuleName, _context.VariableGlobalDefault);

            // Setup the return handler.
            _actionSet = _subroutineRule.ActionSet
                         .ContainVariableAssigner()
                         .SetThisTypeLinker(_context.TypeLinker)
                         .New(_context.Controller.Attributes.IsRecursive);

            // Create the function builder.
            var controller = _context.Controller;

            // Create the parameter handlers.
            _parameterHandler = controller.CreateParameterHandler(_actionSet, null);

            // If the subroutine is an object function inside a class, create a variable to store the class object.
            if (controller.Attributes.IsInstance)
            {
                _objectStore = _actionSet.VarCollection.Assign(_context.ObjectStackName, true, !controller.Attributes.IsRecursive);

                // Set the objectStore as an empty array if the subroutine is recursive.
                if (controller.Attributes.IsRecursive)
                {
                    // Initialize as empty array.
                    _actionSet.InitialSet().AddAction(_objectStore.SetVariable(Element.EmptyArray()));

                    // Add to assigner with the last of the objectStore stack being the object instance.
                    _context.ContainingType?.AddObjectVariablesToAssigner(_actionSet.ToWorkshop, Element.LastOf(_objectStore.GetVariable()), _actionSet.IndexAssigner);

                    // Set the actionSet.
                    _actionSet = _actionSet.New(Element.LastOf(_objectStore.Get())).PackThis().New(_objectStore.CreateChild(Element.CountOf(_objectStore.Get()) - 1));
                }
                else
                {
                    // Add to assigner with the objectStore being the object instance.
                    _context.ContainingType?.AddObjectVariablesToAssigner(_actionSet.ToWorkshop, _objectStore.GetVariable(), _actionSet.IndexAssigner);

                    // Set the actionSet.
                    _actionSet = _actionSet.New(_objectStore.Get()).PackThis().New(_objectStore);
                }
            }

            _functionBuilder = new WorkshopFunctionBuilder(_actionSet, controller);
            _functionBuilder.ModifySet(a => a.PackThis()); // TODO: is this required?
            _functionBuilder.SetupReturnHandler();
            _parameterHandler.AddParametersToAssigner(_actionSet.IndexAssigner);

            // Done.
            return(Result = new SubroutineCatalogItem(
                       subroutine: subroutine,
                       parameterHandler: _parameterHandler,
                       objectStack: _objectStore,
                       returnHandler: _functionBuilder.ReturnHandler));
        }
Example #5
0
        public HttpRequest GetFrom(string path)
        {
            _path = path.TrimStart('/');

            _message.Method   = HttpMethod.Get;
            _parameterHandler = new GetParameterHandler();

            return(this);
        }
Example #6
0
        public HttpRequest PostTo(string path)
        {
            _path = path.TrimStart('/');

            _message.Method   = HttpMethod.Post;
            _parameterHandler = new PostParameterHandler();

            return(this);
        }
Example #7
0
 public Customer_Service(
     IParameterHandler parameterHandler,
     IGenericRepository <IBase_Model> repository,
     IStoreProcedure <Customer_GetById_Model, Void_Schema> customerGet)
 {
     _repository       = repository;
     _parameterHandler = parameterHandler;
     _customerGet      = customerGet;
 }
Example #8
0
 public Product_Service(IParameterHandler parameterHandler,
                        IGenericRepository <IBase_Model> repository,
                        IStoreProcedure <Product_Model, Product_GetByLocation_Schema> getByLocation,
                        IStoreProcedure <Product_Model, Product_GetPaging_Schema> getPaging)
 {
     _repository       = repository;
     _parameterHandler = parameterHandler;
     _getByLocation    = getByLocation;
     _getPaging        = getPaging;
 }
Example #9
0
 public Business_Service(
     IParameterHandler parameterHandler,
     IGenericRepository <IBase_Model> repository,
     IStoreProcedure <Business_Model, Business_GetByLocation_Schema> getByLocation,
     IStoreProcedure <Business_Model, Business_GetPaging_Schema> getPaging,
     IStoreProcedure <Business_Model, Business_New_Schema> create,
     IStoreProcedure <Business_Model, Business_Edit_Schema> edit)
 {
     _repository       = repository;
     _parameterHandler = parameterHandler;
     _getByLocation    = getByLocation;
     _getPaging        = getPaging;
     _create           = create;
     _edit             = edit;
 }
        public async void CheckDefaultEventFromDefaultParameterHandler(string modName, string funcHandler, string funcTimeout, string funcPort, string funcRuntime, string funcMemoryLimit)
        {
            // Arrange
            EnvironmentManager.SetVariables(modName, funcHandler, funcTimeout, funcPort, funcRuntime, funcMemoryLimit);
            IParameterHandler parameterHandler = GetDefaultParameterHandler();
            HttpRequest       httpRequest      = EnvironmentManager.GetHttpRequest();

            // Act
            (Event @event, _) = await parameterHandler.GetFunctionParameters(httpRequest);

            // Assert
            Assert.NotNull(@event);
            Assert.NotNull(@event.Extensions);
            Assert.Equal(httpRequest, @event.Extensions.HttpRequest);
            Assert.Equal(string.Empty, @event.Data);
        }
Example #11
0
        public string Create(string rule)
        {
            string[]      items = RuleAnalysis.Execute(rule);
            StringBuilder sb    = new StringBuilder();

            foreach (string item in items)
            {
                string[]          properties = RuleAnalysis.GetProperties(item);
                IParameterHandler handler    = null;
                if (mHandlers.TryGetValue(properties[0], out handler))
                {
                    handler.Execute(sb, properties[1]);
                }
            }
            return(sb.ToString());
        }
Example #12
0
        public IParameterHandler[] Parameters()
        {
            var parameters = new IParameterHandler[_root.ParameterCount()];

            for (int i = 0; i < parameters.Length; i++)
            {
                // Get all vars in each function.
                var vars = new IIndexReferencer[VirtualOptions.Length];
                for (int v = 0; v < vars.Length; v++)
                {
                    vars[v] = VirtualOptions[v].GetParameterVar(i);
                }

                parameters[i] = new DefinedParameterHandler(vars, IsRecursive());
            }

            return(parameters);
        }
        public async void CheckContextFromDefaultParameterHandler(string modName, string funcHandler, string funcTimeout, string funcPort, string funcRuntime, string funcMemoryLimit)
        {
            // Arrange
            EnvironmentManager.SetVariables(modName, funcHandler, funcTimeout, funcPort, funcRuntime, funcMemoryLimit);
            IParameterHandler parameterHandler = GetDefaultParameterHandler();
            HttpRequest       httpRequest      = EnvironmentManager.GetHttpRequest();

            // Act
            (_, Context context) = await parameterHandler.GetFunctionParameters(httpRequest);

            // Assert
            Assert.NotNull(context);
            Assert.Equal(modName, context.ModuleName);
            Assert.Equal(funcHandler, context.FunctionName);
            Assert.Equal(funcTimeout, context.Timeout);
            Assert.Equal(funcPort, context.FunctionPort);
            Assert.Equal(funcRuntime, context.Runtime);
            Assert.Equal(funcMemoryLimit, context.MemoryLimit);
        }
Example #14
0
 public UserService(IParameterHandler parameterHandler,
                    IGenericRepository <IBase_Model> repository,
                    IStoreProcedure <IBase_Model, User_SetVerificationCode_Schema> setVerificationCode,
                    IStoreProcedure <IBase_Model, User_Verify_Schema> verify,
                    IStoreProcedure <IBase_Model, User_EnableTwoFactorAuthentication_Schema> enableTwoFactorAuthentication,
                    IStoreProcedure <IBase_Model, User_DisableTwoFactorAuthentication_Schema> disableTwoFactorAuthentication,
                    IStoreProcedure <User_Model, User_SignIn_Schema> signIn,
                    IStoreProcedure <IBase_Model, User_Update_Schema> updateProfile,
                    IStoreProcedure <IBase_Model, User_DisableMe_Schema> disableMe)
 {
     _repository          = repository;
     _parameterHandler    = parameterHandler;
     _setVerificationCode = setVerificationCode;
     _verify = verify;
     _enableTwoFactorAuthentication  = enableTwoFactorAuthentication;
     _disableTwoFactorAuthentication = disableTwoFactorAuthentication;
     _signIn        = signIn;
     _updateProfile = updateProfile;
     _disableMe     = disableMe;
 }
        public async void CheckEventFromDefaultParameterHandler(string eventType, string eventNamespace)
        {
            // Arrange
            string            eventId          = Guid.NewGuid().ToString();
            string            eventTime        = DateTime.Now.ToString();
            var               data             = new { id = Guid.NewGuid() };
            IParameterHandler parameterHandler = GetDefaultParameterHandler();
            HttpRequest       httpRequest      = EnvironmentManager.GetHttpRequest(eventId, eventType, eventTime, eventNamespace, data);

            // Act
            (Event @event, _) = await parameterHandler.GetFunctionParameters(httpRequest);

            // Assert
            Assert.NotNull(@event);
            Assert.NotNull(@event.Extensions);
            Assert.Equal(httpRequest, @event.Extensions.HttpRequest);
            Assert.Equal(eventId, @event.EventId);
            Assert.Equal(eventNamespace, @event.EventNamespace);
            Assert.Equal(eventTime, @event.EventTime);
            Assert.Equal(eventType, @event.EventType);
            Assert.NotNull(@event.Data);
            Assert.Equal(data.id.ToString(), ((JsonElement)@event.Data).GetProperty("id").ToString());
        }
Example #16
0
        public HttpRequest WithQueryParameters()
        {
            _parameterHandler = new GetParameterHandler();

            return(this);
        }
 public RuntimeController(ILogger <RuntimeController> logger, IInvoker invoker, IParameterHandler parameterHandler)
 {
     _logger           = logger;
     _invoker          = invoker;
     _parameterHandler = parameterHandler;
 }
Example #18
0
 public RuntimeController(IFunction function, IParameterHandler parameter, IInvoker invoker)
 {
     _function         = function;
     _invoker          = invoker;
     _parameterManager = parameter;
 }
Example #19
0
 public RuntimeController(IParameterHandler parameterHandler, IInvoker invoker, ILogger <RuntimeController> logger)
 {
     this.invoker          = invoker;
     this.parameterHandler = parameterHandler;
     this.logger           = logger;
 }
Example #20
0
 public StoreProcedure(IGenericRepository <Result> repository, IParameterHandler <Schema> parameterHandler)
 {
     _repository       = repository;
     _parameterHandler = parameterHandler;
 }