Beispiel #1
0
            /// <summary>
            /// Resolves operating unit number.
            /// </summary>
            /// <param name="request">The request.</param>
            /// <returns>The channel Id corresponding to the Operating Unit Number.</returns>
            private SingleEntityDataServiceResponse <long> ResolveOperatingUnitNumber(ResolveOperatingUnitNumberDataRequest request)
            {
                ThrowIf.Null(request, "request");
                ThrowIf.Null(request.QueryResultSettings, "request.QueryResultSettings");

                ChannelL2CacheDataStoreAccessor level2CacheDataAccessor = this.GetChannelL2CacheDataStoreAccessor(request.RequestContext);
                bool foundInCache;
                bool updateCache;

                const long InvalidChannelId = 0;
                long       channelId        = DataManager.GetDataFromCache(() => level2CacheDataAccessor.GetChannelIdByOperatingUnitNumber(request.OperatingUnitNumber), InvalidChannelId, out foundInCache, out updateCache);

                if (!foundInCache)
                {
                    var query = new SqlPagedQuery(request.QueryResultSettings)
                    {
                        Select = new ColumnSet(ChannelIdColumnName),
                        From   = StorageLookupView,
                        Where  = "ISPUBLISHED = 1 AND OPERATINGUNITNUMBER = @oun",
                    };

                    query.Parameters["@oun"] = request.OperatingUnitNumber;

                    using (SqlServerDatabaseContext sqlServerDatabaseContext = new SqlServerDatabaseContext(request))
                    {
                        channelId = sqlServerDatabaseContext.ExecuteScalar <long>(query);
                    }
                }

                if (updateCache)
                {
                    level2CacheDataAccessor.PutChannelIdByOperatingUnitNumber(request.OperatingUnitNumber, channelId);
                }

                return(new SingleEntityDataServiceResponse <long>(channelId));
            }