public ServiceAddWindow(BimbotDocument document)
        {
            InitializeComponent();
            DataContext           = this;
            CurrentBimbotDocument = document;

            // Get services
            if (AvailableServices == null)
            {
                AvailableServices = new ObservableCollection <Service>();
                GetAvailableServices();
            }
            ReUseAuthorizedProviders(document);

            this.Title = "Add service to project '" + CurrentBimbotDocument.Name + "'";

            // Fill the combobox of triggers
            newTrigger.Items.Clear();
            foreach (string key in textToTrigger.Keys)
            {
                newTrigger.Items.Add(key);
            }

            // Fill the combobox of configurations
            IFCExportConfigurationsMapCustom configurationsMap = new IFCExportConfigurationsMapCustom();

            foreach (var config in configurationsMap.Values)
            {
                newConfiguration.Items.Add(config);
            }
        }
Beispiel #2
0
        public void Execute(UIApplication app)
        {
            doc = app.ActiveUIDocument.Document;
            try
            {
                Dictionary <string, byte[]> ifcData = new Dictionary <string, byte[]>();
                foreach (Service service in services)
                {
                    // Skip creation of ifcData generation when this already exists
                    // (checked by ifcexportconfiguration name of the service)
                    //
                    if (ifcData.ContainsKey(service.IfcExportConfiguration))
                    {
                        continue;
                    }

                    // Export to IFC according to all used Ifc export configurations
                    IFCExportConfigurationsMapCustom configurationsMap = new IFCExportConfigurationsMapCustom();
                    foreach (IFCExportConfigurationCustom config in configurationsMap.Values)
                    {
                        if (config.Name.Equals(service.IfcExportConfiguration))
                        {
                            IFCExportOptions IFCOptions = new IFCExportOptions();

                            //Get the current view Id, or -1 if you want to export the entire model
                            config.ActiveViewId = -1;

                            //Update the IFCExportOptions
                            config.UpdateOptions(IFCOptions, null);

                            string filename = IfcUtils.ExportProjectToIFC(doc, IFCOptions);
                            ifcData.Add(config.Name, File.ReadAllBytes(filename));
                            File.Delete(filename);
                        }
                    }
                }

                BackgroundWorker bgw = new BackgroundWorker();
                bgw.DoWork             += new DoWorkEventHandler(bgWorker_DoWork);
                bgw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bgWorker_Completed);
                bgw.RunWorkerAsync(new Tuple <Document, Dictionary <string, byte[]> >(doc, ifcData));
            }
            catch (Exception e)
            {
                MessageBox.Show("Failed to create IFC data to send to services.");
            }
        }