Exemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();

            // Hide modal windows
            gridEditParams.Visibility   = Visibility.Hidden;
            gridBatchMonitor.Visibility = Visibility.Hidden;

            // Instantiate the main Manager object
            MainManager = new Manager();

            // Get all libraries from Unifi and display in the libraries combobox
            MainManager.Libraries = Unifi.GetLibraries();

            // Sort the libraries by name
            MainManager.Libraries.OrderBy(o => o.Name).ToList();

            // Add each library to the combobox as items
            foreach (var library in MainManager.Libraries)
            {
                comboLibraries.Items.Add(library);
            }

            MainManager.Assets = Asset.GetAssetsFromDb(Connector.InitializeSheet());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Edit form Save button click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            // Get selected row as a Content object
            var selectedItem = dataGridMain.SelectedItems.OfType <Content>().ToList().FirstOrDefault();

            if (selectedItem == null)
            {
                return;
            }

            // Get selected Type Name
            var familyTypeName = comboFamilyTypes.SelectedValue.ToString();

            try {
                // Call API to set the Type Parameter value and retrieve the response as Batch object
                var batchManufacturer =
                    Unifi.SetTypeParameterValue(selectedItem, familyTypeName, "Manufacturer", txtBxManufacturer.Text, "TEXT", 2016);
                var batchModel = Unifi.SetTypeParameterValue(selectedItem, familyTypeName, "Model", txtBxModel.Text, "TEXT", 2016);

                comboBatches.Items.Add(batchManufacturer.BatchId);
                comboBatches.Items.Add(batchModel.BatchId);
            }
            catch (Exception ex) { MessageBox.Show(ex.ToString()); }

            CloseEditForm();
        }
Exemplo n.º 3
0
        private void editContent(Content selectedContent)
        {
            // Show form for editing parameters
            gridEditParams.Visibility = Visibility.Visible;

            // Prepopulate Manufacturer and Model fields
            if (selectedContent.Manufacturer != "")
            {
                txtBxManufacturer.Text = selectedContent.Manufacturer;
            }

            if (selectedContent.Model != "")
            {
                txtBxModel.Text = selectedContent.Model;
            }

            // Get Revit Family Types
            selectedContent.FamilyTypes = Unifi.GetFamilyTypes(selectedContent);

            // Add each Revit Family Type to the combobox as items
            foreach (var familyType in selectedContent.FamilyTypes)
            {
                comboFamilyTypes.Items.Add(familyType);
            }

            // Select first Family Type in list
            comboFamilyTypes.SelectedIndex = 0;
        }
        public MainWindow()
        {
            InitializeComponent();

            // Hide modal windows
            gridEditParams.Visibility   = Visibility.Hidden;
            gridBatchMonitor.Visibility = Visibility.Hidden;

            // Get all libraries from Unifi and display in the libraries combobox
            var libraries = Unifi.GetLibraries(Secrets.ApiKey);

            // Sort the libraries by name
            libraries = libraries.OrderBy(o => o.Name).ToList();

            // Add each library to the combobox as items
            foreach (var library in libraries)
            {
                comboLibraries.Items.Add(library);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Method to execute whenever the Library selection changes
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ComboLibraries_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // Assign the selected Library
            SelectedLibrary = comboLibraries.SelectedItem as Library;

            // Get all content from the select library
            MainManager.Families = Unifi.GetContentFromLibrary(SelectedLibrary.Id);

            // Loop through all Content and retrieve Manufacturer and Model parameter data
            foreach (var c in MainManager.Families)
            {
                c.Manufacturer = Unifi.GetParameterByName(c, "Manufacturer").Value;
                c.Model        = Unifi.GetParameterByName(c, "Model").Value;
            }

            // Display list of Content objects in main DataGrid
            dataGridMain.ItemsSource = MainManager.Families;

            // Update status message
            textBoxStatus.Text = SelectedLibrary.Name + ": " + MainManager.Families.Count().ToString();
        }
Exemplo n.º 6
0
        /// <summary>
        /// Check the status of a batch and display monitor data
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void BtnRefreshBatchMon_Click(object sender, RoutedEventArgs e)
        {
            // Get BatchId from combobox
            if (comboBatches.SelectedItem == null)
            {
                return;
            }

            var batchId = comboBatches.SelectedItem.ToString();

            var loading = $"[{DateTime.Now.ToLocalTime()}] {batchId}: Loading...";

            listBatchStatus.Items.Add(loading);

            // Retrieve BatchStatus and display data
            var status = await Unifi.GetBatchStatus(batchId);

            listBatchStatus.Items.Remove(loading);
            listBatchStatus.Items.Add($"[{DateTime.Now.ToLocalTime()}] {batchId} {status.TotalFiles} Files | " +
                                      $"{status.PendingFiles} Pending | {status.OkFiles} Complete | {status.FailedFiles} Failed");
        }
        /// <summary>
        /// Method to execute whenever the Library selection changes
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ComboLibraries_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (!(comboLibraries.SelectedItem is Library selectedLib))
            {
                return;
            }

            // Get all content from the select library
            var contentList = Unifi.GetContentFromLibrary(Secrets.ApiKey, selectedLib.Id);

            // Loop through all Content and retrieve Manufacturer and Model parameter data
            foreach (var c in contentList)
            {
                var parameters = new List <Parameter>();
                parameters = c.Parameters.ToList();

                // Loop through all parameters to retrieve the Manufacturer and Model parameter values for display in DataGrid
                foreach (var p in parameters)
                {
                    // Pass parameter values to Content object
                    if (p.Name == "Manufacturer")
                    {
                        c.Manufacturer = p.Value;
                    }

                    if (p.Name == "Model")
                    {
                        c.Model = p.Value;
                    }
                }
            }

            // Display list of Content objects in main DataGrid
            dataGridMain.ItemsSource = contentList;

            // Update status message
            textBoxStatus.Text = selectedLib.Name + ": " + contentList.Count().ToString();
        }