Тема: Generic SQL error.
Показать сообщение отдельно
Старый 15.10.2008, 10:06   #4  
maclai is offline
maclai
Участник
 
14 / 11 (1) +
Регистрация: 09.10.2008
вот код создания сервиса:

Код:
 
 internal static CrmService GetCrmService(IPluginExecutionContext context, Boolean flag)
        {
            CrmAuthenticationToken authToken = new CrmAuthenticationToken();
            authToken.AuthenticationType = 0;
            authToken.OrganizationName = context.OrganizationName;
 
            if (flag)
                authToken.CallerId = context.UserId;
            else
                authToken.CallerId = context.InitiatingUserId;
            CrmService service = new CrmService();
            service.CrmAuthenticationTokenValue = authToken;
            service.UseDefaultCredentials = true;
            //service.Credentials = System.Net.CredentialCache.DefaultCredentials;
 
            CorrelationToken corToken = new CorrelationToken();
            corToken.CorrelationId = context.CorrelationId;
            corToken.CorrelationUpdatedTime = context.CorrelationUpdatedTime;
            corToken.Depth = context.Depth;
            Microsoft.Win32.RegistryKey regkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\MSCRM");
            service.Url = String.Concat(regkey.GetValue("ServerUrl").ToString(), "/2007/crmservice.asmx");
            service.CorrelationTokenValue = corToken;
            return service;
        }