/// <summary>
        /// When the user updates the shared coordinates in the link model, Revit calls this
        /// method.  In this implementation, the updated local version of the link on the user's
        /// machine is uploaded (copied) back to the server location.
        /// </summary>
        public void OnLocalLinkSharedCoordinatesSaved(ExternalResourceReference changedReference)
        {
            string localLinkPath       = SampleExternalResourceDBServer.GetFullLinkCachedFilePath(changedReference);
            string fullServerPath      = SampleExternalResourceDBServer.GetFullServerLinkFilePath(changedReference);
            String serverDirectoryName = System.IO.Path.GetDirectoryName(fullServerPath);

            if (!System.IO.Directory.Exists(serverDirectoryName))
            {
                System.IO.Directory.CreateDirectory(serverDirectoryName);
            }
            System.IO.File.Copy(localLinkPath, fullServerPath, true); // Overwrite
        }
コード例 #2
0
        /// <summary>
        /// Registers an instance of a SampleExternalResourceDBServer with the ExternalService
        /// of type ExternalResourceService.
        /// </summary>
        /// <param name="application">An object that is passed to the external application
        /// which contains the controlled application.</param>
        /// <returns>Return the status of the external application.  A result of Succeeded
        /// means that the external application was able to register the IExternalResourceServer.
        /// </returns>
        public ExternalDBApplicationResult OnStartup(ControlledApplication application)
        {
            // Get Revit's ExternalResourceService.
            ExternalService externalResourceService = ExternalServiceRegistry.GetService(ExternalServices.BuiltInExternalServices.ExternalResourceService);

            if (externalResourceService == null)
            {
                return(ExternalDBApplicationResult.Failed);
            }

            // Create an instance of your IExternalResourceServer and register it with the ExternalResourceService.
            IExternalResourceServer sampleServer = new SampleExternalResourceDBServer();

            externalResourceService.AddServer(sampleServer);
            return(ExternalDBApplicationResult.Succeeded);
        }
 /// <summary>
 /// This implementation simply retrieves the same local file name that the server
 /// uses when first copying the link document to the user's machine.
 /// </summary>
 public string GetLocalPathForOpen(ExternalResourceReference desiredReference)
 {
     return(SampleExternalResourceDBServer.GetFullLinkCachedFilePath(desiredReference));
 }