/// <summary> /// /// </summary> /// <param name="doc"></param> private static void CheckIn(Document doc) { CommunicatorUtilities.SetCommunicatorImage(); new Thread(() => new Tools.MissionControl.MissionControl().CheckIn(doc)) { Priority = ThreadPriority.BelowNormal, IsBackground = true }.Start(); }
public Result OnStartup(UIControlledApplication application) { try { Instance = this; var appId = application.ActiveAddInId; DoorUpdaterInstance = new DoorUpdater(appId); DtmUpdaterInstance = new DtmUpdater(appId); Tasks = new Queue <Action <UIApplication> >(); application.Idling += OnIdling; application.ControlledApplication.DocumentOpening += OnDocumentOpening; application.ControlledApplication.DocumentOpened += OnDocumentOpened; application.ControlledApplication.FailuresProcessing += FailureProcessor.CheckFailure; application.ControlledApplication.DocumentClosing += OnDocumentClosing; application.ControlledApplication.DocumentSynchronizingWithCentral += OnDocumentSynchronizing; application.ControlledApplication.DocumentSynchronizedWithCentral += OnDocumentSynchronized; application.ControlledApplication.DocumentCreated += OnDocumentCreated; #if RELEASE2015 || RELEASE2016 || RELEASE2017 // (Konrad) We are not going to process warnings here. #else application.ControlledApplication.FailuresProcessing += OnFailureProcessing; #endif // (Konrad) Create buttons and register dockable panel. CommunicatorUtilities.RegisterCommunicator(application); CreateButtons(application); // (Konrad) Since Communicator Task Assistant offers to open Families for editing, // it requires an External Event because new document cannot be opened from Idling Event CommunicatorHandler = new CommunicatorRequestHandler(); CommunicatorEvent = ExternalEvent.Create(CommunicatorHandler); } catch (Exception ex) { Log.AppendLog(LogMessageType.EXCEPTION, ex.Message); } return(Result.Succeeded); }
/// <summary> /// Method to "check into" mission control. It posts all initial data, and stores all needed references. /// </summary> /// <param name="doc"></param> public void CheckIn(Document doc) { try { var centralPath = FileInfoUtil.GetCentralFilePath(doc); // (Konrad) We can publish a file path to the DB. // That will make it easier to create Configurations. // Valid file is: // - not detached // - not a family // - is workshared // - is saved on the network, revit server or bim 360 server if (!doc.IsDetached && !doc.IsFamilyDocument && doc.IsWorkshared && FilePathItem.IsValidFilePath(centralPath)) { if (!ServerUtilities.Post(new FilePathItem(centralPath, doc.Application.VersionNumber), "filepaths/add", out FilePathItem unused)) { Log.AppendLog(LogMessageType.ERROR, "Failed to publish File Path: " + centralPath); } } // (Konrad) Get Configuration/Project. if (!ServerUtilities.GetByCentralPath(centralPath, "configurations/centralpath", out Configuration configFound)) { DisableMissionControl(); return; } if (!ServerUtilities.Get("projects/configid/" + configFound.Id, out Project projectFound)) { DisableMissionControl(); return; } if (MissionControlSetup.Configurations.ContainsKey(centralPath)) { MissionControlSetup.Configurations.Remove(centralPath); } MissionControlSetup.Configurations.Add(centralPath, configFound); if (MissionControlSetup.Projects.ContainsKey(centralPath)) { MissionControlSetup.Projects.Remove(centralPath); } MissionControlSetup.Projects.Add(centralPath, projectFound); // (Konrad) This might be a good time to let users know that Mission Control is ready to go. AppCommand.CommunicatorHandler.Status = Status.Success; AppCommand.CommunicatorHandler.Message = "Successfully connected to Mission Control!"; AppCommand.CommunicatorHandler.Request.Make(RequestId.ReportStatus); AppCommand.CommunicatorEvent.Raise(); // (Konrad) Register Updaters that are in the config file. CommunicatorUtilities.LaunchCommunicator(); ApplyConfiguration(doc); #if RELEASE2015 || RELEASE2016 || RELEASE2017 // (Konrad) We are not going to process warnings here. #else CollectWarnings(doc); #endif EnableMissionControl(); Log.AppendLog(LogMessageType.INFO, "Mission Control check in succeeded."); } catch (Exception ex) { Log.AppendLog(LogMessageType.EXCEPTION, ex.Message); } }