Inheritance: System.MarshalByRefObject
Exemplo n.º 1
0
        public TM_GUI_Objects GetGUIObjects()
        {
            //   var sessionLibrary = "CWE";
             //   Session["Library"] = sessionLibrary;

            var libraryId = GetCurrentSessionLibrary();

            if (guiObjectsCacheOk &&  last_Gui_Objects.notNull())		// returns cached version on next calls
                return last_Gui_Objects;

            var guiObjects = new TM_GUI_Objects();
            var guidanceItems = (libraryId == Guid.Empty)
                                        ? tmXmlDatabase.tmGuidanceItems()
                                        : GetGuidanceItemsInLibrary(libraryId);
            foreach (var row in guidanceItems)
            {
                var guidanceItemMappings = "{0},{1},{2},{3},{4},{5},{6}".format(
                                                //guiObjects.add_UniqueString(row.guidanceItemId.str().hash().str()),	// this will shave off another 80k from the request
                                                guiObjects.add_UniqueString(row.Metadata.Id.str()),
                                                guiObjects.add_UniqueString(""), //row.libraryId.str()),
                                                guiObjects.add_UniqueString(row.Metadata.Title),
                                                guiObjects.add_UniqueString(row.Metadata.Technology),
                                                guiObjects.add_UniqueString(row.Metadata.Phase),
                                                guiObjects.add_UniqueString(row.Metadata.Type),
                                                guiObjects.add_UniqueString(row.Metadata.Category));

                guiObjects.GuidanceItemsMappings.Add(guidanceItemMappings);
            }
            last_Gui_Objects = guiObjects;
            //for the big library this is now a 360k string
            guiObjectsCacheOk = true;
            return guiObjects;
        }
Exemplo n.º 2
0
        public TM_GUI_Objects GetGUIObjects()
        {
            //   var sessionLibrary = "CWE";
            //   Session["Library"] = sessionLibrary;

            var libraryId = GetCurrentSessionLibrary();


            if (guiObjectsCacheOk && last_Gui_Objects.notNull())                // returns cached version on next calls
            {
                return(last_Gui_Objects);
            }

            var guiObjects    = new TM_GUI_Objects();
            var guidanceItems = (libraryId == Guid.Empty)
                                        ? tmXmlDatabase.tmGuidanceItems()
                                        : GetGuidanceItemsInLibrary(libraryId);

            foreach (var row in guidanceItems)
            {
                var guidanceItemMappings = "{0},{1},{2},{3},{4},{5},{6}".format(
                    //guiObjects.add_UniqueString(row.guidanceItemId.str().hash().str()),	// this will shave off another 80k from the request
                    guiObjects.add_UniqueString(row.Metadata.Id.str()),
                    guiObjects.add_UniqueString(""),                             //row.libraryId.str()),
                    guiObjects.add_UniqueString(row.Metadata.Title),
                    guiObjects.add_UniqueString(row.Metadata.Technology),
                    guiObjects.add_UniqueString(row.Metadata.Phase),
                    guiObjects.add_UniqueString(row.Metadata.Type),
                    guiObjects.add_UniqueString(row.Metadata.Category));

                guiObjects.GuidanceItemsMappings.Add(guidanceItemMappings);
            }
            last_Gui_Objects = guiObjects;
            //for the big library this is now a 360k string
            guiObjectsCacheOk = true;
            return(guiObjects);
        }
        public static Library_V3 getFolderStructure_Library(this TM_WebServices tmWebServices, Guid libraryId, TM_GUI_Objects guiObjects)
        {
            // ReSharper disable AccessToModifiedClosure
            //pre-create this mapping since the view retrieval was a massive performance bottle neck
            var allViews = new Dictionary<Guid, View_V3>();
            foreach(var view in tmWebServices.GetViews())
                if (allViews.hasKey(view.viewId))
                    "[getFolderStructure_Library] duplicate viewID: {0} from Library {0}".format(view.viewId, view.libraryId);  // this should be moved into a TM Library health check
                else
                    allViews.Add(view.viewId, view);

            Action<Folder_V3> mapFolderViews =  null;

            Func<List<Guid>, List<View_V3>> mapViews =
                (viewGuids) =>
                            {
                                var views = new List<View_V3>();

                                foreach(var viewGuid in viewGuids)
                                {
                                    var view = 	allViews[viewGuid];

                                    /*// compress view.guidanceItems using guiObjects
                                    view.guidanceItems_Indexes = (from guid in view.guidanceItems
                                                                  select guiObjects.get_Index(guid.str()).str()).toList()
                                                                  .join(",").remove(" ");
                                    view.guidanceItems.Clear();*/
                                    views.add(view);
                                }
                                return views;
                            };
            // ReSharper disable PossibleNullReferenceException
            // ReSharper disable ImplicitlyCapturedClosure
            mapFolderViews =
                (folder) => {
                                 var mappedViews = mapViews(folder.views.guids());
                                 folder.views.Clear();
                                 folder.views.add(mappedViews);
                                 foreach(var subFolder in folder.subFolders)
                                    mapFolderViews(subFolder);
                            };
            Action<List<Folder_V3>, List<Folder_V3>> mapFolders = (folders, parentFolder) =>
                {
                    foreach(var folder in folders)
                    {
                        parentFolder.add(folder);
                        mapFolderViews(folder);
                    }
                };
            Func<Guid,string, Library_V3> mapLibrary =
                (library_Id, libraryName)=> {
                                        var libraryV3 = new Library_V3
                                            {
                                                        libraryId = library_Id,
                                                        name = libraryName
                                                    };
                                        mapFolders(tmWebServices.GetFolders(library_Id), libraryV3.subFolders);
                                        libraryV3.views.add(mapViews(tmWebServices.GetViewsInLibraryRoot(libraryId).guids()));
                                        libraryV3.guidanceItems = tmWebServices.getGuidanceItemsIds_NotInViews(library_Id);
                                        return libraryV3;
                                    };

            Func<Guid,Library_V3> getLibrary_TreeStructure =
                (id)=>{
                                var tmLibrary = tmWebServices.GetLibraryById(id);
                                if (tmLibrary.isNull())
                                {
                                    "[in getLibraryFolderStructure] could not find library with id: {0}".error(id);
                                    return null;
                                }
                                return mapLibrary(id, tmLibrary.caption);
                            };
            return getLibrary_TreeStructure(libraryId);
            // ReSharper restore PossibleNullReferenceException
            // ReSharper restore ImplicitlyCapturedClosure
            // ReSharper restore AccessToModifiedClosure
        }
 public static List<Library_V3> getFolderStructure_Libraries(this TM_WebServices tmWebServices, TM_GUI_Objects guiObjects)
 {
     return (from library in tmWebServices.GetLibraries()
             select tmWebServices.getFolderStructure_Library(library.Id,guiObjects)).toList();
 }
 public static List <Library_V3> getFolderStructure_Libraries(this TM_WebServices tmWebServices, TM_GUI_Objects guiObjects)
 {
     return((from library in tmWebServices.GetLibraries()
             select tmWebServices.getFolderStructure_Library(library.Id, guiObjects)).toList());
 }
        public static Library_V3 getFolderStructure_Library(this TM_WebServices tmWebServices, Guid libraryId, TM_GUI_Objects guiObjects)
        {
            // ReSharper disable AccessToModifiedClosure
            //pre-create this mapping since the view retrieval was a massive performance bottle neck
            var allViews = new Dictionary <Guid, View_V3>();

            foreach (var view in tmWebServices.GetViews())
            {
                if (allViews.hasKey(view.viewId))
                {
                    "[getFolderStructure_Library] duplicate viewID: {0} from Library {0}".format(view.viewId, view.libraryId);              // this should be moved into a TM Library health check
                }
                else
                {
                    allViews.Add(view.viewId, view);
                }
            }

            Action <Folder_V3> mapFolderViews = null;

            Func <List <Guid>, List <View_V3> > mapViews =
                (viewGuids) =>
            {
                var views = new List <View_V3>();

                foreach (var viewGuid in viewGuids)
                {
                    var view = allViews[viewGuid];

                    /*// compress view.guidanceItems using guiObjects
                     * view.guidanceItems_Indexes = (from guid in view.guidanceItems
                     *                                                    select guiObjects.get_Index(guid.str()).str()).toList()
                     *                                                        .join(",").remove(" ");
                     * view.guidanceItems.Clear();*/
                    views.add(view);
                }
                return(views);
            };

            // ReSharper disable PossibleNullReferenceException
            // ReSharper disable ImplicitlyCapturedClosure
            mapFolderViews =
                (folder) => {
                var mappedViews = mapViews(folder.views.guids());
                folder.views.Clear();
                folder.views.add(mappedViews);
                foreach (var subFolder in folder.subFolders)
                {
                    mapFolderViews(subFolder);
                }
            };
            Action <List <Folder_V3>, List <Folder_V3> > mapFolders = (folders, parentFolder) =>
            {
                foreach (var folder in folders)
                {
                    parentFolder.add(folder);
                    mapFolderViews(folder);
                }
            };
            Func <Guid, string, Library_V3> mapLibrary =
                (library_Id, libraryName) => {
                var libraryV3 = new Library_V3
                {
                    libraryId = library_Id,
                    name      = libraryName
                };
                mapFolders(tmWebServices.GetFolders(library_Id), libraryV3.subFolders);
                libraryV3.views.add(mapViews(tmWebServices.GetViewsInLibraryRoot(libraryId).guids()));
                libraryV3.guidanceItems = tmWebServices.getGuidanceItemsIds_NotInViews(library_Id);
                return(libraryV3);
            };

            Func <Guid, Library_V3> getLibrary_TreeStructure =
                (id) => {
                var tmLibrary = tmWebServices.GetLibraryById(id);
                if (tmLibrary.isNull())
                {
                    "[in getLibraryFolderStructure] could not find library with id: {0}".error(id);
                    return(null);
                }
                return(mapLibrary(id, tmLibrary.caption));
            };

            return(getLibrary_TreeStructure(libraryId));
            // ReSharper restore PossibleNullReferenceException
            // ReSharper restore ImplicitlyCapturedClosure
            // ReSharper restore AccessToModifiedClosure
        }
Exemplo n.º 7
0
 public bool ClearGUIObjects()
 {
     last_Gui_Objects  = null;
     guiObjectsCacheOk = false;
     return(last_Gui_Objects.isNull());
 }
Exemplo n.º 8
0
 public bool ClearGUIObjects()
 {
     last_Gui_Objects = null;
     guiObjectsCacheOk = false;
     return last_Gui_Objects.isNull();
 }