Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public static load(dir?: string): typeof IModelJsNative {
return this.isMobile ? this.imodeljsMobile.imodeljsNative : // we are running on a mobile platform
require("@bentley/imodeljs-native/loadNativePlatform.js").loadNativePlatform(dir); // We are running in node or electron.
}
}
const poll = () => {
if (!this.isOpen) {
resolve({ status: QueryResponseStatus.Done, rows: [] });
} else {
const pollrc = this.nativeDb.pollConcurrentQuery(postrc.taskId);
if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Done)
resolve({ status: QueryResponseStatus.Done, rows: JSON.parse(pollrc.result, reviver) });
else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Partial)
resolve({ status: QueryResponseStatus.Partial, rows: JSON.parse(pollrc.result, reviver) });
else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Timeout)
resolve({ status: QueryResponseStatus.Timeout, rows: [] });
else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Pending)
setTimeout(() => { poll(); }, IModelHost.configuration!.concurrentQuery.pollInterval);
else
resolve({ status: QueryResponseStatus.Error, rows: [pollrc.result] });
}
};
setTimeout(() => { poll(); }, IModelHost.configuration!.concurrentQuery.pollInterval);
return new Promise((resolve) => {
const postrc = this.nativeDb.postConcurrentQuery(ecsql, JSON.stringify(bindings, replacer), limit!, quota!, priority!);
if (postrc.status !== IModelJsNative.ConcurrentQuery.PostStatus.Done)
resolve({ status: QueryResponseStatus.PostError, rows: [] });
const poll = () => {
if (!this.nativeDb || !this.nativeDb.isOpen()) {
resolve({ status: QueryResponseStatus.Done, rows: [] });
} else {
const pollrc = this.nativeDb.pollConcurrentQuery(postrc.taskId);
if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Done)
resolve({ status: QueryResponseStatus.Done, rows: JSON.parse(pollrc.result, reviver) });
else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Partial)
resolve({ status: QueryResponseStatus.Partial, rows: JSON.parse(pollrc.result, reviver) });
else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Timeout)
resolve({ status: QueryResponseStatus.Timeout, rows: [] });
else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Pending)
setTimeout(() => { poll(); }, IModelHost.configuration!.concurrentQuery.pollInterval);
else
const poll = () => {
if (!this.nativeDb || !this.nativeDb.isOpen()) {
resolve({ status: QueryResponseStatus.Done, rows: [] });
} else {
const pollrc = this.nativeDb.pollConcurrentQuery(postrc.taskId);
if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Done)
resolve({ status: QueryResponseStatus.Done, rows: JSON.parse(pollrc.result, reviver) });
else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Partial)
resolve({ status: QueryResponseStatus.Partial, rows: JSON.parse(pollrc.result, reviver) });
else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Timeout)
resolve({ status: QueryResponseStatus.Timeout, rows: [] });
else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Pending)
setTimeout(() => { poll(); }, IModelHost.configuration!.concurrentQuery.pollInterval);
else
resolve({ status: QueryResponseStatus.Error, rows: [pollrc.result] });
}
};
setTimeout(() => { poll(); }, IModelHost.configuration!.concurrentQuery.pollInterval);
const poll = () => {
if (!this.isOpen) {
resolve({ status: QueryResponseStatus.Done, rows: [] });
} else {
const pollrc = this.nativeDb.pollConcurrentQuery(postrc.taskId);
if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Done)
resolve({ status: QueryResponseStatus.Done, rows: JSON.parse(pollrc.result, reviver) });
else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Partial)
resolve({ status: QueryResponseStatus.Partial, rows: JSON.parse(pollrc.result, reviver) });
else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Timeout)
resolve({ status: QueryResponseStatus.Timeout, rows: [] });
else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Pending)
setTimeout(() => { poll(); }, IModelHost.configuration!.concurrentQuery.pollInterval);
else
resolve({ status: QueryResponseStatus.Error, rows: [pollrc.result] });
}
};
setTimeout(() => { poll(); }, IModelHost.configuration!.concurrentQuery.pollInterval);
return new Promise((resolve) => {
if (!this.isOpen) {
resolve({ status: QueryResponseStatus.Done, rows: [] });
} else {
const postrc = this.nativeDb.postConcurrentQuery(ecsql, JSON.stringify(bindings, replacer), limit!, quota!, priority!);
if (postrc.status !== IModelJsNative.ConcurrentQuery.PostStatus.Done)
resolve({ status: QueryResponseStatus.PostError, rows: [] });
const poll = () => {
if (!this.isOpen) {
resolve({ status: QueryResponseStatus.Done, rows: [] });
} else {
const pollrc = this.nativeDb.pollConcurrentQuery(postrc.taskId);
if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Done)
resolve({ status: QueryResponseStatus.Done, rows: JSON.parse(pollrc.result, reviver) });
else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Partial)
resolve({ status: QueryResponseStatus.Partial, rows: JSON.parse(pollrc.result, reviver) });
else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Timeout)
resolve({ status: QueryResponseStatus.Timeout, rows: [] });
else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Pending)
setTimeout(() => { poll(); }, IModelHost.configuration!.concurrentQuery.pollInterval);
else
resolve({ status: QueryResponseStatus.Error, rows: [pollrc.result] });
const poll = () => {
if (!this.nativeDb || !this.nativeDb.isOpen()) {
resolve({ status: QueryResponseStatus.Done, rows: [] });
} else {
const pollrc = this.nativeDb.pollConcurrentQuery(postrc.taskId);
if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Done)
resolve({ status: QueryResponseStatus.Done, rows: JSON.parse(pollrc.result, reviver) });
else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Partial)
resolve({ status: QueryResponseStatus.Partial, rows: JSON.parse(pollrc.result, reviver) });
else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Timeout)
resolve({ status: QueryResponseStatus.Timeout, rows: [] });
else if (pollrc.status === IModelJsNative.ConcurrentQuery.PollStatus.Pending)
setTimeout(() => { poll(); }, IModelHost.configuration!.concurrentQuery.pollInterval);
else
resolve({ status: QueryResponseStatus.Error, rows: [pollrc.result] });
}
};
setTimeout(() => { poll(); }, IModelHost.configuration!.concurrentQuery.pollInterval);
public static performUpgrade(pathname: string): DbResult {
const nativeDb = new IModelHost.platform.DgnDb();
const res = nativeDb.openIModel(pathname, OpenMode.ReadWrite, IModelJsNative.UpgradeOptions.Upgrade);
if (DbResult.BE_SQLITE_OK === res)
nativeDb.closeIModel();
return res;
}