Ejemplo n.º 1
0
        public override void Update()
        {
            if (Session.FindObject <PersistentAssemblyInfo>(info => info.Name == DynamicAssemblyCalculatedField.AttributeRegistrator.MasterDetailDynamicAssembly) == null)
            {
                IPersistentAssemblyInfo persistentAssemblyInfo = new DynamicAssemblyBuilder(Session).Build(DynamicAssemblyCalculatedField.AttributeRegistrator.DMDCustomer, DMDOrder,
                                                                                                           DMDOrderLine, DynamicAssemblyCalculatedField.AttributeRegistrator.MasterDetailDynamicAssembly);
                IPersistentClassInfo persistentClassInfo =
                    persistentAssemblyInfo.PersistentClassInfos.Single(info => info.Name == DynamicAssemblyCalculatedField.AttributeRegistrator.DMDCustomer);
                var persistentCoreTypeMemberInfo = new PersistentCoreTypeMemberInfo(persistentClassInfo.Session);
                persistentCoreTypeMemberInfo.TypeAttributes.Add(new PersistentVisibleInDetailViewAttribute(persistentCoreTypeMemberInfo.Session));
                persistentCoreTypeMemberInfo.TypeAttributes.Add(new PersistentVisibleInListViewAttribute(persistentCoreTypeMemberInfo.Session));
                persistentCoreTypeMemberInfo.TypeAttributes.Add(new PersistentVisibleInLookupListViewAttribute(persistentCoreTypeMemberInfo.Session));
                persistentCoreTypeMemberInfo.TypeAttributes.Add(new PersistentPersistentAliasAttribute(persistentCoreTypeMemberInfo.Session)
                {
                    AliasExpression = "DMDOrders.Min(OrderDate)"
                });
                persistentCoreTypeMemberInfo.Name     = "FirstOrderDate";
                persistentCoreTypeMemberInfo.DataType = DBColumnType.DateTime;
                var codeTemplateInfo = new CodeTemplateInfo(persistentCoreTypeMemberInfo.Session);
                var codeTemplate     = new CodeTemplate(codeTemplateInfo.Session)
                {
                    TemplateType = TemplateType.XPCalculatedPropertyMember
                };
                codeTemplate.SetDefaults();
                codeTemplate.Name             = "CalculatedProperty";
                codeTemplateInfo.TemplateInfo = codeTemplate;

                persistentCoreTypeMemberInfo.CodeTemplateInfo = codeTemplateInfo;
                persistentClassInfo.OwnMembers.Add(persistentCoreTypeMemberInfo);
                XPObjectSpace.FindObjectSpaceByObject(persistentClassInfo).CommitChanges();
            }
        }
Ejemplo n.º 2
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            if (ObjectSpace.QueryObject <PersistentAssemblyInfo>(info => info.Name == DynamicAssemblyCalculatedField.AttributeRegistrator.MasterDetailDynamicAssembly) == null)
            {
                var customer = DynamicAssemblyCalculatedField.AttributeRegistrator.DMDCustomer;
                var persistentAssemblyInfo = new DynamicAssemblyBuilder(ObjectSpace).Build(customer, DMDOrder,
                                                                                           DMDOrderLine, DynamicAssemblyCalculatedField.AttributeRegistrator.MasterDetailDynamicAssembly);

                var persistentClassInfo          = persistentAssemblyInfo.PersistentClassInfos.First(info => info.Name == customer);
                var persistentCoreTypeMemberInfo = persistentClassInfo.CreateSimpleMember(DBColumnType.DateTime, "FirstOrderDate");
                AddAttributes(persistentCoreTypeMemberInfo);
                persistentCoreTypeMemberInfo.CodeTemplateInfo = CreateCalculatedCodeTemplateInfo(persistentCoreTypeMemberInfo);
            }
        }
Ejemplo n.º 3
0
        public override void Update() {
            if (Session.FindObject<PersistentAssemblyInfo>(info => info.Name == Module.WorldCreator.DynamicAssemblyCalculatedField.AttributeRegistrator.MasterDetailDynamicAssembly) == null) {
                IPersistentAssemblyInfo persistentAssemblyInfo =new DynamicAssemblyBuilder(Session).Build(Module.WorldCreator.DynamicAssemblyCalculatedField.AttributeRegistrator.DMDCustomer, DMDOrder,
                        DMDOrderLine,Module.WorldCreator.DynamicAssemblyCalculatedField.AttributeRegistrator.MasterDetailDynamicAssembly);
                IPersistentClassInfo persistentClassInfo =
                    persistentAssemblyInfo.PersistentClassInfos.Where(info =>info.Name == Module.WorldCreator.DynamicAssemblyCalculatedField.AttributeRegistrator.DMDCustomer).Single();
                var persistentCoreTypeMemberInfo = new PersistentCoreTypeMemberInfo(persistentClassInfo.Session);
                persistentCoreTypeMemberInfo.TypeAttributes.Add(new PersistentVisibleInDetailViewAttribute(persistentCoreTypeMemberInfo.Session));
                persistentCoreTypeMemberInfo.TypeAttributes.Add(new PersistentVisibleInListViewAttribute(persistentCoreTypeMemberInfo.Session));
                persistentCoreTypeMemberInfo.TypeAttributes.Add(new PersistentVisibleInLookupListViewAttribute(persistentCoreTypeMemberInfo.Session));
                persistentCoreTypeMemberInfo.TypeAttributes.Add(new PersistentPersistentAliasAttribute(persistentCoreTypeMemberInfo.Session) { AliasExpression = "DMDOrders.Min(OrderDate)" });
                persistentCoreTypeMemberInfo.Name = "FirstOrderDate";
                persistentCoreTypeMemberInfo.DataType = DBColumnType.DateTime;
                var codeTemplateInfo = new CodeTemplateInfo(persistentCoreTypeMemberInfo.Session);
                var codeTemplate = new CodeTemplate(codeTemplateInfo.Session) { TemplateType = TemplateType.XPCalculatedPropertyMember };
                codeTemplate.SetDefaults();
                codeTemplate.Name = "CalculatedProperty";
                codeTemplateInfo.TemplateInfo = codeTemplate;

                persistentCoreTypeMemberInfo.CodeTemplateInfo = codeTemplateInfo;
                persistentClassInfo.OwnMembers.Add(persistentCoreTypeMemberInfo);
                ObjectSpace.FindObjectSpaceByObject(persistentClassInfo).CommitChanges();
            }
        }