Last updated

StormContext

Deprecated

The Storm API client for .net has been tag:ed end of life and will be ceased to be updated and supported in roll out tests in an unspecified later date.

All Storm’s API’s moves to open API standards and swagger endpoints and these old clients with dependencies to 3rd party technologies or tools will stop being supported. No specific date in set yet.

The StormContext is a cookie based container of user and setup data for Storm accessible through out the application. It provides means to log in and out a user. It can be encrypted in Web.config so no one can tamper with the cookie.

PropertyTypeDescription
AccountIdint?Logged in Account Id. Null when not logged in. AccountId is used to tag who updated data through Storm API. Pass this when required in updates so Storm API knows who changed data.
LoginNamestringLogged in Account Login Name. Null when not logged in.
RememberMebool?Current setting for if account will be remembered between settings or not. Set this in the login page.
CustomerIdint?Current Customer Id. Used to set basket when logged in and to show the right information in my pages.
CompanyIdint?Current Company Id. Used to set basket when logged in and to show the right information in my pages. A customer can be connected to more than one company.
DivisionIdint?Current Store or Division Id. Used to set basket when logged in if a store is selected and to show the right store on hand information.
BasketIdint?Current Basket Id. Use Api call CreateBasket when basket id is null to get a new basket Id.
CurrencyIdintCurrent Currency Id. Pass this to all Storm API calls that show prices to get the returned prices in the right currency. Change this when changing currecncy.
CultureCodestringCurrent Culture Code. Pass this to all Storm API calls that show translated text to show the right language. Change this when changing langugage.
SalesAreaIdintCurrent Sales Area Id. Pass this to all Storm API calls that show prices to get the right VAT. Change this when changing sales area.
ShowPricesIncVatbool?Current VAT setting. Not selected when null. Use this to know if you should add VAT when showing prices on your site. Not passed to Storm API.
IsPrivatebool?Current setting for if visitor is private or company. Not selected when null. Use this to know if you should show company site or private site. Not passed to Storm API.
ReferIdint?Deprecated setting that used to track what registered referrer this user last came from.
PropertyTypeDescription
PriceListIdsListA list of activated price lists other than public price lists and price lists activated by customer, company or division. Pass PriceListIdSeed that is a comma separated string that represents this list to all Storm API calls that show prices to add available price lists.
ConfirmedBasketIdint?Set in checkout process when payment is confirmed to be able to show basket on confirmation page. When payment is confirmed then StormContext.BasketId is cleared so no more changes will be made on this basket. The basket Id is copied to ConfirmedBasketId to be able to show confirmation page and set up basket tracking.
ReferUrlstringKeeps track of what referrer url that inititated this session.
IsInitialRequestboolTrue for the first request of the session. All other request this is false.

Methods

MethodReturnsDescription
LoginUser(loginName, rememberMe)voidLogs in a user to StormContext. Sets LoginName, AccountId, first connected CompanyId, CustomerId and RemeberMe flag. Basket is updated with customer and company as long as the basket does not belong to another customer. Then that basket is closed and a new basket will be created.
LogoutUser()voidLoginName, AccountId, CompanyId and CustomerId is set to null. Basket is updated to an anonymous basket.
SessionItemsNameValueCollectionA NameValueCollection that is stored in the session cookie. Don’t put large items here since it is transfered in every request.
PersitedItemsNameValueCollectionA NameValueCollection that is stored in the persisted cookie for 30 days. Don’t put large items here since it is transfered in every request.

Configuration

The following must be present in the configuration file under configuration:

<configSections>
   <sectionGroup name="stormSettings">

 ...

<section name="storm" type="Enferno.Web.StormUtils.StormConfigurationSection, Enferno.Web.StormUtils" allowLocation="true" allowDefinition="Everywhere" />
    </sectionGroup>
  </configSections>

And the section should look like:

<stormSettings>
  <storm encryptCookie="true" assortmentIdSeed="1" productStatusIdSeed="1,2,3,4" showPricesIncVat="true" imageUrl="http://services.enferno.se/image/" />
</stormSettings>

Note that there are more settings that can be defined.

We do have a StormModule : IHttpModule located in Enferno.Web.StormUtils that hooks into the application’s Begin-/EndRequest in order to handle Load and Save of cookie data.

The StormModule is registered in the configuration file as:

<system.webServer>
        <modules runAllManagedModulesForAllRequests="true">
            <add name="StormModule" type="Enferno.Web.StormUtils.StormModule, Enferno.Web.StormUtils" preCondition="" />
        </modules>
</system.webServer>