920 likes | 934 Views
Litium Certified Developer. Welcome, who are you?. Installation. Installation Pre-requisites. System requirements https://docs.litium.com/documentation/get-started/system-requirements VS 2017 Sql Server 2012 .NET 4.7.2 dev pack
E N D
Installation Pre-requisites • System requirementshttps://docs.litium.com/documentation/get-started/system-requirements • VS 2017 • Sql Server 2012 • .NET 4.7.2 dev pack • Litium NuGet feed https://docs.litium.com/download/litium-nuget-feed • Requires docs.litium.com account with download rights • IIS should have .net development enabled. (From turn windows features on/off, in IIS section)
Installation • Installation is done through Visual Studio • With or without accelerator • Litium is available only through Litium NuGet-feed (private) • NuGet-feed is connected to your user account in http://docs.litium.com • One DLL = one NuGet package
NuGet package for installation Litium.Web.Setup.Complete Litium.Setup.Complete
Distribution – Add-Ons/Accelerator • Compiled Add-Ons (e.g. payment provider addOns) • Install via NuGet packages • Accelerator and source code Add-Ons (e.g. Integration Kit) • Download from KC (Litium Knowledge Center) • The Litium platform and licensed Add-Ons (e.g. Accelerator and Integration Kit) can not be reused or shared after download
What is Litium Accelerator? • A packaged technical solution, • Speed up staring new projects. • No need to build everything from scratch, • Provides the base for common functionality to start development. • Delivered as source code. • Once customized, accelerator will be part of the solution.
Litium Accelerator 7 • Based on ASP.NET • Mvc, React and Redux • ES6 • BEM (Block Element Modifier) methodology • Responsive design framework - Foundation Zurb • Email html generation – Foundation email by Zurb • No JQuery
Task: Install Litium Accelerator (Part 1) • Login to docs.litium.com • Download and unzip latest MVC accelerator source from KC • Assert that you have set up Litium NuGet feed according tohttps://docs.litium.com/download/litium-nuget-feed • Open the Accelerator.sln in Visual Studio • In Package Manager Console, run Update-Package –ReInstall • Optional tip, init git repo in folder to document progress (and possibly revert) changes
Database • Database installed to web/App_data • Moving database from App_data to sql server • In some machines, the Sql server permissions may fail due to sql server not having enough permissions in windows. • You may manually mount the database, the files are located in ” \packages\Litium.Setup.Core.7.0.0\Tools\db” folder. • Copy the files to a different location! • You might need to run the sql server management studio as an Administrator in certain cases. CREATE DATABASE KcSamplesL5 ON (FILENAME = 'D:\Sandbox\KcSamplesL5\DB\KcSamplesL5.mdf'), (FILENAME = 'D:\Sandbox\KcSamplesL5\DB\KcSamplesL5_log.ldf') FOR ATTACH;
Options in Web.config • Update database connection string • Update the files folder. • Used for • Temporary files. • Lucene search index. • Media files. • CommonFilesDirectory • Sessionstate, inProc vs StateServer • …and more (SMTP, HTTPS etc.) https://docs.litiumstudio.com/documentation/get-started/configure/web_config
Should you use IIS in dev? • IIS Express has limitations, by using IIS during development these will not come as a surprise when moving to production • If you ever need to check something, without opening visual studio! https://msdn.microsoft.com/en-us/library/58wxa9w5(v=vs.120).aspx
Configuring IIS • Remember to add Https • If not possible, useSecureConnection = false • Set ping enabled to false for application pool
Useful tools • Localtest • You can use <yourDomainName>.localtest.me instead of using windows hosts file • Will not work offline • ReAttach, a Visual Studio addon that makes it easy to attach to IIS process for debugging. • Baretail or Wintail to keep an eye on the log • PaperCut for local email testing
Login to backoffice • <mydomain>/litium • If you belong to the local administrators group in windows, use your windows account user name and password. • Otherwise, you need to change web.config to specify a different group to allow login locally.
Backoffice Settings Personal settings
Task: Install Litium Accelerator (Part 2) Return to the Accelerator site created in Part 1 and: • Run the site when nuget is completed (Ctrl+F5) • Login to Litium Backoffice using local windows admin • http://<your domain>/Litium • \my.name@litium.com • Control panel > Deployment > Accelerator B2B/B2C • Remove /litium... from url to visit public website
Accelerator • What is deployed? • New site in websites area • New assortment in products area • Fields and templates in Blocks, Customers, Websites and PIM • Globalization artifacts • Channel, Country, Currency, Domain name, Market and Tax class • Explore Accelerator and backoffice • Create an order
Task: brief overview of Litium back-office • Create an order • In back-office • View order • View created person • Explore the products that are bought • Base product and variants • Prices • Stock balances • Publishing to channel • View the website and checkout page
Web solution ASP.NET web app running on IIS • Integration- file based / Web APIs / Headless • - Windows Service /ASP.NET web app running on IIS Accelerator (MVC REACT)Foundation by Zurb Foundation Email by Zurb Litium API Sites Products Orders Customer Media Globalization Dashboard Price calculations Validation rules State Transitions Search Campaign Engine Field framework Querying Batching Security Dependencyinjection Event Auditing Log Infrastructure CDN FileStorage Service bus Database
Litium API • New API • Products – Litium 5.x • Media and Customers – Litium 6.x • Websites – Litium 7.x • Ecommerce – Litium 8.x • Service Oriented design • Each entity has its service for create/update/delete operations • Business logic in extensible interface implementations • Use decorator pattern to extend • Old API (Ecommerce module) • Based on architecture popular in year 2000 to 2010 • “Collection” classes as object creators • “Carrier” is a pure code object (no operations) • “Entity” has operations • Business logic in extensible interface implementations • Use inheritance to extend
Entity model • Each entity has its own “entity service” • Use the service to get, create, update and delete entities • Example:
Entity model - Updating an entity • Create a updatable copy from calling the MakeWritableClone() method on the entity. • Then update the cloned copy and call the update method of the respective entity service. • The objects are readOnly because “Cached“ entities should be “non modifiable”
Entity model - Relationships between entities • Where domain model contains • “main entity” – “child entity” relationships • Other “entity” – “entity” relationships • Main entity only have “Links” to the other entities • The link has the “SystemId” of “Child entity” • Link may have other information related to the relationship
Link specific information Note that TaxClass can exist on its own, but CountryToTaxClassLink needs a Country to exist. Implication: TaxClass has its own TaxClassService, but there is no CountryToTaxClassLinkService
--Check whether page type already registered in db SELECT * FROM [Common].[Setting] where [Key] like ‘%Author%' Task – Create Author PageType • Copy \Src\Litium.Accelerator.Mvc\Controllers\Article\ArticleController.cs and paste as AuthorController.cs • Copy \Src\Litium.Accelerator\Builders\Article\ArticleViewModelBuilder.cs and paste as AuthorViewModelBuilder.cs • Copy \Src\Litium.Accelerator\ViewModels\Article\ArticleViewModel.cs and paste as AuthorViewModel.cs • Modify the class name accordingly. • Modify the Mappings class accordingly. • Copy \Src\Litium.Accelerator.Mvc\Views\Article\Index.cshtml and paste as src\ Litium.Accelerator.Mvc \Views\Author\Index.cshtml • Modify the @model directive accordingly. • Modify Src\Litium.Accelerator.Mvc\Definitions\FieldTemplateSetupDecorator.cs to map the controller. • Copy \Src\Litium.Accelerator\Definitions\Pages\ArticlePageTemplateSetup.cs and paste as AuthorPageTemplateSetup.cs in the same folder • Modify the class name to AuthorPageTemplateSetup. • Change the template name from “PageTemplateNameConstants.Article” to “Author” • For template name, enter an entry into Src\Litium.Accelerator.Mvc\Site\Resources\Administration\Administration.resx • Entry name key is fieldtemplate.websitearea.Author.name • Delete the template from back-office, restart site, it is not recreated! • Reason: IsAlreadyExecuted<T> in the \Src\Litium.Accelerator\Definitions\DefinitionSetup.cs • Entry in the Common.Settings table ; delete it from database! Need to restart site after sql operations to flush caches.
Component model • Namespaces • Same namespace for domain entity and its service contract. • Example: Variant and VariantService in same Litium.Products namespace • Assembly Structure, examples • Litium.Abstractions • Litium.Web.Abstractions • Litium.Web.Mvc.Abstractions • Litium.Web.WebApi.Abstractions • Litium.Web.Administration.Abstractions • Implementations • Litium.Application • Litium.Infrastructure.MicrosoftServiceBus
Component model - Assemblies • Litium.Abstractions • Domain entities, events and service contracts. • When there are breaking changes • Information in release notes. • Except items where namespace name include ”Internal” • Litium.Application • Implementation of service contracts. • Litium.Infrastructure.X • Implementation of external services, e.g: Service Bus
Service Model • Litium contracts (Services) • Artifacts that have “methods” or “operations” • Interfaces • Implement an interface to extend the functionality • Or change default functionality by extending default implementation (service decorator pattern) • Example: IPriceCalculator • Abstract Classes • Declare service definitions that implementation projects are not expected to change. • Example: BaseProductService
Litium Service Decorator • To change or replace default implementation • Usually to inject business logic • “Strategy pattern” in software design • To inject new business logic • “Decorator pattern” in software design • Advantages over “inheritance” (subclass) • Dynamically add/replace business logic • Reference Litium abstraction namespaces only • Extend without knowing which class implements interface • https://docs.litium.com/documentation/architecture/dependency-injection/service-decorator
using Litium.Runtime.DependencyInjection; Take note of run-time dependency! Replace business logic Modify business logic
custom implementation run-time depends on default implementation
Dependency injection Litium.Runtime.DependencyInjection • What is it? • Say object A needs object B, the one who “creates/invokes” object A “gives” the object B to A. • Object A is not required to ”know”, how to find/create ”B” • If the reference from A to B is through an interface, the coupling between A and B is independent from implementation of B.
Dependency injection Litium.Runtime.DependencyInjection
Litium.Runtime.DependencyInjection Dependency injection Lifetime • Scoped • For every request within a scope (usually the web request) • Transient • A new instance of the component will be created each time the service is requested from the container • Singleton • Clients will always receive that same instance from the container
Security Token • In Litium, permissions are enforced by using “SecurityToken” object • SecurityToken.CurrentSecurityToken contains the security token for the logged in user • Current token is automatically “applied” in the “code execution context” • Current running code has the current logged in users permissions • Just anonymous permission if no one is logged in
If a user who do not have permissions calls this method, it will throw a Litium.Security.AuthorizationException
Security Token – Impersonate SystemUser • To give “system permissions” use SecurityContextService.ActAsSystem() • E.g. ..\Src\Litium.Accelerator\Services\LoginServiceImpl.cs • Gives system permission to update the user after changing password
Security Token – Old API (Ecommerce) • In old api sections, token is passed into every API method that requires permission enforcement • Current SecurityToken can be constructor injected • Can also be taken from SecurityToken.CurrentSecurityToken • Src\Litium.Accelerator\Services\CheckoutServiceImpl.cs
Litium Accelerator 7 MVC ReactRedux Selectedcomponents Most pages Web api Business LogicLayer (BLL) Litium API
Improvements Accelerator 7 • A complete re-write • Total business logic separation • True MVC design pattern • Blocks instead of old sections • Settings moved into platform