/// <summary> /// Get the plural label for an object type /// </summary> /// <param name="uot"></param> /// <returns></returns> public static string GetTypeLabelPlural( UserObjectType uot) { if (uot == UserObjectType.Query) { return("Queries"); } if (uot == UserObjectType.CnList) { return("Lists"); } if (uot == UserObjectType.CalcField) { return("Calculated Fields"); } if (uot == UserObjectType.SpotfireLink) { return("Spotfire Links"); } if (uot == UserObjectType.Annotation) { return("Annotations"); } if (uot == UserObjectType.CondFormat) { return("Conditional Formattings"); } if (uot == UserObjectType.Folder) { return("Folders"); } return(""); }
/// <summary> /// Fetch info for the set of objects of a given object type visible to the specified user, optionally includes publicly visible objects as well. /// </summary> /// <param name="type">Object type</param> /// <param name="userId"></param> /// <param name="includeShared"></param> /// <returns>Set of user objects ordered by folderType, folderId, & (case insensitively) obj name</returns> public static List <UserObject> ReadMultiple( UserObjectType type, string userId, bool includeShared, bool includeContent) { if (ServiceFacade.UseRemoteServices) { Mobius.Services.Native.INativeSession nativeClient = ServiceFacade.CreateNativeSessionProxy(); Services.Native.NativeMethodTransportObject resultObject = ServiceFacade.InvokeNativeMethod(nativeClient, (int)Services.Native.ServiceCodes.MobiusUserObjectService, (int)Services.Native.ServiceOpCodes.MobiusUserObjectService.ReadMultiple2, new Services.Native.NativeMethodTransportObject( new object[] { (int)type, userId, includeShared, includeContent, false })); ((System.ServiceModel.IClientChannel)nativeClient).Close(); if (resultObject == null || resultObject.Value == null) { return(null); } _uoList = UserObject.DeserializeListBinary((byte[])resultObject.Value); return(_uoList); } else { return(UAL.UserObjectDao.ReadMultiple(type, userId, includeShared, includeContent)); } }
/// <summary> /// Read object matching the type, folder, owner, name /// </summary> /// <param name="type">type of object</param> /// <param name="owner">userid of object owner</param> /// <param name="folderId">folder that it's in</param> /// <param name="name">name of object</param> /// <returns></returns> public static UserObject Read( UserObjectType type, string owner, string folderId, string name) { if (ServiceFacade.UseRemoteServices) { Mobius.Services.Native.INativeSession nativeClient = ServiceFacade.CreateNativeSessionProxy(); Services.Native.NativeMethodTransportObject resultObject = ServiceFacade.InvokeNativeMethod(nativeClient, (int)Services.Native.ServiceCodes.MobiusUserObjectService, (int)Services.Native.ServiceOpCodes.MobiusUserObjectService.Read3, new Services.Native.NativeMethodTransportObject(new object[] { (int)type, owner, folderId, name })); ((System.ServiceModel.IClientChannel)nativeClient).Close(); if (resultObject == null || resultObject.Value == null) { return(null); } _uo = UserObject.DeserializeBinary((byte[])resultObject.Value); return(_uo); } else { return(UAL.UserObjectDao.Read(type, owner, folderId, name)); } }
/// <summary> /// Parse a name string of the form QUERY_123 into the object type and id /// </summary> /// <param name="internalName"></param> /// <param name="type"></param> /// <param name="id"></param> public static bool ParseObjectTypeAndIdFromInternalName( string internalName, out UserObjectType type, out int id) { type = UserObjectType.Unknown; string idString; id = -1; int i1 = internalName.IndexOf("_"); int i2 = internalName.LastIndexOf("_"); if (i1 >= 0) { string typeName = internalName.Substring(0, i1); type = ParseTypeName(typeName); idString = internalName.Substring(i2 + 1); } else // no type supplied { type = UserObjectType.Unknown; idString = internalName; } int.TryParse(idString, out id); if (type != UserObjectType.Unknown && id >= 0) { return(true); } return(false); }
public UserObject( // constructor with type, owner, name supplied UserObjectType type, string owner, string name) { Type = type; Owner = owner; Name = name; }
/// <summary> /// Return true if folder type object /// </summary> /// <param name="type"></param> /// <returns></returns> public static bool IsFolderType( UserObjectType type) { if (type == UserObjectType.Folder || type == UserObjectType.UserDatabase) { return(true); } return(false); }
/// <summary> /// User object types that correspond to metatables /// </summary> /// <param name="type"></param> /// <returns></returns> public static bool IsMetaTableType( UserObjectType type) { if ( type == UserObjectType.Annotation || type == UserObjectType.CalcField) // || // type == UserObjectType.MultiTable) { return(true); } return(false); }
/// <summary> /// Mainly written for cache data as JSON for backing source. Please do not call this method from anywhere /// other than the derived classes of <see cref="Runtime.Caching.ProviderItemBase"/>. /// </summary> public T GetCacheData <T>(object data, BitSet flag, UserObjectType userObjectType) { var dataList = data as ICollection; // If data was requested by socket server if (dataList != null && typeof(object).IsAssignableFrom(typeof(T))) { return((T)(object)UserBinaryObject.CreateUserBinaryObject(dataList)); } return(SerializationUtil.SafeDeserializeInProc <T>(data, string.Empty, flag, userObjectType, false)); }
/// <summary> /// Parse an internal user object name into a UserObject setting type /// </summary> /// <param name="name">objectType_objectId (e.g. "QUERY_456") or folderId.name (e.g. "FOLDER_123.My Query")</param> /// <param name="objType">UserObjectType</param> /// <returns></returns> /// public static UserObject ParseInternalUserObjectName( string objectName, UserObjectType objType, string userName) { UserObject uo = ParseInternalUserObjectName(objectName, userName); if (uo != null) { uo.Type = objType; } return(uo); }
/// <summary> /// Return true if this type of UserObject can be copied and pasted /// </summary> /// <param name="type"></param> /// <returns></returns> public static bool CanCopyPaste(UserObjectType type) { if ( // allowed types for copy type == UserObjectType.Annotation || type == UserObjectType.CalcField || type == UserObjectType.SpotfireLink || type == UserObjectType.CnList || type == UserObjectType.MultiTable || type == UserObjectType.Query) { return(true); } return(false); }
public ConfigurationValue(string name, ConfigurationValueType type, object defaultValue, IObjectDescription description, List <IObjectDescription> options = null, UserObjectType subType = UserObjectType.None) { DisplayName = name; Type = type; Description = description.Description; DetailedDescription = description.DetailedDescription; Options = options; Subtype = subType; object verifiedDefault; if (!Validate(defaultValue, out verifiedDefault)) { throw new ArgumentException("Default value is not acceptable for this type."); } DefaultValue = verifiedDefault; }
/// <summary> /// Construct setting type of edit /// </summary> /// <param name="type"></param> public UserDataEditor(UserObjectType type) { if (type == UserObjectType.UserDatabase) { UserDatabase = true; AnnotationTable = false; } else if (type == UserObjectType.Annotation) { AnnotationTable = true; UserDatabase = false; } return; }
/// <summary> /// Mainly written for cache data as JSON for backing source. Please do not call this method from anywhere /// other than the derived classes of <see cref="Runtime.Caching.ProviderItemBase"/>. /// </summary> public T GetCacheData <T>(object data, BitSet flag, UserObjectType userObjectType) { var userBinaryObject = data as UserBinaryObject; // Cache Items if (userBinaryObject != default(UserBinaryObject)) { var serializedObject = userBinaryObject.GetFullObject() as byte[]; if (_context.CompressionEnabled) { serializedObject = CompressionUtil.Decompress(serializedObject, flag); } return(SerializationUtil.SafeDeserializeOutProc <T>(serializedObject, _context.SerializationContext, flag, true, userObjectType)); } return((T)data); }
/// <summary> /// User object types that are editable /// </summary> /// <param name="type"></param> /// <returns></returns> public static bool IsUserEditableType( UserObjectType type) { if ( type == UserObjectType.Query || type == UserObjectType.CnList || type == UserObjectType.CalcField || type == UserObjectType.SpotfireLink || type == UserObjectType.CondFormat || type == UserObjectType.Annotation || type == UserObjectType.Folder || type == UserObjectType.MultiTable || type == UserObjectType.UserDatabase) { return(true); } return(false); }
/// <summary> /// Test for factory classes /// </summary> /// <param name="type"></param> /// <returns></returns> public static bool IsFactory(this UserObjectType type) { return(type >= UserObjectType.TriggerFactory); }
public UserObject( // constructor with type UserObjectType type) { Type = type; }
/// <summary> /// Fetch all objects of a given type regardless of who owns it or where it is located. /// </summary> /// <param name="type"></param> /// <param name="includeContent"></param> /// <returns>Set of user objects ordered by obj_id</returns> public List <UserObject> ReadMultiple( UserObjectType type, bool includeContent) { return(UserObjectDao.ReadMultiple(type, includeContent)); }
/// <summary> /// Process a configuration block /// </summary> /// <param name="defaultLang"></param> /// <param name="element"></param> /// <returns></returns> private static IConfigurationDescription ProcessConfiguration(string defaultLang, XElement parent) { List <IConfigurationValue> values = new List <IConfigurationValue>(); IEnumerable <XElement> nodes = from node in parent.Descendants(ValueTag) where (node.Attribute(NameAttribute) != null) && (node.Attribute(TypeAttribute) != null) && (node.Attribute(DefaultAttribute) != null) select node; foreach (XElement node in nodes) { // Get required attributes (name, type and default) Dictionary <string, string> attributes = new Dictionary <string, string>(); attributes[NameAttribute] = node.Attribute(NameAttribute).Value; attributes[TypeAttribute] = node.Attribute(TypeAttribute).Value; attributes[DefaultAttribute] = node.Attribute(DefaultAttribute).Value; LogHost.Default.Debug("Adding configuration entry '{0}' ({1})", attributes[NameAttribute], attributes[TypeAttribute]); // Verify the type ConfigurationValueType valueType; if (!Enum.TryParse(attributes[TypeAttribute], false, out valueType)) { LogHost.Default.Warn("Unrecognised configuration type '{0}'", attributes[TypeAttribute]); continue; } // Process the description of the entry ObjectDescription description = ProcessDescription(defaultLang, node); // Do type specific configuration List <IObjectDescription> options = null; if (valueType == ConfigurationValueType.OptionList) { // Build a list of individual options IEnumerable <XElement> optionNodes = from option in node.Descendants(SelectionTag) where option.Attribute(NameAttribute) != null select option; if (optionNodes.Count() == 0) { LogHost.Default.Error("Configuration values of type 'OptionList' require options."); return(null); } options = new List <IObjectDescription>(); foreach (XElement item in optionNodes) { options.Add(ProcessDescription(defaultLang, item)); } } UserObjectType objectType = UserObjectType.None; if ((valueType == ConfigurationValueType.ObjectList) || (valueType == ConfigurationValueType.ObjectValue)) { if (!Enum.TryParse(node.Attribute(SubtypeAttribute).Value, true, out objectType)) { LogHost.Default.Error("Fields of type {0} require a valid '{1}' attribute.", valueType, SubtypeAttribute); return(null); } } // Create and add the value ConfigurationValue configValue = new ConfigurationValue( attributes[NameAttribute], valueType, attributes[DefaultAttribute], description, options, objectType ); values.Add(configValue); } return(new ConfigurationDescription(values)); }
/// <summary> /// Dialog to open a user object /// </summary> /// <param name="objType">Type of object to open</param> /// <param name="prompt"></param> /// <param name="defaultName"></param> /// <returns></returns> public static UserObject ShowDialog( UserObjectType objType, string title) { return(ShowDialog(objType, title, null)); }
/// <summary> /// Dialog to open a user object /// </summary> /// <param name="objType">Type of object to open</param> /// <param name="prompt"></param> /// <param name="defaultName"></param> /// <returns></returns> public static UserObject ShowDialog( UserObjectType objType, string title, UserObject defaultUo) { MetaTreeNode mtn = null; MetaTreeNodeType mtnFilter; string response, objectTypeName; int i1; GetInstance(); objectTypeName = UserObject.GetTypeLabel(objType); string defaultName = ""; string defaultFolder = SS.I.PreferredProjectId; if (defaultUo != null) { defaultName = defaultUo.Name; defaultFolder = defaultUo.ParentFolder; } Instance.UoType = objType; Instance.Text = title; Instance.Prompt.Text = "Select a " + objectTypeName + " from the choices shown below"; mtnFilter = MetaTreeNodeType.Project; // show project folders and above mtnFilter |= UserObjectTree.UserObjectTypeToMetaTreeNodeType(objType); // user objects of specified type mtnFilter |= MetaTreeNodeType.UserFolder; // and any user folders string expandNodeTarget = "", expandNodeTarget2 = ""; if (objType != UserObjectType.UserDatabase) { mtn = UserObjectTree.FindObjectTypeSubfolder(SS.I.PreferredProjectId, objType, SS.I.UserName); if (mtn == null) { MetaTreeNode defProjNode = UserObjectTree.FindFolderNode(SS.I.PreferredProjectId); if (defProjNode == null) { defProjNode = UserObjectTree.AddSystemFolderNode(SS.I.PreferredProjectId); } mtn = UserObjectTree.FindObjectTypeSubfolder(defProjNode.Name, objType, SS.I.UserName); if (mtn == null) { mtn = UserObjectTree.CreateUserFolderObjectAndNode(defProjNode, UserObject.GetTypeLabelPlural(objType), SS.I.UserName); } } } else { if (UserObjectTree.FolderNodes.ContainsKey(defaultFolder)) { mtn = UserObjectTree.FolderNodes[defaultFolder]; } else { DebugLog.Message("Couldn't find default folder in tree: " + defaultFolder); // just log & ignore } } if (mtn?.Target != null) { expandNodeTarget = mtn.Target; if (mtn.Parent != null) { expandNodeTarget2 = mtn.Parent.Target; } } Instance.ContentsTreeWithSearch.ContentsTreeCtl.FillTree("root", mtnFilter, null, expandNodeTarget, expandNodeTarget2, false, false); Instance.ContentsTreeWithSearch.ContentsTreeCtl.SelectNode(expandNodeTarget); Instance.ContentsTreeWithSearch.CommandLineControl.Text = ""; Instance.ObjectName.Text = defaultName; Instance.SelectedNode = null; // node selected from tree QbUtil.SetProcessTreeItemOperationMethod(TreeItemOperation); DialogResult dr = Instance.ShowDialog(SessionManager.ActiveForm); QbUtil.RestoreProcessTreeItemOperationMethod(); if (dr == DialogResult.Cancel) { return(null); } return(Instance.OpenUoInfo); }
public UserObjectNode(UserObjectType uonType) { this.Type = uonType; }
public virtual object SafeSerialize(object serializableObject, string serializationContext, ref BitSet flag, CacheImplBase cacheImpl, ref long size, UserObjectType userObjectType, bool isCustomAttributeBaseSerialzed = false) { return(null); }
/// <summary> /// Parse an internal user object name into a UserObject setting type /// </summary> /// <param name="name">objectType_objectId (e.g. "QUERY_456") or folderId.name (e.g. "FOLDER_123.My Query")</param> /// <param name="objType">UserObjectType</param> /// <returns></returns> public static UserObject ParseInternalUserObjectName( string objectName, UserObjectType objType) { return(UserObject.ParseInternalUserObjectName(objectName, objType, SS.I.UserName)); }
/// <summary> /// Can this object type be deleted by the user? /// </summary> /// <param name="type"></param> /// <returns></returns> public static bool IsDeletable(this UserObjectType type) { return(!(type.IsFactory() || (type == UserObjectType.Server) || (type == UserObjectType.Plugin))); }
public ConfigurationValue(string name, ConfigurationValueType type, object defaultValue, IObjectDescription description, List<IObjectDescription> options = null, UserObjectType subType = UserObjectType.None) { DisplayName = name; Type = type; Description = description.Description; DetailedDescription = description.DetailedDescription; Options = options; Subtype = subType; object verifiedDefault; if (!Validate(defaultValue, out verifiedDefault)) throw new ArgumentException("Default value is not acceptable for this type."); DefaultValue = verifiedDefault; }
public virtual T SafeDeserialize <T>(object serializedObject, string serializationContext, BitSet flag, CacheImplBase cacheImpl, UserObjectType userObjectType) { return(default(T)); }