private void buttonDeleteIFC_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (dataGridIfc.SelectedItems.Count > 0)
                {
                    int         index = dataGridOpenSolibri.SelectedIndex;
                    ProcessUnit unit  = processUnits[index];

                    for (int i = dataGridIfc.SelectedItems.Count - 1; i > -1; i--)
                    {
                        OpenModel model = dataGridIfc.SelectedItems[i] as OpenModel;
                        unit.IfcFiles.Remove(model);
                    }

                    processUnits.RemoveAt(index);
                    processUnits.Insert(index, unit);
                    dataGridOpenSolibri.SelectedIndex = index;
                    isEditing = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to delete IFC items.\n" + ex.Message, "Delete IFC Items", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
示例#2
0
        private static void DetermineCheckEnabled(ProcessUnit unit, out bool checkEnabled, out bool commentEnabled)
        {
            checkEnabled   = false;
            commentEnabled = false;
            try
            {
                if (unit.PresentationCreate.IsSelected || unit.PresentationUpdate.IsSelected)
                {
                    checkEnabled   = true;
                    commentEnabled = true;
                    return;
                }

                if (!string.IsNullOrEmpty(unit.CheckingReport.PdfFile) || !string.IsNullOrEmpty(unit.CheckingReport.RtfFile))
                {
                    checkEnabled = true;
                }
                if (!string.IsNullOrEmpty(unit.PresentationReport.PdfFile) || !string.IsNullOrEmpty(unit.PresentationReport.RtfFile) || !string.IsNullOrEmpty(unit.BCFReport.File) || !string.IsNullOrEmpty(unit.CoordReport.File))
                {
                    checkEnabled   = true;
                    commentEnabled = true;
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
            }
        }
        private void buttonAddIFC_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (null != dataGridOpenSolibri.SelectedItem)
                {
                    int         index = dataGridOpenSolibri.SelectedIndex;
                    ProcessUnit unit  = processUnits[index];

                    OpenFileDialog openDialog = new OpenFileDialog();
                    openDialog.Filter      = "IFC files (*.ifc)|*.ifc";
                    openDialog.Title       = "Add IFC Files to be Combined";
                    openDialog.Multiselect = true;
                    if (openDialog.ShowDialog() == true)
                    {
                        foreach (string fileName in openDialog.FileNames)
                        {
                            unit.IfcFiles.Add(new OpenModel(fileName));
                        }

                        processUnits.RemoveAt(index);
                        processUnits.Insert(index, unit);
                        dataGridOpenSolibri.SelectedIndex = index;

                        isEditing = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to add IFC items.\n" + ex.Message, "Add IFC Items", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
示例#4
0
        public static ObservableCollection <ProcessUnit> ExtractProcessUnits(Batch batch)
        {
            ObservableCollection <ProcessUnit> processUnits = new ObservableCollection <ProcessUnit>();

            try
            {
                ProcessUnit unit = new ProcessUnit();
                ObservableCollection <GenericElement> elements = batch.Target.Elements;
                for (int i = 0; i < elements.Count; i++)
                {
                    GenericElement element     = elements[i];
                    string         elementType = element.GetType().Name;
                    switch (elementType)
                    {
                    case "OpenModel":
                        OpenModel openModel = element as OpenModel;
                        if (openModel.FileExtension == ".smc")
                        {
                            unit.OpenSolibri = openModel;
                        }
                        else if (openModel.FileExtension == ".ifc")
                        {
                            unit.IfcFiles.Add(openModel);
                        }
                        break;

                    case "BCFReport":
                        unit.BCFReport = element as BCFReport;
                        break;

                    case "SaveModel":
                        unit.SaveSolibri = element as SaveModel;
                        if (unit.IfcFiles.Count > 0)
                        {
                            unit.OpenSolibri = new OpenModel(unit.SaveSolibri.File);
                        }
                        break;

                    case "CloseModel":
                        processUnits.Add(unit);
                        unit = new ProcessUnit();
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to extract process units.\n" + ex.Message, "Extract Process Unit", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            return(processUnits);
        }
 private void UpdateSettings()
 {
     try
     {
         for (int i = processUnits.Count - 1; i > -1; i--)
         {
             ProcessUnit unit = processUnits[i];
             unit = ApplySettings(unit);
             processUnits.RemoveAt(i);
             processUnits.Insert(i, unit);
         }
     }
     catch (Exception ex)
     {
         string message = ex.Message;
     }
 }
 private void buttonDeleteTask_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (dataGridTasks.SelectedItems.Count > 0)
         {
             for (int i = dataGridTasks.SelectedItems.Count - 1; i > -1; i--)
             {
                 ProcessUnit unit = dataGridTasks.SelectedItems[i] as ProcessUnit;
                 processUnits.Remove(unit);
             }
         }
     }
     catch (Exception ex)
     {
         string message = ex.Message;
     }
 }
 private void buttonAddTask_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         CreateTaskWindow taskWindow = new CreateTaskWindow();
         taskWindow.Owner = this;
         if ((bool)taskWindow.ShowDialog())
         {
             ProcessUnit unit = taskWindow.Task;
             processUnits.Add(unit);
             dataGridTasks.SelectedIndex = processUnits.IndexOf(unit);
             ApplySettings(dataGridTasks.SelectedIndex);
         }
     }
     catch (Exception ex)
     {
         string message = ex.Message;
     }
 }
        private void dataGridOpenSolibri_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                dataGridIfc.ItemsSource = null;
                if (null != dataGridOpenSolibri.SelectedItem)
                {
                    ProcessUnit selectedUnit = dataGridOpenSolibri.SelectedItem as ProcessUnit;
                    dataGridIfc.ItemsSource = selectedUnit.IfcFiles;

                    int index = dataGridOpenSolibri.SelectedIndex;
                    dataGridBCF.SelectedIndex         = index;
                    dataGridSaveSolibri.SelectedIndex = index;
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
            }
        }
        private void buttonCombineIFC_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.Filter           = "IFC files (*.ifc)|*.ifc";
                openFileDialog.RestoreDirectory = false;
                openFileDialog.Title            = "Open IFC Files";
                openFileDialog.Multiselect      = true;
                if (openFileDialog.ShowDialog() == true)
                {
                    if (openFileDialog.FileNames.Length > 0)
                    {
                        ProcessUnit unit = new ProcessUnit();
                        foreach (string fileName in openFileDialog.FileNames)
                        {
                            unit.IfcFiles.Add(new OpenModel(fileName));
                        }

                        IFCWindow ifcWindow = new IFCWindow(unit);
                        if (ifcWindow.ShowDialog() == true)
                        {
                            unit = ifcWindow.Unit;
                            if (commonRuleSets.Count > 0)
                            {
                                //autorunSetting
                                unit = ApplySettings(unit);
                            }
                            processUnits.Add(unit);
                        }
                        isEditing = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to combine IFC files.\n" + ex.Message, "Combine IFC files", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
示例#10
0
        private void buttonDeleteSolibri_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (dataGridOpenSolibri.SelectedItems.Count > 0)
                {
                    for (int i = dataGridOpenSolibri.SelectedItems.Count - 1; i > -1; i--)
                    {
                        ProcessUnit unit = dataGridOpenSolibri.SelectedItems[i] as ProcessUnit;
                        if (null != unit)
                        {
                            processUnits.Remove(unit);
                        }
                    }

                    isEditing = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to delete Solibri items.\n" + ex.Message, "Delete Solibri Items", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
示例#11
0
 private void buttonAddSolibri_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         OpenFileDialog openDialog = new OpenFileDialog();
         openDialog.Filter      = "Solibri Model Checker Files (*.smc)|*.smc";
         openDialog.Title       = "Open Solibri Models";
         openDialog.Multiselect = true;
         if (openDialog.ShowDialog() == true)
         {
             string      fileName = openDialog.FileName;
             ProcessUnit unit     = new ProcessUnit();
             unit.OpenSolibri = new OpenModel(fileName);
             unit             = ApplySettings(unit);
             processUnits.Add(unit);
             isEditing = true;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Failed to add solibri files.\n" + ex.Message, "Add Solibri Items", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
示例#12
0
 private void buttonSetting_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         SettingWindow settingWindow = new SettingWindow(settings);
         settingWindow.Owner = this;
         if (settingWindow.ShowDialog() == true)
         {
             settings = settingWindow.Settings;
             for (int i = processUnits.Count - 1; i > -1; i--)
             {
                 ProcessUnit unit = processUnits[i];
                 unit = ApplySettings(unit);
                 processUnits.RemoveAt(i);
                 processUnits.Insert(i, unit);
             }
         }
     }
     catch (Exception ex)
     {
         string message = ex.Message;
     }
 }
示例#13
0
        private ProcessUnit ApplySettings(ProcessUnit unit)
        {
            ProcessUnit pUnit = unit;

            try
            {
                string solibriFileName = unit.OpenSolibri.File;
                string dateSuffix      = DateTime.Now.ToString("yyyy-MM-dd");
                string fileNameOnly    = System.IO.Path.GetFileNameWithoutExtension(solibriFileName);
                string smcFileName     = System.IO.Path.GetFileName(solibriFileName);
                if (settings.SaveSolibriSettings.SaveInPlace)
                {
                    if (settings.SaveSolibriSettings.AppendDate)
                    {
                        solibriFileName = solibriFileName.Replace(smcFileName, fileNameOnly + "-" + dateSuffix + ".smc");
                    }
                }
                else
                {
                    string folder = settings.SaveSolibriSettings.OutputFolder;
                    if (settings.SaveSolibriSettings.AppendDate)
                    {
                        solibriFileName = System.IO.Path.Combine(folder, fileNameOnly + "-" + dateSuffix + ".smc");
                    }
                    else
                    {
                        solibriFileName = System.IO.Path.Combine(folder, smcFileName);
                    }
                }
                unit.SaveSolibri = new SaveModel(solibriFileName);

                string bcfFileName = "";
                if (commonRuleSets.Count > 0)
                {
                    if (settings.SaveBCFSettings.SaveInPlace)
                    {
                        string directory = System.IO.Path.GetDirectoryName(unit.OpenSolibri.File);
                        if (settings.SaveBCFSettings.AppendDate)
                        {
                            bcfFileName = System.IO.Path.Combine(directory, fileNameOnly + "-" + dateSuffix + ".bcfzip");
                        }
                        else
                        {
                            bcfFileName = System.IO.Path.Combine(directory, fileNameOnly + ".bcfzip");
                        }
                    }
                    else
                    {
                        string folder = settings.SaveBCFSettings.OutputFolder;
                        if (settings.SaveBCFSettings.AppendDate)
                        {
                            bcfFileName = System.IO.Path.Combine(folder, fileNameOnly + "-" + dateSuffix + ".bcfzip");
                        }
                        else
                        {
                            bcfFileName = System.IO.Path.Combine(folder, fileNameOnly + ".bcfzip");
                        }
                    }
                }

                unit.BCFReport = new BCFReport(bcfFileName);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to apply settings.\n" + ex.Message, "Apply Settings", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            return(pUnit);
        }
示例#14
0
        private void Window_Drop(object sender, DragEventArgs e)
        {
            try
            {
                if (e.Data.GetDataPresent(DataFormats.FileDrop))
                {
                    string[]      files        = (string[])e.Data.GetData(DataFormats.FileDrop);
                    string        xmlFile      = "";
                    List <string> solibriFiles = new List <string>();
                    List <string> ifcFiles     = new List <string>();
                    List <string> rulesetFiles = new List <string>();
                    foreach (string file in files)
                    {
                        if (System.IO.Path.GetExtension(file).Contains("smc"))
                        {
                            solibriFiles.Add(file);
                        }
                        if (System.IO.Path.GetExtension(file).Contains("xml"))
                        {
                            xmlFile = file; break;
                        }
                        if (System.IO.Path.GetExtension(file).Contains("ifc"))
                        {
                            ifcFiles.Add(file);
                        }
                        if (System.IO.Path.GetExtension(file).Contains("cset"))
                        {
                            rulesetFiles.Add(file);
                        }
                    }

                    if (!string.IsNullOrEmpty(xmlFile))
                    {
                        bool read = BatchSetupUtils.ReadBatchConfig(xmlFile, out batch);
                        if (read)
                        {
                            processUnits   = BatchSetupUtils.ExtractProcessUnits(batch);
                            commonRuleSets = BatchSetupUtils.ExtractRulesets(batch);
                            DisplayConfig();
                        }
                    }
                    else
                    {
                        if (solibriFiles.Count > 0)
                        {
                            foreach (string sfile in solibriFiles)
                            {
                                ProcessUnit pUnit = new ProcessUnit();
                                pUnit.OpenSolibri = new OpenModel(sfile);
                                pUnit             = ApplySettings(pUnit);
                                processUnits.Add(pUnit);
                            }
                            dataGridOpenSolibri.SelectedIndex = processUnits.Count - 1;
                            isEditing = true;
                        }

                        if (rulesetFiles.Count > 0)
                        {
                            bool updateBCF = false;
                            if (commonRuleSets.Count == 0)
                            {
                                updateBCF = true;
                            }

                            foreach (string ruleset in rulesetFiles)
                            {
                                commonRuleSets.Add(new OpenRuleset(ruleset));
                            }
                            if (updateBCF)
                            {
                                UpdateSettings();
                            }
                            isEditing = true;
                        }
                        if (ifcFiles.Count > 0)
                        {
                            ProcessUnit pUnit = new ProcessUnit();
                            foreach (string ifcFile in ifcFiles)
                            {
                                pUnit.IfcFiles.Add(new OpenModel(ifcFile));
                            }
                            IFCWindow ifcWindow = new IFCWindow(pUnit);
                            if (ifcWindow.ShowDialog() == true)
                            {
                                pUnit = ifcWindow.Unit;
                                pUnit = ApplySettings(pUnit);
                                processUnits.Add(pUnit);
                                dataGridOpenSolibri.SelectedIndex = processUnits.Count - 1;
                                isEditing = true;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to drop files.\n" + ex.Message, "File Drop", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
示例#15
0
        public static ObservableCollection <ProcessUnit> ExtractProcessUnits(Batch batch)
        {
            ObservableCollection <ProcessUnit> processUnits = new ObservableCollection <ProcessUnit>();

            try
            {
                ProcessUnit unit = new ProcessUnit();
                ObservableCollection <GenericElement> elements = batch.Target.Elements;
                for (int i = 0; i < elements.Count; i++)
                {
                    GenericElement element     = elements[i];
                    string         elementType = element.GetType().Name;
                    switch (elementType)
                    {
                    case "OpenModel":
                        OpenModel openModel = element as OpenModel;
                        if (openModel.FileExtension == ".smc")
                        {
                            unit.OpenSolibri = openModel;
                        }
                        else if (modelExtensions.Contains(openModel.FileExtension))
                        {
                            InputModel modeltoOpen = new InputModel(openModel);
                            unit.Models.Add(modeltoOpen);
                        }
                        break;

                    case "UpdateModel":
                        UpdateModel updateModel   = element as UpdateModel;
                        InputModel  modeltoUpdate = new InputModel(updateModel);
                        unit.Models.Add(modeltoUpdate);
                        break;

                    case "OpenRuleset":
                        OpenRuleset ruleset = element as OpenRuleset;
                        unit.Rulesets.Add(ruleset);
                        break;

                    case "OpenClassification":
                        OpenClassification classification = element as OpenClassification;
                        unit.Classifications.Add(classification);
                        break;

                    case "Check":
                        Check check = element as Check;
                        check.IsSpecified = true;
                        unit.CheckTask    = check;
                        break;

                    case "AutoComment":
                        AutoComment comment = element as AutoComment;
                        comment.IsSpecified = true;
                        unit.CommentTask    = comment;
                        break;

                    case "WriterReport":
                        unit.CheckingReport = element as WriterReport;
                        break;

                    case "CreatePresentation":
                        CreatePresentation createP = element as CreatePresentation;
                        createP.IsSelected      = true;
                        unit.PresentationCreate = createP;
                        break;

                    case "UpdatePresentation":
                        UpdatePresentation updateP = element as UpdatePresentation;
                        updateP.IsSelected      = true;
                        unit.PresentationUpdate = updateP;
                        break;

                    case "GeneralReport":
                        unit.PresentationReport = element as GeneralReport;
                        break;

                    case "BCFReport":
                        unit.BCFReport = element as BCFReport;
                        break;

                    case "CoordinationReport":
                        unit.CoordReport = element as CoordinationReport;
                        break;

                    case "SaveModel":
                        unit.SaveSolibri = element as SaveModel;
                        unit.TaskName    = System.IO.Path.GetFileNameWithoutExtension(unit.SaveSolibri.File);
                        break;

                    case "CloseModel":
                        processUnits.Add(unit);
                        unit = new ProcessUnit();
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to extract process units.\n" + ex.Message, "Extract Process Unit", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            return(processUnits);
        }
示例#16
0
 public IFCWindow(ProcessUnit pUnit)
 {
     unit = pUnit;
     InitializeComponent();
 }