Beispiel #1
0
        public bool IsResourceWellFormed(ExternalResourceReference extRef)
        {
            bool valid = false;

            try
            {
                if (extRef.ServerId != GetServerId())
                {
                    return(false);
                }
                if (!extRef.HasValidDisplayPath())
                {
                    return(false);
                }

                IDictionary <string, string> refMap = extRef.GetReferenceInformation();
                if (refMap.ContainsKey("VersionNumber"))
                {
                    valid = KeynoteDatabase.IsValidRevitVersion(refMap["VersionNumber"]);
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
            }
            return(valid);
        }
Beispiel #2
0
        public String GetInSessionPath(ExternalResourceReference resourceReference, String originalPath)
        {
            string file = resourceReference.GetReferenceInformation()["File"];

            DBUtils.DBItem dbItem = DBUtils.FindDBItem(file);
            return(ServerName + "://" + FileUtils.GetRelativePath(Application.BaseFolder, dbItem.Path));
        }
        /// <summary>
        /// <para>Computes the full path on the end user's local drive where an
        /// ExternalResourceReference's link model will be copied when the user loads the
        /// link from the server.</para>
        ///<para>The paths of the local copies relative to this cache root folder will be the
        /// same as the paths of the original server copies relative to the Revit links
        /// to the root folder on the (compare this method with the GetFullServerLinkFilePath method).</para>
        /// </summary>
        /// <param name="resource">An ExternalResourceReference for a Revit link stored on this server.</param>
        /// <returns>A string representing the full path to the link model on the end user's local drive.</returns>
        public static String GetFullLinkCachedFilePath(ExternalResourceReference resource)
        {
            if (resource == null)
            {
                return("");
            }

            IDictionary <String, String> refMap = resource.GetReferenceInformation();

            if (!refMap.ContainsKey(RefMapLinkPathEntry))
            {
                return("");
            }

            return(LocalLinkCacheFolder + resource.GetReferenceInformation()[RefMapLinkPathEntry].Replace("/", "\\"));
        }
        /// <summary>
        /// Checks whether the given ExternalResourceReference is formatted correctly for this server.
        /// The format should match one of the formats created in the SetupBrowserData method.
        /// </summary>
        public bool IsResourceWellFormed(ExternalResourceReference extRef)
        {
            if (extRef.ServerId != GetServerId())
            {
                return(false);
            }
            if (!extRef.HasValidDisplayPath())
            {
                return(false);
            }

            // Either the ExternalResourceReference has a valid database key (German/French keynote case) ...
            IDictionary <string, string> refMap = extRef.GetReferenceInformation();

            if (refMap.ContainsKey(RefMapDBKeyEntry))
            {
                return(KeynotesDatabase.IsValidDBKey(refMap[RefMapDBKeyEntry]));
            }
            else if (refMap.ContainsKey(RefMapLinkPathEntry)) // ... OR it is a Revit link file
            {
                return(File.Exists(GetFullServerLinkFilePath(extRef)));
            }

            // ... OR it is a keynote file (non- French/German cases).
            return(File.Exists(GetFullServerKeynoteFilePath(extRef)));
        }
        public String GetInSessionPath(ExternalResourceReference resourceReference, String originalPath)
        {
            string file = resourceReference.GetReferenceInformation()["File"];

            DBUtils.DBItem dbItem = DBUtils.FindDBItem(file);
            return(GetPath(dbItem));
        }
Beispiel #6
0
        public void LoadResource(Guid loadRequestId, ExternalResourceType resourceType,
                                 ExternalResourceReference resourceReference, ExternalResourceLoadContext loadContext,
                                 ExternalResourceLoadContent content)
        {
            LinkLoadContent linkLoadContent = (LinkLoadContent)content;

            string file = resourceReference.GetReferenceInformation()["File"];

            DBUtils.DBItem dbItem    = DBUtils.FindDBItem(file);
            ModelPath      linksPath = ModelPathUtils.ConvertUserVisiblePathToModelPath(dbItem.Path);

            linkLoadContent.SetLinkDataPath(linksPath);
            content.LoadStatus = ExternalResourceLoadStatus.Success;
            return;
        }
        public void LoadResource(Guid loadRequestId, ExternalResourceType resourceType,
                                 ExternalResourceReference resourceReference, ExternalResourceLoadContext loadContext,
                                 ExternalResourceLoadContent content)
        {
            KeyBasedTreeEntriesLoadContent kdrlc = (KeyBasedTreeEntriesLoadContent)content;
            string tableName = resourceReference.GetReferenceInformation()["TableName"];

            DBUtils.GetAllDBItems(tableName).ForEach(item =>
            {
                kdrlc.AddEntry(new KeynoteEntry(item.Key, item.ParentKey, item.Text));
            });

            kdrlc.BuildEntries();
            kdrlc.LoadStatus = ExternalResourceLoadStatus.Success;
            return;
        }
Beispiel #8
0
        private string GetCurrentAvailableResourceVersion(ExternalResourceReference extResRef)
        {
            string databaseVersion = "";

            try
            {
                IDictionary <string, string> refMap = extResRef.GetReferenceInformation();
                if (refMap.ContainsKey("VersionNumber"))
                {
                    return(KeynoteDatabase.GetCurrentVersion());
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
            }
            return(databaseVersion);
        }
        /// <summary>
        /// Returns a string specifying the version of an external resource available from the server.
        /// </summary>
        /// <param name="extResRef">The ExternalResourceReference of the resource whose version is requested.</param>
        /// <returns>A string containing the version of the specified resource.</returns>
        private String GetCurrentlyAvailableResourceVersion(ExternalResourceReference extResRef)
        {
            IDictionary <string, string> refMap = extResRef.GetReferenceInformation();

            if (refMap.ContainsKey(RefMapDBKeyEntry))
            {
                return(KeynotesDatabase.CurrentVersion);
            }
            else if (refMap.ContainsKey(RefMapLinkPathEntry)) // ... OR it is a Revit link file
            {
                String serverLinkPath = GetFullServerLinkFilePath(extResRef);
                return(GetFileVersion(serverLinkPath));
            }

            // ... OR it is a keynote file (non- French/German cases).
            String serverKeynoteFilePath = GetFullServerKeynoteFilePath(extResRef);

            return(GetFileVersion(serverKeynoteFilePath));
        }
        /// <summary>
        /// Loads the keynote data resources, either from the fictitious French/German database, or from a file.
        /// </summary>
        /// <param name="resourceReference">An ExternalResourceReference identifying which particular resource to load.</param>
        /// <param name="loadContent">An ExternalResourceLoadContent object that will be populated with load data by the
        /// server.  There are different subclasses of ExternalResourceLoadContent for different ExternalResourceTypes.</param>
        private void LoadKeynoteDataResource(ExternalResourceReference resourceReference, ExternalResourceLoadContent loadContent)
        {
            KeyBasedTreeEntriesLoadContent kdrlc = (KeyBasedTreeEntriesLoadContent)loadContent;

            if (kdrlc == null)
            {
                throw new ArgumentException("Wrong type of ExternalResourceLoadContent (expecting a KeyBasedTreeEntriesLoadContent) for keynote data.", "loadContent");
            }

            kdrlc.Reset();

            // Either the ExternalResourceReference has a valid database key (German/French case) ...
            IDictionary <string, string> refMap = resourceReference.GetReferenceInformation();

            if (refMap.ContainsKey(RefMapDBKeyEntry))
            {
                try
                {
                    KeynotesDatabase.LoadKeynoteEntries(refMap[RefMapDBKeyEntry], ref kdrlc);
                    kdrlc.BuildEntries();
                    loadContent.LoadStatus = ExternalResourceLoadStatus.Success;
                }
                catch (ArgumentOutOfRangeException)
                {
                }
                catch (ArgumentNullException)
                {
                }
            }
            else
            {
                // ... OR it is a real file (all other cases).
                String serverKeynoteFilePath = GetFullServerKeynoteFilePath(resourceReference);
                bool   doesReadingSucceed    = KeynoteEntries.LoadKeynoteEntriesFromFile(serverKeynoteFilePath, kdrlc);
                if (doesReadingSucceed)
                {
                    kdrlc.BuildEntries();
                    loadContent.LoadStatus = ExternalResourceLoadStatus.Success;
                }
            }
        }
Beispiel #11
0
        private void LoadKeynoteDataResource(ExternalResourceReference resourceReference, ExternalResourceLoadContent loadContent)
        {
            try
            {
                KeyBasedTreeEntriesLoadContent entriesContent = (KeyBasedTreeEntriesLoadContent)loadContent;
                if (null == entriesContent)
                {
                    throw new ArgumentException("Wrong type of ExternalResourceLoadContent (expecting a KeyBasedTreeEntriesLoadContent) for keynote data.", "loadContent");
                }

                entriesContent.Reset();
                IDictionary <string, string> refMap = resourceReference.GetReferenceInformation();
                if (refMap.ContainsKey("VersionNumber") && refMap.ContainsKey("ProjectName"))
                {
                    KeynoteDatabase.LoadKeynoteEntries(refMap, ref entriesContent);
                    entriesContent.BuildEntries();
                    loadContent.LoadStatus = ExternalResourceLoadStatus.Success;
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
            }
        }
 public String GetInSessionPath(ExternalResourceReference resourceReference, String originalPath)
 {
     return(ServerName + "://" + resourceReference.GetReferenceInformation()["TableName"] + ".txt");
 }