//Guid _reportLinkId; #endregion Class Level Members #region How To Sample Code /// <summary> /// Create and configure the organization service proxy. /// Retrieve the history limit of a report. /// </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(); //<snippetPublishReport1> // Define an anonymous type to define the possible values for // report type. var ReportTypeCode = new { ReportingServicesReport = 1, OtherReport = 2, LinkedReport = 3 }; // Define an anonymous type to define the possible values for // report category. var ReportCategoryCode = new { SalesReports = 1, ServiceReports = 2, MarketingReports = 3, AdministrativeReports = 4 }; // Define an anonymous type to define the possible values for // report visibility var ReportVisibilityCode = new { ReportsGrid = 1, Form = 2, Grid = 3, }; // Instantiate a report object. // See the Entity Metadata topic in the SDK documentation to determine // which attributes must be set for each entity. Report sampleReport = new Report { Name = "Sample Report", BodyText = File.ReadAllText("SampleReport.rdl"), FileName = "SampleReport.rdl", LanguageCode = 1033, // US English ReportTypeCode = new OptionSetValue(ReportTypeCode.ReportingServicesReport) }; // Create a report record named Sample Report. _reportId = _serviceProxy.Create(sampleReport); // Set the report category. ReportCategory sampleReportCategory = new ReportCategory { ReportId = new EntityReference(Report.EntityLogicalName, _reportId), CategoryCode = new OptionSetValue(ReportCategoryCode.AdministrativeReports) }; _reportCategoryId = _serviceProxy.Create(sampleReportCategory); // Define which entity this report uses. ReportEntity reportEntity = new ReportEntity { ReportId = new EntityReference(Report.EntityLogicalName, _reportId), ObjectTypeCode = Account.EntityLogicalName }; _reportEntityId = _serviceProxy.Create(reportEntity); // Set the report visibility. ReportVisibility rv = new ReportVisibility { ReportId = new EntityReference(Report.EntityLogicalName, _reportId), VisibilityCode = new OptionSetValue(ReportVisibilityCode.Form) }; _reportVisibilityId1 = _serviceProxy.Create(rv); rv = new ReportVisibility { ReportId = new EntityReference(Report.EntityLogicalName, _reportId), VisibilityCode = new OptionSetValue(ReportVisibilityCode.Grid) }; _reportVisibilityId2 = _serviceProxy.Create(rv); rv = new ReportVisibility { ReportId = new EntityReference(Report.EntityLogicalName, _reportId), VisibilityCode = new OptionSetValue(ReportVisibilityCode.ReportsGrid) }; _reportVisibilityId3 = _serviceProxy.Create(rv); Console.WriteLine("{0} published in Microsoft Dynamics CRM.", sampleReport.Name); //</snippetPublishReport1> 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; } }
//Guid _reportLinkId; #endregion Class Level Members #region How To Sample Code /// <summary> /// Create and configure the organization service proxy. /// Retrieve the history limit of a report. /// </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(); //<snippetPublishReport1> // Define an anonymous type to define the possible values for // report type. var ReportTypeCode = new { ReportingServicesReport = 1, OtherReport = 2, LinkedReport = 3 }; // Define an anonymous type to define the possible values for // report category. var ReportCategoryCode = new { SalesReports = 1, ServiceReports = 2, MarketingReports = 3, AdministrativeReports = 4 }; // Define an anonymous type to define the possible values for // report visibility var ReportVisibilityCode = new { ReportsGrid = 1, Form = 2, Grid = 3, }; // Instantiate a report object. // See the Entity Metadata topic in the SDK documentation to determine // which attributes must be set for each entity. Report sampleReport = new Report { Name = "Sample Report", BodyText = File.ReadAllText("SampleReport.rdl"), FileName = "SampleReport.rdl", LanguageCode = 1033, // US English ReportTypeCode = new OptionSetValue(ReportTypeCode.ReportingServicesReport) }; // Create a report record named Sample Report. _reportId = _serviceProxy.Create(sampleReport); // Set the report category. ReportCategory sampleReportCategory = new ReportCategory { ReportId = new EntityReference(Report.EntityLogicalName, _reportId), CategoryCode = new OptionSetValue(ReportCategoryCode.AdministrativeReports) }; _reportCategoryId = _serviceProxy.Create(sampleReportCategory); // Define which entity this report uses. ReportEntity reportEntity = new ReportEntity { ReportId = new EntityReference(Report.EntityLogicalName, _reportId), ObjectTypeCode = Account.EntityLogicalName }; _reportEntityId = _serviceProxy.Create(reportEntity); // Set the report visibility. ReportVisibility rv = new ReportVisibility { ReportId = new EntityReference(Report.EntityLogicalName, _reportId), VisibilityCode = new OptionSetValue(ReportVisibilityCode.Form) }; _reportVisibilityId1 = _serviceProxy.Create(rv); rv = new ReportVisibility { ReportId = new EntityReference(Report.EntityLogicalName, _reportId), VisibilityCode = new OptionSetValue(ReportVisibilityCode.Grid) }; _reportVisibilityId2 = _serviceProxy.Create(rv); rv = new ReportVisibility { ReportId = new EntityReference(Report.EntityLogicalName, _reportId), VisibilityCode = new OptionSetValue(ReportVisibilityCode.ReportsGrid) }; _reportVisibilityId3 = _serviceProxy.Create(rv); Console.WriteLine("{0} published in Microsoft Dynamics CRM.", sampleReport.Name); //</snippetPublishReport1> 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; } }
[STAThread] // Required to support the interactive login experience static void Main(string[] args) { CrmServiceClient service = null; try { service = SampleHelpers.Connect("Connect"); if (service.IsReady) { // Create any entity records that the demonstration code requires SetUpSample(service); #region Demonstrate // Define an anonymous type to define the possible values for // report type. var ReportTypeCode = new { ReportingServicesReport = 1, OtherReport = 2, LinkedReport = 3 }; // Define an anonymous type to define the possible values for // report category. var ReportCategoryCode = new { SalesReports = 1, ServiceReports = 2, MarketingReports = 3, AdministrativeReports = 4 }; // Define an anonymous type to define the possible values for // report visibility var ReportVisibilityCode = new { ReportsGrid = 1, Form = 2, Grid = 3, }; // Instantiate a report object. // See the Entity Metadata topic in the SDK documentation to determine // which attributes must be set for each entity. var sampleReport = new Report { Name = "Sample Report", BodyText = File.ReadAllText("SampleReport.rdl"), FileName = "SampleReport.rdl", LanguageCode = 1033, // US English ReportTypeCode = new OptionSetValue(ReportTypeCode.ReportingServicesReport) }; // Create a report record named Sample Report. _reportId = service.Create(sampleReport); // Set the report category. var sampleReportCategory = new ReportCategory { ReportId = new EntityReference(Report.EntityLogicalName, _reportId), CategoryCode = new OptionSetValue(ReportCategoryCode.AdministrativeReports) }; _reportCategoryId = service.Create(sampleReportCategory); // Define which entity this report uses. var reportEntity = new ReportEntity { ReportId = new EntityReference(Report.EntityLogicalName, _reportId), ObjectTypeCode = Account.EntityLogicalName }; _reportEntityId = service.Create(reportEntity); // Set the report visibility. var rv = new ReportVisibility { ReportId = new EntityReference(Report.EntityLogicalName, _reportId), VisibilityCode = new OptionSetValue(ReportVisibilityCode.Form) }; _reportVisibilityId1 = service.Create(rv); rv = new ReportVisibility { ReportId = new EntityReference(Report.EntityLogicalName, _reportId), VisibilityCode = new OptionSetValue(ReportVisibilityCode.Grid) }; _reportVisibilityId2 = service.Create(rv); rv = new ReportVisibility { ReportId = new EntityReference(Report.EntityLogicalName, _reportId), VisibilityCode = new OptionSetValue(ReportVisibilityCode.ReportsGrid) }; _reportVisibilityId3 = service.Create(rv); Console.WriteLine("{0} published in Common Data Service.", sampleReport.Name); #endregion Demonstrate #region Clean up CleanUpSample(service); #endregion Clean up } else { const string UNABLE_TO_LOGIN_ERROR = "Unable to Login to Common Data Service"; if (service.LastCrmError.Equals(UNABLE_TO_LOGIN_ERROR)) { Console.WriteLine("Check the connection string values in cds/App.config."); throw new Exception(service.LastCrmError); } else { throw service.LastCrmException; } } } catch (Exception ex) { SampleHelpers.HandleException(ex); } finally { if (service != null) { service.Dispose(); } Console.WriteLine("Press <Enter> to exit."); Console.ReadLine(); } }
/// <summary> /// Initializes a new instance of the <see cref="CustomReportDefinition"/> class. /// </summary> /// <param name="title">The title.</param> /// <param name="description">The description.</param> /// <param name="fileName">Name of the file.</param> /// <param name="visibility">The visibility.</param> /// <param name="securityConfigurations">The security configurations.</param> public CustomReportDefinition( string title, string description, string fileName, ReportVisibility visibility, IEnumerable<CustomReportSecurityConfiguration> securityConfigurations) { _title = title; _description = description; _fileName = fileName; _visibility = visibility; _securityConfigurations.AddRange(securityConfigurations); }