public override void Setup(ApplicationModulesManager moduleManager) {
            base.Setup(moduleManager);
            var businessClassesList = GetAdditionalClasses(moduleManager);
            WCTypesInfo.Instance.Register(businessClassesList);
            if (Application == null || GetPath() == null)
                return;
            Application.SettingUp += ApplicationOnSettingUp;
            if (FullConnectionString != null) {
                var xpoMultiDataStoreProxy = new SqlMultiDataStoreProxy(FullConnectionString, GetReflectionDictionary());
                using (var dataLayer = new SimpleDataLayer(xpoMultiDataStoreProxy)) {
                    using (var session = new Session(dataLayer)) {
                        using (var unitOfWork = new UnitOfWork(session.DataLayer)) {
                            RunUpdaters(session);
                            AddDynamicModules(moduleManager, unitOfWork);
                        }
                    }
                }
            } else {
                var assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(assembly => assembly.ManifestModule.ScopeName.EndsWith(CompileEngine.XpandExtension));
                foreach (var assembly1 in assemblies) {
                    moduleManager.AddModule(assembly1.GetTypes().Where(type => typeof(ModuleBase).IsAssignableFrom(type)).Single());
                }
            }


            Application.SetupComplete += ApplicationOnSetupComplete;

        }
示例#2
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);

                    }
                }
            }
        }
 protected override IEnumerable<Type> GetDeclaredExportedTypes() {
     var existentTypesMemberCreator = new ExistentTypesMemberCreator();
     if (FullConnectionString != null) {
         var xpoMultiDataStoreProxy = new SqlMultiDataStoreProxy(FullConnectionString, GetReflectionDictionary());
         var simpleDataLayer = new SimpleDataLayer(xpoMultiDataStoreProxy);
         var session = new Session(simpleDataLayer);
         existentTypesMemberCreator.CreateMembers(session);
     }
     return base.GetDeclaredExportedTypes();
 }
示例#4
0
 public void SynchronizeTypes( string connectionString) {
     var types = new XPCollection<XPObjectType>(new Session { ConnectionString = connectionString });
     var xpObjectTypes = types.ToList().Where(objectType => ReflectionHelper.FindType(objectType.TypeName) != null);
     var sqlMultiDataStoreProxy = new SqlMultiDataStoreProxy(connectionString);
     foreach (var connstring in GetConnectionStrings(sqlMultiDataStoreProxy.DataStoreManager, xpObjectTypes,connectionString)) {
         if (connstring!=connectionString) {
             SynchronizeTypes(connstring, xpObjectTypes);
         }
     }
 }
示例#5
0
 protected override BusinessClassesList GetBusinessClassesCore() {
     var existentTypesMemberCreator = new ExistentTypesMemberCreator();
     if (ConnectionString != null) {
         var xpoMultiDataStoreProxy = new SqlMultiDataStoreProxy(ConnectionString, GetReflectionDictionary());
         var simpleDataLayer = new SimpleDataLayer(xpoMultiDataStoreProxy);
         var session = new Session(simpleDataLayer);
         existentTypesMemberCreator.CreateMembers(session);
     }
     return base.GetBusinessClassesCore();
 }