public PopupForm(IFormHandler _formHandler)
 {
     this.formHandler = _formHandler;
     InitializeComponent();
     FormItem = formHandler.GetForm();
     FormView.Children.Add(FormItem);
 }
        /// <summary>
        /// Get form handler with specific name
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static IFormHandler Get(string name)
        {
            IFormHandler formHandler = null;

            formHandlers.TryGetValue(name, out formHandler);
            return(formHandler);
        }
Exemple #3
0
 public SubmitFormVariablesInvocation(IFormHandler formHandler, IVariableMap properties,
                                      IVariableScope variableScope) : base(null, null)
 {
     this.FormHandler   = formHandler;
     this.Properties    = properties;
     this.VariableScope = variableScope;
 }
 /// <summary> Handler, called when the try. </summary>
 /// <param name="args">    The arguments. </param>
 /// <param name="handler"> The handler. </param>
 /// <param name="context"> The context. </param>
 private void TryHandler(T args, IFormHandler <T> handler, ControllerContext context)
 {
     try
     {
         handler.Handle(args);
         Success.ExecuteResult(context);
     }
     catch (Exception)
     {
         Error.ExecuteResult(context);
     }
 }
Exemple #5
0
        public virtual string Execute(CommandContext commandContext)
        {
            var                     processEngineConfiguration = context.Impl.Context.ProcessEngineConfiguration;
            DeploymentCache         deploymentCache            = processEngineConfiguration.DeploymentCache;
            ProcessDefinitionEntity processDefinition          = deploymentCache.FindDeployedProcessDefinitionById(processDefinitionId);

            foreach (var checker in commandContext.ProcessEngineConfiguration.CommandCheckers)
            {
                checker.CheckReadProcessDefinition(processDefinition);
            }

            IExpression formKeyExpression = null;

            if (ReferenceEquals(TaskDefinitionKey, null))
            {
                // TODO: Maybe add getFormKey() to FormHandler interface to avoid the following cast
                IFormHandler formHandler = processDefinition.StartFormHandler;

                if (formHandler is DelegateStartFormHandler)
                {
                    var delegateFormHandler = (DelegateStartFormHandler)formHandler;
                    formHandler = delegateFormHandler.FormHandler;
                }

                // Sorry!!! In case of a custom start form handler (which does not extend
                // the DefaultFormHandler) a formKey would never be returned. So a custom
                // form handler (for a startForm) has always to extend the DefaultStartFormHandler!
                if (formHandler is DefaultStartFormHandler)
                {
                    var startFormHandler = (DefaultStartFormHandler)formHandler;
                    formKeyExpression = startFormHandler.FormKey;
                }
            }

            string formKey = null;

            if (formKeyExpression != null)
            {
                formKey = formKeyExpression.ExpressionText;
            }
            return(formKey);
        }
        public IActionResult Send()
        {
            Form form = this.Storage.GetRepository <IFormRepository>().WithKey(int.Parse(this.Request.Form["formId"]));
            IDictionary <Field, string>  valuesByFields         = this.GetValuesByFields(form);
            IDictionary <string, byte[]> attachmentsByFilenames = this.GetAttachmentsByFilenames(form);

            if (form.ProduceCompletedForms)
            {
                this.ProduceCompletedForms(form, valuesByFields, attachmentsByFilenames);
            }

            IFormHandler formHandler = StringActivator.CreateInstance <IFormHandler>(form.CSharpClassName);

            if (formHandler != null)
            {
                return(formHandler.Handle(this, form, valuesByFields, attachmentsByFilenames));
            }

            return(this.NotFound());
        }
Exemple #7
0
        public string GetFormUrl(IFormHandler formHandler)
        {
            var gameResponse = _gameHandler.GetGame();

            // Find Form
            JToken form;

            using (var stream = gameResponse.MessageBody)
            {
                var json = stream.GetJson();
                form = formHandler.GetForm(json);

                if (form == null)
                {
                    return(null);
                }
            }

            return((string)form["action"]);
        }
Exemple #8
0
        public async Task <IActionResult> SendAsync(int formId, string origin)
        {
            Form form = await this.Storage.GetRepository <int, Form, FormFilter>().GetByIdAsync(
                formId,
                new Inclusion <Form>(f => f.Name.Localizations),
                new Inclusion <Form>("Fields.FieldType"),
                new Inclusion <Form>("Fields.Name.Localizations")
                );

            IDictionary <Field, string> valuesByFields = this.GetValuesByFields(form);

            foreach (Field field in valuesByFields.Keys)
            {
                if (!string.IsNullOrEmpty(field.FieldType.ValidatorCSharpClassName))
                {
                    if (!await this.CreateFieldValidator(field.FieldType).ValidateAsync(this.HttpContext, form, field, valuesByFields[field]))
                    {
                        return(this.BadRequest());
                    }
                }
            }

            IDictionary <string, byte[]> attachmentsByFilenames = this.GetAttachmentsByFilenames(form);

            if (form.ProduceCompletedForms)
            {
                await this.ProduceCompletedForms(form, valuesByFields, attachmentsByFilenames);
            }

            IFormHandler formHandler = StringActivator.CreateInstance <IFormHandler>(form.FormHandlerCSharpClassName);

            if (formHandler != null)
            {
                return(await formHandler.HandleAsync(this.HttpContext, origin, form, valuesByFields, attachmentsByFilenames));
            }

            return(this.NotFound());
        }
 /// <summary>
 /// Register form handler
 /// </summary>
 /// <param name="formHandler"></param>
 public static void RegisterFormHandler(IFormHandler formHandler)
 {
     formHandlers.Add(formHandler.Name, formHandler);
 }
 public DelegateFormHandler(IFormHandler formHandler, string deploymentId)
 {
     this.formHandler  = formHandler;
     this.deploymentId = deploymentId;
 }
Exemple #11
0
 public void GenerateCSVFile(IFormHandler formHandler, dynamic target)
 {
     formHandler.GenerateFlow(target);
 }