private void PrepareFields() { _fields.Clear(); var i = 0; foreach (var attr in Query.Attributes) { _fields.Add( new SqlQueryField { Index = i, SelectAttribute = attr, AttrDef = attr.Def, AttributeId = attr.Def != null ? attr.Def.Id : Guid.Empty, AttributeName = attr.Def != null ? attr.Def.Name : SystemIdentConverter.Convert(attr.Ident), IsIdent = attr.IsSystemIdent, Ident = attr.IsSystemIdent ? attr.Ident : SystemIdent.Id, IsExp = attr.IsMultiExpression, DocDef = attr.Attributes[0].Source != null ? attr.Attributes[0].Source.GetDocDef() : null, DocDefId = attr.Attributes[0].Source != null ? attr.Attributes[0].Source.GetDocDef().Id : Guid.Empty, DataType = attr.IsSystemIdent ? SystemIdentConverter.ToBaseType(attr.Ident) : attr.Def != null ? CissaDataTypeHelper.ConvertToBase(attr.Def.Type.Id) : BaseDataType.Unknown }); i++; } }
protected override SqlQuerySourceAttribute AddAttribute(string attrDefName) { string alias; SqlQuerySourceAttribute attribute; if (attrDefName.Length > 0 && attrDefName[0] == '&') { var ident = SystemIdentConverter.Convert(attrDefName); alias = GetAttributeAlias(attrDefName); attribute = new SqlQueryDocSourceAttribute(ident, alias); } else { var attrDef = FindAttributeDef(attrDefName); if (attrDef == null) { throw new ApplicationException(String.Format("Атрибут \"{0}\" не найден!", attrDefName)); } alias = GetAttributeAlias(attrDefName); attribute = new SqlQueryDocSourceAttribute(attrDef, alias); } AttributeAliases.Add(alias.ToUpper()); Attributes.Add(attribute); return(attribute); }
public override BaseDataType GetDataType() { if (Grouping == SqlQuerySummaryFunction.Count) { return(BaseDataType.Int); } return(AttrDef != null ? CissaDataTypeHelper.ConvertToBase(AttrDef.Type.Id) : SystemIdentConverter.ToBaseType(Ident)); }
protected override SqlQuerySourceAttribute AddAttribute(SystemIdent attrIdent) { var alias = GetAttributeAlias(SystemIdentConverter.Convert(attrIdent)); SqlQuerySourceAttribute attribute = new SqlQueryDocSourceAttribute(attrIdent, alias); AttributeAliases.Add(alias.ToUpper()); Attributes.Add(attribute); return(attribute); }
public virtual bool SameAttrName(string name) { if (name.Length <= 0 || name[0] != '&') { return(Def != null && String.Equals(Def.Name, name, StringComparison.OrdinalIgnoreCase)); } var ident = SystemIdentConverter.Convert(name); return(Def == null && Ident == ident); }
public bool HasAttributeDef(string attrDefName) { if (attrDefName.Length > 0 && attrDefName[0] == '&') { SystemIdent ident; if (SystemIdentConverter.TryConvert(attrDefName, out ident)) { return(true); } } return(FindAttributeDef(attrDefName) != null); }
private void InitComboBox(BizComboBox control, Combo_Box controlData, DocDef def) { AttrDef attrDef = null; if (def != null) { if (controlData.Attribute_Id != null) { attrDef = def.Attributes.FirstOrDefault(a => a.Id == controlData.Attribute_Id); } if (attrDef == null && controlData.Attribute_Name != null) { attrDef = def.Attributes.FirstOrDefault(a => String.Equals(a.Name, controlData.Attribute_Name, StringComparison.OrdinalIgnoreCase)); } } control.Rows = controlData.Rows ?? 0; control.IsRadio = controlData.Is_Radio ?? false; if (attrDef != null) { control.AttributeDefId = attrDef.Id; control.AttributeName = attrDef.Name; } else { var attrName = controlData.Attribute_Name ?? String.Empty; SystemIdent attrIdent; if (SystemIdentConverter.TryConvert(attrName, out attrIdent)) { control.Ident = attrIdent; control.AttributeName = attrName; //InitComboBox(control, attrIdent); } } control.DetailAttributeId = controlData.Detail_Attribute_Id; control.DetailAttributeName = controlData.Detail_Attribute_Name; /*if (attrDef != null) * { * //if (!controlData.Attribute_DefsReference.IsLoaded) controlData.Attribute_DefsReference.Load(); * * InitComboBox(control, attrDef /*controlData.Attribute_Defs#1#); * } */ InitControl(control, controlData); // AddQueryItems(control, controlData); // Вызывает ошибку дублирования QueryItems }
public int TryGetAttributeIndex(SqlQuerySource source, string attrDefName) { SqlQuerySelectAttribute attr; if (attrDefName.Length > 0 && attrDefName[0] == '&') { var ident = SystemIdentConverter.Convert(attrDefName); attr = Query.Attributes.FirstOrDefault(a => a.Source == source && a.IsSystemIdent && a.Attribute.Ident == ident); } else { attr = Query.Attributes.FirstOrDefault( a => a.Source == source && String.Equals(a.Def.Name, attrDefName, StringComparison.OrdinalIgnoreCase)); } if (attr == null) { return(-1); } return(Query.Attributes.IndexOf(attr)); }
public BizDataControl CreateEditor(Editor editor, DocDef def) { BizDataControl result = null; AttrDef attrDef = null; if (def != null) { if (editor.Attribute_Id != null) { attrDef = def.Attributes.FirstOrDefault(a => a.Id == editor.Attribute_Id); } if (attrDef == null && !String.IsNullOrEmpty(editor.Attribute_Name) && editor.Attribute_Name[0] != '&') { attrDef = def.Attributes.FirstOrDefault( a => String.Equals(a.Name, editor.Attribute_Name, StringComparison.OrdinalIgnoreCase)); } } if (attrDef != null) { result = CreateTypeEditor(editor, attrDef); } /*else * { * if (!editor.Attribute_DefsReference.IsLoaded) editor.Attribute_DefsReference.Load(); * if (editor.Attribute_Defs == null) return null; * * result = CreateTypeEditor(editor.Attribute_Defs); * }*/ else { var attrName = editor.Attribute_Name ?? String.Empty; SystemIdent attrIdent; if (SystemIdentConverter.TryConvert(attrName, out attrIdent)) { switch (attrIdent) { case SystemIdent.OrgId: case SystemIdent.OrgName: case SystemIdent.OrgCode: case SystemIdent.State: // case SystemIdent.InState: result = new BizEditText { Ident = attrIdent, ReadOnly = true, AttributeName = attrName }; break; case SystemIdent.Id: case SystemIdent.UserId: case SystemIdent.UserName: result = new BizEditText { Ident = attrIdent, ReadOnly = true, AttributeName = attrName }; break; case SystemIdent.Created: case SystemIdent.Modified: case SystemIdent.StateDate: result = new BizEditDateTime { Ident = attrIdent, ReadOnly = true, AttributeName = attrName }; break; } } } AddChildren(result, editor, def); if (result is BizEdit) { InitEditor((BizEdit)result, editor); } if (result is BizComboBox) { InitComboBox(result as BizComboBox, editor, attrDef); } return(result); }