Tuesday 28 February 2017

DYNAMICS 365 DEVELOPER TOOLKIT FOR VISUAL STUDIO 2013

Requirements

1)Visual studio 2013

2) Dynamics 365 SDK

3) Microsoft Dynamics 365 developer toolkit download

https://visualstudiogallery.msdn.microsoft.com/65199277-820a-4315-8783-82da19bd04d8/viewReviews/Reviews

4) Dynamics 365 instance.



To install the developer toolkit, download the developer toolkit for visual studio 2013 and open the visual studio select the new project and select the dynamics 365  then plugin library.

After following the steps on the plugin registration tool, it prompts for visual studio > tools > options> dynamics developer toolkit > then map the plugin registration tool and bin directory from the dynamics 365 sdk.

That's it you are good to go...


Friday 17 February 2017

Dynamics 365

Dynamics 365

Intelligence business applications in the cloud


> SALES > CUSTOMER SERVICE > OPERATIONS > MARKETING >FIELD SERVICE > PROJECT SERVICE AUTOMATION

OFFICE 365 | AZURE IOT |POWER BI | CORTANA INTELLIGENCE


Digital Transformation


>Engage your customers

> Empower your employees

> Transform your products


> Optimize your operations

ODATA RESOURCES PATH EXAMPLES

OData Resource Path Examples


Resource                                                       URL
Service                                  OrganizationData.svc

Entity Set                              OrgainzationData.svc/ContactSet

Entity                                    OrgainzationData.svc/ContactSet("guid")

Relationship                          OrgainzationData.svc/ContactSet ("guid")/Contact_Appointments                                                              

Property                                OrgainzationData.svc/ContactSet("guid")/FirstName
                                             

Mulitple Properties               OrgainzationData.svc/ContactSet("guid Key")?$Select =                                                                 FirstName, Address1_City                                           

HANDLING EXCEPTIONS IN MICROSOFT DYNAMICS CRM PLUG-INS

Handling faults


Required reference in your code

 Use Microsoft.Xrm.Sdk.OrganizationServiceFault
  catch(FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault> ex)


other Common exceptions and faults to handle


System.TimeoutException

 catch(System.TimeoutException ex)

System.Exception

 catch(System.Exception ex)


Other exceptions and faults to handle

 -securityTokenValidationException
 -ExpiredSecurityTokenException
 -SecurityAccessDeniedException
 -MessageSecurityException
 -SecurityNegotiationException

Microsoft Dynamics CRM Online
  SecurityAccessDeniedException : Using a valid Microsoft Account, but it is not associated with a CRM Online Organization.

MessageSecutiyException: Your Microsoft Account is not valid or did not authenticate.

Thursday 16 February 2017

JAVASCRIPT EVENTS IN MICROSOFT DYNAMICS CRM


Form and field events


--OnLoad
--OnSave
--OnChange
--TabStateChange
--OnReadyState
--PreSearch
--OnStageChange
--OnStageSelected

STEPS TO MODIFY NAVIGATION BY EDITING THE XML

STEPS TO MODIFY NAVIGATION BY EDITING THE XML


1.Create a new solution

2.Add the site map to the new solution

3.Export the new solution

4.Extract the .ZIP file

5.Open the customization .xml file

6.Locate the Site Map node

7.Edit the map and save

8. Add modified .XML back to .ZIP file

9.Import the solution file

10. Publish the customizations

XRMTOOLBOX is the microsoft recommended tool for site map or if you are capable of editing and modifying the xml then OOB is the better option.

I hope this help someone cheers..

SOLUTIONS IN MICROSOFT DYNAMICS CRM

Solutions overview


Solutions are used to package..
  Entity & schema customizations
  Plugins processes, workflow activities
  Web resources, navigations, visualizations
  Template,security, reports

Example of developers use solutions:
  Develop a solution for credit scroing:
      Entity customizations
      Custom workflow activities
      Client side scripts

Two types: Managed and UnManaged

SOLUTION COMPONENTS:

ENTITIES:
Attributes
Forms
Views
Charts/Visualizations
Relationships
Hierarchy Settings


GLOBAL OPTION SETS
Web Resources
  Javascripts

Dashboards
Ribbons
SiteMap

Workflow Definitions
Dialog Definitions
Business Custom Activities
Plug-ins (Assemblies and Steps)
Service Endpoints

TEMPLATES
System settings
Security Roles
Connection Roles
Field Level Security Profiles
Routing & Case Creation Rules
SLA's
Reports


Default Solution vs Custom Solution:

-Default solution is everything
-Default publisher prefix is new_(should set to something different)


Creating custom solutions early on is a good idea:
 -Recommended to specify a different publisher other than default.

  -Custom solutions can be exported
  -Either as unmanaged or managed

EXTENDING DYNAMICS CRM IMPORTANT CONCEPTS

Review


Navigation and Command Bar-Customization
Form event scripting
Web resources
Working with services
Querying CRM data
Using the Rest OData endpoint
Plug-ins
Custom workflow activities


CONFIGURE , CUSTOMIZE AND EXTEND

Configure: System Settings, Security Settings, Email Configuration, Data Management.


Customize: Schema Changes, Form & View Chnages, Visualizations, Solutions , Processes

Extend: Client Scripting, Navigation, Plug-ins, Workflow Activities, Integration


BUILT - IN FUNCTIONALITY

Before you start designing you won custom items to extend the application consider the built-in options available.

.Processes Tracking & Automation
  -Workflows, Dialogs, Business Process Flows, Custom Actions

.Client Side Customizations:
   -Business Rules, Rollup fileds, Calculated Fields, etc.

.Additional Funtionality:
 -Product Catalog, Case Management, Service Management.


EXTENDING CRM

CLIENT
-Navigation & Commanding
-Client Scripting
-Custom User Interfaces

SERVER
-Plug-ins
-Custom Workflow Activities
-Custom Actions

INTEGRATION
-3rd Party Applications
-Remote Plug-in Execution
-Power BI 
-Sharepoint


NAVIGATION AND COMMANDING

.SITE MAP: Used to control application navigation
 - Navigation Elements can be added, edited and Removed as needed.

-COMMAND BAR: Display actions and commands that are available
 - Can Add, Remove, and Edit.

URL ADDRESSABLE FORMS: Access CRM forms and lists directly through their URL.



API DRIVEN SCRIPTING

-Allows for enhanced functionality & flexibility on forms

- calculated fields, formatting, data validations etc.

Scripts can be associated to events at a form and fileds levels
 - Onload, Onsave, Onchange, TabStateChange etc..

-Script Libraries are used for easier deployment and availability

-Business rules provide simple business at the field level.
 -Don't require uploading of custom scripts
 - Can be created by non - developer
 -Traditional client javascript can focus on more complex tasks
 -Can run on the server also.


CUSTOM USER INTERFACES WITH WEB RESOURCES

- Stored in CRM as solution components
-Exported to any CRM deployment
-AVailable in Outlook with offline access

Types:
-Javascript
-HTML Web Page
-Images(PNG, JPG, GIF, ICO)
-Style Sheets (CSS and XML)
Sliverlight


BUILDING SERVER SIDE EXTENSIONS

-Organization service API provides data and service request execution
-Rich event model allows for triggering custom code using plg-ins
-Custom worklfow activities allow custom code to execute from declarative workflows.
-Custom actions allow defining custom messages that are callable from code but the implementation is defined declaratively.


--------------------------------------------------------------------------------------------------------------------------

WORKING WITH DATA AND SERVICES

-REST endpoint for working with data
-SOAP endpoint allows full message execution

Task                                                                                               Web Service
create, Retrieve, Update and Delete records                 SOAP OR REST ENDPOINT
Associate and Disassociate records                                SOAP OR REST ENDPOINT
Assign Records                                                                 SOAP ENDPOINT
Retrieve Metadata                                                           SOAP ENDPOINT
Execute Messages and anything else                              SOAP ENDPOINT

--------------------------------------------------------------------------------------------------------------------------

THE EVENT MODEL

Create Request
      |
Pre-Operation Events
     |
Platform Operation
     |
Post-Operation Events
     |
Create Response

=============

API access for CRM metadata and deployment services

-Working with metadata
  - Provides support for querying and dynamic discovery of values
  - Creating /Changing
  -Example - add entity and add attributes etc
  -Example- I need the labels for an option set converted to the current                     users language settings

-Working with deployment services
 -Create /Manage organizations, servers, licenses, etc.

-Discovery service
  - Determine organization a user belongs to and endpoint URL for each organization


------------
Plug-ins
-.Net assemblies
-Can be triggered off multiple messages events
-Can run a different stages
-On-Premises and Online
-Offline and server execution options


Custom workflows activities
-.Net Assemblies
-Building blocks for composable custom code
-Can be used by workflows or dialogs
-Support all deployments types by allowing execution in sandbox

=============

CUSTOM ACTIONS

Custom actions are multi -step declarative custom logic that can be invoked via API calls

-Example -Schedule, Escalate, Route Lead

-Actions are a new type of processes that allows specification of input and ouput parameters

-Actions can be called from code

Can also be called from workflows or dialogs

-Execution is always synchronous

======================

Integration

-Unified Service Desk
-Azure Active Directory
-Azure Service Bus
-Portals and other custom user experiences

Unified Service Desk:
Windows Desktop App that loads an agent desktop experience
Agent desktop configured vai CRM entities that define how the components are presented and intreacted with

Developers can further extend beyond configuration using the UII framework directly.

------------------------------------------------------------------------------------------------------------------------
Azure Active Directory: 

 Standalone Cloud Directory
 Provide authentication for CRM Online

Provide support for integration with on-premises

Provides API support


Azure Service Bus:
 Works with Dynamics CRM'S Async service to offload work from CRM
  Secure integration with 3rd parties

MULTI TENANT DEPLOYMENT

 -Multi - Tenant uses:
-Hosting company providing dynamics CRM for multiple customers
-Separate organization undera single holding company
-Separate organizations for development, testing, production, etc in a single deployment.

example:
A. Single Tenant, Single Instance(one database)

B.Multi Tenant, Shared Deployment(One database, one server)

C.Multi Instance, Multi Deployment(two databases, two servers

Wednesday 15 February 2017

LEARN MORE FROM MICROSOFT DYNAMICS CRM SDK

Learn More from the SDK



Other Examples from the SDK


--Add Activity
--Auto Route Lead
--Date Checker
--Distance Calculator
--Post URL.


 Workflow Activities


Custom Worklfow Activities make good building blocks to allow non-developers to do custom code in workflows

CRM Developer Toolkit provides a streamlined approach to building Custom Workflow Activities

MICROSOFT DYNAMICS CRM WORKFLOW ACTIVITY.


CUSTOM WORKFLOW ACTIVITIES


-Allows building custom steps that are available for use in the web workflow designer.

-Built on Windows Worklfow Foundation V4.

-Work for on-premise and CRM online deployments

- Can be used in workflows or dialogs.

--------------------------------------------------------------------------------------------------------------------------

Overview of CRM Workflows


-- Rule: Define the logic that is executed when a specific triggering event occurs on a record.

-- Events: Assign, Attributes Chnage(Update), Change Status, Create, Delete and On Demand

--Conditions: Check values to provide rules for what actions to perform.

--Actions: Create Record, Update Record, Assign Record, Send Email, Start Child Workflow, Change Status, Stop Workflow

--------------------------------------------------------------------------------------------------------------------------

OVERVIEW OF CRM DIALOGS


-Input Arguments: Data that is passed from  a parent dialog.

-Variable: Store intermediate values as users move through the dialog.

-Pages: Provides the body of the dialog by adding prompts and responses

-Prompts & Responses: Poses a question to a user and captures the response.

-Actions & Conditions: Checks values and performs specifics tasks.

--------------------------------------------------------------------------------------------------------
WORKFLOW EXECUTION WITH CUSTOM ACTIVITIES

   Workflow
 step1 -Check Condition
 step2 - Update Record
 step3 -Your Custom Activity

--------------------------------------------------------------------------------------------------------------------------

CUSTOM ACTIVITY SCENARIOS


-Complex calculation

-Performing actions on child records

-Pull a customer's credit score from a 3rd party to be used for loan approval

-Any Integration with other systems called on demand.

- Any scenario where you want to surface custom code in the CRM workflow editor.





CUSTOM WORKFLOW ACTIVITY CLASS DIAGRAM


Without Developer Toolkit

--CodeActivity Class

--Your Custom Class

--code example:

public sealed partial class CustomActivity : CodeActivity
{
   protected override void Execute(CodeActivityContext executionContext)
{

}
}




With Developer Toolkit


--CodeActivity Class

--WorkflowActivityBase Class

--Your Custom Class

--code example:

public sealed partial class CustomActivity : CodeActivity
{
public override void ExecuteCRMWorkflowActivity(CodeActivityContext executeContext, LocalWorkflowContext crmWorkflowContext)
{

}
}

--------------------------------------------------------------------------------------------------------------------------

WORKING WITH PARAMETERS


-Used to configure a workflow activity
- Exposed via the worklfow editor

-CRM supports two types
   -- input and ouput

--Values are populated at time of execution of cutom activity

The DefaultAttribute class allows you to specify a default value for an input parameters

Declaring Parameters

[RequiredArguments]
[Input("InputEntity")]                    -------------1
[ReferenceTarget("account")]

public InArgument<EntityReference> inputEntity {get; set;}
[Output ("TaskCreated")]
[ReferenceTarget("task")]            -----------------2

public OutArgument<EntityReference> taskCreated  {get; set;} -----3

protected override void Execute(CodeActivityContext executeContext )
{

}

--------------------------------------------------------------------------------------------------------------------------

Getting and Setting Parameters Values


Setting and getting values must is done using the Set/Get methods and referencing the execution context

Guid accountId = this.inputEntity.Get(executionContext).Id;

this.taskCreated.Set(executionContext, new EntityReference("task", taskId));



-------------------------------------------------------------------------------------------------------------------------

Working with services


The Workflow ExecutionContext.GetExtension method provides access to the CRM services like

--Organization Service

--Tracing Service

IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();

IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();

IOrganizationService service = serviceFactor createOrganizationService(context.UserId);





Working with Services using Developer Toolkit


public class CustomWorkflowActivity : WorkflowActivityBase
{
    public override void ExecuteCRMWorkflowActivity(CodeActivityContect executionContext, LocalWorklfowContext crmWorkflowContext)
{
     crmWorkflowContext.Trace("Plug-in is Starting");

var  whoamiResult  = crmWorkflowContext.OrganizationService.Execute(new WhoAmIRequest());
}
}
























DYNAMICS CRM ONLINE UPDATE 1 TRACING SUPPORT

DYNAMICS CRM ONLINE UPDATE 1 TRACING SUPPORT


-TRACE PLUG-IN LOG CAN WRITE RUN-TIME INFORMATION ON PLUG-INS
USING THE ITRACINGSERVICE.

Trace records can be viewed through web application 
-Setting -Plug-in Trace Log Tile

To Enable the trace logging feature

Option                                                        Description
-Off          -Writing to the trace log is disabled. No PluginTraceLog records will be created(Custom                                             Code can still the Trace Method even though no log is written)

-Exceptions        -Trace information is written to the log if an exception is passed back to the platform                               from custom code.

-All                  -Trace information is written to the log upon code completion or exception is passed back to the platform from custom code

PLUG-INS TRACING AND DEBUGGING - ON PREMISES


Tracing  and Debugging plug-ins --On-Premises


-Register and deploy the plug-in assembly.(Disk)

-Configure the debugger

Plugin Registration Configuration                      Service Process

-Running the application in onlinemode              -w3wp.exe

-Running the application in offlinemode              -Microsoft.Crm.Application.Hoster.exe
                                              
-Asynchronous registered plug-ins                        -CrmAsyncService.exe

-Sandbox(isolation mode)                                       -Microsoft.Crm.Sandbox.WorkerProcess.exe                               

Tuesday 14 February 2017

MICROSOFT DYNAMICS CRM TRANSACTION SUPPORT

TRANSACTION SUPPORT 



-CRM stages suport plug-in execution inside the database transcation

-Stages 20 Pre-Operation & 40 Post - Operation

-Uncaught exceptions force a rollback

-IExecution Context is in Transcation

-Transaction spans CRM DB operations only 

- No distributed transcation support.

SANDBOX PLUG-INS RESTRICTIONS

MICROSOFT DYNAMICS CRM SANDBOX PLUG-INS RESTRICTIONS


- Only HTTP and HTTPS protocols are allowed

- Access to localhost (loopback) is not permitted

- IP addresses cannot be used. (Plug-ins must use a named web addresss that requires DNS resolution)

-Anonymous authentication is supported and recommended. No provision for prompting for credentails or saving credentails.

SANDBOX PLUG-IN ARCHITECTURE IN MS CRM

MICROSOFT DYNAMICS CRM SANDBOX PLUG-IN ARCHITECTURE


Sandbox Architecture

--Has its own separate processing service

--Executes in partial trust with restrictions

--Allows for multiple process servers

--Plug-ins executing in the sandbox have a two minute limit.

MICROSOFT DYNAMICS CRM PLUG-IN REGISTRATION WAYS



PLUG-IN REGISTRATION 




Plugin -ins can be deployed to a CRM environment in mulitple ways:


1) Plug-in registration tool

2) Programmatically 
  - Using PluginAssembly, PluginType 
    SdkMessageProcessingStep, and 
    SdkMessageProcessingStepImage

3) By using the developer tools

-----------------------------------------------------------------------------------------------------------------------

Plugin Isolation##



Trusts

Full : Plug-ins registration outside of the sandbox
 -on-premise
-W3wp.exe

Partial: Registration inside of the sandbox
 -On-Premise & CRM Online

 - Microsoft.crm.Sandbox.WorkerProcess.exe

Monday 13 February 2017

PLUG-IN ARCHITECTURE

Exploring plug - in architecture

-------------------------------------------------------------------------------------------------------------------------

Event Execution Pipeline


Input/Output Parameters


Pre/Post Images


Isolation: Sandbox/Full Trust


Transcation Scope

Saturday 11 February 2017

MICROSOFT DYNAMICS CRM COMMUNITY RESOURCES

Community Resources 


Toolbox for Dynamics CRM - Site Map Editor


http://xrmtoolbox.com

Pragma Toolkit - Ribbon and Site Map Editor


http://pragmatoolkit.codeplex.com

CRM Solution Manager Site Map Editor

http://crmsolutionmanager.com

Xrm.Tools Visual Site Map Editor

http://Xrm.Tools

Friday 10 February 2017

SORT A LIST OF SIMPLE TYPES IN C#

using System;
using System.Text;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace ConsoleApplication4
{
    public class MainClass
    {
        public static void Main()
        {

            List<int> numbers = new List<int>() { 1, 9, 12, 8, 6, 3 };
            Console.WriteLine("Numbers before sorting");
            foreach(int number in numbers)
            {
                Console.WriteLine(number);
                Console.ReadLine();
            }
            numbers.Sort();

           
            Console.WriteLine("Numbers after sorting");
            foreach (int number in numbers)
            {
                Console.WriteLine(number);
                Console.ReadLine();
            }

            numbers.Reverse();
            Console.WriteLine("Numbers in descending order");
            foreach (int number in numbers)
            {
                Console.WriteLine(number);
                Console.ReadLine();
            }

            List<string> alphabets = new List<string>() { "B", "F", "D", "E", "A", "C" };
            Console.WriteLine("Alphabets before sorting");
            foreach (string alphabet in alphabets)
            {
                Console.WriteLine(alphabet);
                Console.ReadLine();
            }
            alphabets.Sort();

            Console.WriteLine("Alphabets after sorting");
            foreach (string alphabet in alphabets)
            {
                Console.WriteLine(alphabet);
                Console.ReadLine();
            }

            alphabets.Reverse();

            Console.WriteLine("Alphabets in descending order ");
            foreach (string alphabet in alphabets)
            {
                Console.WriteLine(alphabet);
                Console.ReadLine();
            }
            Customer Customer1 = new Customer()
            {
                ID = 101,
                Name = "Malla",
                Salary = 5000
            };
            Customer Customer2 = new Customer()
            {
                ID = 102,
                Name = "Mark",
                Salary = 7000
            };

            Customer Customer3 = new Customer()
            {
                ID = 119,
                Name = "Mla",
                Salary = 5500
            };
        }

      public class Customer
      {
          public int ID { get; set; }
          public string Name { get; set; }
          public int Salary { get; set; }
      }
    }
}

   

LIST COLLECTION CLASS IN C#

List Collection class in C#

List is one of the generic collection classes present in system.collection.generic namespace.

There are several generic collection classes in system.collection.generic namespace as listed below.

1. Dictionary 
2.List
3.Stack
4.Queue etc

A List class can be used to create a collection of any type.

For example, we can create a list of integers,strings  and even complex types.

The objects stored in the list can be accessed by index.

This class also provides methods to search, sort, and manipulate lists.



using System;
using System.Text;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace ConsoleApplication4
{
    public class MainClass
    {
        public static void Main()
        {
            Customer Customer1 = new Customer()
            {
                ID = 101,
                Name = "Malla",
                Salary = 5000
            };
            Customer Customer2 = new Customer()
            {
                ID = 102,
                Name = "Mark",
                Salary = 5000
            };

            Customer Customer3 = new Customer()
            {
                ID = 119,
                Name = "Mla",
                Salary = 5000
            };

            List<Customer> customers = new List<Customer>(2);
            customers.Add(Customer1);
            customers.Add(Customer2);
            customers.Add(Customer3);

            for (int i = 0; i < customers.Count; i++)
            {
             Customer c = customers[i];
             Console.WriteLine("ID = {0}, Name = {1},Salary = {2}", c.ID, c.Name, c.Salary);
             Console.ReadLine(); 
            }

            //foreach (Customer c in customers)
            //{
            // Console.WriteLine("ID = {0}, Name = {1},Salary = {2}", c.ID, c.Name, c.Salary);
            // Console.ReadLine(); 
            //}
            
          
           
        }

      public class Customer
      {
          public int ID { get; set; }
          public string Name { get; set; }
          public int Salary { get; set; }
      }
    }

}


   =====================================================================

 customers.Insert(0, Customer3);

            foreach(Customer c in customers)
            {
                Console.WriteLine(c.ID);
                Console.ReadLine();
            }

 ====================================================================

using System;
using System.Text;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace ConsoleApplication4
{
    public class MainClass
    {
        public static void Main()
        {
            Customer Customer1 = new Customer()
            {
                ID = 101,
                Name = "Malla",
                Salary = 5000
            };
            Customer Customer2 = new Customer()
            {
                ID = 102,
                Name = "Mark",
                Salary = 5000
            };

            Customer Customer3 = new Customer()
            {
                ID = 119,
                Name = "Mla",
                Salary = 5000
            };

            List<Customer> customers = new List<Customer>(2);
            customers.Add(Customer1);
            customers.Add(Customer2);
            customers.Add(Customer3);
            customers.Insert(0, Customer3);

            Console.WriteLine(customers.IndexOf(Customer3,1,3));
            Console.ReadLine();
        }

      public class Customer
      {
          public int ID { get; set; }
          public string Name { get; set; }
          public int Salary { get; set; }
      }
    }

}
=======================================================================
1. Contains() function- Checks if an item exists in the list.This method returns true if the item exists, else false.


2.Exists() function-Checks if an item exists in the list based on a condition. This method returns    true if the items exists, else false.

3.Find() function - Searches for an element that matches the conditions defined by the specified    lambda expression and returns the first matching item from the list.

4. FindLast() function-Searches for an element that matches the conditions defined by the         specified lambda expression and returns the last matching item from the list.


5. FindAll() function-Returns all the items from the list that match the conditions specified by the lambda expression.



6.FindIndex() function- Returns the index of the first item, that matches the condition specified by the lambda expression. There are 2 other overloads of this method which allows us to specify the range of elements to search, with in the list.

7.FindLastIndex() function-Returns the index of the last item, that matches the condition specified by the lambda expression. There are 2 other overloads of this method which allows us to specify the range of elements to search, with in the list.

Convert an array to a List - Use ToList() method

Convert a list to an array - Use ToArray() method


Convert a List to a Dictionary - Use ToDictionary() method


using System;
using System.Text;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace ConsoleApplication4
{
    public class MainClass
    {
        public static void Main()
        {
            Customer Customer1 = new Customer()
            {
                ID = 101,
                Name = "Malla",
                Salary = 5000
            };
            Customer Customer2 = new Customer()
            {
                ID = 102,
                Name = "Mark",
                Salary = 5000
            };

            Customer Customer3 = new Customer()
            {
                ID = 119,
                Name = "Mla",
                Salary = 5000
            };

            List<Customer> listcustomers = new List<Customer>(2);
            listcustomers.Add(Customer1);
            listcustomers.Add(Customer2);
           
            if(listcustomers.Contains(Customer3))
            {
                Console.WriteLine("Customers3 object exists in the lsit");
                Console.ReadLine();
            }
            else
            {
                Console.WriteLine("Customer3 object does not exist in the list");
                Console.ReadLine();          
            }
            
        }

      public class Customer
      {
          public int ID { get; set; }
          public string Name { get; set; }
          public int Salary { get; set; }
      }
    }

}


   

   =====================================================================
using System;
using System.Text;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace ConsoleApplication4
{
    public class MainClass
    {
        public static void Main()
        {
            Customer Customer1 = new Customer()
            {
                ID = 101,
                Name = "Malla",
                Salary = 5000
            };
            Customer Customer2 = new Customer()
            {
                ID = 102,
                Name = "Mark",
                Salary = 5000
            };

            Customer Customer3 = new Customer()
            {
                ID = 119,
                Name = "Mla",
                Salary = 5000
            };

            List<Customer> listcustomers = new List<Customer>(2);
            listcustomers.Add(Customer1);
            listcustomers.Add(Customer2);
            listcustomers.Add(Customer3);
           
            if(listcustomers.Exists(cust => cust.Name.StartsWith("Z")))
            {
                Console.WriteLine("Customers3 object exists in the list");
                Console.ReadLine();
            }
            else
            {
                Console.WriteLine("Customer3 object does not exist in the list");
                Console.ReadLine();          
            }
        }

      public class Customer
      {
          public int ID { get; set; }
          public string Name { get; set; }
          public int Salary { get; set; }
      }
    }

}


   ---------------------------------------------------------------------------------------------------------------------
using System;
using System.Text;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace ConsoleApplication4
{
    public class MainClass
    {
        public static void Main()
        {
            Customer Customer1 = new Customer()
            {
                ID = 101,
                Name = "Malla",
                Salary = 5000
            };
            Customer Customer2 = new Customer()
            {
                ID = 102,
                Name = "Mark",
                Salary = 7000
            };

            Customer Customer3 = new Customer()
            {
                ID = 119,
                Name = "Mla",
                Salary = 5500
            };

            List<Customer> listcustomers = new List<Customer>(2);
            listcustomers.Add(Customer1);
            listcustomers.Add(Customer2);
            listcustomers.Add(Customer3);

            Customer c = listcustomers.Find(cust => cust.Salary > 5000);
           //  Customer c = listcustomers.FindLast(cust => cust.Salary > 5000);
            Console.WriteLine("ID={0},Name = {1},Salary = {2}", c.ID, c.Name, c.Salary);
            Console.ReadLine();
  
        }

      public class Customer
      {
          public int ID { get; set; }
          public string Name { get; set; }
          public int Salary { get; set; }
      }
    }

}


   =======================================================================
using System;
using System.Text;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace ConsoleApplication4
{
    public class MainClass
    {
        public static void Main()
        {
            Customer Customer1 = new Customer()
            {
                ID = 101,
                Name = "Malla",
                Salary = 5000
            };
            Customer Customer2 = new Customer()
            {
                ID = 102,
                Name = "Mark",
                Salary = 7000
            };

            Customer Customer3 = new Customer()
            {
                ID = 119,
                Name = "Mla",
                Salary = 5500
            };

            List<Customer> listcustomers = new List<Customer>(2);
            listcustomers.Add(Customer1);
            listcustomers.Add(Customer2);
            listcustomers.Add(Customer3);

            List<Customer> customers = listcustomers.FindAll(cust => cust.Salary > 5000);
            foreach (Customer c in customers)
            {
                Console.WriteLine("ID={0},Name = {1},Salary = {2}", c.ID, c.Name, c.Salary);
                Console.ReadLine();
            }
       
        }

      public class Customer
      {
          public int ID { get; set; }
          public string Name { get; set; }
          public int Salary { get; set; }
      }
    }

}


   

Thursday 9 February 2017

Wednesday 8 February 2017

DICTIONARY IN C#

1.A dictionary is a collection of(Key.value)pairs
2.Dictionary class is present in System.Collection.Generic namespace.
3.When creating s dictionary , we need to specify the type for key and value.
4.Dictionary provides fast lookups for values using keys.
5.Keys in the dictionary must be unique.


using System;
using System.Text;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace ConsoleApplication4
{
    public class MainClass
    {
        public static void Main()
        {
            Customer Customer1 = new Customer()
            {
                ID = 101,
                Name = "Malla",
                Salary = 5000
            };
            Customer Customer2 = new Customer()
            {
                ID = 102,
                Name = "Mark",
                Salary = 5000
            };

            Customer Customer3 = new Customer()
            {
                ID = 119,
                Name = "Mla",
                Salary = 5000
            };

            Dictionary<int, Customer> dictionaryCustomer = new Dictionary<int, Customer>();
            dictionaryCustomer.Add(Customer1.ID, Customer1);
            dictionaryCustomer.Add(Customer2.ID, Customer2);
            dictionaryCustomer.Add(Customer3.ID, Customer3);

            Customer Customer119 = dictionaryCustomer[119];
          foreach(KeyValuePair<int,Customer> customerkeyValuePair in dictionaryCustomer)
          {
              Console.WriteLine("Key = {0}", customerkeyValuePair.Key);
              Customer cust = customerkeyValuePair.Value;
              Console.WriteLine("ID ={0}, Name ={1},Salary = {2}", cust.ID, cust.Name, cust.Salary);
              Console.WriteLine("-----------------------------------");
              Console.ReadLine();

          }
            Console.ReadLine();
        }

      public class Customer
      {
          public int ID { get; set; }
          public string Name { get; set; }
          public int Salary { get; set; }
      }
    }

}
=================================================================
Methods of dictionary class
1. TryGetValue()
2.Count()
3.Remove()
4.Clear()
5.Using LINQ extension methods with Dictionary

6.Different ways to convert an array into a dictionary.


using System;
using System.Text;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace ConsoleApplication4
{
    public class MainClass
    {
        public static void Main()
        {
            Customer Customer1 = new Customer()
            {
                ID = 101,
                Name = "Malla",
                Salary = 5000
            };
            Customer Customer2 = new Customer()
            {
                ID = 102,
                Name = "Mark",
                Salary = 5000
            };

            Customer Customer3 = new Customer()
            {
                ID = 119,
                Name = "Mla",
                Salary = 5000
            };

            Dictionary<int, Customer> dictionaryCustomer = new Dictionary<int, Customer>();
            dictionaryCustomer.Add(Customer1.ID, Customer1);
            dictionaryCustomer.Add(Customer2.ID, Customer2);
            dictionaryCustomer.Add(Customer3.ID, Customer3);

            Console.WriteLine("Total Items = {0}", dictionaryCustomer.Count);
            Console.ReadLine();

            dictionaryCustomer.Remove(110);
            Console.ReadLine();
            //Customer cust;
            //if (dictionaryCustomer.TryGetValue(101, out cust))
            //{
            //    Console.WriteLine("ID = {0}, Name = {1}, Salary = {2}", cust.ID, cust.Name, cust.Salary);
            //    Console.ReadLine();
            //}
            //else
            //{
            //    Console.WriteLine("The Key is not found");
            //}
        
           
        }

      public class Customer
      {
          public int ID { get; set; }
          public string Name { get; set; }
          public int Salary { get; set; }
      }
    }

}

   

CODE SNIPPETS IN VISUAL STUDIO

CODE SNIPPET TYPES

Expansion : These snippets allows the code snippet to be inserted at the cursor.

SurroundsWith: These snippets allows the code snippets to be placed around a selected piece of code

Refactoring: These snippets are used during code refactoring.



Control K X for intellesense in visual studio

right click in visual studio program and select the insert snippets > visual c# > for loop

CODE SNIPPET MANAGER

Tool > code snippet manager

HOW TO MAKE METHOD PARAMETERS OPTIONAL IN C#

OPTIONAL PARAMETERS



FOUR WAYS

1) Use parameter arrays
2) Method overloading
3) Specify parameter defaults
4) Use OptionalAttribute that is present in System.Runtime.InteropService namespace


1)Use parameter arrays


using System;
using System.Text;
namespace ConsoleApplication4
{
    public class MainClass
    {
        public static void Main()
        {
            AddNumber(10, 20 new object[] {30,50,40});
        }

        public static void AddNumber(int firstNumber, int SecondNumber, params object[] restofNumbers)
        {
            int result = firstNumber + SecondNumber;
            if(restofNumbers != null)
            {
                foreach(int i in restofNumbers)
                {
                    result += i;
                }
            }
            Console.WriteLine("Sum = " + result);
            Console.ReadLine();
        }

    }

}


   

2) Making method parameters optional using Method overloading 


using System;
using System.Text;
namespace ConsoleApplication4
{
    public class MainClass
    {
        public static void Main()
        {
            AddNumber(10, 20, new int[] {30,40});
        }
// over loading method
      public static void AddNumber(int firstNumber, int SecondNumber)
        {
            AddNumber(firstNumber, SecondNumber, null);
        }
       

        public static void AddNumber(int firstNumber, int SecondNumber, params int[] restofNumbers)
        {
            int result = firstNumber + SecondNumber;
            if(restofNumbers != null)
            {
                foreach(int i in restofNumbers)
                {
                    result += i;
                }
            }
            Console.WriteLine("Sum = " + result);
            Console.ReadLine();
        }

    }

}


3) Specify parameter defaults


using System;
using System.Text;
namespace ConsoleApplication4
{
    public class MainClass
    {
        public static void Main()
        {
            AddNumber(10, 20, new int[] {30,40});
        }

        // optional parameters appears after all the parameters
     
        public static void AddNumber(int firstNumber, int SecondNumber,  int[] restofNumbers = null)
        {
            int result = firstNumber + SecondNumber;
            if(restofNumbers != null)
            {
                foreach(int i in restofNumbers)
                {
                    result += i;
                }
            }
            Console.WriteLine("Sum = " + result);
            Console.ReadLine();
        }

    }

}


   NAMED PARAMETERS

using System;
using System.Text;
namespace ConsoleApplication4
{
    public class MainClass
    {
        public static void Main()
        {
            Test(1,c:20);
        }

        // optional parameters appears after all the parameters

        public static void Test(int a, int b = 10, int c = 20)
        {
            Console.WriteLine("a = " + a);
            Console.WriteLine("b = " + b);
            Console.WriteLine("c = " + c);
            Console.ReadLine();
        }

    }

}


 4)  Making Method parameters optional by using OptionalAttributes


using System;
using System.Text;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace ConsoleApplication4
{
    public class MainClass
    {
        public static void Main()
        {
            AddNumber(10, 20);
        }

        

        public static void AddNumber(int firstNumber, int SecondNumber,[Optional] int[] restofNumbers)
        {
            int result = firstNumber + SecondNumber;
            if (restofNumbers != null)
            {
                foreach (int i in restofNumbers)
                {
                    result += i;
                }
            }
            Console.WriteLine("Sum = " + result);
            Console.ReadLine();
        }


    }

}

   

Monday 6 February 2017

TOP MARKETING TOOLS FOR MICROSOFT DYNAMICS CRM



TOP MARKETING TOOLS FOR MICROSOFT DYNAMICS CRM 


Check out the various email marketing tools for microsoft dynamics crm as follows through the below link, as i thought it would be helpful to someone like me, before choosing one.


http://www.encorebusiness.com/blog/dynamics-crm-marketing-automation-tools/

Office 365 - Outlook for Windows Manual Exchange Configuration

WHAT ARE PARTIAL CLASSES

WHAT ARE PARTIAL CLASSES


what are partial classes?
what are the advantages or uses of partial classes?
where are partail classes used?
Partial classes allows us to split class into 2 or more files. All these parts are then combined into a single class, when the application is compiled. the partial keyword can also be used to split a struct or an interface over two or more files.


DIFFERENCE BETWEEN SYSTEM.STRING AND SYSTEM.TEXT.STRINGBUILDER

DIFFERENCE BETWEEN SYSTEM.STRING AND SYSTEM.TEXT.STRINGBUILDER


System.String is immutable  |||      StringBuilder is Mutable

As StringBuilder objects are mutable, they offer better performance than string objects of type
System.String, when heavy string manipulation is involved.



EXAMPLE OF SYSTEM.STRING  I.E STRING() METHOD
Stack       and       Heap
string                   c#
                            vidoe
                             tutorial
                             for
                             beginners


EXAMPLE  OF SYSTEM.TEXT.STRINGBUILDER
Stack       and       Heap
string                   c# video tutorial for beginners


using System;
using System.Text;
namespace ConsoleApplication4
{
    public class MainClass
    {
        public static void Main()
        {


            string userString = string.Empty;
            for(int i = 1; i <= 10000;i++ )
            {
                userString += i.ToString() + " ";
                
            }
            Console.WriteLine(userString);
            Console.ReadLine();
            
            // using system.string  
            //string userstring = "C#";
            //userstring += "Vidoe";
            //userstring += "Tutorail";
            //userstring += "for";
            //userstring += "Beginners";
            //Console.WriteLine(userString);
            //Console.ReadLine();


            //// using system.text.stringbuilder
            //StringBuilder userString = new StringBuilder("C#");
            //userString.Append(" Video");
            //userString.Append(" Tutorial");
            //userString.Append(" For");
            //userString.Append(" Beginners");
            //Console.WriteLine(userString.ToString());
            //Console.ReadLine();

        }

    }

}

   

DIFFERENCE BETWEEN CONVERT.TOSTRING() AND TOSTRING()

DIFFERENCE BETWEEN CONVERT.TOSTRING() AND TOSTRING()


Convert.Tostring() handles null, while ToString() doesn't  and throws a NULL
Reference exception.

Depending on the type of the application architecture and what you are trying to achieve , 
you choose one over the other.

using System;

namespace ConsoleApplication4
{
    public class MainClass
    {
        public static void Main()
        {
            Customer C1 = null;
            string str = Convert.ToString(C1);
            Console.WriteLine(str);
            Console.ReadLine();
        }

    }

    public class Customer
    {
        public string Name { get; set; }
      
      
    }
}

   

Sunday 5 February 2017

WHY SHOULD YOU OVERRIDE EQUALS METHOD

WHY SHOULD YOU OVERRIDE EQUALS METHOD


1. WHAT IS EQUALS METHOD

2. WHY SHOULD YOU OVERRIDE IT.



using System;

namespace ConsoleApplication4
{
    public class MainClass
    {
        public static void Main()
        {
            Customer C1 = new Customer();
            C1.FirstName = "Malla";
            C1.LastName = "Gurram";

            Customer C2 = new Customer();
            C2.FirstName = "Malla";
            C2.LastName = "Gurram";


            Console.WriteLine(C1 == C2);
            Console.WriteLine(C1.Equals(C2));
            Console.ReadLine();
        }

    }

    public class Customer
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }

        public override bool Equals(object obj)
        {
           
            if(obj == null)
            {
                return false;
            }

            if(!(obj is Customer))
            {
                return false;
            }

            return this.FirstName == ((Customer)obj).FirstName &&
                this.LastName == ((Customer)obj).LastName;
        }

        public override int GetHashCode()
        {
            return this.FirstName.GetHashCode() ^ this.LastName.GetHashCode();
        }
    }
}

   

WHY SHOULD WE OVERRIDE TOSTRING METHOD

WHY SHOULD WE OVERRIDE TOSTRING METHOD


1. What is ToString() Method.

2. Why should we override it ?


using System;
using System.Reflection;

namespace ConsoleApplication4
{
    public class MainClass
    {
        public static void Main()
        {
            int Number = 10;

            Console.WriteLine(Number.ToString());
            Console.ReadLine();

            Customer C1 = new Customer();
            C1.FirstName = "Malla";
            C1.LastName = "Gurram";

            //Console.WriteLine(C1.ToString());   
            Console.WriteLine(Convert.ToString(C1));


            Console.ReadLine();
        }

    }

    public class Customer
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }

        public override string ToString()
        {
            return this.LastName + ", " + this.FirstName;
        }
    }
}