Exemplo n.º 1
0
        public List <DynamicType> GetRootMaps(string repositoryName, Guid domainId, ITypeDescriptorCollection entityFields)
        {
            List <DynamicType> nodes = new List <DynamicType>();

            using (SqlConnection dbConnection = new SqlConnection(_connectionSetting.GetConnectionString()))
            {
                using (SqlCommand dbCommand = new SqlCommand())
                {
                    dbCommand.Connection  = dbConnection;
                    dbCommand.CommandType = CommandType.StoredProcedure;
                    dbCommand.CommandText = "dbo.GetRootMaps";

                    // Get the root maps for all domains unless a domain is specified.
                    if (!domainId.Equals(Guid.Empty))
                    {
                        dbCommand.Parameters.Add("@DomainId", System.Data.SqlDbType.UniqueIdentifier).Value = @domainId;
                    }

                    dbConnection.Open();
                    nodes = ReadNodes(dbCommand, repositoryName, entityFields);
                }
            }

            return(nodes);
        }
Exemplo n.º 2
0
      /// <summary>
      /// Gets the map nodes contained in a map from a Glyma repository.
      /// </summary>
      /// <param name="repositoryName">The name of the Glyma repository.</param>
      /// <param name="domainId">The GUID of the map node's domain.</param>
      /// <param name="rootMapId">The GUID of the node's root map.</param>
      /// <param name="mapId">The GUID of the map node's parent map.</param>
      /// <param name="nodeId">The GUID of the map node to retrieve nodes from.</param>
      /// <param name="lastCrawlStartTime">Specifies the last crawl time.</param>
      /// <param name="entityFields">A ITypeDescriptorCollection object that contains the fields to retrieve for each node.</param>
      /// <returns>A collection of DynamicType objects containing details of the nodes retrieved from a Glyma repository.</returns>
      /// <remarks>This is intended to be used as an AssociationNavigator method for a map entity in a BCS model.</remarks>
      public List<DynamicType> GetMapNodesInMap(string repositoryName, Guid domainId, Guid rootMapId, Guid mapId, Guid nodeId, DateTime lastCrawlStartTime, ITypeDescriptorCollection entityFields)
      {
         GlymaSearchLogger.WriteTrace(LogCategoryId.Connector, TraceSeverity.Verbose, "GetMapNodesInMap(" + repositoryName + ", " + domainId + ", " + rootMapId + ", " + mapId + ", " + nodeId + ")");

         List<DynamicType> nodes = MapRepository.GetNodesInMap(repositoryName, nodeId, entityFields, true);
         nodes.RemoveAll(node => !CrawlRules.Apply(node, MapRepository));

         return nodes;
      }
Exemplo n.º 3
0
        private static void SetSecondaryFields(SPListItem listItem, SPBusinessDataField dataField, IEntityInstance entityInstance, string finderMethod)
        {
            try
            {
                // Convert the entity to a formatted datatable
                System.Data.DataTable dtBDCData = entityInstance.EntityAsFormattedDataTable;

                // Set the BCS field itself (Display Value)
                listItem[dataField.Id] = dtBDCData.Rows[0][dataField.BdcFieldName].ToString();

                // Get the specific finder method to get the columns that returns
                IMethodInstance           method       = entityInstance.Entity.GetMethodInstances(MethodInstanceType.SpecificFinder)[finderMethod];
                ITypeDescriptorCollection oDescriptors = method.GetReturnTypeDescriptor().GetChildTypeDescriptors()[0].GetChildTypeDescriptors();

                // Set the column names to the correct values
                foreach (ITypeDescriptor oType in oDescriptors)
                {
                    if (oType.ContainsLocalizedDisplayName())
                    {
                        if (dtBDCData.Columns.Contains(oType.Name))
                        {
                            dtBDCData.Columns[oType.Name].ColumnName = oType.GetLocalizedDisplayName();
                        }
                    }
                }

                // Get the secondary field display names - these should be set
                string[] sSecondaryFieldsDisplayNames = dataField.GetSecondaryFieldsNames();

                // Loop through the fields and set each column to its value
                foreach (string columnNameInt in sSecondaryFieldsDisplayNames)
                {
                    foreach (SPField field in listItem.Fields)
                    {
                        if (field.Title.StartsWith(dataField.Title) && field.GetProperty("BdcField") == columnNameInt)
                        {
                            Guid gFieldID = listItem.Fields[field.Title].Id;
                            listItem[gFieldID] = dtBDCData.Rows[0][columnNameInt].ToString();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                LogError("SetSecondaryFields errored with message " + e.Message, ErrorLevel.Warning);
                throw;
            }
        }
Exemplo n.º 4
0
      /// <summary>
      /// Gets the root map nodes from a Glyma repository.
      /// </summary>
      /// <param name="entityFields">A ITypeDescriptorCollection object that contains the fields to retrieve for each node.</param>
      /// <returns>A collection of DynamicType objects containing details of the nodes retrieved from a Glyma repository.</returns>
      /// <remarks>This is intended to be used as a Finder method in a BCS model.</remarks>
      public List<DynamicType> GetRooMaps(ITypeDescriptorCollection entityFields)
      {
         GlymaSearchLogger.WriteTrace(LogCategoryId.Connector, TraceSeverity.Verbose, "GetRootMaps");

         Uri startUrl = new Uri(StartAddress);
         Guid domainId = Guid.Empty;

         if (startUrl.Segments.Length == 2)
         {
            domainId = new Guid(startUrl.Segments[1].TrimEnd('/'));
         }

         List<DynamicType> nodes = MapRepository.GetRootMaps(RepositoryName, domainId, entityFields);
         nodes.RemoveAll(node => !CrawlRules.Apply(node, MapRepository));

         return nodes;
      }
Exemplo n.º 5
0
        /// <summary>
        /// Gets the root map nodes from a Glyma repository.
        /// </summary>
        /// <param name="entityFields">A ITypeDescriptorCollection object that contains the fields to retrieve for each node.</param>
        /// <returns>A collection of DynamicType objects containing details of the nodes retrieved from a Glyma repository.</returns>
        /// <remarks>This is intended to be used as a Finder method in a BCS model.</remarks>
        public List <DynamicType> GetRooMaps(ITypeDescriptorCollection entityFields)
        {
            GlymaSearchLogger.WriteTrace(LogCategoryId.Connector, TraceSeverity.Verbose, "GetRootMaps");

            Uri  startUrl = new Uri(StartAddress);
            Guid domainId = Guid.Empty;

            if (startUrl.Segments.Length == 2)
            {
                domainId = new Guid(startUrl.Segments[1].TrimEnd('/'));
            }

            List <DynamicType> nodes = MapRepository.GetRootMaps(RepositoryName, domainId, entityFields);

            nodes.RemoveAll(node => !CrawlRules.Apply(node, MapRepository));

            return(nodes);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Get the fields that have been defined for the return entity of a method.
        /// </summary>
        /// <param name="methodInstance">The method to examine.</param>
        /// <returns>A collection of fields defined on the return entity of the the method.</returns>
        protected virtual ITypeDescriptorCollection GetEntityFields(Microsoft.BusinessData.MetadataModel.IMethodInstance methodInstance)
        {
            ITypeDescriptor           returnType   = methodInstance.GetReturnTypeDescriptor();
            ITypeDescriptorCollection entityFields = null;

            if (returnType.IsCollection)
            {
                ITypeDescriptorCollection childTypes = returnType.GetChildTypeDescriptors();
                if (childTypes.Count > 0)
                {
                    entityFields = childTypes[0].GetChildTypeDescriptors();
                }
            }
            else
            {
                entityFields = returnType.GetChildTypeDescriptors();
            }

            return(entityFields);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Initialises a DynamicType object using details from a ITypeDescriptorCollection object.
 /// </summary>
 /// <param name="node">A DynamicType object to initialise.</param>
 /// <param name="entityFields">A ITypeDescriptorCollection object containing the details of the fields.</param>
 public static void Initialise(this DynamicType node, ITypeDescriptorCollection entityFields)
 {
     // Add an entry for each field in entityFields and initialise its value to an appropriate default.
     foreach (ITypeDescriptor fieldDefinition in entityFields)
     {
         Type   fieldType = Type.GetType(fieldDefinition.TypeName, true, true);
         object fieldValue;
         if (fieldType == typeof(string))
         {
             fieldValue = string.Empty;
         }
         else if (fieldType == typeof(DateTime))
         {
             fieldValue = new DateTime(1970, 1, 1);
         }
         else
         {
             fieldValue = Activator.CreateInstance(fieldType);
         }
         node.Add(fieldDefinition.Name, fieldValue);
     }
 }
Exemplo n.º 8
0
 /// <summary>
 /// Initialises a DynamicType object using details from a ITypeDescriptorCollection object.
 /// </summary>
 /// <param name="node">A DynamicType object to initialise.</param>
 /// <param name="entityFields">A ITypeDescriptorCollection object containing the details of the fields.</param>
 public static void Initialise(this DynamicType node, ITypeDescriptorCollection entityFields)
 {
     // Add an entry for each field in entityFields and initialise its value to an appropriate default.
     foreach (ITypeDescriptor fieldDefinition in entityFields)
     {
         Type fieldType = Type.GetType(fieldDefinition.TypeName, true, true);
         object fieldValue;
         if (fieldType == typeof(string))
         {
             fieldValue = string.Empty;
         }
         else if (fieldType == typeof(DateTime))
         {
             fieldValue = new DateTime(1970, 1, 1);
         }
         else
         {
             fieldValue = Activator.CreateInstance(fieldType);
         }
         node.Add(fieldDefinition.Name, fieldValue);
     }
 }
Exemplo n.º 9
0
        public List <DynamicType> GetNodesInMap(string repositoryName, Guid mapId, ITypeDescriptorCollection entityFields, bool mapsOnly)
        {
            List <DynamicType> nodes = new List <DynamicType>();

            if (!mapId.Equals(Guid.Empty))
            {
                using (SqlConnection dbConnection = new SqlConnection(_connectionSetting.GetConnectionString()))
                {
                    using (SqlCommand dbCommand = new SqlCommand())
                    {
                        dbCommand.Connection  = dbConnection;
                        dbCommand.CommandType = CommandType.StoredProcedure;
                        dbCommand.CommandText = "dbo.GetNodesInMap";
                        dbCommand.Parameters.Add("@MapId", System.Data.SqlDbType.UniqueIdentifier).Value = mapId;
                        dbCommand.Parameters.Add("@MapsOnly", System.Data.SqlDbType.Bit).Value           = mapsOnly;
                        dbConnection.Open();
                        nodes = ReadNodes(dbCommand, repositoryName, entityFields);
                    }
                }
            }

            return(nodes);
        }
Exemplo n.º 10
0
        public DynamicType GetNode(string repositoryName, Guid nodeId, ITypeDescriptorCollection entityFields)
        {
            DynamicType node = null;

            using (SqlConnection dbConnection = new SqlConnection(_connectionSetting.GetConnectionString()))
            {
                using (SqlCommand dbCommand = new SqlCommand())
                {
                    dbCommand.Connection  = dbConnection;
                    dbCommand.CommandText = "dbo.GetNodeInMapDetails";
                    dbCommand.CommandType = CommandType.StoredProcedure;
                    dbCommand.Parameters.Add("@NodeId", System.Data.SqlDbType.UniqueIdentifier).Value = nodeId;

                    dbConnection.Open();
                    List <DynamicType> nodes = ReadNodes(dbCommand, repositoryName, entityFields);
                    if (nodes.Count > 0)
                    {
                        node = nodes[0];
                    }
                }
            }
            return(node);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Set the secondary fields of a BDC field
        /// </summary>
        /// <param name="listItem"></param>
        /// <param name="dataField"></param>
        /// <param name="entityInstance"></param>
        private static void SetSecondaryFields(SPListItem listItem, SPBusinessDataField dataField, IEntityInstance entityInstance)
        {
            //Copy the fieldset to a datatable
            DataTable dtBDCData = entityInstance.EntityAsFormattedDataTable;

            //Update the BDC primary field ID with the primary field in the datatable
            listItem[dataField.Id] = dtBDCData.Rows[0][dataField.BdcFieldName].ToString();

            //Get the Specific Finder method of the BDC entity and get the collection of columns/descriptors
            IMethodInstance           method       = entityInstance.Entity.GetMethodInstances(MethodInstanceType.SpecificFinder)[0].Value;
            ITypeDescriptorCollection oDescriptors = method.GetReturnTypeDescriptor().GetChildTypeDescriptors()[0].GetChildTypeDescriptors();

            //Loop through each Type Descriptor in the specific finder instance and update the local datatable column names appropriately
            foreach (ITypeDescriptor oType in oDescriptors)
            {
                if (oType.ContainsLocalizedDisplayName())
                {
                    if (dtBDCData.Columns.Contains(oType.Name))
                    {
                        dtBDCData.Columns[oType.Name].ColumnName = oType.GetLocalizedDisplayName();
                    }
                }
            }

            //Loop through each column name in the data source and update the corresponding list item column
            string[] sSecondaryFieldsDisplayNames = dataField.GetSecondaryFieldsNames();
            foreach (string columnNameint in sSecondaryFieldsDisplayNames)
            {
                Guid gFieldID = listItem.Fields[String.Format("{0}: {1}", dataField.Title, dtBDCData.Columns[columnNameint].Caption)].Id;
                listItem[gFieldID] = dtBDCData.Rows[0][columnNameint].ToString();
            }

            //Set the final values of the list item linking the item to its actual BDC Identity (allows for manually refreshing the list)
            listItem[dataField.Id]           = dtBDCData.Rows[0][dataField.BdcFieldName].ToString();
            listItem[dataField.RelatedField] = dtBDCData.Rows[0]["BdcIdentity"].ToString();
        }
Exemplo n.º 12
0
        /// <summary>
        /// Get the details of a Glyma node.
        /// </summary>
        /// <param name="repositoryName">The name of the Glyma repository.</param>
        /// <param name="domainId">The GUID of the node's domain.</param>
        /// <param name="rootMapId">The GUID of the node's root map.</param>
        /// <param name="mapId">The GUID of the node's parent map.</param>
        /// <param name="nodeId">The GUID of the node to retrieve details from.</param>
        /// <param name="entityFields">A ITypeDescriptorCollection object that contains the fields to retrieve for each node.</param>
        /// <returns>A DynamicType object containing the details for the node.</returns>
        public DynamicType GetNode(string repositoryName, Guid domainId, Guid rootMapId, Guid mapId, Guid nodeId, ITypeDescriptorCollection entityFields)
        {
            GlymaSearchLogger.WriteTrace(LogCategoryId.Connector, TraceSeverity.Verbose, "GetNode(" + repositoryName + ", " + domainId + ", " + rootMapId + ", " + mapId + ", " + nodeId + ")");

            DynamicType node = null;

            node = MapRepository.GetNode(repositoryName, nodeId, entityFields);
            if (node != null)
            {
                CrawlRules.Apply(node, MapRepository);
            }

            return(node);
        }
Exemplo n.º 13
0
      /// <summary>
      /// Get the access control list (ACL) for a node.
      /// </summary>
      /// <param name="repositoryName">The name of the Glyma repository.</param>
      /// <param name="domainId">The GUID of the node's domain.</param>
      /// <param name="rootMapId">The GUID of the node's root map.</param>
      /// <param name="mapId">The GUID of the node's parent map.</param>
      /// <param name="nodeId">The GUID of the node to retrieve details from.</param>
      /// <param name="entityFields">A ITypeDescriptorCollection object that contains the fields to retrieve for each node.</param>
      /// <returns></returns>
      public byte[] GetNodeAcl(string repositoryName, Guid domainId, Guid rootMapId, Guid mapId, Guid nodeId, ITypeDescriptorCollection entityFields)
      {
         GlymaSearchLogger.WriteTrace(LogCategoryId.Connector, TraceSeverity.Verbose, "GetNodeAcl(" + repositoryName + ", " + domainId + ", " + rootMapId + ", " + mapId + ", " + nodeId + ")");

         byte[] nodeAcl = null;

         if (IsSecurityEnabled)
         {
            nodeAcl = SecurityManager.GetNodeAcl(MapRepository.GetDatabaseName(), repositoryName, domainId, rootMapId);
         }
         else
         {
            nodeAcl = SecurityManager.GetAllowAllNodeAcl(repositoryName, domainId, rootMapId);
         }

         return nodeAcl;
      }
Exemplo n.º 14
0
      /// <summary>
      /// Get the details of a Glyma node.
      /// </summary>
      /// <param name="repositoryName">The name of the Glyma repository.</param>
      /// <param name="domainId">The GUID of the node's domain.</param>
      /// <param name="rootMapId">The GUID of the node's root map.</param>
      /// <param name="mapId">The GUID of the node's parent map.</param>
      /// <param name="nodeId">The GUID of the node to retrieve details from.</param>
      /// <param name="entityFields">A ITypeDescriptorCollection object that contains the fields to retrieve for each node.</param>
      /// <returns>A DynamicType object containing the details for the node.</returns>
      public DynamicType GetNode(string repositoryName, Guid domainId, Guid rootMapId, Guid mapId, Guid nodeId, ITypeDescriptorCollection entityFields)
      {
         GlymaSearchLogger.WriteTrace(LogCategoryId.Connector, TraceSeverity.Verbose, "GetNode(" + repositoryName + ", " + domainId + ", " + rootMapId + ", " + mapId + ", " + nodeId + ")");

         DynamicType node = null;

         node = MapRepository.GetNode(repositoryName, nodeId, entityFields);
         if (node != null)
         {
            CrawlRules.Apply(node, MapRepository);
         }

         return node;
      }
Exemplo n.º 15
0
        /// <summary>
        /// Gets the map nodes contained in a map from a Glyma repository.
        /// </summary>
        /// <param name="repositoryName">The name of the Glyma repository.</param>
        /// <param name="domainId">The GUID of the map node's domain.</param>
        /// <param name="rootMapId">The GUID of the node's root map.</param>
        /// <param name="mapId">The GUID of the map node's parent map.</param>
        /// <param name="nodeId">The GUID of the map node to retrieve nodes from.</param>
        /// <param name="lastCrawlStartTime">Specifies the last crawl time.</param>
        /// <param name="entityFields">A ITypeDescriptorCollection object that contains the fields to retrieve for each node.</param>
        /// <returns>A collection of DynamicType objects containing details of the nodes retrieved from a Glyma repository.</returns>
        /// <remarks>This is intended to be used as an AssociationNavigator method for a map entity in a BCS model.</remarks>
        public List <DynamicType> GetMapNodesInMap(string repositoryName, Guid domainId, Guid rootMapId, Guid mapId, Guid nodeId, DateTime lastCrawlStartTime, ITypeDescriptorCollection entityFields)
        {
            GlymaSearchLogger.WriteTrace(LogCategoryId.Connector, TraceSeverity.Verbose, "GetMapNodesInMap(" + repositoryName + ", " + domainId + ", " + rootMapId + ", " + mapId + ", " + nodeId + ")");

            List <DynamicType> nodes = MapRepository.GetNodesInMap(repositoryName, nodeId, entityFields, true);

            nodes.RemoveAll(node => !CrawlRules.Apply(node, MapRepository));

            return(nodes);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Executes a MethodInstance in the model against the specified external system instance with given parameters.
        /// </summary>
        /// <param name="methodInstance">The method instance being executed.</param>
        /// <param name="lobSystemInstance">The external system instance which the method instance is being executed against.</param>
        /// <param name="args">Parameters of the method. The size of the parameter array is equal to the number of parameter objects in the method definition in the BCS model file, and the values are passed in order. Out and return parameters will be a null reference.</param>
        /// <param name="context">ExecutionContext in which this execution is happening. This value will be a null reference if ExecutionContext is not created.</param>
        /// <remarks>
        /// This method is executed in a separate thread.
        /// </remarks>
        public override void ExecuteStatic(Microsoft.BusinessData.MetadataModel.IMethodInstance methodInstance, Microsoft.BusinessData.MetadataModel.ILobSystemInstance lobSystemInstance, object[] args, Microsoft.BusinessData.Runtime.IExecutionContext context)
        {
            // Modify the execution behaviour for the method instance types that are used in the Glyma repository model and revert to the base class implementation
            // for all other method instance types (until a better understanding is developed on how the other method instance types are used).
            switch (methodInstance.MethodInstanceType)
            {
            case MethodInstanceType.Finder:
            case MethodInstanceType.SpecificFinder:
            case MethodInstanceType.AssociationNavigator:
            case MethodInstanceType.ChangedIdEnumerator:
            case MethodInstanceType.DeletedIdEnumerator:
            case MethodInstanceType.BinarySecurityDescriptorAccessor:

                // Validate parameters to ensure all required execution details are available.
                if (methodInstance == null)
                {
                    throw new ArgumentNullException("methodInstance");
                }

                if (lobSystemInstance == null)
                {
                    throw new ArgumentNullException("lobSystemInstance");
                }

                if (args == null)
                {
                    throw new ArgumentNullException("args");
                }

                if (context == null)
                {
                    throw new ArgumentNullException("context");
                }

                IConnectionContext connectionContext = (IConnectionContext)context["ConnectionContext"];
                if (connectionContext == null)
                {
                    throw new ArgumentNullException("The BDC execution context doesn't contain a connection context.");
                }

                // Create the proxy and execute the method.
                GlymaRepositoryProxy proxy = null;
                try
                {
                    proxy = CreateProxy();
                    if (proxy == null)
                    {
                        throw new ArgumentException("The proxy returned from the BDC shim is null.");
                    }

                    GlymaSearchLogger.WriteTrace(LogCategoryId.Connector, TraceSeverity.Verbose, "Configuring proxy to execute " + methodInstance.MethodInstanceType.ToString() + " method for: " + connectionContext.Path.OriginalString);
                    SetGlobalSettings(proxy, lobSystemInstance.GetLobSystem().GetProperties());
                    SetStartAddress(proxy, connectionContext.Path.OriginalString);
                    SetRepositoryName(proxy, lobSystemInstance.Name);
                    SetMapConnectionString(proxy, lobSystemInstance.GetProperties(), lobSystemInstance.Name);

                    // Get the definition of the fields for the entity that will be returned by the proxy method.  This enables the connector to build entities
                    // based on the definitions in the model file instead of having entities with fixed pre-defined properties.
                    ITypeDescriptorCollection entityFields = GetEntityFields(methodInstance);

                    GlymaSearchLogger.WriteTrace(LogCategoryId.Connector, TraceSeverity.Verbose, "Executing " + methodInstance.MethodInstanceType.ToString() + " proxy method for: " + connectionContext.Path.OriginalString);
                    ExecuteProxyMethod(proxy, methodInstance, args, entityFields);
                    GlymaSearchLogger.WriteTrace(LogCategoryId.Connector, TraceSeverity.Verbose, "Completed execution of " + methodInstance.MethodInstanceType.ToString() + " proxy method for: " + connectionContext.Path.OriginalString);
                }
                catch (Exception currentException)
                {
                    GlymaSearchLogger.WriteTrace(LogCategoryId.Connector, TraceSeverity.Unexpected, currentException.ToString());
                    throw;
                }
                finally
                {
                    if (proxy != null)
                    {
                        DisposeProxy(proxy);
                        proxy = null;
                    }
                }
                break;

            default:
                base.ExecuteStatic(methodInstance, lobSystemInstance, args, context);
                break;
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Executes the proxy method using reflection.
        /// </summary>
        /// <param name="proxy">A GlymaRepositoryProxy object used to execute the method.</param>
        /// <param name="methodInstance">The method to execute.</param>
        /// <param name="methodArgs">The parameters of the method.</param>
        /// <param name="entityFields">A ITypeDescriptorCollection object that contains the fields to retrieve for the entity containing the method to execute.</param>
        protected virtual void ExecuteProxyMethod(GlymaRepositoryProxy proxy, IMethodInstance methodInstance, object[] methodArgs, ITypeDescriptorCollection entityFields)
        {
            // Extract the method details required to execute it using reflection.
            IMethod              method               = methodInstance.GetMethod();
            string               methodName           = (method.LobName != null) ? method.LobName : method.Name;
            List <Type>          parameterTypes       = new List <Type>();
            List <object>        parameters           = new List <object>(methodArgs.Length);
            IParameterCollection parameterDefinitions = method.GetParameters();

            foreach (IParameter parameterDefinition in parameterDefinitions)
            {
                if (parameterDefinition.Direction != DirectionType.Return)
                {
                    Type parameterType = parameterDefinition.TypeReflector.ResolveDotNetType(parameterDefinition.GetRootTypeDescriptor().TypeName, method.GetDataClass().GetLobSystem());
                    if (parameterDefinition.Direction != DirectionType.In)
                    {
                        parameterType = parameterType.MakeByRefType();
                    }
                    parameters.Add(methodArgs[parameterDefinition.OrdinalNumber]);
                    parameterTypes.Add(parameterType);
                }
            }

            // Pass the entity fields as the last parameter to the proxy method.
            parameters.Add(entityFields);
            parameterTypes.Add(typeof(ITypeDescriptorCollection));

            // Execute the method using reflection.
            object[]   parametersArray = parameters.ToArray();
            MethodInfo proxyMethodInfo = typeof(GlymaRepositoryProxy).GetMethod(methodName, BindingFlags.Public | BindingFlags.Instance, null, parameterTypes.ToArray(), null);

            if (proxyMethodInfo == null)
            {
                throw new Microsoft.BusinessData.Runtime.RuntimeException("A method with the name \"" + methodName + "\" with the specified parameters could not be found in the proxy.");
            }
            object result = proxyMethodInfo.Invoke(proxy, parametersArray);

            // Set the parameter values using the results of the method execution.
            foreach (IParameter parameterDefinition in parameterDefinitions)
            {
                if (parameterDefinition.Direction == DirectionType.Return)
                {
                    methodArgs[parameterDefinition.OrdinalNumber] = result;
                }
                else
                {
                    methodArgs[parameterDefinition.OrdinalNumber] = parametersArray[parameterDefinition.OrdinalNumber];
                }
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Get the access control list (ACL) for a node.
        /// </summary>
        /// <param name="repositoryName">The name of the Glyma repository.</param>
        /// <param name="domainId">The GUID of the node's domain.</param>
        /// <param name="rootMapId">The GUID of the node's root map.</param>
        /// <param name="mapId">The GUID of the node's parent map.</param>
        /// <param name="nodeId">The GUID of the node to retrieve details from.</param>
        /// <param name="entityFields">A ITypeDescriptorCollection object that contains the fields to retrieve for each node.</param>
        /// <returns></returns>
        public byte[] GetNodeAcl(string repositoryName, Guid domainId, Guid rootMapId, Guid mapId, Guid nodeId, ITypeDescriptorCollection entityFields)
        {
            GlymaSearchLogger.WriteTrace(LogCategoryId.Connector, TraceSeverity.Verbose, "GetNodeAcl(" + repositoryName + ", " + domainId + ", " + rootMapId + ", " + mapId + ", " + nodeId + ")");

            byte[] nodeAcl = null;

            if (IsSecurityEnabled)
            {
                nodeAcl = SecurityManager.GetNodeAcl(MapRepository.GetDatabaseName(), repositoryName, domainId, rootMapId);
            }
            else
            {
                nodeAcl = SecurityManager.GetAllowAllNodeAcl(repositoryName, domainId, rootMapId);
            }

            return(nodeAcl);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Read the Glyma nodes from a Glyma Repository.
        /// </summary>
        /// <param name="dbReader">A dbCommand object containing the details required to retrieve nodes from a Glyma repository.  This must reference an open database connection.</param>
        /// <param name="repositoryName">The name of the repository the nodes were retrieved from.</param>
        /// <param name="entityFields">A ITypeDescriptorCollection object that contains the fields to retrieve for each node.</param>
        /// <returns>A collection of DynamicType objects containing details of the nodes retrieved from a Glyma repository.</returns>
        protected virtual List <DynamicType> ReadNodes(SqlCommand dbCommand, string repositoryName, ITypeDescriptorCollection entityFields)
        {
            List <DynamicType> nodes   = new List <DynamicType>();
            DynamicType        newNode = null;
            Guid currentNodeId         = Guid.Empty;

            using (SqlDataReader dbReader = dbCommand.ExecuteReader())
            {
                while (dbReader.Read())
                {
                    Guid readNodeId = dbReader.GetValue <Guid>(GlymaEntityFields.Id);
                    if (!readNodeId.Equals(currentNodeId))
                    {
                        currentNodeId = readNodeId;
                        newNode       = new DynamicType();
                        newNode.Initialise(entityFields);
                        ReadBaseNodeProperties(newNode, dbReader, repositoryName);
                        nodes.Add(newNode);
                    }
                    ReadNodeProperty(newNode, dbReader);
                }
            }

            return(nodes);
        }