コード例 #1
0
        public Result Execute(ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements)
        {
            Log.AppendLog(LogMessageType.INFO, "Started");

            try
            {
                var addins = AppCommand.thisApp.addins;
                StoreTempCollection(addins.AddinCollection);
                var viewModel  = new AddInViewModel(addins);
                var mainWindow = new MainWindow {
                    DataContext = viewModel
                };
                if (mainWindow.ShowDialog() == true)
                {
                    var vm = (AddInViewModel)mainWindow.DataContext;
                    try
                    {
                        // (Konrad) We are gathering information about the addin use. This allows us to
                        // better maintain the most used plug-ins or discontiue the unused ones.
                        // If Window was closed using the OK button we can collect more details about the app to publish.
                        var log = new AddinLog("AddinManager", commandData.Application.Application.VersionNumber)
                        {
                            DetailInfo = vm.AddinsObj.AddinCollection
                                         .Select(x => new InfoItem {
                                Name = x.ToolName, Value = x.ToolLoadType.ToString()
                            })
                                         .ToList()
                        };
                        AddinUtilities.PublishAddinLog(log);
                    }
                    catch (Exception e)
                    {
                        Log.AppendLog(LogMessageType.EXCEPTION, e.Message);
                    }

                    // write setting and load addins.
                    AppCommand.thisApp.addins = vm.AddinsObj;
                    AppCommand.thisApp.ProcessPlugins();
                }
                else
                {
                    // If user cancelled out of this window, we don't need to log all the details, other than that it was opened.
                    AddinUtilities.PublishAddinLog(new AddinLog("AddinManager", commandData.Application.Application.VersionNumber));

                    OverrideTempSettings();
                }
            }
            catch (Exception ex)
            {
                Log.AppendLog(LogMessageType.EXCEPTION, ex.Message);
            }

            Log.AppendLog(LogMessageType.INFO, "Ended");
            return(Result.Succeeded);
        }
コード例 #2
0
        /// <summary>
        /// Publishes Addin Log to MongoDB in asynch fashion.
        /// </summary>
        /// <param name="addinLog">AddinLog data to be published.</param>
        /// <returns></returns>
        public static async void PublishAddinLog(AddinLog addinLog)
        {
            try
            {
                var unused = await ServerUtilities.PostAsync <AddinLog>(addinLog, "addins");

                Log.AppendLog(LogMessageType.INFO, "Addin info was published. " + unused.Id);
            }
            catch (Exception e)
            {
                Log.AppendLog(LogMessageType.EXCEPTION, e.Message);
            }
        }