Ejemplo n.º 1
0
        /// <summary>
        /// Publishes webresources changes
        /// </summary>
        /// <param name="webresourcesIds">List of webresource IDs to publish</param>
        private async System.Threading.Tasks.Task PublishWebResourcesAsync(IEnumerable <Guid> webresourcesIds)
        {
            var settings = await SettingsService.Instance.GetSettingsAsync();

            var selectedConnection = settings.SelectedConnection;
            var orgService         = await selectedConnection.GetCrmServiceClientAsync();

            await Logger.WriteLineWithTimeAsync("Publishing...");

            //await Logger.WriteLineAsync("Publishing...");
            var orgContext = new OrganizationServiceContext(orgService);

            if (webresourcesIds == null)
            {
                throw new ArgumentNullException("webresourcesId");
            }
            if (webresourcesIds.Any())
            {
                var request = GetPublishRequest(webresourcesIds);
                await orgContext.ExecuteAsync(request);
            }
            var count = webresourcesIds.Count();
            await Logger.WriteLineWithTimeAsync(count + " file" + (count == 1 ? " was" : "s were") + " published");

            //await Logger.WriteLineAsync(count + " file" + (count == 1 ? " was" : "s were") + " published");
        }