public SqlSynchronizationTransaction(PpsApplication application, IPpsSqlConnectionHandle connection, long lastSyncronizationStamp, bool leaveConnectionOpen) : base(application, connection, leaveConnectionOpen) { Connection.EnsureConnectionAsync(true).AwaitTask(); // create transaction transaction = SqlConnection.BeginTransaction(IsolationLevel.ReadCommitted); // get the current sync id using (var cmd = SqlConnection.CreateCommand()) { cmd.CommandTimeout = 6000; cmd.Transaction = transaction; cmd.CommandText = "SELECT change_tracking_current_version(), create_date FROM sys.databases WHERE database_id = DB_ID()"; using (var r = cmd.ExecuteReaderEx(CommandBehavior.SingleRow)) { if (!r.Read()) { throw new InvalidOperationException(); } if (r.IsDBNull(0)) { throw new ArgumentException("Change tracking is not active in this database."); } startCurrentSyncId = r.GetInt64(0); // get highest SyncId isForceFull = r.GetDateTime(1).ToFileTimeUtc() > lastSyncronizationStamp; // recreate database } } } // ctor
/// <summary></summary> /// <param name="dataSource"></param> /// <param name="name"></param> /// <param name="config"></param> /// <param name="configurationStamp"></param> public PpsDataSetServerDefinition(PpsDataSource dataSource, string name, XElement config, DateTime configurationStamp) { this.dataSource = dataSource; this.application = dataSource.GetService <PpsApplication>(true); this.lua = dataSource.GetService <IDELuaEngine>(true).Lua; this.name = name; this.configurationStamp = configurationStamp; // get inherited list this.inheritedFrom = config.GetStrings("inherited", true); // get script list this.serverScripts = config.GetStrings("serverScripts", true); this.clientScripts = config.GetPaths("clientScripts", true); // parse data table schema foreach (var cur in config.Elements()) { if (cur.Name == xnTable) { var tableName = cur.GetAttribute("name", String.Empty); if (String.IsNullOrEmpty(tableName)) { throw new DEConfigurationException(cur, "table needs a name."); } // create a table var table = FindTable(tableName); if (table != null) { throw new DEConfigurationException(cur, $"table is not unique ('{tableName}')"); } Add(CreateTableDefinition(tableName, cur)); } else if (cur.Name == xnMeta) { metaInfo.Add(cur); } else if (cur.Name == xnAutoTag) { Add(new PpsDataSetAutoTagDefinition(this, cur.GetAttribute("name", String.Empty), cur.GetAttribute("tableName", String.Empty), cur.GetAttribute("columnName", String.Empty), cur.GetAttribute <PpsDataSetAutoTagMode>("mode", PpsDataSetAutoTagMode.First)) ); } } // foreach c } // ctor
/// <summary></summary> /// <param name="sp"></param> /// <param name="name"></param> public DataWareHouseClientItem(IServiceProvider sp, string name) : base(sp, name) { application = sp.GetService <PpsApplication>(true); } // ctor