Sample Console Application Using Service End Point-WhoAmIResponse

new_name —- Zipcode
new_owner1 —-Owner
new_firstname —FirstName
new_lastname —-Lastname
new_name —–Name
new_emailaddress —- Email Address
new_salary ——- Salary

new_iscontactcreatedbycrm
new_city
new_dateofbirth

/*using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Crm.Sdk;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Client;
using System.Configuration;
using System.ServiceModel;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Crm.Sdk.Messages;
using Microsoft.Xrm.Client.Services;
using System.ServiceModel.Description;
using Microsoft.Xrm.Sdk.Client;
*/
namespace Datatypes
{
class Program
{
private Guid _accountId;
static IOrganizationService _orgService;
static void Main(string[] args)
{

//String ConnectionString = ConfigurationManager.ConnectionStrings[“connection”].ToString();
//String[] appConfigEntity = ConfigurationManager.ConnectionStrings[“ConnectionString”].Split(‘,’);
//CrmServiceClient conn = new CrmServiceClient(ConfigurationManager.ConnectionStrings[“Connection”].ConnectionString);
////var connection = CrmConnection.Parse(“Url=crm url; Domain=org22ddaf0b; Username=yourusername; Password=yourpassword;”);
//_service = (IOrganizationService)conn.OrganizationWebProxyClient != null ? (IOrganizationService)conn.OrganizationWebProxyClient : (IOrganizationService)conn.OrganizationServiceProxy;

//Guid userid = ((WhoAmIResponse)_service.Execute(new WhoAmIRequest())).UserId;
////SystemUser systemUser = (SystemUser)_service.Retrieve(“systemuser”, userid, new ColumnSet(new string[] { “firstname”, “lastname” }));
////Console.WriteLine(“Logged on user is {0} {1}.”, systemUser.FirstName, systemUser.LastName);
//Console.ReadLine();

 

//String ConnectionString = ConfigurationManager.ConnectionStrings[“Crm”].ToString();
//CrmConnection connection = CrmConnection.Parse(ConnectionString);
ClientCredentials credentials = new ClientCredentials();
credentials.UserName.UserName = “chaitanya@mkkgroup.onmicrosoft.com”;
credentials.UserName.Password = “uday@KIRAN1188”;
Uri serviceUri = new Uri(“https://mkkgroup.api.crm8.dynamics.com/XRMServices/2011/Organization.svc”);
OrganizationServiceProxy proxy = new OrganizationServiceProxy(serviceUri, null, credentials, null);
proxy.EnableProxyTypes();
_orgService = (IOrganizationService)proxy;
//OrganizationService _orgService = new OrganizationService(connection);

//Guid userid = ((WhoAmIResponse)_orgService.Execute(new WhoAmIRequest())).UserId;
Entity contact = new Entity();
contact.LogicalName = “contact”;
Console.WriteLine(“To Fill the Account details to create an account Press Enter”);
Console.ReadLine();
Console.WriteLine(“Press enter to give City”);
if (Console.ReadLine() == “Hyderabad”)
{
OptionSetValue obj = new OptionSetValue(Convert.ToInt32(100000000));
contact.Attributes[“new_city”] = obj;
}
Console.WriteLine(“Type yes if it is from crm or else no “);
if (Console.ReadLine() == “yes”)
{
contact.Attributes[“new_iscontactcreatedbycrm”] = true;
}
Console.WriteLine(“Enter First Name”);
contact.Attributes[“firstname”] = Console.ReadLine().ToString();
Console.WriteLine(“Enter Date of Birth”);
Console.ReadLine();
Console.WriteLine(“Enter Day”);
String Day = Console.ReadLine().ToString();
Console.WriteLine(“Enter Month”);
String Month = Console.ReadLine().ToString();
Console.WriteLine(“Enter Year”);
String Year = Console.ReadLine().ToString();
DateTime dob = new DateTime(Convert.ToInt32(Year), Convert.ToInt32(Month), Convert.ToInt32(Day));
contact.Attributes[“new_dateofbirth”] = dob;
_orgService.Create(contact);
}
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s