Beispiel #1
0
        public BCFWindow(Dictionary <string, LinkedBcfFileInfo> fileHistory, FolderHolders folders)
        {
            bcfFileDictionary = fileHistory;
            googleFolders     = folders;
            if (null != googleFolders)
            {
                bcfProjectId     = googleFolders.RootId;
                bcfColorSchemeId = googleFolders.ColorSheet.Id;
            }

            foreach (LinkedBcfFileInfo info in bcfFileDictionary.Values)
            {
                linkedBCFs.Add(info);
            }
            linkedBCFs = linkedBCFs.OrderBy(o => o.BCFName).ToList();

            InitializeComponent();
            if (!string.IsNullOrEmpty(bcfProjectId))
            {
                textBoxId.Text = bcfProjectId;
                sharedLink     = FileManager.GetSharedLinkAddress(bcfProjectId);
            }
            dataGridBCFs.ItemsSource = null;
            dataGridBCFs.ItemsSource = linkedBCFs;
        }
 public OnlineBCFWindow(FolderHolders folders)
 {
     googleFolders = folders;
     projectId     = googleFolders.RootId;
     InitializeComponent();
     labelProjectId.Content = projectId;
     DisplaySheetList();
 }
Beispiel #3
0
        private void buttonAdd_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                bcfProjectId = textBoxId.Text;
                sharedLink   = FileManager.GetSharedLinkAddress(bcfProjectId);
                if (!string.IsNullOrEmpty(bcfProjectId))
                {
                    if (null == googleFolders)
                    {
                        googleFolders = FileManager.FindGoogleFolders(bcfProjectId);
                    }

                    if (null != googleFolders)
                    {
                        //add online BCF
                        OnlineBCFWindow onlineBCFWindow = new OnlineBCFWindow(googleFolders);
                        if (onlineBCFWindow.ShowDialog() == true)
                        {
                            List <OnlineBCFInfo> onlineBCFs = onlineBCFWindow.OnlineBCFs;

                            foreach (OnlineBCFInfo info in onlineBCFs)
                            {
                                if (info.IsSelected)
                                {
                                    OnlineBCFInfo uploadedBCF = FileManager.UploadOnlineBCF(googleFolders, info);
                                    string        bcfName     = uploadedBCF.SheetTitle.Replace("_Markup.csv", "");

                                    LinkedBcfFileInfo linkedBCF = new LinkedBcfFileInfo(bcfName, uploadedBCF.MarkupSheetId, uploadedBCF.ViewpointSheetId, sharedLink, googleFolders.RootTitle, bcfProjectId);
                                    dataGridBCFs.ItemsSource = null;
                                    linkedBCFs.Add(linkedBCF);
                                    linkedBCFs = linkedBCFs.OrderBy(o => o.BCFName).ToList();
                                    dataGridBCFs.ItemsSource = linkedBCFs;
                                }
                            }
                            onlineBCFWindow.Close();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Please enter a valid BCF project Id.", "Invalid BCF Project Id", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to add an online BCF./n" + ex.Message, "Add Online BCF", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Beispiel #4
0
        public ImportBCFWindow(FolderHolders folders)
        {
            googleFolders = folders;
            if (null != googleFolders)
            {
                bcfProjectId = googleFolders.RootId;
            }

            InitializeComponent();
            if (!string.IsNullOrEmpty(bcfProjectId))
            {
                sharedLink         = FileManager.GetSharedLinkAddress(bcfProjectId);
                textBoxFolder.Text = sharedLink;
            }
            AbortFlag.SetAbortFlag(false);
        }
Beispiel #5
0
        private void buttonImport_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(textBoxId.Text))
                {
                    if (textBoxId.Text != bcfProjectId)
                    {
                        bcfProjectId  = textBoxId.Text;
                        sharedLink    = FileManager.GetSharedLinkAddress(bcfProjectId);
                        googleFolders = FileManager.FindGoogleFolders(textBoxId.Text);
                    }
                }
                ImportBCFWindow importWindow = new ImportBCFWindow(googleFolders);
                if (importWindow.ShowDialog() == true)
                {
                    if (importWindow.RememberProjectId)
                    {
                        bcfProjectId     = importWindow.BCFProjectId;
                        bcfColorSchemeId = importWindow.BCFColorSchemeId;
                        googleFolders    = importWindow.GoogleFolders;
                        if (!string.IsNullOrEmpty(bcfProjectId))
                        {
                            textBoxId.Text = bcfProjectId;
                        }
                    }
                    LinkedBcfFileInfo fileInfo = importWindow.BCFFileInfo;

                    dataGridBCFs.ItemsSource = null;
                    linkedBCFs.Add(fileInfo);
                    linkedBCFs = linkedBCFs.OrderBy(o => o.BCFName).ToList();
                    dataGridBCFs.ItemsSource = linkedBCFs;
                    importWindow.Close();
                }
                else
                {
                    importWindow.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to import BCF.\n" + ex.Message, "Import BCF", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Beispiel #6
0
        private void buttonManage_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                UpdateLableDelegate    updateLabelDelegate    = new UpdateLableDelegate(statusLable.SetValue);
                UpdateProgressDelegate updateProgressDelegate = new UpdateProgressDelegate(progressBar.SetValue);

                BCFWindow bcfWindow = new BCFWindow(bcfFileDictionary, googleFolders);
                if (bcfWindow.ShowDialog() == true)
                {
                    Dispatcher.Invoke(updateLabelDelegate, System.Windows.Threading.DispatcherPriority.Background, new object[] { TextBlock.TextProperty, "Loading BCF Information..." });

                    bcfFileDictionary = new Dictionary <string, LinkedBcfFileInfo>();
                    bcfFileDictionary = bcfWindow.BCFFileDictionary;
                    bcfProjectId      = bcfWindow.BCFProjectId;
                    googleFolders     = bcfWindow.GoogleFolders;

                    if (!string.IsNullOrEmpty(bcfProjectId) && null != googleFolders)
                    {
                        bcfColorSchemeId = googleFolders.ColorSheet.Id;
                        categorySheetId  = googleFolders.CategorySheet.Id;
                        bcfWindow.Close();

                        m_handler.BCFFileDictionary = bcfFileDictionary;
                        m_handler.BCFProjectId      = bcfProjectId;
                        m_handler.BCFColorSchemeId  = bcfColorSchemeId;
                        m_handler.CategorySheetId   = categorySheetId;
                        m_handler.GoogleFolders     = googleFolders;
                        m_handler.Request.Make(RequestId.UpdateLinkedFileInfo);
                        m_event.Raise();
                        SetFocus();
                    }

                    Dispatcher.Invoke(updateLabelDelegate, System.Windows.Threading.DispatcherPriority.Background, new object[] { TextBlock.TextProperty, "Ready" });
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to open BCF window.\n" + ex.Message, "Open Manage BCF", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Beispiel #7
0
        public WalkerWindow(ExternalEvent exEvent, WalkerHandler handler)
        {
            m_event   = exEvent;
            m_handler = handler;
            m_handler.WalkerWindow = this;
            InitializeComponent();

            expanderBCF.Header = "Show BCF Info";
            //expanderRowDefinition.Height = new GridLength(40);
            this.MinHeight    = 535;
            this.Height       = 535;
            this.Title        = "smartBCF v." + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
            labelStep.Content = "";

            filterOnImage  = ImageUtil.LoadBitmapImage("filter.png", 24);
            filterOffImage = ImageUtil.LoadBitmapImage("filter_empty.png", 24);

            buttonFilterImage.Source = filterOffImage;

            bcfFileDictionary = m_handler.BCFFileDictionary;
            bcfDictionary     = m_handler.BCFDictionary;
            categoryInfoList  = m_handler.CategoryInfoList;
            schemeInfo        = m_handler.SchemeInfo;
            bcfProjectId      = m_handler.BCFProjectId;
            bcfColorSchemeId  = m_handler.BCFColorSchemeId;
            googleFolders     = m_handler.GoogleFolders;

            if (bcfDictionary.Count > 0)
            {
                currentIndex = 0;
                DisplayLinkedBCF();
                DisplayColorscheme(schemeInfo);
            }
            else
            {
                //MessageBox.Show("Elements cannot be found in the active Revit document.\n", "Elements Not Found", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
        private Dictionary <string, IssueEntry> GetBCFIssueInfo(Document doc, LinkedBcfFileInfo bcfFileInfo)
        {
            Dictionary <string, IssueEntry> issueDictionary = new Dictionary <string, IssueEntry>();

            try
            {
                issueDictionary = FileManager.ReadIssues(bcfFileInfo);

                List <string> issueIds = issueDictionary.Keys.ToList();
                progressWindow.SetMaximum(issueIds.Count);

                double progressValue = 0;
                foreach (string issueId in issueIds)
                {
                    if (AbortFlag.GetAbortFlag())
                    {
                        progressWindow.Close();  return(new Dictionary <string, IssueEntry>());
                    }

                    progressValue++;
                    progressWindow.SetProgressValue(progressValue);

                    IssueEntry issueEntry = issueDictionary[issueId];
                    List <int> elementIds = issueEntry.ElementDictionary.Keys.ToList();
                    foreach (int elementId in elementIds)
                    {
                        ElementProperties property = issueEntry.ElementDictionary[elementId];

                        Element element = m_doc.GetElement(new ElementId(elementId));
                        if (null != element)
                        {
                            if (null != element.Category)
                            {
                                if (!categoryNames.Contains(element.Category.Name))
                                {
                                    categoryNames.Add(element.Category.Name);
                                }

                                if (element.Category.AllowsBoundParameters)
                                {
                                    int categoryId = element.Category.Id.IntegerValue;
                                    if (!catDictionary.ContainsKey(categoryId))
                                    {
                                        BuiltInCategory bltCategory = (BuiltInCategory)categoryId;
                                        if (bltCategory != BuiltInCategory.INVALID)
                                        {
                                            catDictionary.Add(categoryId, bltCategory);
                                        }
                                    }
                                }
                            }

                            ElementProperties ep = new ElementProperties(element);
                            ep.IssueId          = property.IssueId;
                            ep.Action           = property.Action;
                            ep.ResponsibleParty = property.ResponsibleParty;
                            ep.CellEntries      = property.CellEntries;

                            issueDictionary[issueId].ElementDictionary.Remove(elementId);
                            issueDictionary[issueId].ElementDictionary.Add(elementId, ep);
                        }
                    }
                    issueDictionary[issueId].NumElements = issueDictionary[issueId].ElementDictionary.Count;
                    if (null == issueDictionary[issueId].Snapshot)
                    {
                        if (bcfFileInfo.SharedLinkId == bcfProjectId && null != googleFolders)
                        {
                            issueDictionary[issueId].Snapshot = FileManager.DownloadImage(issueId, googleFolders.ActiveImgFolder.Id);
                        }
                        else if (bcfFileInfo.SharedLinkId == bcfProjectId)
                        {
                            googleFolders = FileManager.FindGoogleFolders(bcfProjectId);
                            if (null != googleFolders)
                            {
                                issueDictionary[issueId].Snapshot = FileManager.DownloadImage(issueId, googleFolders.ActiveImgFolder.Id);
                            }
                        }
                        else
                        {
                            FolderHolders tempFolders = FileManager.FindGoogleFolders(bcfFileInfo.SharedLinkId);
                            if (null != tempFolders)
                            {
                                issueDictionary[issueId].Snapshot = FileManager.DownloadImage(issueId, tempFolders.ActiveImgFolder.Id);
                            }
                        }
                    }
                }

                if (bcfDictionary.ContainsKey(bcfFileInfo.MarkupFileId))
                {
                    bcfDictionary.Remove(bcfFileInfo.MarkupFileId);
                }
                bcfDictionary.Add(bcfFileInfo.MarkupFileId, issueDictionary);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to add issue items into BCF dictionary.\n" + ex.Message, "Add BCF to Dictionary", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            return(issueDictionary);
        }
        public WalkerHandler(UIApplication uiapp)
        {
            try
            {
                m_app = uiapp;
                m_doc = uiapp.ActiveUIDocument.Document;

                View3D view3d = m_doc.ActiveView as View3D;
                if (null != view3d)
                {
                    activeView = view3d;
                }
                else
                {
                    FilteredElementCollector collector = new FilteredElementCollector(m_doc);
                    List <View3D>            view3ds   = collector.OfClass(typeof(View3D)).ToElements().Cast <View3D>().ToList();
                    var viewfound = from view in view3ds where view.IsTemplate == false && view.IsPerspective == false && view.ViewName == "{3D}" select view;
                    if (viewfound.Count() > 0)
                    {
                        activeView = viewfound.First();
                        using (Transaction trans = new Transaction(m_doc, "Open 3D View"))
                        {
                            try
                            {
                                trans.Start();
                                uiapp.ActiveUIDocument.ActiveView = activeView;
                                trans.Commit();
                            }
                            catch
                            {
                                trans.RollBack();
                            }
                        }
                    }
                }

                bcfProjectId = ParameterUtil.GetBCFProjectId(m_app);
                if (!string.IsNullOrEmpty(bcfProjectId))
                {
                    googleFolders = FileManager.FindGoogleFolders(bcfProjectId);
                    if (null != googleFolders.ColorSheet)
                    {
                        bcfColorSchemeId = googleFolders.ColorSheet.Id;
                    }
                    if (null != googleFolders.CategorySheet)
                    {
                        categorySheetId = googleFolders.CategorySheet.Id;
                    }
                    if (!string.IsNullOrEmpty(bcfColorSchemeId) && !string.IsNullOrEmpty(categorySheetId))
                    {
                        schemeInfo = FileManager.ReadColorSchemes(bcfColorSchemeId, categorySheetId, false);
                    }

                    bcfFileDictionary = DataStorageUtil.ReadLinkedBCFFileInfo(m_doc, bcfProjectId);
                    bcfDictionary     = GetBCFDictionary(m_doc);

                    List <BuiltInCategory> bltCategories = catDictionary.Values.ToList();
                    bool parameterCreated = ParameterUtil.CreateBCFParameters(m_app, bltCategories);

                    foreach (string catName in categoryNames)
                    {
                        CategoryInfo catInfo = new CategoryInfo(catName, true);
                        categoryInfoList.Add(catInfo);
                    }
                }
                else
                {
                    MessageBox.Show("Please enter a BCF Project Id in Project Information.", "Empty BCF Project Id", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to initialize External Event handler.\n" + ex.Message, "External Event Handler", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Beispiel #10
0
        private void buttonImport_Click(object sender, RoutedEventArgs e)
        {
            UpdateLableDelegate    updateLabelDelegate    = new UpdateLableDelegate(statusLable.SetValue);
            UpdateProgressDelegate updateProgressDelegate = new UpdateProgressDelegate(progressBar.SetValue);

            try
            {
                double progressValue = 0;
                progressBar.Maximum    = 3;
                progressBar.Value      = progressValue;
                progressBar.Visibility = Visibility.Visible;
                bcfPath    = textBoxBCF.Text;
                sharedLink = textBoxFolder.Text;
                string folderId = "";
                if (sharedLink.Contains("id="))
                {
                    folderId = FileManager.GetFolderId(sharedLink);
                }

                if (!string.IsNullOrEmpty(bcfProjectId))
                {
                    if (folderId != bcfProjectId)
                    {
                        bcfProjectId  = folderId;
                        googleFolders = FileManager.FindGoogleFolders(bcfProjectId);
                    }
                }
                else
                {
                    bcfProjectId  = folderId;
                    googleFolders = FileManager.FindGoogleFolders(bcfProjectId);
                }

                if (AbortFlag.GetAbortFlag())
                {
                    this.DialogResult = false; return;
                }

                File        colorSheet     = null;
                File        uploadedBCF    = null;
                File        markupSheet    = null;
                File        viewpointSheet = null;
                List <File> uploadedImages = null;

                if (!string.IsNullOrEmpty(bcfPath) && null != googleFolders)
                {
                    if (null != googleFolders)
                    {
                        progressValue += 1;
                        Dispatcher.Invoke(updateLabelDelegate, System.Windows.Threading.DispatcherPriority.Background, new object[] { TextBlock.TextProperty, "Searching default folders..." });
                        Dispatcher.Invoke(updateProgressDelegate, System.Windows.Threading.DispatcherPriority.Background, new object[] { ProgressBar.ValueProperty, progressValue });

                        colorSheet       = googleFolders.ColorSheet;
                        bcfColorSchemeId = colorSheet.Id;

                        string bcfName = System.IO.Path.GetFileNameWithoutExtension(bcfPath);
                        if (FileManager.CheckExistingFiles(bcfName, googleFolders))
                        {
                            string uploadId = Guid.NewGuid().ToString();

                            if (null != googleFolders.ArchiveBCFFolder)
                            {
                                if (AbortFlag.GetAbortFlag())
                                {
                                    this.DialogResult = false; return;
                                }

                                progressValue += 1;
                                Dispatcher.Invoke(updateLabelDelegate, System.Windows.Threading.DispatcherPriority.Background, new object[] { TextBlock.TextProperty, "Uploading bcfzip to an archive folder..." });
                                Dispatcher.Invoke(updateProgressDelegate, System.Windows.Threading.DispatcherPriority.Background, new object[] { ProgressBar.ValueProperty, progressValue });

                                string parentId = googleFolders.ArchiveBCFFolder.Id;
                                uploadedBCF = FileManager.UploadBCF(bcfPath, parentId, uploadId);
                            }
                            if (null != googleFolders.ActiveBCFFolder && null != googleFolders.ArchiveImgFolder)
                            {
                                if (AbortFlag.GetAbortFlag())
                                {
                                    this.DialogResult = false; return;
                                }

                                BCFUtil bcfUtil = new BCFUtil();
                                bcfzip = bcfUtil.ReadBCF(bcfPath);

                                progressValue += 1;
                                Dispatcher.Invoke(updateLabelDelegate, System.Windows.Threading.DispatcherPriority.Background, new object[] { TextBlock.TextProperty, "Creating Google spreadsheet..." });
                                Dispatcher.Invoke(updateProgressDelegate, System.Windows.Threading.DispatcherPriority.Background, new object[] { ProgressBar.ValueProperty, progressValue });

                                if (AbortFlag.GetAbortFlag())
                                {
                                    this.DialogResult = false; return;
                                }

                                string parentId = googleFolders.ActiveBCFFolder.Id;
                                System.IO.MemoryStream markupStream = BCFParser.CreateMarkupStream(bcfzip);
                                if (null != markupStream)
                                {
                                    string title = bcfName + "_Markup.csv";
                                    markupSheet = FileManager.UploadSpreadsheet(markupStream, title, parentId, uploadId);
                                }

                                System.IO.MemoryStream viewpointStream = BCFParser.CreateViewpointStream(bcfzip);
                                if (null != viewpointStream)
                                {
                                    string title = bcfName + "_Viewpoint.csv";
                                    viewpointSheet = FileManager.UploadSpreadsheet(viewpointStream, title, parentId, uploadId);
                                }

                                if (AbortFlag.GetAbortFlag())
                                {
                                    this.DialogResult = false; return;
                                }

                                if (null != bcfzip)
                                {
                                    Dispatcher.Invoke(updateLabelDelegate, System.Windows.Threading.DispatcherPriority.Background, new object[] { TextBlock.TextProperty, "Uploading BCF images..." });
                                    Dispatcher.Invoke(updateProgressDelegate, System.Windows.Threading.DispatcherPriority.Background, new object[] { ProgressBar.ValueProperty, progressValue });
                                    parentId       = googleFolders.ActiveImgFolder.Id;
                                    uploadedImages = FileManager.UploadBCFImages(bcfzip, parentId, uploadId, progressBar);
                                }

                                if (AbortFlag.GetAbortFlag())
                                {
                                    this.DialogResult = false; return;
                                }

                                if (null != uploadedBCF && null != markupSheet && null != viewpointSheet && null != uploadedImages)
                                {
                                    Dispatcher.Invoke(updateLabelDelegate, System.Windows.Threading.DispatcherPriority.Background, new object[] { TextBlock.TextProperty, "Completed." });
                                    progressBar.Visibility = Visibility.Hidden;

                                    bcfFileInfo       = new LinkedBcfFileInfo(bcfName, markupSheet.Id, viewpointSheet.Id, sharedLink, googleFolders.RootTitle, bcfProjectId);
                                    this.DialogResult = true;
                                }
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Folder Id cannot be identified.\n Please enter a valid shared link.\n", "Invalid Shared Link", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                }
                else
                {
                    MessageBox.Show("Please enter a correct form of the file path of bcf or the address of shared link.\n", "Invalid Path", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to import BCF.\n" + ex.Message, "Import BCF", MessageBoxButton.OK, MessageBoxImage.Warning);
                Dispatcher.Invoke(updateLabelDelegate, System.Windows.Threading.DispatcherPriority.Background, new object[] { TextBlock.TextProperty, "Ready." });
            }
            progressBar.Visibility = Visibility.Hidden;
        }