Пример #1
0
 public ProjectCreator(ProjectRequest projectRequest, ProjectTemplateInfo projectTemplate, IMessageBoxService messageBoxService)
 {
     _projectRequest    = projectRequest;
     _messageBoxService = messageBoxService;
     ProjectTemplate    = projectTemplate;
 }
Пример #2
0
        // Execute the default task sequence on the project.
        // When a template is created from a Single file project, task sequencies is null.
        private void ExecuteTaskSequence(FileBasedProject project, ProjectFile[] projectFiles, ProjectRequest request)
        {
            try
            {
                var taskSequence = project.RunDefaultTaskSequence(projectFiles.GetIds(), (sender, e) =>
                {
                    if (Requests != null)
                    {
                        OnProgressChanged(_currentProgress + (double)e.PercentComplete / Requests.Count);
                    }
                }, (sender, e) =>
                {
                    OnMessageReported(project, e.Message);
                });
                project.Save();

                if (taskSequence.Status.Equals(TaskStatus.Completed))
                {
                    if (SuccessfulRequests != null)
                    {
                        SuccessfulRequests.Add(Tuple.Create(request, project));
                        OnMessageReported(project, $"Project {request.Name} created successfully.");
                    }
                }
                else
                {
                    OnMessageReported(project, $"Project {request.Name} creation failed.");
                }
            }
            catch (Exception ex)
            {
                Log.Logger.Error($"ExecuteTaskSequence method: {ex.Message}\n {ex.StackTrace}");
                _messageBoxService.ShowMessage(PluginResources.ProjectTemplateSequenceSelection_Message, string.Empty);
            }
        }