Esempio n. 1
0
        public TypeDef(Attribute_Def data)
        {
            if (data != null)
            {
                Id = data.Type_Id ?? 0;

                if (!data.Data_TypesReference.IsLoaded)
                {
                    data.Data_TypesReference.Load();
                }
                if (data.Data_Types != null)
                {
                    Name = data.Data_Types.Name;
                }
            }
        }
Esempio n. 2
0
        private AttrDef CreateAttrDef(Attribute_Def source)
        {
            if (source == null)
            {
                return(null);
            }

            var result = new AttrDef
            {
                Id           = source.Id,
                Name         = source.Name ?? String.Empty,
                Caption      = source.Full_Name ?? String.Empty,
                IsNotNull    = source.Is_Not_Null ?? false,
                IsUnique     = source.Is_Unique ?? false,
                MaxLength    = source.Max_Length ?? 0,
                MaxValue     = source.Max_Value,
                MinValue     = source.Min_Value,
                DefaultValue = source.Default_Value ?? String.Empty,
                OrgTypeId    = source.Org_Type_Id,
                Script       = source.CalculateScript,
                BlobInfo     = new BlobInfo
                {
                    MaxHeight    = source.BlobMaxHeight ?? 0,
                    MaxWidth     = source.BlobMaxWidth ?? 0,
                    MaxSizeBytes = source.BlobMaxSizeBytes ?? 0,
                    IsImage      = source.BlobIsImage ?? false
                }
            };

            // DONE: Исключить постоянное чтение типов данных из БД
            // if (!source.Data_TypesReference.IsLoaded) source.Data_TypesReference.Load();
            // if (source.Data_Types != null)
            if (source.Type_Id != null)
            {
                var typeDefs = GetTypeDefs();
                var typeDef  = typeDefs.FirstOrDefault(d => d.Id == source.Type_Id);
                if (typeDef != null)
                {
                    result.Type = new TypeDef
                    {
                        Id   = typeDef.Id,
                        Name = typeDef.Name
                    }
                }
                ;
                else
                {
                    result.Type = new TypeDef {
                        Id = (short)source.Type_Id
                    }
                };
            }
            else
            {
                return(null);
            }

            if (source.Enum_Id != null)
            {
                // DONE: Исключить прямое чтение справочных данных из БД
                //if (!source.Enum_DefsReference.IsLoaded) source.Enum_DefsReference.Load();
                var enumDef = _enumRepo.Find((Guid)source.Enum_Id);
                if (enumDef != null)
                {
                    result.EnumDefType = new EnumDef
                    {
                        Id          = enumDef.Id,
                        Description = enumDef.Description,
                        Name        = enumDef.Name,
                        Caption     = enumDef.Caption
                    }
                }
                ;
            }
            if (source.Document_Id != null)
            {
                // DONE: Исключить прямое чтение описаний документов из БД
                //if (!source.Document_DefsReference.IsLoaded) source.Document_DefsReference.Load();
                //var attrDocDef = Find((Guid) source.Document_Id);
                //if (attrDocDef != null)
                result.DocDefType = new DocDef
                {
                    Id = (Guid)source.Document_Id      /*, //attrDocDef.Id,
                                                        * Name = attrDocDef.Name,
                                                        * Caption = attrDocDef.Caption,
                                                        * AncestorId = attrDocDef.AncestorId,
                                                        * IsInline = attrDocDef.IsInline,
                                                        * IsPublic = attrDocDef.IsPublic*/
                };
            }
            return(result);
        }