Пример #1
0
        public static CriteriaOperator GetClassTypeFilter(this Type type, Session session)
        {
            XPClassInfo  xpClassInfo  = session.GetClassInfo(type);
            XPObjectType xpObjectType = session.GetObjectType(xpClassInfo);

            return(XPObject.Fields.ObjectType.IsNull() |
                   XPObject.Fields.ObjectType == new OperandValue(xpObjectType.Oid));
        }
Пример #2
0
 void SynchronizeTypesCore(XPObjectType xpObjectType, Session session)
 {
     if (session.FindObject <XPObjectType>(objectType => objectType.TypeName == xpObjectType.TypeName) == null)
     {
         var objectType = new XPObjectType(session, xpObjectType.AssemblyName, xpObjectType.TypeName);
         session.Save(objectType);
     }
 }
Пример #3
0
        public static CriteriaOperator GetClassTypeFilter(this Type type, Session session, string path)
        {
            path = path.TrimEnd('.');
            XPClassInfo  xpClassInfo  = session.GetClassInfo(type);
            XPObjectType xpObjectType = session.GetObjectType(xpClassInfo);
            string       propertyName = path + "." + XPObject.Fields.ObjectType.PropertyName;

            return
                (new GroupOperator(GroupOperatorType.Or, new NullOperator(propertyName),
                                   new BinaryOperator(propertyName, xpObjectType)));
        }
Пример #4
0
 void SynchronizeTypesCore(XPObjectType xpObjectType, Session session) {
     if (session.FindObject<XPObjectType>(objectType => objectType.TypeName == xpObjectType.TypeName) == null) {
         var objectType = new XPObjectType(session, xpObjectType.AssemblyName, xpObjectType.TypeName);
         session.Save(objectType);
     }
 }
Пример #5
0
        void SynchronizeTypes(UnitOfWork unitOfWork) {
            var xpObjectTypes = new XPCollection<XPObjectType>(unitOfWork);
            var dataStoreManager = new SqlMultiDataStoreProxy(ConnectionString);
            foreach (var xpObjectType in xpObjectTypes) {
                var type = ReflectionHelper.FindType(xpObjectType.TypeName);
                if (type != null) {
                    var connectionString = dataStoreManager.DataStoreManager.GetConnectionString(type);
                    var sqlDataStoreProxy = new SqlDataStoreProxy(connectionString);
                    var xpoObjectHacker = new XpoObjectHacker();
                    XPObjectType type1 = xpObjectType;
                    var simpleDataLayer = new SimpleDataLayer(sqlDataStoreProxy);
                    var session = new Session(simpleDataLayer);
                    bool sync = false;
                    sqlDataStoreProxy.DataStoreModifyData += (sender, args) => {
                        var insertStatement = args.ModificationStatements.OfType<InsertStatement>().Where(statement => statement.TableName == typeof(XPObjectType).Name).SingleOrDefault();
                        if (insertStatement != null && !sync) {
                            sync = true;
                            xpoObjectHacker.CreateObjectTypeIndetifier(insertStatement, simpleDataLayer, type1.Oid);
                            ModificationResult modificationResult = sqlDataStoreProxy.ModifyData(insertStatement);
                            args.ModificationResult = modificationResult;
                            args.ModificationResult.Identities = new[] { new ParameterValue { Value = type1.Oid }, };
                        }
                    };

                    if (session.FindObject<XPObjectType>(objectType => objectType.TypeName == type1.TypeName) == null) {
                        var objectType = new XPObjectType(session, xpObjectType.AssemblyName, xpObjectType.TypeName);
                        session.Save(objectType);

                    }
                }
            }
        }