Microsoft Dynamics CRM için Örnek Bir Code Snippet

 Visual Studio 2005 ile birlikte hayatımıza giren Code-Snippets’lar ile birlikte yazdığımız belli başlıklı kod bloklarını hazırlayıp kaydedip Ctrl +K ve ardından Ctrl+X ile kolayca kullanabiliriz. Ve neydi yazacağım kod diye sağa sola bakınmanıza gerek kalmaz.

Bu makalemde de Visual Studio kullanarak Microsoft Dynamics CRM 4.0 için bir snippet hazırlayacağız.

Öncelikle code snippet - kod bloğunu xml formatta hazırlıyoruz. Bu xml dosyanın içeriği şöyle olacak:

CRMSnippets.snippet

CRM Randevu
BookCRMAppointment

public Guid BookMyAppointment (Guid myId, string subject, string description, string location, string start, string end)

{

activityparty myParty = new activityparty();

myParty.partyid = CrmTypes.CreateLookup(EntityName.systemuser.ToString(), myId);

appointment myAppointment = new appointment();

myAppointment.description = description;

myAppointment.ownerid = CrmTypes.CreateOwner(EntityName.systemuser.ToString(), myId);

myAppointment.scheduledstart = CrmTypes.CreateCrmDateTime(start);

myAppointment.scheduledend = CrmTypes.CreateCrmDateTime(end);

myAppointment.location = location;

myAppointment.subject = subject;

myAppointment.requiredattendees = new activityparty[] { myParty };

TargetScheduleAppointment myAppointmentTarget = new TargetScheduleAppointment();

myAppointmentTarget.Appointment = myAppointment;

BookRequest myBookRequest = new BookRequest();

myBookRequest.Target = myAppointmentTarget;

BookResponse booked = (BookResponse)myService.Execute(myBookRequest);

if (booked.ValidationResult.ValidationSuccess)

{

return booked.ValidationResult.ActivityId;

}

else return new Guid();

}]]>

Xml dosyamız hazır bunu sonu CRMSnippets.snippet olarak kaydediyoruz. Bu snippet’imizi projemizde kullanmak için Visual Studio 2005 veya Visual Studio 2008'i açıp, Tools bölümünden Code Snippets Manager bölümüne gidip My Code Snippets klasörüne kendi hazırladığımız xml formatında ki kod bloğunu Import etmeliyiz.

Bundan sonrasında ise projenizi yazarken Ctrl +K ve ardından Ctrl+X dedikten sonra snippet’inizi seçmeniz yeterli olacak

EkleBunu Sosyal Paylaşım Butonu

Önceki Sayfa | : | Sonraki Sayfa