当前位置: 首页>>代码示例>>C#>>正文


C# IMaintainableRefObject.HasMaintainableId方法代码示例

本文整理汇总了C#中IMaintainableRefObject.HasMaintainableId方法的典型用法代码示例。如果您正苦于以下问题:C# IMaintainableRefObject.HasMaintainableId方法的具体用法?C# IMaintainableRefObject.HasMaintainableId怎么用?C# IMaintainableRefObject.HasMaintainableId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IMaintainableRefObject的用法示例。


在下文中一共展示了IMaintainableRefObject.HasMaintainableId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckEqualsWithNoVersion

        /// <summary>
        /// Checks if <paramref name="first"/> and <paramref name="second"/>  without checking the version.
        /// </summary>
        /// <param name="first">The first <see cref="IMaintainableRefObject"/>.</param>
        /// <param name="second">The second <see cref="IMaintainableRefObject"/>.</param>
        /// <returns><c>true</c> if <paramref name="first"/> and <paramref name="second"/> have the same MaintainableId and AgencyId, <c>false</c> otherwise.</returns>
        public static bool CheckEqualsWithNoVersion(IMaintainableRefObject first, IMaintainableRefObject second)
        {
            if (first == null && second == null)
            {
                return true;
            } 
            
            if (first == null || second == null)
            {
                return false;
            }

            if (first.HasMaintainableId() && second.HasMaintainableId())
            {
                if (!first.MaintainableId.Equals(second.MaintainableId))
                {
                    return false;
                }
            } 
            else if (first.HasMaintainableId() || second.HasMaintainableId())
            {
                return false;
            }

            if (first.HasAgencyId() && second.HasAgencyId())
            {
                var firstAgency = NormalizeAgencyId(first);
                var secondAgency = NormalizeAgencyId(second);
                if (!firstAgency.Equals(secondAgency))
                {

                    return false;
                }
            }
            else if (first.HasAgencyId() || second.HasAgencyId())
            {
                return false;
            }

            return true;
        }
开发者ID:SDMXISTATFRAMEWORK,项目名称:ISTAT_ENHANCED_SDMXRI_WS,代码行数:47,代码来源:EDIUtil.cs

示例2: AddWhereClauses

        /// <summary>
        /// Add where clauses and populate <paramref name="parameters"/>
        /// </summary>
        /// <param name="maintainableRef">
        ///     The maintainable reference which may contain ID, AGENCY ID and/or VERSION.
        /// </param>
        /// <param name="database">
        ///     The database.
        /// </param>
        /// <param name="sqlCommand">
        ///     The SQL command.
        /// </param>
        /// <param name="parameters">
        ///     The parameters.
        /// </param>
        /// <param name="allowedDataflows">
        ///     The allowed dataflows.
        /// </param>
        /// <param name="whereState">the current state of the WHERE clause in <paramref name="sqlCommand"/></param>
        /// <returns>
        /// The <paramref name="parameters"/>
        /// </returns>
        public static IList<DbParameter> AddWhereClauses(IMaintainableRefObject maintainableRef, Database database, StringBuilder sqlCommand, IList<DbParameter> parameters, ICollection<IMaintainableRefObject> allowedDataflows, WhereState whereState)
        {
            if (allowedDataflows == null)
            {
                return parameters;
            }

            maintainableRef = maintainableRef ?? new MaintainableRefObjectImpl();
            switch (whereState)
            {
                case WhereState.Nothing:
                    sqlCommand.Append(" WHERE (");
                    break;
                case WhereState.Where:
                    break;
                case WhereState.And:
                    sqlCommand.Append(" AND (");
                    break;
            }

            int lastClause = sqlCommand.Length;
            int count = 0;
            bool addedClauses = false;
            foreach (IMaintainableRefObject allowedDataflow in allowedDataflows)
            {
                // TODO check if allowed dataflow id is mandatory. If not we need to change this.
                if (!maintainableRef.HasMaintainableId() || string.Equals(maintainableRef.MaintainableId, allowedDataflow.MaintainableId))
                {
                    string countString = count.ToString(CultureInfo.InvariantCulture);
                    sqlCommand.Append("(");

                    // id
                    string idParam = ParameterNameConstants.IdParameter + countString;
                    sqlCommand.AppendFormat(" A.ID = {0} ", database.BuildParameterName(idParam));
                    parameters.Add(database.CreateInParameter(idParam, DbType.String, allowedDataflow.MaintainableId));

                    // version
                    var versionParameters = allowedDataflow.GenerateVersionParameters(database, parameters, "A.VERSION", versionNumber => string.Format(CultureInfo.InvariantCulture, "{0}{1}_{2}", ParameterNameConstants.VersionParameter, versionNumber, countString));
                    if (versionParameters.Length > 0)
                    {
                        sqlCommand.AppendFormat(CultureInfo.InvariantCulture, "AND {0}", versionParameters);
                    }

                    // agency
                    if (allowedDataflow.HasAgencyId())
                    {
                        string name = ParameterNameConstants.AgencyParameter + countString;
                        sqlCommand.AppendFormat(" AND A.AGENCY = {0} ", database.BuildParameterName(name));
                        parameters.Add(database.CreateInParameter(name, DbType.String, allowedDataflow.AgencyId));
                    }

                    sqlCommand.Append(" ) ");
                    lastClause = sqlCommand.Length;
                    sqlCommand.Append(" OR ");
                    count++;
                    addedClauses = true;
                }
            }

            sqlCommand.Length = lastClause;

            if (!addedClauses)
            {
                sqlCommand.Append("'ACCESS' = 'DENIED'");
            }

            sqlCommand.Append(" ) ");

            return parameters;
        }
开发者ID:alcardac,项目名称:SDMXRI_ENH_WS,代码行数:92,代码来源:SecurityHelper.cs

示例3: GetMappingSet

        /// <summary>
        /// This method queries the mapping store for a mapping set for a specific dataflow.
        /// If such a mapping set exists, it is returned as a <see cref="MappingSetEntity"/>.
        /// Else null is returned.
        /// </summary>
        /// <param name="connectionStringSettings">
        /// The connection string parameters used to connect to the Mapping Store Database
        /// </param>
        /// <param name="maintainableRef">
        /// The reference of the DataFlow
        /// </param>
        /// <param name="allowedDataflows">
        /// The collection of dataflow that can be returned. It can be null in which case all dataflows are returned, If is empty or the requested dataflow is not in the allowed collection then null is returned.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// connectionStringSettings or dataflowId is null
        /// </exception>
        /// <returns>
        /// The populated <see cref="MappingSetEntity"/> or null if the dataflow is not found or it is not in the allowed list
        /// </returns>
        public static MappingSetEntity GetMappingSet(
            ConnectionStringSettings connectionStringSettings, 
            IMaintainableRefObject maintainableRef,
            IList<IMaintainableRefObject> allowedDataflows)
        {
            if (connectionStringSettings == null)
            {
                throw new ArgumentNullException("connectionStringSettings");
            }

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

            if (!maintainableRef.HasMaintainableId())
            {
                throw new ArgumentException(ErrorMessages.DataflowIdIsNull, "maintainableRef");
            }

            if (!SecurityHelper.Contains(allowedDataflows, maintainableRef))
            {
                return null;
            }

            MappingSetEntity ret = null;
            long datasetId = 0;

            var mappingStoreDb = new Database(connectionStringSettings);

            using (DbCommand command = BuildSqlCommand(maintainableRef, mappingStoreDb, allowedDataflows))
            {
                // populate MappingSet
                using (IDataReader dataReader = mappingStoreDb.ExecuteReader(command))
                {
                    // we expect only 1 record here
                    if (dataReader.Read())
                    {
                        ret = new MappingSetEntity(DataReaderHelper.GetInt64(dataReader, "MAP_SET_ID"));

                        ret.Id = DataReaderHelper.GetString(dataReader, "ID");
                        ret.Description = DataReaderHelper.GetString(dataReader, "DESCRIPTION");
                        ret.Dataflow = new DataflowEntity(DataReaderHelper.GetInt64(dataReader, "DF_ID"));
                        ret.Dataflow.Id = DataReaderHelper.GetString(dataReader, "DFID");

                        ret.Dataflow.Version = DataReaderHelper.GetString(dataReader, "DFVER");
                        ret.Dataflow.Agency = DataReaderHelper.GetString(dataReader, "DFAG");
                        ret.Dataflow.MappingSet = ret;
                        datasetId = DataReaderHelper.GetInt64(dataReader, "DS_ID");
                    }
                }
            }

            if (ret == null)
            {
                // throw new Exception(String.Format(CultureInfo.InvariantCulture,"There was no mapping for dataflow:{0}", dataflowId));
                // MAt-395
                return null;
            }

            // populate the dataset field
            ret.DataSet = GetDatasetById(mappingStoreDb, datasetId);

            // populate the dataflow field
            // ret.Dataflow = GetDataFlowByMappingSetSysId(connectionStringSettings, ret.SysId);
            ret.Dataflow.Dsd = GetDsdByDataFlowSysId(mappingStoreDb, ret.Dataflow.SysId);

            // populate the mapping field
            GetMappingsByMappingSetSysId(mappingStoreDb, ret);

            return ret;
        }
开发者ID:SDMXISTATFRAMEWORK,项目名称:ISTAT_ENHANCED_SDMXRI_WS,代码行数:92,代码来源:MappingSetRetriever.cs

示例4: Contains

        /// <summary>
        /// Checks if there is a .
        /// </summary>
        /// <param name="allowedDataflows">
        /// The allowed dataflows.
        /// </param>
        /// <param name="requestedObject">
        /// The requested object.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public static bool Contains(ICollection<IMaintainableRefObject> allowedDataflows, IMaintainableRefObject requestedObject)
        {
            if (allowedDataflows == null)
            {
                return true;
            }

            foreach (IMaintainableRefObject allowedDataflow in allowedDataflows)
            {
                if ((!requestedObject.HasMaintainableId() || string.Equals(allowedDataflow.MaintainableId, requestedObject.MaintainableId))
                    && ((!allowedDataflow.HasVersion() || !requestedObject.HasVersion() || string.Equals(requestedObject.Version, allowedDataflow.Version))
                        && (!allowedDataflow.HasAgencyId() || !requestedObject.HasAgencyId() || string.Equals(requestedObject.AgencyId, allowedDataflow.AgencyId))))
                {
                    return true;
                }
            }

            return false;
        }
开发者ID:alcardac,项目名称:SDMXRI_ENH_WS,代码行数:31,代码来源:SecurityHelper.cs


注:本文中的IMaintainableRefObject.HasMaintainableId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。