Applies to Infiniti v8.0 or later
 
A state provider is a component that can trigger custom events during a web form. A state provider works in much the same way as a Delivery Provider but is triggered when the ‘Next’ and ‘Save’ buttons are used rather than upon the completion of a web form.
 
Note: There are no packaged State Providers in Infiniti. Most tasks can be handled by other out-of-box solutions, but on occasion you may need to create a State Provider for a custom solution.
 
This guide is not a real-world example of something you would want to implement, but provides an idea of how the code could work. If you feel that a State Provider is required for you project, determine what you need and contact your account representative.

How to develop a Hello World State Provider

 
Open Visual Studio and create a new Class Library Project and give it a meaningful name. For this example, we will use ‘HelloWorldStateProvider’.
 
 
 
 
Add the following references to the project:
.NET References:
  • System.Configuration
  • System.Web
  • Intelledox.State
  • Intelledox.InfinitiProviderBase.dll
  • Intelledox.QAWizard
 
Inherit the Intelledox.State.Provider and override necessary StateProvider methods, as per the sample below.
 

using System;
using System.Web.UI.WebControls;

namespace HelloWorldStateProvider
{
    public class HelloWorldState : Intelledox.State.StateProvider
    {
        public override void AnswerFileSaving(Guid userGuid, string answerFile, Intelledox.QAWizard.WizardSession wizard)
        {
            throw new NotImplementedException();
        }

        public override void ChangingPage(Guid userGuid, string answerFile, Intelledox.QAWizard.WizardSession wizard, Intelledox.QAWizard.PageChangeArguments direction)
        {
            throw new NotImplementedException();
        }

        public override WebControl CustomUI(Guid userGuid, Intelledox.QAWizard.WizardSession wizard)
        {
            throw new NotImplementedException();
        }

        public override bool UseStandardSave(Intelledox.QAWizard.WizardSession wizard)
        {
            throw new NotImplementedException();
        }
    }
}

The override methods and their input parameters are described in the tables below:
 
Input parameters
 
userGuid A guid representing the current user, can be used to retrieve user data.
answerFile A string representation of the user’s answers to the form.
wizard An object representation of the user’s answers to the form so far.
direction A flag to specific if the user is navigating forward or backwards through the form.
 
Output parameters
 
AnswerFileSaving Called when a user clicks the save button during a web form.
UseStandardSave A flag indicating if Infiniti should carry out its regular save routine when the user clicks save. I.e. if a custom save feature has been implemented it may be appropriate to ‘turn off’ the standard Infiniti save.
ChangingPage Called when a user navigates forwards or backwards through the form’s pages.
CustomUI Allows a custom UI such as a button to be displayed in the form.
 
For this ‘hello world’ state provider we will save a backup copy of the answer file to another system each time the user navigates though a form. Maybe so it could be retrieved by a third party system and reused in the future. In the example below, the standard save is set to true, no UI is returned and the changing page method saves a file to disk by.
 
using System;
using System.Web.UI.WebControls;
using System.IO;
using Intelledox.State;
using Intelledox.QAWizard;

namespace HelloWorldStateProvider
{
    public class HelloWorldState : StateProvider
    {
        public override void ChangingPage(Guid userGuid, string answerFile, WizardSession wizard, PageChangeArguments direction)
        {
            File.WriteAllText(@"c:\Temp\" + wizard.WizardSession.WizardSession.Variables.RunId + ".xml", wizard.WizardToString());
        }

        public override WebControl CustomUI(Guid userGuid, WizardSession wizard)
        {
            return null;
        }

        public override void AnswerFileSaving(Guid userGuid, string answerFile, WizardSession wizard)
        {
        }

        public override bool UseStandardSave(WizardSession wizard)
        {
            return true;
        }
    }
}

Deploying a state provider

State Providers are deployed to an Infiniti environment by copying the State Provider’s .dll file to the Produce bin directory and referencing it within Produce’s web.config file.
 
1. Locate your ‘HelloWorldStateProvider.dll’ file and copy it to the Produce bin directory (usually located C:\inetpub\wwwroot\Infiniti\Produce\bin).
 
Open the produce web.config file and locate the configuration/configSections element of the web.config file:
 
  <configSections>
…
…
    <section name="escalation" type="Intelledox.Escalation.EscalationSection, Intelledox.Escalation" restartOnExternalChanges="true" />
    <section name="customquestion" type="Intelledox.CustomQuestion.CustomQuestionSection, Intelledox.CustomQuestion" restartOnExternalChanges="true" />
   <section name="state" type="Intelledox.State.StateSection, Intelledox.State" restartOnExternalChanges="true" />
…
…
  </configSections>
2. Add the following elements to the configuration sections
 
   <section name="state" type="Intelledox.State.StateSection, Intelledox.State" restartOnExternalChanges="true" />
3. Now add the following elements to the configuration Node
 
<state>
<providers>
</providers>
</state>
4. Insert the state providers entry into the above configuration/state/providers element using the syntax below:
 
<add name="name" type="namespace.class AssemblyName">
<add name="HelloWorldStateProvider" type="HelloWorldStateProvider.HelloWorldState, HelloWorldStateProvider">
</add>
</add>
5. Save the web.config file.
 

Related Articles

 

Keywords

state provider register code answer file answerfile