Paste the code snippet in the try loop and execute the code snippets
Code:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Xrm.Sdk; using System.ServiceModel.Description; using System.Net; using Microsoft.Xrm.Sdk.Client; using System.Windows.Forms; using Microsoft.Xrm.Sdk.Query; using Microsoft.Crm.Sdk.Messages; using Microsoft.Xrm.Sdk.Messages; using Microsoft.Xrm.Sdk.Metadata; using System.IO; using SSB.Xrm; using Microsoft.Xrm.Sdk.Deployment; namespace DynamicsTest { class Program { static void Main(string[] args) { string dest = "prod"; string prod = "http://crm/prod/XRMServices/2011/Organization.svc"; string test = "http://crm/Test/XRMServices/2011/Organization.svc"; string test2 = "http://crm/Testt/XRMServices/2011/Organization.svc"; string dev = "http://crm/Dev/XRMServices/2011/Organization.svc"; string server = ""; switch (dest) { case "prod": server = prod; break; case "test2": server = test2; break; case "test": server = test; break; default: server = dev; break; } Uri organizationUri = new Uri(server); Uri homeRealmUri = null; ClientCredentials credentials = new ClientCredentials(); credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials; OrganizationServiceProxy _serviceProxy = new OrganizationServiceProxy(organizationUri, homeRealmUri, credentials, null); _serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior()); IOrganizationService _service = (IOrganizationService)_serviceProxy; if (!Directory.Exists("Logs")) { Directory.CreateDirectory("Logs"); } StreamWriter w = new StreamWriter(".\\Logs\\DynamicsTest" + DateTime.Now.ToString("_yyyyMMdd") + ".log", true); try { //Code snippet goes here } catch (Exception ex) { MessageBox.Show(ex.Message); Helper.Log(ex.Message, w, true); } finally { if (w != null) w.Close(); } } } }
No comments:
Post a Comment