Ejemplo n.º 1
0
        /// <summary>
        /// Sets the contents of the package from the given experiment, types and components.
        /// </summary>
        /// <param name="pInfo">Experiment info.</param>
        /// <param name="pTypes">Collection of type assembly files.</param>
        /// <param name="pComponents">Collection of component assembly files.</param>
        /// <returns></returns>
        private PackageSourceInfo SetPackageContent(ExperimentInfo pInfo, ISet <string> pTypes, ISet <string> pComponents)
        {
            var info = new PackageSourceInfo();

            // Adding components
            if (pComponents.Count > 0)
            {
                PackageHeirarchyItem componentsFolder = CreateFolder(info.Root, "Components");
                componentsFolder.HasComponents = true;
                foreach (string component in pComponents)
                {
                    AddFile(componentsFolder, component);
                }
            }

            // Adding experiment
            PackageHeirarchyItem experimentFolder = CreateFolder(info.Root, "Experiment");

            AddFile(experimentFolder, pInfo.FilePath);
            info.Name = pInfo.Name + " Package";

            // Adding types
            if (pTypes.Count > 0)
            {
                PackageHeirarchyItem typesFolder = CreateFolder(info.Root, "Types");
                typesFolder.HasTypes = true;
                foreach (string type in pTypes)
                {
                    AddFile(typesFolder, type);
                }
            }

            return(info);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new empty instance of the Package Builder.
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();
            var info = new PackageSourceInfo();

            DataContext = info;
        }
Ejemplo n.º 3
0
        private void GenerateExperimentPackageButton_Click(object sender, RoutedEventArgs e)
        {
            var viewModel             = (PackageBuilderViewModel)DataContext;
            var ePkgResults           = viewModel.Pack();
            PackageSourceInfo pkgInfo = SetPackageContent(ePkgResults);

            viewModel.PackageSourceInfo = pkgInfo;
            viewModel.CurrentState      = PackageBuilderWizardPage.FileViewer;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the Package Builder with context set to the given experiment,
        /// types and components.
        /// </summary>
        /// <param name="pInfo">Experiment info.</param>
        /// <param name="pTypes">Collection of type assembly files.</param>
        /// <param name="pComponents">Collection of component assembly files.</param>
        public MainWindow(ExperimentInfo pInfo, ISet <string> pTypes, ISet <string> pComponents)
        {
            InitializeComponent();
            this.isExperimentPackage = true;
            PackageSourceInfo pkgInfo = SetPackageContent(pInfo, pTypes, pComponents);

            BuildButton.IsEnabled = (pkgInfo.Root.Children.Count > 0);
            DataContext           = pkgInfo;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Sets the contents of the package from the given experiment, types and components.
        /// </summary>
        /// <param name="pInfo">Experiment info.</param>
        /// <param name="pTypes">Collection of type assembly files.</param>
        /// <param name="pComponents">Collection of component assembly files.</param>
        /// <returns></returns>
        private PackageSourceInfo SetPackageContent(ExperimentPackagingResults pResults)
        {
            var info = new PackageSourceInfo();

            // Adding components
            if (pResults.ComponentAssemblies.Count > 0)
            {
                PackageHeirarchyItem componentsFolder = CreateFolder(info.Root, "Components");
                componentsFolder.HasComponents = true;
                foreach (string component in pResults.ComponentAssemblies)
                {
                    AddFile(componentsFolder, component);
                }
            }

            // Adding experiment
            PackageHeirarchyItem experimentFolder = CreateFolder(info.Root, "Experiment");

            AddFile(experimentFolder, pResults.Experiment.ExperimentInfo.FilePath);
            info.Name = pResults.Experiment.ExperimentInfo.Name + " Package";

            // Adding refered types into subfolder of Experiment
            if (pResults.Files.Count > 0)
            {
                foreach (PackageFileInfo file in pResults.Files)
                {
                    PackageHeirarchyItem lastFolder = CreateRelativeFolders(experimentFolder, file);
                    AddFile(lastFolder, file.AbsoluteLocation);
                }
            }

            //Adding refered directories into subfolder of Experiment
            if (pResults.Directories.Count > 0)
            {
                foreach (PackageFileInfo dir in pResults.Directories)
                {
                    PackageHeirarchyItem lastFolder = CreateRelativeFolders(experimentFolder, dir);
                    AddFolder(lastFolder, dir.AbsoluteLocation);
                }
            }

            // Adding types
            if (pResults.TypeAssemblies.Count > 0)
            {
                PackageHeirarchyItem typesFolder = CreateFolder(info.Root, "Types");
                typesFolder.HasTypes = true;
                foreach (string type in pResults.TypeAssemblies)
                {
                    AddFile(typesFolder, type);
                }
            }

            return(info);
        }
Ejemplo n.º 6
0
        private void TreeListView_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Delete || e.Key == Key.Back)
            {
                TreeListView          view   = (TreeListView)sender;
                PackageSourceInfo     source = (PackageSourceInfo)view.DataContext;
                PackageFileSourceInfo info   = view.SelectedItem as PackageFileSourceInfo;
                if (info != source.Root && info != null)
                {
                    info.Parent.Children.Remove(info);
                    view.Focus();
                }

                // Enabling/Disabling the Build button depending if the package is empty or not
                var pkgInfo = (PackageSourceInfo)DataContext;
                BuildButton.IsEnabled = (pkgInfo.Root.Children.Count > 0);
            }
        }
Ejemplo n.º 7
0
        private void TreeListView_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Delete || e.Key == Key.Back)
            {
                TreeListView view = (TreeListView)sender;

                //data context of the view is multibinding to two objects - the first one is the packageBuilder,
                //the second one is that currentState (so that when it changes the view gets notification)
                List <object> values = view.DataContext as List <object>;
                if (values != null)
                {
                    PackageBuilderViewModel viewModel = (PackageBuilderViewModel)values[0];
                    PackageSourceInfo       source    = viewModel.PackageSourceInfo;
                    PackageFileSourceInfo   info      = view.SelectedItem as PackageFileSourceInfo;
                    if (info != source.Root && info != null)
                    {
                        info.Parent.Children.Remove(info);
                        view.Focus();
                    }
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Handles the Click event of the Build Package Button
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void BuildPkgButton_Click(object sender, RoutedEventArgs e)
        {
            MainBorder.Visibility = System.Windows.Visibility.Visible;

            var viewModel          = (PackageBuilderViewModel)DataContext;
            PackageSourceInfo info = viewModel.PackageSourceInfo;
            bool noError           = true;

            TraceLab.Core.PackageSystem.Package pkg = null;

            string pkgFilePath = GetFilePath(info.Name);

            if (pkgFilePath != null)
            {
                string pkgFileName      = System.IO.Path.GetFileNameWithoutExtension(pkgFilePath);
                string pkgTempDirectory = pkgFilePath + "~temp";

                try
                {
                    System.IO.Directory.CreateDirectory(pkgTempDirectory);

                    try
                    {
                        pkg = new TraceLab.Core.PackageSystem.Package(info.Name, pkgTempDirectory, false);
                    }
                    catch (TraceLab.Core.PackageSystem.PackageAlreadyExistsException)
                    {
                        MessageBox.Show("Package already exists in: " + pkgTempDirectory,
                                        "Package Creation Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        noError = false;
                    }
                    catch (TraceLab.Core.PackageSystem.PackageException ex)
                    {
                        MessageBox.Show("Error creating package: " + ex.Message,
                                        "Package Creation Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        noError = false;
                    }

                    if (pkg != null && noError)
                    {
                        foreach (PackageFileSourceInfo item in info.Files)
                        {
                            noError = noError && AddItemToPackage(pkg, item);
                        }

                        pkg.SaveManifest();

                        using (System.IO.FileStream stream = new System.IO.FileStream(pkgFilePath, System.IO.FileMode.Create))
                        {
                            pkg.Pack(stream);
                        }
                    }
                }
                catch (System.IO.IOException error)
                {
                    MessageBox.Show("Unable to create package. Error: " + error.Message,
                                    "Package Creation Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    noError = false;
                }
                catch (System.UnauthorizedAccessException error)
                {
                    MessageBox.Show("Unable to create package - Unauthorized access: " + error.Message,
                                    "Package Creation Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    noError = false;
                }

                try
                {
                    if (System.IO.Directory.Exists(pkgTempDirectory))
                    {
                        System.IO.Directory.Delete(pkgTempDirectory, true);
                    }
                }
                catch (System.IO.IOException error)
                {
                    MessageBox.Show("Unable to cleanup after package creation. Error: " + error.Message,
                                    "After Package Cleanup Failure", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                }
                catch (System.UnauthorizedAccessException error)
                {
                    MessageBox.Show("Unable to cleanup after package creation. Unauthorized access: " + error.Message,
                                    "After Package Cleanup Failure", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }

            if (noError && pkg != null)
            {
                MessageBox.Show("Package \"" + info.Name + "\" was built successfully.", "Package Created",
                                MessageBoxButton.OK, MessageBoxImage.Information);
            }

            MainBorder.Visibility = System.Windows.Visibility.Hidden;
        }
Ejemplo n.º 9
0
        public void Build(String filePath)
        {
            m_viewModel.GeneratePackageContent(); //it sets the root package source info
            m_viewModel.CurrentState = PackageBuilderWizardPage.FileViewer;

            PackageSourceInfo info = m_viewModel.PackageSourceInfo;
            bool noError           = true;

            TraceLab.Core.PackageSystem.Package pkg = null;

            // string pkgFilePath = GetFilePath(info.Name);
            string pkgFilePath = filePath;
            // HERZUM SPRINT 3: TLAB-206
            string pkgFileName = System.IO.Path.GetFileNameWithoutExtension(pkgFilePath);

            // END HERZUM SPRINT 3: TLAB-206
            if (pkgFilePath != null)
            {
                // string pkgFileName = System.IO.Path.GetFileNameWithoutExtension(pkgFilePath);
                string pkgTempDirectory = pkgFilePath + "~temp";

                try
                {
                    System.IO.Directory.CreateDirectory(pkgTempDirectory);

                    try
                    {
                        // HERZUM SPRINT 3: TLAB-206
                        // pkg = new TraceLab.Core.PackageSystem.Package(info.Name, pkgTempDirectory, false);
                        pkg = new TraceLab.Core.PackageSystem.Package(pkgFileName, pkgTempDirectory, false);
                        // END HERZUM SPRINT 3: TLAB-206
                    }
                    catch (TraceLab.Core.PackageSystem.PackageAlreadyExistsException)
                    {
                        ShowMessageDialog("Package already exists in: " + pkgTempDirectory,
                                          "Package Creation Error", Gtk.ButtonsType.Ok, Gtk.MessageType.Error);
                        noError = false;
                    }
                    catch (TraceLab.Core.PackageSystem.PackageException ex)
                    {
                        ShowMessageDialog("Error creating package: " + ex.Message,
                                          "Package Creation Error", Gtk.ButtonsType.Ok, Gtk.MessageType.Error);
                        noError = false;
                    }

                    if (pkg != null && noError)
                    {
                        foreach (PackageFileSourceInfo item in info.Files)
                        {
                            try
                            {
                                noError = noError && PackageCreator.AddItemToPackage(pkg, item, m_viewModel.IsExperimentPackage);
                            }
                            catch (TraceLab.Core.Exceptions.PackageCreationFailureException ex)
                            {
                                ShowMessageDialog("Error creating package: " + ex.Message,
                                                  "Package Creation Error", Gtk.ButtonsType.Ok, Gtk.MessageType.Error);
                                noError = false;
                            }
                        }

                        pkg.SaveManifest();

                        using (System.IO.FileStream stream = new System.IO.FileStream(pkgFilePath, System.IO.FileMode.Create))
                        {
                            pkg.Pack(stream);
                        }
                    }
                }
                catch (System.IO.IOException error)
                {
                    ShowMessageDialog("Unable to create package. Error: " + error.Message,
                                      "Package Creation Error", Gtk.ButtonsType.Ok, Gtk.MessageType.Error);
                    noError = false;
                }
                catch (System.UnauthorizedAccessException error)
                {
                    ShowMessageDialog("Unable to create package - Unauthorized access: " + error.Message,
                                      "Package Creation Error", Gtk.ButtonsType.Ok, Gtk.MessageType.Error);
                    noError = false;
                }

                try
                {
                    if (System.IO.Directory.Exists(pkgTempDirectory))
                    {
                        System.IO.Directory.Delete(pkgTempDirectory, true);
                    }
                }
                catch (System.IO.IOException error)
                {
                    ShowMessageDialog("Unable to cleanup after package creation. Error: " + error.Message,
                                      "After Package Cleanup Failure", Gtk.ButtonsType.Ok, Gtk.MessageType.Warning);
                }
                catch (System.UnauthorizedAccessException error)
                {
                    ShowMessageDialog("Unable to cleanup after package creation. Unauthorized access: " + error.Message,
                                      "After Package Cleanup Failure", Gtk.ButtonsType.Ok, Gtk.MessageType.Warning);
                }
            }

            if (noError && pkg != null)
            {
                // HERZUM SPRINT 3: TLAB-206
                // ShowMessageDialog("Package \"" + info.Name + "\" was built successfully.", "Package Created",
                ShowMessageDialog("Package \"" + pkgFileName + "\" was built successfully.", "Package Created",
                                  // END HERZUM SPRINT 3: TLAB-206
                                  Gtk.ButtonsType.Ok, Gtk.MessageType.Info);
            }
        }
Ejemplo n.º 10
0
        protected void buildButtonClicked(object sender, EventArgs e)
        {
            PackageSourceInfo info = m_viewModel.PackageSourceInfo;
            bool noError           = true;

            TraceLab.Core.PackageSystem.Package pkg = null;

            string pkgFilePath = GetFilePath(info.Name);

            if (pkgFilePath != null)
            {
                string pkgFileName      = System.IO.Path.GetFileNameWithoutExtension(pkgFilePath);
                string pkgTempDirectory = pkgFilePath + "~temp";

                try
                {
                    System.IO.Directory.CreateDirectory(pkgTempDirectory);

                    // HERZUM SPRINT 4.2: TLAB-215
                    if (info.Name.Contains(" "))
                    {
                        ShowMessageDialog("Package name:" + info.Name + ", can not contain space characters: ",
                                          "Package Creation Error", Gtk.ButtonsType.Ok, Gtk.MessageType.Error);
                        noError = false;
                    }
                    // END HERZUM SPRINT 4.2: TLAB-215

                    try
                    {
                        pkg = new TraceLab.Core.PackageSystem.Package(info.Name, pkgTempDirectory, false);
                    }
                    catch (TraceLab.Core.PackageSystem.PackageAlreadyExistsException)
                    {
                        ShowMessageDialog("Package already exists in: " + pkgTempDirectory,
                                          "Package Creation Error", Gtk.ButtonsType.Ok, Gtk.MessageType.Error);
                        noError = false;
                    }
                    catch (TraceLab.Core.PackageSystem.PackageException ex)
                    {
                        ShowMessageDialog("Error creating package: " + ex.Message,
                                          "Package Creation Error", Gtk.ButtonsType.Ok, Gtk.MessageType.Error);
                        noError = false;
                    }

                    if (pkg != null && noError)
                    {
                        foreach (PackageFileSourceInfo item in info.Files)
                        {
                            try
                            {
                                noError = noError && PackageCreator.AddItemToPackage(pkg, item, m_viewModel.IsExperimentPackage);
                            }
                            catch (TraceLab.Core.Exceptions.PackageCreationFailureException ex)
                            {
                                ShowMessageDialog("Error creating package: " + ex.Message,
                                                  "Package Creation Error", Gtk.ButtonsType.Ok, Gtk.MessageType.Error);
                                noError = false;
                            }
                        }

                        pkg.SaveManifest();

                        using (System.IO.FileStream stream = new System.IO.FileStream(pkgFilePath, System.IO.FileMode.Create))
                        {
                            pkg.Pack(stream);
                        }
                    }
                }
                catch (System.IO.IOException error)
                {
                    ShowMessageDialog("Unable to create package. Error: " + error.Message,
                                      "Package Creation Error", Gtk.ButtonsType.Ok, Gtk.MessageType.Error);
                    noError = false;
                }
                catch (System.UnauthorizedAccessException error)
                {
                    ShowMessageDialog("Unable to create package - Unauthorized access: " + error.Message,
                                      "Package Creation Error", Gtk.ButtonsType.Ok, Gtk.MessageType.Error);
                    noError = false;
                }

                try
                {
                    if (System.IO.Directory.Exists(pkgTempDirectory))
                    {
                        System.IO.Directory.Delete(pkgTempDirectory, true);
                    }
                }
                catch (System.IO.IOException error)
                {
                    ShowMessageDialog("Unable to cleanup after package creation. Error: " + error.Message,
                                      "After Package Cleanup Failure", Gtk.ButtonsType.Ok, Gtk.MessageType.Warning);
                }
                catch (System.UnauthorizedAccessException error)
                {
                    ShowMessageDialog("Unable to cleanup after package creation. Unauthorized access: " + error.Message,
                                      "After Package Cleanup Failure", Gtk.ButtonsType.Ok, Gtk.MessageType.Warning);
                }
            }

            if (noError && pkg != null)
            {
                ShowMessageDialog("Package \"" + info.Name + "\" was built successfully.", "Package Created",
                                  Gtk.ButtonsType.Ok, Gtk.MessageType.Info);
            }
        }