public static async Task SetParametersCommandStep
            ([OrchestrationTrigger] IDurableOrchestrationContext context)
        {
            InstanceParameter payload = context.GetInput <InstanceParameter>();

            if (payload != null)
            {
                Command cmdApplyAccruedInterest = new Command(payload.DomainName, payload.Name, payload.InstanceKey);
                if (cmdApplyAccruedInterest != null)
                {
                    await cmdApplyAccruedInterest.SetParameter(payload.ParameterName, payload.ParameterValue);
                }
            }
        }
        public static async Task <HttpResponseMessage> ApplyAccruedInterestCommand(
            [HttpTrigger(AuthorizationLevel.Function, "POST", Route = @"ApplyAccruedInterest/{accountnumber}")] HttpRequestMessage req,
            string accountnumber,
            [DurableClient] IDurableOrchestrationClient applyInterestOrchestration)
        {
            #region Tracing telemetry
            Activity.Current.AddTag("Account Number", accountnumber);
            #endregion

            // Set the start time for how long it took to process the message
            DateTime startTime = DateTime.UtcNow;

            // use a durable functions GUID so that the orchestration is replayable

            //Command cmdApplyAccruedInterest
            CommandAttribute commandToRun = new CommandAttribute("Bank", "Apply Accrued Interest");
            string           commandId    = await applyInterestOrchestration.StartNewAsync(nameof(StartCommand), commandToRun);

            commandToRun = new CommandAttribute("Bank", "Apply Accrued Interest", commandId);
            Command cmdApplyAccruedInterest = new Command(commandToRun);

            // No parameters passed in - but set the as-of date/time so that if this command is
            // re-executed it does not return a different result
            InstanceParameter paramAsOf = new InstanceParameter(cmdApplyAccruedInterest.AsAttribute(), "As Of Date", startTime);
            await applyInterestOrchestration.StartNewAsync(nameof(SetParametersCommandStep), paramAsOf);

            InstanceParameter paramAccount = new InstanceParameter(cmdApplyAccruedInterest.AsAttribute(), "Account Number", accountnumber);
            await applyInterestOrchestration.StartNewAsync(nameof(SetParametersCommandStep), paramAccount);

            // The rest of the command is performed by a durable functions orchestration
            await applyInterestOrchestration.StartNewAsync(nameof(ApplyAccruedInterestCommandStep), cmdApplyAccruedInterest.AsAttribute());

            // Return that the command has been initiated...
            return(req.CreateResponse <FunctionResponse>(System.Net.HttpStatusCode.OK,
                                                         FunctionResponse.CreateResponse(startTime,
                                                                                         false,
                                                                                         $"Interest accrual process for { accountnumber} initiated"),
                                                         FunctionResponse.MEDIA_TYPE));
        }
Esempio n. 3
0
 public void PutInstanceParameter(InstanceParameter instanceParameter)
 {
     InstanceParameters.Add(instanceParameter);
 }
Esempio n. 4
0
            public static string InternalBuffersInitialization(IEnumerable <FBInstance> instances, IEnumerable <Connection> connections, IEnumerable <Event> nonFilteredEvents, IEnumerable <Variable> nonFilteredVariables, IEnumerable <InstanceParameter> instanceParameters, bool mainModule = false)
            {
                string buffersInit = "";

                foreach (FBInstance instance in instances)
                {
                    var instanceVariables = nonFilteredVariables.Where(v => v.FBType == instance.InstanceType && v.Direction != Direction.Internal && !v.IsConstant);
                    var instanceEvents    = nonFilteredEvents.Where(ev => ev.FBType == instance.InstanceType && ev.Direction != Direction.Internal);
                    foreach (Event ev in instanceEvents)
                    {
                        //Connection inputConnection;
                        //if (!_isInputFromComponent(ev, connections, instance.Name, out inputConnection))
                        //{
                        buffersInit += String.Format(Smv.VarInitializationBlock, instance.Name + "_" + ev.Name, Smv.False);
                        //}
                    }
                    foreach (Variable variable in instanceVariables)
                    {
                        Connection inputConnection;
                        if (_nonInitializableVar(variable))
                        {
                            continue;                                 // do not initialize SMV variables for FB_DELAY and E_CYCLE data IOs
                        }
                        if (_isInputFromComponent(variable, connections, instance.Name, out inputConnection))
                        {
                            continue;
                        }

                        // if(! _isInputFromComponent)
                        InstanceParameter instanceParameter = instanceParameters.FirstOrDefault(p => p.InstanceName == instance.Name && p.Name == variable.Name);
                        if (variable.ArraySize == 0)
                        {
                            string value = instanceParameter == null?Smv.InitialValue(variable) : Smv.ClearInitialValue(instanceParameter.Value, variable);

                            buffersInit += String.Format(Smv.VarInitializationBlock, instance.Name + "_" + variable.Name, value);
                        }
                        else
                        {
                            string[] values;

                            if (instanceParameter == null)
                            {
                                values = new string[variable.ArraySize];
                                for (int i = 0; i < variable.ArraySize; i++)
                                {
                                    values[i] = Smv.InitialValue(variable);
                                }
                            }
                            else
                            {
                                char[] trimChars = { '[', ']' };
                                values = instanceParameter.Value.Trim(trimChars).Split(',');
                                if (values.Count() != variable.ArraySize)
                                {
                                    throw new Exception("Invalid array value " + instanceParameter.Value);
                                }
                            }
                            for (int i = 0; i < variable.ArraySize; i++)
                            {
                                buffersInit += String.Format(Smv.VarInitializationBlock, instance.Name + "_" + variable.Name + Smv.ArrayIndex(i), Smv.ClearInitialValue(values[i], variable));
                            }
                        }
                    }
                    if (!mainModule)
                    {
                        buffersInit += String.Format(Smv.VarInitializationBlock, instance.Name + "_" + Smv.Alpha, Smv.False);
                        buffersInit += String.Format(Smv.VarInitializationBlock, instance.Name + "_" + Smv.Beta, Smv.False);
                    }
                    buffersInit += "\n";
                }
                return(buffersInit);
            }