示例#1
0
        public ClassificatorDescModel GetClassificatorExpDescRecursive(CardAttributeModel cardAttribute)
        {
            LOG_TRACE($"GetClassificatorExpDesc");
            if (_client != null && cardAttribute.AttributeType == AttributeType.ClassificatorExp)
            {
                ClassificatorDesc classificatorDesc = null;
                try
                {
                    using (OperationContextScope scope = new OperationContextScope(_client.InnerChannel))
                    {
                        HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty();
                        httpRequestProperty.Headers[System.Net.HttpRequestHeader.Authorization] = "Basic " +
                                                                                                  Convert.ToBase64String(Encoding.ASCII.GetBytes(_client.ClientCredentials.UserName.UserName + ":" + _client.ClientCredentials.UserName.Password));
                        OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestProperty;
                        classificatorDesc = _client.GetClassificatorDesc((int)cardAttribute.AttributeNumber, 0);
                    }
                }
                catch (InvalidCastException)
                { }

                if (classificatorDesc != null)
                {
                    ClassificatorDescModel ret = new ClassificatorDescModel(classificatorDesc.type);

                    foreach (var item in classificatorDesc.values)
                    {
                        var addedItem = new ClassificatorDescModel.ClassificatorDescModelItem(item.name, item.oid);
                        ret.Values.Add(addedItem);
                        GetClassificatorDescModelItemRecursive((int)cardAttribute.AttributeNumber, item.oid, addedItem.Childrens);
                    }
                    return(ret);
                }
            }
            return(null);
        }
示例#2
0
        public ClassificatorDescModel GetClassificatorDesc(CardAttributeModel cardAttribute)
        {
            LOG_TRACE($"GetClassificatorDesc");
            var _logSb = new StringBuilder();

            if (_client != null && cardAttribute.AttributeType == AttributeType.Classificator)
            {
                ClassificatorDesc classificatorDesc;

                using (OperationContextScope scope = new OperationContextScope(_client.InnerChannel))
                {
                    HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty();
                    httpRequestProperty.Headers[System.Net.HttpRequestHeader.Authorization] = "Basic " +
                                                                                              Convert.ToBase64String(Encoding.ASCII.GetBytes(_client.ClientCredentials.UserName.UserName + ":" + _client.ClientCredentials.UserName.Password));
                    OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestProperty;
                    classificatorDesc = _client.GetClassificatorDesc((int)cardAttribute.AttributeNumber, 0);
                }

                _logSb.Clear();
                _logSb.Append(classificatorDesc.type).Append("/");
                if (classificatorDesc != null && classificatorDesc.values.Any())
                {
                    foreach (var item in classificatorDesc.values)
                    {
                        _logSb.Append(item.oid).Append("/").Append(item.name).Append("\t");
                    }
                }
                LOG_TRACE($"{_logSb.ToString()}");
                return(new ClassificatorDescModel(classificatorDesc));
            }
            return(null);
        }