Beispiel #1
0
        /// <summary>
        /// Determines if a plugin has timestamp support.
        /// </summary>
        /// <param name="pluginIdentifier"></param>
        //public bool HasTimestampSupport(string pluginIdentifier) {
        //    ITimestampControl ts = PluginManager.Plugins.Get(pluginIdentifier) as ITimestampControl;
        //    if (ts == null)
        //        return false;
        //    return true;
        //}
        /// <summary>
        /// Deploys files.
        /// </summary>
        /// <param name="project">Contains information about what and where to deploy.</param>
        /// <param name="files">The files to deploy.</param>
        public void DeployFiles(DeploymentProject project, IList<DeploymentFile> files)
        {
            // Nothing to deploy?
            if(files.Count == 0)
                return;

            EventManager.OnNotificationMessage("Updating timestamp...");
            UpdateTimestamp(project);

            EventManager.OnNotificationMessage("Starting deployment...");

            try {
                // Initiate all deployment hooks
                foreach (var hook in project.ActiveDeployConfig.HookSettings)
                {
                    IDeployerHook hookPlugin = PluginManager.GetPluginForHook(hook);
                    hookPlugin.BeforeDeploy(this);
                }

                // Signal to all plugins in the project that deployment is starting
                foreach (DeployDestination dest in project.ActiveDeployConfig.Destinations)
                {
                    var plugin = PluginManager.GetPluginForDestination(dest) as IFileDeployer;
                    if(plugin != null)
                        plugin.DeployStart(this);
                }

                // Deploy files
                foreach(DeploymentFile file in files) {
                    if(file.IncludeInDeployment) {
                        EventManager.OnNotificationMessage(string.Format("Deploying \"{0}\"...", file.Name));

                        // Signal that transfer started
                        TransferEventArgs args = new TransferEventArgs(file.LocalPath);
                        EventManager.OnTransferBegin(args);

                        // Start transferring
                        string destid = file.DeployDestinationIdentifier;
                        IDeployerPlugin plugin = PluginManager.GetPlugin(destid);
                        if(plugin == null)
                            throw new ApplicationException(string.Format("Unable to deploy to destination '{0}'. The destination has not been configured.", destid));

                        var fileDeployer = plugin as IFileDeployer;
                        if(fileDeployer == null)
                            throw new InvalidOperationException(string.Format("Plugin '{0}' does not support file deployment.", plugin.Name));

                        // Transfer retry loop
                        bool retry;
                        do {
                            retry = false;		// Assume we won't retry operation
                            try {
                                string remotename = string.IsNullOrEmpty(file.RemoteName) ? file.Name : file.RemoteName;

                                // Deploy file using plugin
                                fileDeployer.DeployFile(file.LocalPath, file.RemotePath, remotename);

                                // All ok, update event args
                                args.BytesSent = args.TotalBytes;
                            }
                            catch (DeployCancelException) {
                                throw;			// Rethrow exception to cancel deployment loop
                            }
                            catch(DeploySkipException) {
                                EventManager.OnNotificationMessage("Skipped file " + file.LocalPath);
                            }
                            catch(Exception ex) {
                                DeployErrorForm dlg = new DeployErrorForm();
                                dlg.ErrorMessage = ex.Message;
                                dlg.SetLocalInfo("Local File:", file.LocalPath);
                                dlg.SetRemoteInfo("Remote Path:", file.RemotePath);
                                dlg.Plugin = fileDeployer.Name;
                                DialogResult result = dlg.ShowDialog();
                                switch(result) {
                                    case DialogResult.Retry:
                                        retry = true;
                                        break;
                                    case DialogResult.Ignore:
                                        break;		// Skip to next file
                                    case DialogResult.Cancel:
                                        throw new DeployCancelException("User cancelled.");
                                }
                            }
                        } while (retry);

                        // Signal that transfer is complete
                        EventManager.OnTransferComplete(args);
                    }
                }

                // Signal to all plugins in the project that deployment is complete
                foreach (DeployDestination dest in project.ActiveDeployConfig.Destinations) {
                    var plugin = PluginManager.GetPluginForDestination(dest) as IFileDeployer;
                    if(plugin != null)
                        plugin.DeployEnd();
                }

                // Signal all deployment hooks
                foreach (var hook in project.ActiveDeployConfig.HookSettings)
                {
                    IDeployerHook hookPlugin = PluginManager.GetPluginForHook(hook);
                    hookPlugin.AfterDeploy(this);
                }

                EventManager.OnNotificationMessage("Deployment completed.");
            }
            catch (DeployCancelException ex) {
                // Deployment has been cancelled
                EventManager.OnNotificationMessage("*** Deployment stopped! " + ex.Message);
            }
            finally
            {
                // Signal to all plugins in the project that deployment is complete
                foreach (DeployDestination dest in project.ActiveDeployConfig.Destinations)
                {
                    var plugin = PluginManager.GetPluginForDestination(dest) as IFileDeployer;
                    if (plugin != null)
                        plugin.DeployEnd();
                }
            }
        }
Beispiel #2
0
 public void OnTransferProgress(object sender, TransferEventArgs e)
 {
     EventManager.OnTransferProgress(e);
 }
Beispiel #3
0
        /// <summary>
        /// Deploys a single file.
        /// </summary>
        /// <param name="localFilePath">The local path to the file.</param>
        /// <param name="remoteDirectoryPath">The remote directory to deploy the file to.</param>
        /// <param name="remoteFilename">The name that the file will have in the remote path.</param>
        public void DeployFile(string localFilePath, string remoteDirectoryPath, string remoteFilename)
        {
            bool retry;

            // Retry loop
            do {
                retry = false;			// Assume we won't retry
                try {
                    // Verify remote path
                    if(_currentRemotePath != remoteDirectoryPath) {
                        ChangeRemoteDirectory(Path.Combine(_remoteRootPath, remoteDirectoryPath));		// Will create the directory if not existing
                        _currentRemotePath = remoteDirectoryPath;
                    }

                    // Deploy file
                    _currentTransferEventArgs = new DeployerPluginInterfaces.TransferEventArgs(localFilePath);
                    //string fname = Path.GetFileName(localFilePath);
                    _ftp.Put(localFilePath, remoteFilename);
                }
                catch (Exception ex) {
                    FtpErrorForm dlg = new FtpErrorForm();
                    dlg.ErrorMessage = ex.Message;
                    dlg.LocalFile = localFilePath;
                    dlg.RemotePath = remoteDirectoryPath;
                    DialogResult result = dlg.ShowDialog();
                    switch(result) {
                        case DialogResult.Retry:
                            retry = true;
                            break;
                        case DialogResult.Ignore:
                            break;
                        case DialogResult.Cancel:
                            throw new DeployCancelException("User cancelled.");
                    }
                }
            } while (retry);
        }
Beispiel #4
0
        private void EventManager_TransferProgress(TransferEventArgs e)
        {
            if (_currentQueueItem >= 0) {
                int percent = CalculateTransferPercent(e.BytesSent, e.TotalBytes);
                _progressdialog.ItemProgress.Value = percent;

                ProgressBar pb = (ProgressBar)_fileQueueList.Items[_currentQueueItem].SubItems[(int)FileQueueListColumns.Progress].Control;
                pb.Value = percent;

                PumpProgressEvents();
            }

            CheckDeployAbort();
        }
Beispiel #5
0
        private void EventManager_TransferComplete(TransferEventArgs e)
        {
            _progressdialog.TotalProgress.Value++;
            _progressdialog.TotalText =
                string.Format("Files: {0}/{1}", _progressdialog.TotalProgress.Value, _progressdialog.TotalProgress.Maximum);
            UpdateProgressPercent();

            int percent = CalculateTransferPercent(e.BytesSent, e.TotalBytes);
            if (_currentQueueItem >= 0) {
                _progressdialog.ItemProgress.Value = percent;

                ProgressBar pb = (ProgressBar)_fileQueueList.Items[_currentQueueItem].SubItems[(int)FileQueueListColumns.Progress].Control;
                pb.Value = percent;

                if (percent < 100 || !_queueAutoRemove.Checked)
                    _currentQueueItem++;		// Skip item
                else {
                    _fileQueueList.Items.Remove(_currentQueueItem);		// Remove item
                    _fileQueueList.Refresh();
                }
            }

            CheckDeployAbort();

            Application.DoEvents();
        }
Beispiel #6
0
        private void EventManager_TransferBegin(TransferEventArgs e)
        {
            // Find current item
            _currentQueueItem = -1; // Assume we can't find it
            for (int i = 0; i < _fileQueueList.Items.Count; i++) {
                if (_fileQueueList.Items[i].Text == e.Filename) {
                    _currentQueueItem = i;
                    _progressdialog.ItemProgress.Maximum = 100;
                    _progressdialog.ItemProgress.Value = 0;
                    _progressdialog.ItemText = string.Format("Transfering: \"{0}\"...", e.Filename);

                    Application.DoEvents();
                    break;
                }
            }
            CheckDeployAbort();
        }