Ejemplo n.º 1
0
        public async Task <DeploymentChangeSummary> PublishContentToSingleSite(Site site)
        {
            string   lockPath = Path.Combine(site.FilePath, "deployment.lock");
            LockFile lockFile = null;

            Trace.TraceInformation("Sync to single site: {0}", site.Name);

            try
            {
                if (LockFile.TryGetLockFile(lockPath, out lockFile))
                {
                    WebDeployHelper webDeployHelper = new WebDeployHelper();
                    return(await Task <DeploymentChangeSummary> .Run(() =>
                                                                     webDeployHelper.DeployContentToOneSite(
                                                                         Repository,
                                                                         Environment.Instance.ContentPath,
                                                                         site.Settings.FilePath)));
                }

                return(null);
            }
            catch (Exception e)
            {
                Trace.TraceError("Error processing {0}: {1}", Path.GetFileName(site.Settings.FilePath), e.ToString());
                return(null);
            }
            finally
            {
                if (lockFile != null)
                {
                    lockFile.Dispose();
                    lockFile = null;
                }
            }
        }
Ejemplo n.º 2
0
        private async Task PublishContentToAllSites(string contentPath, string publishSettingsPath)
        {
            string[] publishSettingsFiles = Directory.GetFiles(publishSettingsPath);

            Trace.TraceInformation("Publish settings found: {0}", String.Join(",", publishSettingsFiles));

            var webDeployHelper = new WebDeployHelper();

            // Publish to all the target sites in parallel
            var allChanges = await Task.WhenAll(publishSettingsFiles.Select(async publishSettingsFile =>
            {
                try
                {
                    return(await Task <DeploymentChangeSummary> .Run(() => webDeployHelper.DeployContentToOneSite(Environment.Instance.ContentPath, publishSettingsFile)));
                }
                catch (Exception e)
                {
                    Trace.TraceError("Error processing {0}: {1}", Path.GetFileName(publishSettingsFile), e.ToString());
                    return(null);
                }
            }));

            // Trace all the results
            for (int i = 0; i < allChanges.Length; i++)
            {
                DeploymentChangeSummary changeSummary = allChanges[i];
                if (changeSummary == null)
                {
                    continue;
                }

                Trace.TraceInformation("Processed {0}", Path.GetFileName(publishSettingsFiles[i]));

                Trace.TraceInformation("BytesCopied: {0}", changeSummary.BytesCopied);
                Trace.TraceInformation("Added: {0}", changeSummary.ObjectsAdded);
                Trace.TraceInformation("Updated: {0}", changeSummary.ObjectsUpdated);
                Trace.TraceInformation("Deleted: {0}", changeSummary.ObjectsDeleted);
                Trace.TraceInformation("Errors: {0}", changeSummary.Errors);
                Trace.TraceInformation("Warnings: {0}", changeSummary.Warnings);
                Trace.TraceInformation("Total changes: {0}", changeSummary.TotalChanges);
            }
        }
Ejemplo n.º 3
0
        private async Task PublishContentToAllSites(string contentPath, string publishSettingsPath)
        {
            string[] publishSettingsFiles = Directory.GetFiles(publishSettingsPath);

            Trace.TraceInformation("Publish settings found: {0}", String.Join(",", publishSettingsFiles));

            var webDeployHelper = new WebDeployHelper();

            // Publish to all the target sites in parallel
            var allChanges = await Task.WhenAll(publishSettingsFiles.Select(async publishSettingsFile =>
            {
                try
                {
                    return await Task<DeploymentChangeSummary>.Run(() => webDeployHelper.DeployContentToOneSite(Environment.Instance.ContentPath, publishSettingsFile));
                }
                catch (Exception e)
                {
                    Trace.TraceError("Error processing {0}: {1}", Path.GetFileName(publishSettingsFile), e.ToString());
                    return null;
                }
            }));

            // Trace all the results
            for (int i = 0; i < allChanges.Length; i++)
            {
                DeploymentChangeSummary changeSummary = allChanges[i];
                if (changeSummary == null) continue;

                Trace.TraceInformation("Processed {0}", Path.GetFileName(publishSettingsFiles[i]));

                Trace.TraceInformation("BytesCopied: {0}", changeSummary.BytesCopied);
                Trace.TraceInformation("Added: {0}", changeSummary.ObjectsAdded);
                Trace.TraceInformation("Updated: {0}", changeSummary.ObjectsUpdated);
                Trace.TraceInformation("Deleted: {0}", changeSummary.ObjectsDeleted);
                Trace.TraceInformation("Errors: {0}", changeSummary.Errors);
                Trace.TraceInformation("Warnings: {0}", changeSummary.Warnings);
                Trace.TraceInformation("Total changes: {0}", changeSummary.TotalChanges);
            }
        }
Ejemplo n.º 4
0
        public async Task<DeploymentChangeSummary> PublishContentToSingleSite(Site site)
        {
            string lockPath = Path.Combine(site.FilePath, "deployment.lock");
            LockFile lockFile = null;

            Trace.TraceInformation("Sync to single site: {0}", site.Name);

            try
            {
                if (LockFile.TryGetLockFile(lockPath, out lockFile))
                {
                    WebDeployHelper webDeployHelper = new WebDeployHelper();
                    return await Task<DeploymentChangeSummary>.Run(() =>
                        webDeployHelper.DeployContentToOneSite(
                            Repository,
                            Environment.Instance.ContentPath,
                            site.Settings.FilePath));
                }

                return null;
            }
            catch (Exception e)
            {
                Trace.TraceError("Error processing {0}: {1}", Path.GetFileName(site.Settings.FilePath), e.ToString());
                return null;
            }
            finally
            {
                if (lockFile != null)
                {
                    lockFile.Dispose();
                    lockFile = null;
                }
            }

        }