Beispiel #1
0
        void SynchronizeTypes(string connectionString, IEnumerable <XPObjectType> xpObjectTypes)
        {
            var sqlDataStoreProxy = new DataStoreProxy(connectionString);

            using (var simpleDataLayer = new SimpleDataLayer(sqlDataStoreProxy)) {
                using (var session = new Session(simpleDataLayer)) {
                    var   xpoObjectHacker = new XpoObjectHacker();
                    bool  sync            = false;
                    int[] oid             = { 0 };
                    sqlDataStoreProxy.DataStoreUpdateSchema += EnsureIsNotIdentity(xpoObjectHacker);
                    sqlDataStoreProxy.DataStoreModifyData   += (sender, args) => {
                        var insertStatement = args.ModificationStatements.OfType <InsertStatement>().SingleOrDefault(statement => statement.TableName == typeof(XPObjectType).Name);
                        if (insertStatement != null && !sync)
                        {
                            sync = true;
                            xpoObjectHacker.CreateObjectTypeIndetifier(insertStatement, simpleDataLayer, oid[0]);
                            var modificationResult = sqlDataStoreProxy.ModifyData(insertStatement);
                            sync = false;
                            args.ModificationResult            = modificationResult;
                            args.ModificationResult.Identities = new[] { new ParameterValue {
                                                                             Value = oid[0]
                                                                         } };
                        }
                    };
                    foreach (var xpObjectType in xpObjectTypes)
                    {
                        oid[0] = xpObjectType.Oid;
                        SynchronizeTypesCore(xpObjectType, session);
                    }
                }
            }
        }
Beispiel #2
0
 protected override void OnActivated()
 {
     base.OnActivated();
     _dataStoreProxy        = ((IXpandObjectSpaceProvider)Application.ObjectSpaceProvider).DataStoreProvider.Proxy;
     _saveAction            = Frame.GetController <ModificationsController>().SaveAction;
     _saveAction.Executing += SaveActionOnExecuting;
     _saveAction.Executed  += SaveActionOnExecuted;
 }
Beispiel #3
0
        public DataStoreProvider(IDataStore dataStore)
        {
            _storeProxy = new DataStoreProxy(dataStore);
            var connectionProviderSql = dataStore as ConnectionProviderSql;

            if (connectionProviderSql != null)
            {
                _connectionString = connectionProviderSql.ConnectionString;
            }
        }
Beispiel #4
0
 void SubscribeToDataStoreProxyEvents()
 {
     if (Application != null && Application.ObjectSpaceProvider != null)
     {
         var objectSpaceProvider = (Application.ObjectSpaceProvider);
         if (!(objectSpaceProvider is IXpandObjectSpaceProvider))
         {
             throw new NotImplementedException("ObjectSpaceProvider does not implement " + typeof(IXpandObjectSpaceProvider).FullName);
         }
         DataStoreProxy proxy = ((IXpandObjectSpaceProvider)objectSpaceProvider).DataStoreProvider.Proxy;
         proxy.DataStoreModifyData += (o, args) => ModifyData(args.ModificationStatements);
         proxy.DataStoreSelectData += Proxy_DataStoreSelectData;
         ProxyEventsSubscribed      = true;
     }
 }
Beispiel #5
0
 public DataStoreProvider(string connectionString)
 {
     _connectionString = connectionString;
     _storeProxy       = new DataStoreProxy(connectionString);
 }
Beispiel #6
0
 public DataStoreProvider(string connectionString)
 {
     connectionStringCore = connectionString;
     proxyCore            = new DataStoreProxy(connectionString);
 }
Beispiel #7
0
 public DataStoreProvider(IDataStore dataStore)
 {
     proxyCore = new DataStoreProxy(dataStore);
 }