Connect to Dynamics CRM through CRM SDK using C#

There are many ways to connect to and access the database of Dynamics CRM database.

a- If you are creating plug-ins, custom workflow activities, or custom XAML workflows, use Dynamics 365 SDK assemblies

https://msdn.microsoft.com/en-us/library/jj602917.aspx?f=255&MSPPError=-2147217396#SDKAssemblies

b- If you are creating Windows applications for Dynamics 365, use XRM tooling assemblies. More information: .NET Development: Use XRM Tooling assemblies

https://msdn.microsoft.com/en-us/library/jj602917.aspx?f=255&MSPPError=-2147217396#XrmTooling

c- If you are creating non-Windows applications for Dynamics 365, use Web API. More information: Use the Microsoft Dynamics 365 Web API

https://msdn.microsoft.com/en-us/library/mt593051.aspx

The way we will see in this article is to connect through CRM SDK and get the connection Service Proxy object.

In web.config file, add the following entry that carrys the connection string for CRM.

<add key=”XrmConnection” value=”Url=https://crm.domainname.com; Username={0}; password={1}” />

Add reference to following Dll’s

CRM SDK Reference

/// <summary>
/// Method globally used to return a CRM Service Proxy Object, which will be used to make futher calls to CRM.
/// </summary>
/// <param name=”userName”></param>
/// <param name=”password”></param>
/// <returns></returns>
private OrganizationService GetCRMService(string userName, string password)
{
try
{
CrmConnection connection =
CrmConnection.Parse(string.Format(ConfigurationManager.AppSettings[“XrmConnection”], userName, password));
OrganizationService orgService = new OrganizationService(connection);
return orgService;
}
catch (Exception ex)
{
return null;
}
}

This method will return the OrganizationService Proxy object that we can use later to fetch the data from Dynamics CRM Entities.

But before doing this we need to Authenticate and Authorise the user. There are two cases, one in which our application does not require the user to see his personalised content, instead the application is a reporting app, or a generic application for all the users of the organisation. In that case, we can fix the username and password for the master user account in web.config file. Make sure that user have enough previledges requried for the application to run.

In other case, if each user has to login into the application and perform his own activities, in that case above method of connection string and accessing through the metho

ASP.NET Core 2 Preview 1

ASP.NET Core 2.0.0-preview1

The next full version of ASP.NET Core is on its way, and developers who have been following along on the ASP.NET GitHub repositories have been very vocal about their interest in the new features in this version.  Some of these new features include:

  • A new ASP.NET Core meta-package that includes all features that you need to build an application. No longer do you need to pick and choose individual ASP.NET Core features in separate packages as all features are now included in a Microsoft.AspNetCore.All package in the default templates. If there are features you don’t need in your application, our new package trimming features will exclude those binaries in your published application output by default.
  • A new default Web Host configuration, codifying the typical defaults of the web host with the WebHost.CreateDefaultBuilder() API. This adds Kestrel, IIS configuration, default configuration sources, logging providers, and the content root.
  • Updated configuration and simplified logging. We have enhanced the LoggerFactory object to easily support a Dictionary<string, LogLevel> that defines log filters instead of a FilterLoggerSettings object, making it simpler to control the source and level of logs that get propagated from your application to your configured log providers.
  • Create pages without controllers in ASP.NET Core with the new RazorPages capabilities.  Just create a Pages folder and drop in a cshtml file with the new @page directive to get started.
  • Debugging your application in the cloud is easier than ever with integrated Azure Application Insights and diagnostics when debugging in Visual Studio and after deploying to Azure App Service.
  • A newly revamped authentication model that makes it easy to configure authentication for your application using DI.
  • New templates for configuring authentication for your web apps and web APIs using Azure AD B2C
  • New support in ASP.NET Core Identity for providing identity as a service. Updated templates decouple your apps from their identity concerns standard protocols (OpenID Connect, OAuth 2.0). Easily migrate apps using ASP.NET Core Identity for authentication to use Azure AD B2C or any other OpenID Connect compliant identity provider.
  • Build secure web APIs using ASP.NET Core Identity. Acquire access tokens for accessing your web APIs using the Microsoft Authentication Library (MSAL)
  • NET Core has always helped HTMLEncode your content by default, but with the new version we’re taking an extra step to help prevent cross-site request forgery (XSRF) attacks: ASP.NET Core will now emit anti-forgery tokens by default and validate them on form POST actions and pages without extra configuration.

For a full list of changes see the release notes.

“Open Source PostgreSQL on Microsoft Azure” meetup in Islamabad

Microsoft has partnered up with the PostgreSQL Special Interest Group in Islamabad to bring you “Open Source PostgreSQL on the Cloud” on 23rd September, 2016! The session has been delivered by Mr. Ali Sufyan Butt, a Microsoft Most Valuable Professional on Visual Studio and Development Technologies.

Agenda

  • Introduction to Azure & its features
  • Deploy a Ubuntu Linux VM on Azure
  • Install and configure PostgreSQL on Ubuntu Linux Server hosted on Azure
  • Build a quick demo Asp.net app and connect it through the database using EF 6.0 drivers for PostgreSQL
  • Deploy the website on Azure

Mr. Corton Privacy Policy

Personal information

This application does not collect or transmit any user’s personally identifiable information. No personal information is used, stored, secured or disclosed by services this application works with.

Technical information

No technical information is sent (such as IP addresses included in the HTTP calls the application makes) neither of that is used or stored.

Communication

  • The communication made with the app in either text or voice is not stored anywhere in any form, all speech processing is done locally, only send the message to server to send back the response.

Third parties

If the app makes use of third party services, their usage of information is excluded from this privacy policy. You will be clearly made aware of the third parties involved in the app and we will ensure the very minimal set of data is set to those third parties. The third party is our AI engine which processes the sound and sends back the text.

Report violations or get more information

If you would like to report any violations of this policy or get more information on any app, please contact us by emailing at alisufyanbutt@hotmail.com.

This is just a virtual friend, any association or personal attachment to it is not our responsibility, please do not take the responses seriously, it might be not what you like, but we made sure they would be not vulgar, offensive and indecent.

NDepend is something we can depend on

Ndepend is a tool which I am really excited to review at last. I had a long time commitment with NDepend team but I for some reasons I had been too busy in other stuff that I really missed it, But I have not forgotten it at all and been using the tool and had great benefits which I want to share with you guys.

After downloading the tool, it is fairly easy to configure the extension with Visual Studio as well as we can also use Visual NDepend tool to visually analyze the solution or assemblies.

For first timers, this link can help to install and configure http://www.ndepend.com/docs/getting-started-with-ndepend

After running this tool for the first time, I scanned my project and viola, I was in deep trouble, just kidding, I mean I got a detail report of issue with my code, code metrics, dependency graphs, Dependency Matrix and a long list of rules violated in the code. This was really a great thing to see and I immediately started to work on making the mistakes right.

NDepend is giving me insights into my code that we normally ignore, but keep following through the standards and after a few iterations with NDepend, it was all sweet code. All thanks to NDepend tooling and support.