Пример #1
0
        internal Guid DefaultViewId(Guid assetTypeId, EAssetRequestType requestType)
        {
            string sql = string.Empty;

            switch (requestType)
            {
            case EAssetRequestType.Both:
                throw new LogicalException("Cannot request a default view id for definitions and instances.");

            case EAssetRequestType.Definition:
                sql = "SELECT [ViewId] FROM [AssetTypesViews] WITH (NoLock) WHERE ([AssetTypeId] = @Id) AND ([IsInstance] = 0)";
                break;

            case EAssetRequestType.Instance:
                sql = "SELECT [ViewId] FROM [AssetTypesViews] WITH (NoLock) WHERE ([AssetTypeId] = @Id) AND ([IsInstance] = 1)";
                break;
            }

            return(base.ExecuteScalarGuidInLine(sql, new List <SqlParameter>()
            {
                new SqlParameter("@Id", assetTypeId)
            }));
        }
Пример #2
0
        /// <summary>
        /// Gets a list of Views that are compatible with the specified asset type
        /// </summary>
        /// <param name="assetTypeId">id of the asset type the view should be compatible with</param>
        /// <param name="assetRequestType">asset instances or definitions?</param>
        /// <param name="includeNonStandAlone">whether or not to include only stand-alone views</param>
        /// <returns>a dictionary of Guid, string where the Guid is the id of the view and the string is the displayValue or name of the view</returns>
        internal Dictionary <Guid, string> GetDictionaryByAssetTypeId(Guid assetTypeId, EAssetRequestType assetRequestType, bool includeNonStandAlone)
        {
            StringBuilder sql = new StringBuilder();

            sql.AppendLine("SELECT [Id], [DisplayValue] FROM [Views] WITH (NoLock)");
            sql.AppendLine("WHERE [AssetTypeId] = @AssetTypeId");
            sql.AppendLine("AND [Deleted] IS NULL");

            switch (assetRequestType)
            {
            case EAssetRequestType.Both:
                break;

            case EAssetRequestType.Definition:
                sql.AppendLine("AND [IsInstance] = 0");
                break;

            case EAssetRequestType.Instance:
                sql.AppendLine("AND [IsInstance] = 1");
                break;
            }

            if (!includeNonStandAlone)
            {
                sql.AppendLine("AND [IsStandAlone] = 1");
            }

            sql.AppendLine("ORDER BY [DisplayValue]");

            List <SqlParameter> paramList = new List <SqlParameter> {
                new SqlParameter("@AssetTypeId", assetTypeId)
            };

            Dictionary <Guid, string> values = new Dictionary <Guid, string>();

            using (SqlDataReader rdr = base.OpenDataReaderInLine(sql.ToString(), paramList))
            {
                if ((rdr != null) && (rdr.HasRows))
                {
                    while (rdr.Read())
                    {
                        values.Add(rdr.GetGuid(0), rdr.GetString(1));
                    }
                }
            }

            return(values);
        }