当前位置: 首页>>代码示例>>C#>>正文


C# OrganizationServiceProxy.Execute方法代码示例

本文整理汇总了C#中OrganizationServiceProxy.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# OrganizationServiceProxy.Execute方法的具体用法?C# OrganizationServiceProxy.Execute怎么用?C# OrganizationServiceProxy.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OrganizationServiceProxy的用法示例。


在下文中一共展示了OrganizationServiceProxy.Execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

        /// <summary>
        /// Demonstrates how to programmatically install and uninstall the Microsoft
        /// Dynamics CRM sample data records.
        /// </summary>
        /// <param name="serverConfig">Contains server connection information.</param>
        /// <param name="promptforDelete">Not applicable for this sample.</param>
        public void Run(ServerConnection.Configuration serverConfig, bool promptforDelete)
        {
            try
            {
                // Connect to the Organization service. 
                // The using statement assures that the service proxy will be properly disposed.
                using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri,serverConfig.Credentials, serverConfig.DeviceCredentials))
                {
                    // This statement is required to enable early-bound type support.
                    _serviceProxy.EnableProxyTypes();
                    //<snippetImportOrRemoveSampleData1>

                    // Prompt user to install/uninstall sample data.
                    Console.WriteLine("Would you like to:");
                    Console.WriteLine("1) Install sample data for Microsoft Dynamics CRM?");
                    Console.WriteLine("2) Uninstall sample data for Microsoft Dynamics CRM?");
                    Console.Write("Press [1] to Install, [2] to Uninstall: ");
                    String answer = Console.ReadLine();

                    // Update the sample data based on the user's response.
                    switch (answer)
                    {
                        case "1":
                            Console.WriteLine("Installing sample data...");
                            InstallSampleDataRequest request =
                                new InstallSampleDataRequest();
                            InstallSampleDataResponse response =
                                (InstallSampleDataResponse)_serviceProxy.Execute(request);
                            Console.WriteLine("Sample data successfully installed.");
                            break;
                        case "2":
                            Console.WriteLine("Uninstalling sample data...");
                            UninstallSampleDataRequest request2 =
                                new UninstallSampleDataRequest();
                            UninstallSampleDataResponse response2 =
                                (UninstallSampleDataResponse)_serviceProxy.Execute(request2);
                            Console.WriteLine("Sample data successfully uninstalled.");
                            break;
                        default:
                            Console.WriteLine("Neither option was selected. No changes have been made to your records.");
                            break;
                    }

                }
                //</snippetImportOrRemoveSampleData1>
            }

            // Catch any service fault exceptions that Microsoft Dynamics CRM throws.
            catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault>)
            {
                // You can handle an exception here or pass it back to the calling method.
                throw;
            }
        }
开发者ID:cesugden,项目名称:Scripts,代码行数:60,代码来源:ImportOrRemoveSampleData.cs

示例2: Run

        public void Run(ServerConnection.Configuration serverConfig, string solutionPath)
        {
            try
            {
                using (OrganizationServiceProxy _serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri, serverConfig.Credentials, serverConfig.DeviceCredentials))
                {
                    byte[] data = File.ReadAllBytes(solutionPath);
                    Guid importId = Guid.NewGuid();

                    Console.WriteLine("\n Importing solution {0} into Server {1}.", solutionPath, serverConfig.OrganizationUri);

                    _serviceProxy.EnableProxyTypes();
                    ImportSolutionRequest importSolutionRequest = new ImportSolutionRequest()
                    {
                        CustomizationFile = data,
                        ImportJobId = importId
                    };

                    ThreadStart starter = () =>ProgressReport(serverConfig, importId);
                    Thread t = new Thread(starter);
                    t.Start();

                    _serviceProxy.Execute(importSolutionRequest);
                    Console.Write("Solution {0} successfully imported into {1}", solutionPath, serverConfig.OrganizationUri);
                }
            }
            catch (Exception ex)
            {

            }
        }
开发者ID:awong789,项目名称:AWCRMToolkit,代码行数:31,代码来源:ImportSolution.cs

示例3: GetOrganisationService

        public IOrganizationService GetOrganisationService(OrganizationDetail org, string domain, string userName, string password)
        {

            if (org != null)
            {
                Uri orgServiceUri = null;
                orgServiceUri = new Uri(org.Endpoints[EndpointType.OrganizationService]);
                //if (!string.IsNullOrEmpty(OrganisationServiceHostName))
                //{
                //    UriBuilder builder = new UriBuilder(orgServiceUri);
                //    builder.Host = OrganisationServiceHostName;
                //    orgServiceUri = builder.Uri;
                //}

                IServiceConfiguration<IOrganizationService> orgConfigInfo = ServiceConfigurationFactory.CreateConfiguration<IOrganizationService>(orgServiceUri);

                var creds = _credentialsProvider.GetCredentials(orgConfigInfo.AuthenticationType, domain, userName, password);
                var orgService = new OrganizationServiceProxy(orgConfigInfo, creds);
                orgService.Timeout = new TimeSpan(0, 5, 0);

                var req = new WhoAmIRequest();
                var response = (WhoAmIResponse)orgService.Execute(req);

                Debug.WriteLine(string.Format(" Connected to {0} as Crm user id: {1}", orgConfigInfo.CurrentServiceEndpoint.Address.Uri.ToString(), response.UserId));
                return orgService;
            }
            return null;

        }
开发者ID:pharmadata,项目名称:CrmDeploy,代码行数:29,代码来源:CrmServiceProvider.cs

示例4: Main

        //Start of Main
        public static void Main(string[] args)
        {
            Console.WriteLine("The process has started \nTrying to Export Solution");
            //Create new user and gets credentials to login and capture desired solution
            Session loginUser = new Session();
            ClientCredentials credentials = GetCredentials(loginUser);

            using (OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(loginUser.OrganizationUri,null, credentials, GetDeviceCredentials()))
            {
                string outputDir = @"C:\temp\";

                //Creates the Export Request
                ExportSolutionRequest exportRequest = new ExportSolutionRequest();
                exportRequest.Managed = true;
                exportRequest.SolutionName = loginUser.SolutionName;

                ExportSolutionResponse exportResponse = (ExportSolutionResponse)serviceProxy.Execute(exportRequest);

                //Handles the response
                byte[] exportXml = exportResponse.ExportSolutionFile;
                string filename = loginUser.SolutionName + "_" + DateToString() + ".zip";
                File.WriteAllBytes(outputDir + filename, exportXml);

                Console.WriteLine("Solution Successfully Exported to {0}", outputDir + filename);

            }
        }
开发者ID:frechop,项目名称:SolutionExport,代码行数:28,代码来源:Program.cs

示例5: AppSendEmails

 public AppSendEmails(OrganizationServiceProxy service)
 {
     _service = service;
     _wfemailTemp = new ConsoleEmailTemplate(_service);
     WhoAmIRequest requst = new WhoAmIRequest();
     WhoAmIResponse res = (WhoAmIResponse)_service.Execute(requst);
     _userid = res.UserId;
 }
开发者ID:liorg,项目名称:DesignPatternsForXrm,代码行数:8,代码来源:AppSendEmails.cs

示例6: Run

        /// <summary>
        /// This method first creates a new currency within the system, setting its 
        /// exchange rate to a pre-defined value. It then issues a 
        /// RetrieveExchangeRateRequest to get the exchange rate from the created 
        /// currency to the organization's base currency. Finally, it retrieves the 
        /// organization's base currency and displays the conversion rate.
        /// </summary>
        /// <param name="serverConfig">Contains server connection information.</param>
        /// <param name="promptforDelete">When True, the user will be prompted to delete all
        /// created entities.</param>

        public void Run(ServerConnection.Configuration serverConfig, bool promptforDelete)
        {
            try
            {
                //<snippetTransactionCurrencyExchangeRate1>
                // Connect to the Organization service. 
                // The using statement assures that the service proxy will be properly disposed.
                using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri,serverConfig.Credentials, serverConfig.DeviceCredentials))
                // using the service context makes retrieving entities easier
                using (_context = new ServiceContext(_serviceProxy))
                {
                    // This statement is required to enable early-bound type support.
                    _serviceProxy.EnableProxyTypes();

                    String currentOrganizatoinUniqueName = GetCurrentOrganizationName(serverConfig);

                    CreateRequiredRecords();

                    RetrieveExchangeRateRequest request = new RetrieveExchangeRateRequest()
                    {
                        TransactionCurrencyId = _currency.Id
                    };
                    RetrieveExchangeRateResponse response = 
                        (RetrieveExchangeRateResponse)_serviceProxy.Execute(request);
                    Console.WriteLine("  Retrieved exchange rate for created currency");

                    // get the base currency for the current org
                    var baseCurrencyName = 
                        (from currency in _context.TransactionCurrencySet
                         join org in _context.OrganizationSet 
                         on currency.Id equals org.BaseCurrencyId.Id
                         where org.Name == currentOrganizatoinUniqueName
                         select currency.CurrencyName).FirstOrDefault();
                    Console.WriteLine("  This organization's base currency is {0}",
                        baseCurrencyName);

                    Console.WriteLine(
                        "  The conversion from {0} -> {1} is {2}",
                        _currency.CurrencyName,
                        baseCurrencyName,
                        response.ExchangeRate);

                    DeleteRequiredRecords(promptforDelete);
                }
                //</snippetTransactionCurrencyExchangeRate1>
            }

            // Catch any service fault exceptions that Microsoft Dynamics CRM throws.
            catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault>)
            {
                // You can handle an exception here or pass it back to the calling method.
                throw;
            }
        }
开发者ID:cesugden,项目名称:Scripts,代码行数:65,代码来源:TransactionCurrencyExchangeRate.cs

示例7: Run

        /// <summary>
        /// Demonstrates how to programmatically create a Workflow from an existing
        /// Process Template.
        /// </summary>
        /// <param name="serverConfig">Contains server connection information.</param>
        /// <param name="promptforDelete">When True, the user will be prompted to delete all
        /// created entities.</param>
        public void Run(ServerConnection.Configuration serverConfig, bool promptforDelete)
        {
            try
            {
                //<snippetCreateProcessFromTemplate1>
                // Connect to the Organization service. 
                // The using statement assures that the service proxy will be properly disposed.
                using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri,
                                                                     serverConfig.Credentials, serverConfig.DeviceCredentials))
                {
                    // This statement is required to enable early-bound type support.
                    _serviceProxy.EnableProxyTypes();

                    OrganizationServiceContext _orgContext = new OrganizationServiceContext(_serviceProxy);

                    CreateRequiredRecords();

                    CreateWorkflowFromTemplateRequest request = new CreateWorkflowFromTemplateRequest()
                    {
                        WorkflowName = "Workflow From Template",
                        WorkflowTemplateId = _processTemplateId
                    };

                    // Execute request.
                    CreateWorkflowFromTemplateResponse response = (CreateWorkflowFromTemplateResponse)_serviceProxy.Execute(request);
                    _processId = response.Id;

                    // Verify success.
                    // Retrieve the name of the workflow.
                    ColumnSet cols = new ColumnSet("name");
                    Workflow newWorkflow = (Workflow)_serviceProxy.Retrieve(Workflow.EntityLogicalName, response.Id, cols);
                    if (newWorkflow.Name == "Workflow From Template")
                    {
                        Console.WriteLine("Created {0}.", request.WorkflowName);
                    }

                    DeleteRequiredRecords(promptforDelete);
                }
                //</snippetCreateProcessFromTemplate1>
            }

            // Catch any service fault exceptions that Microsoft Dynamics CRM throws.
            catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault>)
            {
                // You can handle an exception here or pass it back to the calling method.
                throw;
            }
        }
开发者ID:cesugden,项目名称:Scripts,代码行数:55,代码来源:CreateProcessFromTemplate.cs

示例8: Run

        /// <summary>
        /// Create an e-mail using a template.
        /// </summary>
        /// <param name="serverConfig">Contains server connection information.</param>
        /// <param name="promptforDelete">When True, the user will be prompted to delete all
        /// created entities.</param>
        public void Run(ServerConnection.Configuration serverConfig, bool promptforDelete)
        {
            try
            {
                // Connect to the Organization service. 
                // The using statement assures that the service proxy will be properly disposed.
                using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri,
                                                                     serverConfig.Credentials, serverConfig.DeviceCredentials))
                {
                    // This statement is required to enable early-bound type support.
                    _serviceProxy.EnableProxyTypes();

                    CreateRequiredRecords();

                    //<snippetCreateEmailUsingTemplate1>

                    // Use the InstantiateTemplate message to create an e-mail message using a template.
                    InstantiateTemplateRequest instTemplateReq = new InstantiateTemplateRequest
                    {
                        TemplateId = _templateId,
                        ObjectId = _accountId,
                        ObjectType = Account.EntityLogicalName
                    };
                    InstantiateTemplateResponse instTemplateResp = (InstantiateTemplateResponse)_serviceProxy.Execute(instTemplateReq);

                    // Serialize the email message to XML, and save to a file.
                    XmlSerializer serializer = new XmlSerializer(typeof(InstantiateTemplateResponse));
                    string filename = "email-message.xml";
                    using (StreamWriter writer = new StreamWriter(filename))
                    {
                        serializer.Serialize(writer, instTemplateResp);
                    }
                    Console.WriteLine("Created e-mail using the template.");
                    //</snippetCreateEmailUsingTemplate1>


                    DeleteRequiredRecords(promptforDelete);
                }
            }

            // Catch any service fault exceptions that Microsoft Dynamics CRM throws.
            catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault>)
            {
                // You can handle an exception here or pass it back to the calling method.
                throw;
            }
        }
开发者ID:cesugden,项目名称:Scripts,代码行数:53,代码来源:CreateEmailUsingTemplate.cs

示例9: Run

        /// <summary>
        /// Create and configure the organization service proxy.
        /// Retrieve the working hours of the current user.        
        /// Optionally delete any entity records that were created for this sample.
        /// </summary>
        /// <param name="serverConfig">Contains server connection information.</param>
        /// <param name="promptforDelete">When True, the user will be prompted to delete all
        /// created entities.</param>
        public void Run(ServerConnection.Configuration serverConfig, bool promptForDelete)
        {
            try
            {

                // Connect to the Organization service. 
                // The using statement assures that the service proxy will be properly disposed.
                using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri,serverConfig.Credentials, serverConfig.DeviceCredentials))
                {
                    // This statement is required to enable early-bound type support.
                    _serviceProxy.EnableProxyTypes();

                    // Call the method to create any data that this sample requires.
                    CreateRequiredRecords();

                    //<snippetQueryWorkingHoursOfUser1>
                    // Get the current user's information.
                    WhoAmIRequest userRequest = new WhoAmIRequest();
                    WhoAmIResponse userResponse = (WhoAmIResponse)_serviceProxy.Execute(userRequest);

                    // Retrieve the working hours of the current user.                                              
                    QueryScheduleRequest scheduleRequest = new QueryScheduleRequest
                    {
                        ResourceId = userResponse.UserId,
                        Start = DateTime.Now,
                        End = DateTime.Today.AddDays(7),
                        TimeCodes = new TimeCode[] { TimeCode.Available }
                    };
                    QueryScheduleResponse scheduleResponse = (QueryScheduleResponse)_serviceProxy.Execute(scheduleRequest);

                    // Verify if some data is returned for the availability of the current user
                    if (scheduleResponse.TimeInfos.Length > 0)
                    {
                        Console.WriteLine("Successfully queried the working hours of the current user.");
                    }
                    //</snippetQueryWorkingHoursOfUser1>                    
                }
            }
            // Catch any service fault exceptions that Microsoft Dynamics CRM throws.
            catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault>)
            {
                // You can handle an exception here or pass it back to the calling method.
                throw;
            }
        }
开发者ID:cesugden,项目名称:Scripts,代码行数:53,代码来源:QueryWorkingHoursOfUser.cs

示例10: FindUser

        public SystemUser FindUser(string userName, string password)
        {
            var credentials = new ClientCredentials();
            credentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
            credentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation;
            credentials.UserName.UserName = userName;
            credentials.UserName.Password = password;
            using (var proxy = new OrganizationServiceProxy(new Uri(_uri + "/XRMServices/2011/Organization.svc"), null,
                credentials, null))
            {
                var whoAmiResponse = proxy.Execute<WhoAmIResponse>(new WhoAmIRequest());

                return new SystemUser
                {
                    Id = whoAmiResponse.UserId.ToString(),
                    UserName = userName,
                    Password = password
                };
            }
        }
开发者ID:AM636E,项目名称:XrmTools,代码行数:20,代码来源:CrmAuthRepository.cs

示例11: Connect

        /// <summary>
        /// Получаем подключение к организации
        /// </summary>
        /// <param name="url"></param>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <param name="environment"></param>
        public static void Connect(string url, string username, string password, string environment)
        {
            ClientCredentials userCredentials = new ClientCredentials();
            userCredentials.UserName.UserName = username;
            userCredentials.UserName.Password = password;
            var orgService = new OrganizationServiceProxy(new Uri(url + "/XRMServices/2011/Organization.svc"), null, userCredentials, null);
            orgService.EnableProxyTypes();
            orgService.Timeout = new TimeSpan(0, 30, 0); // таймаут 30 минут теперь
            var whoAmIResponse = (WhoAmIResponse) orgService.Execute(new WhoAmIRequest());

            switch (environment)
            {
                case "Customization":
                    _serviceCustomization = orgService;
                    break;
                case "Import":
                    _serviceImport = orgService;
                    break;
            }
        }
开发者ID:helekon,项目名称:MergeCustomization,代码行数:27,代码来源:ServiceProvider.cs

示例12: Run

        /// <summary>
        /// Send an e-mail message.
        /// </summary>
        /// <param name="serverConfig">Contains server connection information.</param>
        /// <param name="promptforDelete">When True, the user will be prompted to delete all
        /// created entities.</param>
        public void Run(ServerConnection.Configuration serverConfig, bool promptforDelete)
        {
            try
            {
                // Connect to the Organization service. 
                // The using statement assures that the service proxy will be properly disposed.
                using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri,serverConfig.Credentials, serverConfig.DeviceCredentials))
                {
                    // This statement is required to enable early-bound type support.
                    _serviceProxy.EnableProxyTypes();

                    // Call the method to create any data that this sample requires.
                    CreateRequiredRecords();

                    //<snippetSendEmail1>

                    // Use the SendEmail message to send an e-mail message.
                    SendEmailRequest sendEmailreq = new SendEmailRequest
                    {
                        EmailId = _emailId,
                        TrackingToken = "",
                        IssueSend = true
                    };

                    SendEmailResponse sendEmailresp = (SendEmailResponse)_serviceProxy.Execute(sendEmailreq);
                    Console.WriteLine("Sent the e-mail message.");              

                    //</snippetSendEmail1>

                    DeleteRequiredRecords(promptforDelete);
                }
            }

            // Catch any service fault exceptions that Microsoft Dynamics CRM throws.
            catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault>)
            {
                // You can handle an exception here or pass it back to the calling method.
                throw;
            }
        }
开发者ID:cesugden,项目名称:Scripts,代码行数:46,代码来源:SendEmail.cs

示例13: Run

        /// <summary>
        /// Create and configure the organization service proxy.
        /// Initiate the method to create any data that this sample requires.
        /// Retrieve all queueitems with inactive phone calls from a queue.
        /// Delete all inactive phone call entity instances.
        /// Optionally delete any entity records that were created for this sample.
        /// <param name="serverConfig">Contains server connection information.</param>
        /// <param name="promptforDelete">When True, the user will be prompted to delete all
        /// created entities.</param>
        /// </summary>
        public void Run(ServerConnection.Configuration serverConfig, bool promptForDelete)
        {
            try
            {

                // Connect to the Organization service. 
                // The using statement assures that the service proxy will be properly disposed.
                using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri,
                                                                     serverConfig.Credentials, serverConfig.DeviceCredentials))
                {
                    // This statement is required to enable early-bound type support.
                    _serviceProxy.EnableProxyTypes();

                    CreateRequiredRecords();


                    //<snippetCleanUpQueueItems1>
                    // Retrieve the queueitem with inactive phone calls from a queue            
                    RemoveFromQueueRequest removeFromQueueRequest = new RemoveFromQueueRequest
                    {
                        QueueItemId = _queueItemId
                    };
                    _serviceProxy.Execute(removeFromQueueRequest);

                    //</snippetCleanUpQueueItems1>  

                    Console.WriteLine("Inactive phonecalls have been deleted from the queue.");

                    DeleteRequiredRecords(promptForDelete);

                }
            }
            // Catch any service fault exceptions that Microsoft Dynamics CRM throws.
            catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault>)
            {
                // You can handle an exception here or pass it back to the calling method.
                throw;
            }
        }
开发者ID:cesugden,项目名称:Scripts,代码行数:49,代码来源:CleanUpQueueItems.cs

示例14: Run

        /// <summary>
        /// This method first connects to the Organization service. Afterwards,
        /// retrieves the absolute URL and the parent site collection URL of a 
        /// SharePoint document location record.
        /// </summary>
        /// <param name="serverConfig">Contains server connection information.</param>
        /// <param name="promptforDelete">When True, the user will be prompted to delete all
        /// created entities.</param>
        public void Run(ServerConnection.Configuration serverConfig, bool promptforDelete)
        {
            try
            {
                //<snippetRetrieveAbsoluteAndSiteCollectionURLs1>
                // Connect to the Organization service. 
                // The using statement assures that the service proxy will be properly disposed.
                using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri,serverConfig.Credentials, serverConfig.DeviceCredentials))
                {
                    // This statement is required to enable early-bound type support.
                    _serviceProxy.EnableProxyTypes();

                    CreateRequiredRecords();
                    //<snippetRetrieveAbsoluteAndSiteCollectionURLs2>
                    // Retrieve the absolute URL and the Site Collection URL
                    // of the SharePoint document location record.
                    RetrieveAbsoluteAndSiteCollectionUrlRequest retrieveRequest = new RetrieveAbsoluteAndSiteCollectionUrlRequest
                    {
                        Target = new EntityReference(SharePointDocumentLocation.EntityLogicalName, _spDocLocId)
                    };
                    RetrieveAbsoluteAndSiteCollectionUrlResponse retriveResponse = (RetrieveAbsoluteAndSiteCollectionUrlResponse)_serviceProxy.Execute(retrieveRequest);

                    Console.WriteLine("Absolute URL of document location record is '{0}'.", retriveResponse.AbsoluteUrl.ToString());
                    Console.WriteLine("Site Collection URL of document location record is '{0}'.", retriveResponse.SiteCollectionUrl.ToString());
                    //</snippetRetrieveAbsoluteAndSiteCollectionURLs2>
                    DeleteRequiredRecords(promptforDelete);
                }
                //</snippetRetrieveAbsoluteAndSiteCollectionURLs1>
            }

            // Catch any service fault exceptions that Microsoft Dynamics CRM throws.
            catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault>)
            {
                // You can handle an exception here or pass it back to the calling method.
                throw;
            }
        }
开发者ID:cesugden,项目名称:Scripts,代码行数:45,代码来源:RetrieveAbsoluteAndSiteCollectionURLs.cs

示例15: Run

        /// <summary>
        /// Create and configure the organization service proxy.        
        /// Retrieve the history limit of a report.
        /// Optionally delete any entity records that were created for this sample.
        /// </summary>
        /// <param name="serverConfig">Contains server connection information.</param>
        /// <param name="promptforDelete">When True, the user will be prompted to delete all
        /// created entities.</param>
        public void Run(ServerConnection.Configuration serverConfig, bool promptForDelete)
        {
            try
            {

                // Connect to the Organization service. 
                // The using statement assures that the service proxy will be properly disposed.
                using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri,serverConfig.Credentials, serverConfig.DeviceCredentials))
                {
                    // This statement is required to enable early-bound type support.
                    _serviceProxy.EnableProxyTypes();

                    // Call the method to create any data that this sample requires.
                    CreateRequiredRecords();

                    //<snippetGetReportHistoryLimit1>

                    // Query for an an existing report: Account Overview. This is a default report in Microsoft Dynamics CRM.				    
                    QueryByAttribute reportQuery = new QueryByAttribute(Report.EntityLogicalName);
                    reportQuery.AddAttributeValue("name", "Account Overview");
                    reportQuery.ColumnSet = new ColumnSet("reportid");

                    // Get the report.
                    EntityCollection retrieveReports = _serviceProxy.RetrieveMultiple(reportQuery);

                    // Convert retrieved Entity to a report
                    Report retrievedReport = (Report)retrieveReports.Entities[0];
                    Console.WriteLine("Retrieved the 'Account Overview' report.");

                    // Use the Download Report Definition message.
                    GetReportHistoryLimitRequest reportHistoryRequest = new GetReportHistoryLimitRequest
                    {
                        ReportId = retrievedReport.ReportId.Value
                    };

                    GetReportHistoryLimitResponse reportHistoryResponse = (GetReportHistoryLimitResponse)_serviceProxy.Execute(reportHistoryRequest);

                    // Access the history limit data
                    int historyLimit = reportHistoryResponse.HistoryLimit;

                    Console.WriteLine("The report history limit is {0}.", historyLimit);

                    //</snippetGetReportHistoryLimit1>
                    
                }
            }
            // Catch any service fault exceptions that Microsoft Dynamics CRM throws.
            catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault>)
            {
                // You can handle an exception here or pass it back to the calling method.
                throw;
            }
        }
开发者ID:cesugden,项目名称:Scripts,代码行数:61,代码来源:GetReportHistoryLimit.cs


注:本文中的OrganizationServiceProxy.Execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。