Пример #1
0
        public QueryReaderField AddField(string attrName, string caption = "")
        {
            var field = new QueryReaderField(attrName, caption);

            _fields.Add(field);
            return(field);
        }
Пример #2
0
        public QueryReaderField AddField(Guid attrId, string caption = "")
        {
            var field = new QueryReaderField(attrId, caption);

            _fields.Add(field);
            return(field);
        }
Пример #3
0
        private void PrepareField(QueryReaderField field)
        {
            if (field.AttrDef != null)
            {
                if (field.AttrDef.Type.Id == (short)CissaDataType.Enum && field.AttrDef.EnumDefType != null)
                {
                    if (_enumRepo == null)
                    {
                        _enumRepo = Provider.Get <IEnumRepository>();
                    }

                    if (!_enumValues.ContainsKey(field.AttrDef.Id))
                    {
                        _enumValues.Add(field.AttrDef.Id,
                                        _enumRepo.GetEnumItems(field.AttrDef.EnumDefType.Id));
                    }
                }
                else if (field.AttrDef.Type.Id == (short)CissaDataType.Doc)
                {
                    if (_comboBoxEnumProvider == null)
                    {
                        _comboBoxEnumProvider = Provider.Get <IComboBoxEnumProvider>();
                    }

                    if (!_enumValues.ContainsKey(field.AttrDef.Id))
                    {
                        _enumValues.Add(field.AttrDef.Id,
                                        _comboBoxEnumProvider.GetEnumDocumentValues(field.AttrDef, "Name"));
                    }
                }
                else if (field.AttrDef.Type.Id == (short)CissaDataType.Organization)
                {
                    if (_comboBoxEnumProvider == null)
                    {
                        _comboBoxEnumProvider = Provider.Get <IComboBoxEnumProvider>();
                    }

                    if (!_enumValues.ContainsKey(field.AttrDef.Id))
                    {
                        _enumValues.Add(field.AttrDef.Id,
                                        _comboBoxEnumProvider.GetEnumOrganizationValues(field.AttrDef.OrgTypeId));
                    }
                }
                else if (field.AttrDef.Type.Id == (short)CissaDataType.User)
                {
                    if (_comboBoxEnumProvider == null)
                    {
                        _comboBoxEnumProvider = Provider.Get <IComboBoxEnumProvider>();
                    }

                    if (!_enumValues.ContainsKey(field.AttrDef.Id))
                    {
                        _enumValues.Add(field.AttrDef.Id,
                                        _comboBoxEnumProvider.GetEnumUserValues());
                    }
                }
            }
        }
Пример #4
0
 private void PrepareFields(SqlQueryReader reader)
 {
     if (_fields.Count == 0)
     {
         foreach (var readerField in reader.Fields)
         {
             var field = new QueryReaderField(readerField.AttributeName)
             {
                 AttributeId = readerField.AttributeId,
                 DataType    = readerField.DataType,
                 FieldIndex  = readerField.Index,
                 AttrDef     = readerField.AttrDef
             };
             _fields.Add(field);
             PrepareField(field);
         }
     }
     else
     {
         foreach (var field in _fields)
         {
             if (field.AttributeId != Guid.Empty)
             {
                 var readerField = reader.FindField(field.AttributeId);
                 if (readerField != null)
                 {
                     field.DataType      = readerField.DataType;
                     field.AttributeName = readerField.AttributeName;
                     field.FieldIndex    = readerField.Index;
                     field.AttrDef       = readerField.AttrDef;
                 }
                 else
                 {
                     field.DataType = BaseDataType.Unknown;
                 }
             }
             else
             {
                 var readerField = reader.FindField(field.AttributeName);
                 if (readerField != null)
                 {
                     field.DataType    = readerField.DataType;
                     field.AttributeId = readerField.AttributeId;
                     field.FieldIndex  = readerField.Index;
                     field.AttrDef     = readerField.AttrDef;
                 }
                 else
                 {
                     field.DataType = BaseDataType.Unknown;
                 }
             }
             PrepareField(field);
         }
     }
 }