/// <summary>
        /// Reports the results of loads from the DB server (SampleExternalResourceServer).
        /// This method should be implemented to provide UI to communicate success or failure
        /// of a particular external resource load operation to the user.
        /// </summary>
        /// <param name="doc">The Revit model into which the External Resource was loaded.
        /// </param>
        /// <param name="loadDataList">Contains a list of ExternalResourceLoadData with results
        /// for all external resources loaded by the DB server.  It is possible for the DB server
        /// to have loaded more than one resource (for example, loading several linked files
        /// when a host file is opened by the user).
        /// </param>
        public void HandleLoadResourceResults(Document doc, IList <ExternalResourceLoadData> loadDataList)
        {
            foreach (ExternalResourceLoadData data in loadDataList)
            {
                ExternalResourceType resourceType = data.ExternalResourceType;

                // This message will be posted in a dialog box at the end of this method.
                String myMessage = String.Empty;

                ExternalResourceLoadContext loadContext        = data.GetLoadContext();
                ExternalResourceReference   desiredRef         = data.GetExternalResourceReference();
                ExternalResourceReference   currentlyLoadedRef = loadContext.GetCurrentlyLoadedReference();

                LoadOperationType loadType = loadContext.LoadOperationType;

                switch (loadType)
                {
                case LoadOperationType.Automatic:
                    myMessage = "This is an Automatic load operation. ";
                    break;

                case LoadOperationType.Explicit:
                    myMessage = "This is an Explicit load operation. ";
                    break;

                default:
                    myMessage = "There is no load type information!! ";
                    break;
                }


                bool bUnrecognizedStatus = false;
                if (data.LoadStatus == ExternalResourceLoadStatus.ResourceAlreadyCurrent)
                {
                    if (data.GetLoadContext().LoadOperationType == LoadOperationType.Explicit)
                    {
                        string resourcePath = currentlyLoadedRef.InSessionPath;
                        myMessage += "\n No new changes to load for link: " + resourcePath;
                    }
                    else
                    {
                        continue;
                    }
                }
                else if (data.LoadStatus == ExternalResourceLoadStatus.Uninitialized)
                {
                    myMessage += "\n The load status is uninitialized - this generally shouldn't happen";
                }
                else if (data.LoadStatus == ExternalResourceLoadStatus.Failure)
                {
                    myMessage += "\n The load failed and the reason is unknown.";
                }
                else if (data.LoadStatus == ExternalResourceLoadStatus.Success)
                {
                    if (resourceType == ExternalResourceTypes.BuiltInExternalResourceTypes.KeynoteTable)
                    {
                        string resourcePath = data.GetExternalResourceReference().InSessionPath;
                        myMessage += "\n Version " + data.GetLoadContent().Version + " of keynote data \'" + resourcePath + "\' has been loaded successfully";
                    }
                    else if (resourceType == ExternalResourceTypes.BuiltInExternalResourceTypes.RevitLink)
                    {
                        string          resourcePath    = data.GetExternalResourceReference().InSessionPath;
                        LinkLoadContent ldrlc           = (LinkLoadContent)(data.GetLoadContent());
                        string          destinationPath = ModelPathUtils.ConvertModelPathToUserVisiblePath(ldrlc.GetLinkDataPath());
                        myMessage += "\n Version " + data.GetLoadContent().Version +
                                     " of the file: " + resourcePath +
                                     " has been downloaded into the cached folder: " + destinationPath +
                                     " for this Revit Link.";
                    }
                }
                else
                {
                    myMessage          += "Unrecognized external resource load status.";
                    bUnrecognizedStatus = true;
                }


                if (!bUnrecognizedStatus && resourceType == ExternalResourceTypes.BuiltInExternalResourceTypes.RevitLink)
                {
                    // For Revit links, the UI server can also obtain a RevitLinkLoadResult which contains detailed
                    // information about the status of the attempt to load the local copy of the link into Revit.
                    LinkLoadContent ldrlc      = (LinkLoadContent)(data.GetLoadContent());
                    LinkLoadResult  loadResult = ldrlc.GetLinkLoadResult();
                    if (loadResult != null)
                    {
                        myMessage += "\n LinkLoadResultType: " + loadResult.LoadResult.ToString("g");
                    }
                }
                System.Windows.Forms.MessageBox.Show(myMessage, "UI Server for SDK Sample External Resource Server");
            }
        }
示例#2
0
 public LoadInstruction(int offset, LoadOperationType operation, Operand destination, Operand source)
     : base(offset, destination, source)
 {
     this.operation = operation;
 }
示例#3
0
		public LoadInstruction(int offset, LoadOperationType operation, Operand destination, Operand source)
			: base(offset, destination, source)
		{
			this.operation = operation;
		}