public void QueryForDeviceDetailTest()
        {
            _esSession.Open();
            QueryListResult <HWDeviceDetail> hwDetails = _esSession.DviWorker.QueryForDeviceDetail("test");

            Assert.IsNotNull(hwDetails);
        }
예제 #2
0
        public void QueryForDeviceDetailTest()
        {
            _esSession.Open();
            QueryListResult <HWDeviceDetail> hwDeviceDetails = _esSession.DviWorker.QueryForDeviceDetail("NE=34603409");

            LogUtil.HWLogger.DEFAULT.Info(JsonUtil.SerializeObject(hwDeviceDetails));
            Assert.IsNotNull(hwDeviceDetails);
        }
예제 #3
0
        /// <summary>
        /// 查询服务器详情
        /// </summary>
        /// <param name="dn">设备DN</param>
        /// <returns>详细信息</returns>
        public QueryListResult <HWDeviceDetail> QueryForDeviceDetail(string dn)
        {
            StringBuilder sb = new StringBuilder(ConstMgr.HWESightHost.URL_DEVICEDETAIL);

            sb.Append("?dn=").Append(HttpUtility.UrlEncode(dn, Encoding.UTF8));
            JObject jResult = ESSession.HCGet(sb.ToString(), false);

            CheckAndThrowException(jResult);
            QueryListResult <HWDeviceDetail> queryListResult = jResult.ToObject <QueryListResult <HWDeviceDetail> >();

            //HWDeviceDetail hwDeviceDetail = queryListResult.Data[0];
            return(queryListResult);
        }
        /// <summary>
        /// Maps all rows found in the first resultset of <paramref name="reader"/> to a collectiobn of objects of type <typeparamref name="T"/> using the provided <paramref name="map"/>.
        /// If <paramref name="reader"/> contains a second resultset, it is expected to contain a scalar value that will be used to set <see cref="PagingData.NumberOfRows"/>.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        public static async Task <QueryListResult <T> > MapToMultipleResultsAsync <T>(SqlDataReader reader, DataMap <T> map, CancellationToken cancellationToken) where T : new()
        {
            var result = new QueryListResult <T>();

            //read all rows from the first resultset
            while (await reader.ReadAsync(cancellationToken).ConfigureAwait(false))
            {
                T instance = new T();
                SetResultValuesToObject(reader, map, instance);
                result.Add(instance);
            }

            return(result);
        }
예제 #5
0
        /// <summary>
        /// Converts the first column of all rows found in <paramref name="reader"/> to an object of type <typeparamref name="TResult"/>
        /// </summary>
        /// <param name="reader"></param>
        public static QueryListResult <TResult> MapToMultipleResultsScalar <TResult>(SqlDataReader reader)
        {
            var result = new QueryListResult <TResult>();

            while (reader.Read())
            {
                //read the first column of the first row
                var value = reader.GetValue(0);
                //does it have the correct type?
                if (value is TResult)
                {
                    result.Add((TResult)value);
                }
                else
                {
                    result.Add(default(TResult));
                }
            }

            return(result);
        }
        /// <summary>
        /// Converts the first column of all rows found in <paramref name="reader"/> to an object of type <typeparamref name="TResult"/>
        /// </summary>
        public static async Task <QueryListResult <TResult> > MapToMultipleResultsScalarAsync <TResult>(SqlDataReader reader, CancellationToken cancellationToken)
        {
            var result = new QueryListResult <TResult>();

            while (await reader.ReadAsync(cancellationToken).ConfigureAwait(false))
            {
                //read the first column of the first row
                var value = reader.GetValue(0);
                //does it have the correct type?
                if (value is TResult)
                {
                    result.Add((TResult)value);
                }
                else
                {
                    result.Add(default(TResult));
                }
            }

            return(result);
        }
 /// <summary>
 /// Creates a new instance of <see cref="SqlStatementResult{TResult}"/> with type <see cref="SqlStatementResultCardinality.MultipleRows"/>.
 /// </summary>
 public SqlStatementResult(QueryListResult <TResult> results, int?totalNumberOfRows) : this(results)
 {
     TotalNumberOfRows = totalNumberOfRows;
 }
        /// <summary>
        /// Creates a new instance of <see cref="SqlStatementResult{TResult}"/> with type <see cref="SqlStatementResultCardinality.MultipleRows"/>.
        /// </summary>
        /// <param name="results"></param>
        public SqlStatementResult(QueryListResult <TResult> results)
        {
            ResultCardinality = SqlStatementResultCardinality.MultipleRows;

            MultipleResults = results;
        }