public void Execute(UIApplication app)
        {
            try
            {
                m_doc = app.ActiveUIDocument.Document;

                switch (Request.Take())
                {
                case RequestId.None:
                    return;

                case RequestId.ReadLinkedFileInfo:
                    break;

                case RequestId.UpdateLinkedFileInfo:
                    bool updated = DataStorageUtil.UpdateLinkedBCFFileInfo(m_doc, bcfFileDictionary);
                    Dictionary <string, Dictionary <string, IssueEntry> > dictionary = new Dictionary <string, Dictionary <string, IssueEntry> >();

                    int numCat = categoryNames.Count;
                    AbortFlag.SetAbortFlag(false);
                    progressWindow = new ProgressWindow("Loading BCF issues and images...");
                    progressWindow.Show();

                    foreach (string markupId in bcfFileDictionary.Keys)
                    {
                        LinkedBcfFileInfo bcfInfo = bcfFileDictionary[markupId];
                        if (bcfDictionary.ContainsKey(markupId))
                        {
                            dictionary.Add(markupId, bcfDictionary[markupId]);
                        }
                        else
                        {
                            Dictionary <string, IssueEntry> issueDictionary = GetBCFIssueInfo(m_doc, bcfInfo);
                            if (issueDictionary.Count > 0)
                            {
                                dictionary.Add(markupId, issueDictionary);
                            }
                        }
                    }
                    if (progressWindow.IsActive)
                    {
                        progressWindow.Close();
                    }

                    bcfDictionary = dictionary;

                    if (numCat != categoryNames.Count)
                    {
                        System.IO.MemoryStream stream = BCFParser.CreateCategoryStream(categoryNames);
                        if (null != stream)
                        {
                            Google.Apis.Drive.v2.Data.File file = FileManager.UpdateSpreadsheet(stream, categorySheetId, bcfProjectId);
                        }

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

                        foreach (string catName in categoryNames)
                        {
                            var catFound = from category in categoryInfoList where category.CategoryName == catName select category;
                            if (catFound.Count() == 0)
                            {
                                CategoryInfo catInfo = new CategoryInfo(catName, true);
                                categoryInfoList.Add(catInfo);
                            }
                        }
                    }

                    if (null != walkerWindow)
                    {
                        walkerWindow.BCFFileDictionary = bcfFileDictionary;
                        walkerWindow.BCFDictionary     = bcfDictionary;
                        walkerWindow.CategoryInfoList  = categoryInfoList;
                        walkerWindow.CurrentIndex      = 0;
                        walkerWindow.DisplayLinkedBCF();
                    }

                    bool updatedId = ParameterUtil.SetBCFProjectId(m_doc, bcfProjectId);
                    schemeInfo = FileManager.ReadColorSchemes(bcfColorSchemeId, categorySheetId, false);

                    if (null != walkerWindow)
                    {
                        walkerWindow.SchemeInfo = schemeInfo;
                        walkerWindow.DisplayColorscheme(schemeInfo);
                    }

                    break;

                case RequestId.ReadProjectId:
                    bcfProjectId = ParameterUtil.GetBCFProjectId(app);
                    break;

                case RequestId.UpdateProjectId:
                    bool updatedProjectId = ParameterUtil.SetBCFProjectId(m_doc, bcfProjectId);
                    break;

                case RequestId.ReadBCFParameterInfo:
                    break;

                case RequestId.UpdateBCFParameterInfo:
                    bool updatedParameters = ParameterUtil.UpdateBCFParameters(m_doc, currentElement, selectedIssue, selectedComment);
                    break;

                case RequestId.UpdateAction:
                    bool actionUpdated = ParameterUtil.UpdateBCFParameter(m_doc, currentElement, BCFParameters.BCF_Action, currentElement.Action);
                    break;

                case RequestId.UpdateResponsibility:
                    bool responsibilityUpdated = ParameterUtil.UpdateBCFParameter(m_doc, currentElement, BCFParameters.BCF_Responsibility, currentElement.ResponsibleParty);
                    break;

                case RequestId.CreateIssue:
                    break;

                case RequestId.UpdateViews:
                    IsolateElement(isIsolateOn, m_doc);
                    CreateSectionBox(isSectionBoxOn, m_doc);
                    HighlightElement(isHighlightOn, m_doc);
                    break;

                case RequestId.UpdateParameterByComment:
                    UpdateParameters(m_doc);
                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to execute an external event.\n" + ex.Message, "Execute Event", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            return;
        }
        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);
            }
        }