Configuration of Fluent NHibernate through C# code

Ahamed Fazil Buhari
 
Senior Developer
November 27, 2017
 
Rate this article
 
Views
5850

Hello everyone,

In this article we will see how to configure Fluent NHibernate through C# code, it gives easy way to query, save or update data on Database and it lies on top of NHibernate engine. Please refer this link to know more about Fluent NHibernate.

First and foremost, add fluent nhibernate reference to your project with the help of NuGet Package,

 

image

 

Provide details on Database and Server name through traditional way, connectionString in app.config file

 <connectionStrings>
     <add name="db" connectionString="Data Source=serverName;database=dbName;Integrated Security=True;" />
   </connectionStrings>
 

In the code call a function that will instantiate the configuration and fluent nhibernate configuration done through code not with the help of config file.

 using Ncfg = FluentNHibernate.Cfg;
 public static class DataBaseOperation
     {
         private static ISessionFactory _sessionFactory;
 
         public static void DataBase_Open()
         {
             var connString = ConfigurationManager.ConnectionStrings["db"].ToString();
 
             _sessionFactory = Ncfg.Fluently.Configure()
                 .Database(MsSqlConfiguration.MsSql2008.ConnectionString(connString))
                 .Mappings(m => m.FluentMappings.AddFromAssemblyOf<TablePackage>())
                 .ExposeConfiguration(cfg =>
                 {
                     cfg.SetProperty("adonet.batch_size", "100");
                     new SchemaUpdate(cfg).Execute(false, true);
                 })
        // If you want to overwrite and create new table, then uncomment the below line
                 //.ExposeConfiguration(cfg => new SchemaExport(cfg).Create(true, true))
                 .BuildSessionFactory();
         }
 }
 

There are 3 things we need to setup before configuring. One is connectionString, second is Domain layer (class which contains filed names) and mapping class.

 TablePackage.cs
 public class TablePackage
     {
         public virtual string ID { get; set; }     
         public virtual string Status { get; set; }
         public virtual DateTime CreationDate { get; set; }
     }
 
 TableMapping.cs – Mapping class should extend ClassMap<> FluentNHibernate class
 using FluentNHibernate.Mapping;
     public class TableMapping : ClassMap<TablePackage>
     {
         public TableMapping()
         {
             Id(x => x.ID).GeneratedBy.Assigned();//.GeneratedBy.Increment();
             Map(x => x.Status);
             Map(x => x.CreationDate);
   }
      }
 

In the upcoming article we will see how to deal with data using Fluent NHibernate.

 

Happy Coding

Ahamed

Author Info

Ahamed Fazil Buhari
 
Senior Developer
 
Rate this article
 
Ahamed is a Senior Developer and he has very good experience in the field of Microsoft Technologies, especially SharePoint, Azure, M365, SPFx, .NET and client side scripting - JavaScript, TypeScript, ...read more
 

How to Configure Record Centre in SharePoint Office 365

Sathish Nadarajan
 
Solution Architect
March 2, 2017
 
Rate this article
 
Views
3993

In the last article, we saw a very simple information about the Record Centre and we saw what template to be used to create the Record Centre Site.

Now, let us see how to configure the Record Centre.

1. Let us go to Site Contents. By default, we will be seeing a special document library called “Drop Off Library” and a default Library “Record Library”.

2. Now, let us create our Own Record Library.

clip_image002

clip_image004

3. Select the “Record Library” App and give a name to it.

clip_image006

4. In the meanwhile, create a Content Type based on our Requirement.

clip_image008

clip_image010

5. Add the Content type to the Record Library which we created now.

clip_image012

6. Now, Create sub folders on the Record Library.

clip_image014

clip_image016

7. I have created two folders for this demo.

8. Now go to Library Settings -> information Management Policy Settings.

clip_image018

clip_image019

9. Click on Change the Source.

clip_image021

10. Select “Library and Folder” Option and Click on OK.

clip_image023

11. Now, Click on “Change Source or configure library schedule”

clip_image025

12. Now, select the Folders on the Left Navigation.

clip_image027

clip_image029

13. Add the Retention Stages to the Folders by Click on “Add a retention stage for records..”

clip_image030

14. In the same manner repeat for the other folders as well.

clip_image032

15. Now, we need to create content organizer Rules.

16. Go to Site Settings.

clip_image034

17. Click on Content Organizer Rules.

clip_image036

18. Click on New Item.

clip_image038

clip_image040

You can select the Destination from the below PopUp.

clip_image041

19. Now, go back to our “Drop Off Library” and Upload any document with the Content Type “MyRecordCentreContentType”.

20. Once you Checkin the File, you will be seeing the below message.

clip_image042

21. i.e., the document uploaded on the Drop Off Library has been moved to the Folder1 based on the Content Organizer Rules which we created.

22. Now, let us go to our Folder to make sure that the document is there.

clip_image044

23. Yes, we have the document there. The document has been treated as Record.

24. There are few more conditions can be added on the Content Organizer Rules.

clip_image046

With this, we saw how to create a simple Record Centre for our Organization. There are many other features available on the Record Centre, which will be discussed on the upcoming articles.

Happy Coding,

Sathish Nadarajan.

Author Info

Sathish Nadarajan
 
Solution Architect
 
Rate this article
 
Sathish is a Microsoft MVP for SharePoint (Office Servers and Services) having 15+ years of experience in Microsoft Technologies. He holds a Masters Degree in Computer Aided Design and Business ...read more
 

Configure Windows Firewall for SQL Server Analysis Service (SSAS)

Ahamed Fazil Buhari
 
Senior Developer
November 21, 2016
 
Rate this article
 
Views
4701

Title: Configure Windows Firewall for SQL Server Analysis Service (SSAS)

In one of my previous article “Installation of SQL Server Analysis Service (SSAS) – SQL Server 2012”, in step 4 we had a warning ‘Windows Firewall’ when we install SSAS. In this article we’ll see how to rectify that warning.

1. Go to Start -> select ‘Windows Firewall with Advanced Security’.

clip_image001

2. Go ahead and create new Inbound Rule, if you notice that we already have ‘Allow Inbound 1433’ and this set up was happened when we initially installed our SQL Server on this machine.

clip_image003

3. But our SQL Server Analysis Services also needs to have a new port. For that click on Inbound Rule -> New Rule

clip_image005

4. New Inbound Rule Wizard window will populate and select Port for rule type and click Next

clip_image007

5. In Protocol and Ports steps, select TCP and specify the local ports value as 2383 (Note: port for SQL Server Analysis Service is 2383), we’re going to allow traffic through that port and click on Next.

clip_image009

6. Click on Next for Action, Profile steps as there are no changes.

clip_image011

7. Click on next

clip_image013

8. In final step, provide the Name and the Description (optional) and click on Finish

clip_image015

Now our SSAS will pass through the windows firewall.

clip_image017

Happy Coding

Ahamed

Category : SQL

Author Info

Ahamed Fazil Buhari
 
Senior Developer
 
Rate this article
 
Ahamed is a Senior Developer and he has very good experience in the field of Microsoft Technologies, especially SharePoint, Azure, M365, SPFx, .NET and client side scripting - JavaScript, TypeScript, ...read more
 

How to Configure Secure Store Service in SharePoint 2013 and Generate Secure Store Key

Ahamed Fazil Buhari
 
Senior Developer
October 11, 2016
 
Rate this article
 
Views
5341

Hi, welcome to my article on ‘How to configure secure store service in SharePoint 2013’. I have series of articles like this to show how to configure and use all of the Business Intelligence feature that SharePoint offers. I have lots of great stuff to share you through this article, let’s get started.

Let us go through some useful information on Secure Store Service from MSDN – “The Secure Store Service replaces the Microsoft Office SharePoint Server 2007 Single Sign On feature. Secure Store Service is a shared service that provides storage and mapping of credentials such as account names and passwords. It enables you to securely store data that provides credentials required for connecting to external systems and associating those credentials to a specific identity or group of identities.”

The Secure Store is normally part of the standard installation for SharePoint 2013. It is very important, it’ll give us that unattended service account for things like PerformancePoint, Excel Services, Visio services and so on.

In the below content you can find step by step approach to configure secure store service,

1. Go to Central Administration -> Manage service applications

clip_image001

2. Here I do not have secure store service. So I’m going to create new one, by selecting New (in top ribbon) -> Secure Store Service.

clip_image002

3. In Create New Secure Store Service Application window, give the service name, database server name and database name and I’m using Windows Authentication here,

clip_image004

4. Now select the already existing application pool or create new application pool for this, to keep things simple I was using the same application pool for the most of the service applications. Give the service application pools and the accounts the proper permissions in SQL. Maybe in production environment you may prefer separate service application pool, for various reasons like performance, security and so on.

clip_image006

5. I’ve used already registered Managed account for this service application, you can use your own managed account and then click OK.

clip_image008

6. Secure Store Service has been created.

clip_image010

7. Now we need to start the Secure Store Service on the server. For that, go to Central Admin -> System Settings -> Manage services on server

clip_image012

8. Click on Start.

clip_image014

To use Secure Store Service, we must generate an encryption key. The key is used to encrypt and decrypt the credentials that are stored in the Secure Store Service database.

1. To generate the key, go to Application Management -> Manage service application and click on newly created Secure Store Service. And click on Generate New Key button from the ribbon.

clip_image016

2. We need to create the pass phrase. The requirements for the key are that it must contain at least eight characters, in that eight characters it must contain at least three of the following four character groups -> uppercase alphabets, lowercase alphabets, numbers 0-9, and symbols (&, $, %, #, * and so on)

clip_image018

3. Red error has gone and it says there are no Secure Store Target Application

clip_image020

I’ll explain on how to create Target application and stuffs related to that in my upcoming articles.

Happy Coding

Ahamed

Category : SharePoint

Author Info

Ahamed Fazil Buhari
 
Senior Developer
 
Rate this article
 
Ahamed is a Senior Developer and he has very good experience in the field of Microsoft Technologies, especially SharePoint, Azure, M365, SPFx, .NET and client side scripting - JavaScript, TypeScript, ...read more
 

How to Read the values from Config File – PowerShell

Sathish Nadarajan
 
Solution Architect
May 14, 2016
 
Rate this article
 
Views
15167

Almost in all the PowerShell Scripts, either we will be reading the configuration values from CSV File or an XML file. Let us Keep the code clean to read the value from the XML File.

 function LoadConfigXML()
 {
     $Progress = "0:Entered"
     Write-Host "Entered into LoadConfigXML Method" -ForegroundColor Yellow 
     Add-Content "$ProgressFile" "Entered into LoadConfigXML Method"
     
     $ConfigXmlPath = $scriptBase + "Configuration.xml"
     
     [Xml]$Config = Get-Content $ConfigXmlPath  
     
     Write-Host "Finished LoadConfigXML Method" -ForegroundColor Green 
     Add-Content "$ProgressFile" "Finished LoadConfigXML Method"
     
     return $Config
     
     $Progress = "0:Success"
 }
 
 
 

From the main thread, we can call the below line.

# Load the Configuration File

$Config = LoadConfigXML

In the next article, let us see, how to segregate the PS1 files into small files and load them on the main file.

Happy Coding,

Sathish Nadarajan.

Category : PowerShell

Author Info

Sathish Nadarajan
 
Solution Architect
 
Rate this article
 
Sathish is a Microsoft MVP for SharePoint (Office Servers and Services) having 15+ years of experience in Microsoft Technologies. He holds a Masters Degree in Computer Aided Design and Business ...read more
 

How to Configure Workflow Manager in SharePoint 2013

Sathish Nadarajan
 
Solution Architect
April 20, 2016
 
Rate this article
 
Views
9237

I guess, this would be very late to write about the Workflows configuration by this time. Even, I created the workflows two years back. But, after sometime, when I try to configure in another server, I found it a bit difficult. Then, as usual, thought of having it handy.

The ultimate objective of this article is, from the designer, when I try to create a Workflow, on the Platform Type, I could not find the SharePoint 2013 workflow by default. Have a look on the below screen shot.

clip_image002

We want SharePoint 2013 Workflow should also be displayed on the dropdown. Now, the resolution for this can be a step by step procedure.

1. We need to install the web Platform Installer first. Download link – https://msdn.microsoft.com/en-us/library/jj193525.asp

2. Follow the Installation Link as shown below.

clip_image004

3. Install the Workflow Manager 1.0

clip_image006

clip_image008

clip_image010

clip_image012

clip_image014

4. Now, we need to configure the Workflow Manager.

clip_image016

clip_image017

clip_image018

clip_image019

clip_image020

clip_image021

clip_image022

5. Now the configuration completes as shown in the image.

clip_image023

6. Again, go to the Web Platform Installer.

clip_image025

7. Search for Service Bus 1.0 Cumulative Update 1

clip_image027

clip_image029

clip_image031

8. Install Workflow Manager 1.0 Cumulative Update 3 as well

clip_image033

clip_image035

clip_image037

9. Do an IISRESET

clip_image039

10. Make sure the new Site Workflow Management Site is been created on the IIS

clip_image041

11. Open the Management Shell and execute the below PowerShell Script.

Register-SPWorkflowService -SPSite "http://xxxx" -WorkflowHostUri "http://xxxx:12291" –AllowOAuthHttp

clip_image043

12. Now go back to the designer and we will be able to see the Platform Type as SharePoint 2013 Workflow.

clip_image045

Happy Coding,

Sathish Nadarajan.

Author Info

Sathish Nadarajan
 
Solution Architect
 
Rate this article
 
Sathish is a Microsoft MVP for SharePoint (Office Servers and Services) having 15+ years of experience in Microsoft Technologies. He holds a Masters Degree in Computer Aided Design and Business ...read more
 

Leave a comment