public void InitDB() { lock (_dbLock) { int reTry = 3; X1LogHelper.Log($"InitDB [{_dbName}] [{typeof(T).FullName}]"); Exception ex = null; while (reTry-- > 0) { try { Connection = PersistentDataHelper.Instance.GetConnection(_isGlobal, _dbName); Connection?.CreateTable <T>(); return; } catch (Exception e) { ex = e; } } X1LogHelper.Error("InitDB failed"); if (ex != null) { X1LogHelper.Exception(ex); } } }
void File_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { System.Diagnostics.Debug.WriteLine("[Property changed] " + e.PropertyName + " -> " + sender?.GetType().GetProperty(e.PropertyName)?.GetValue(sender, null)); // Update UI text-fields var downloadFile = ((IDownloadFile)sender); if (downloadFile == null) { return; } // Update UI text-fields switch (e.PropertyName) { case nameof(IDownloadFile.Status): X1LogHelper.Log($"{downloadFile.Url} [status]: {downloadFile.Status}"); break; case nameof(IDownloadFile.TotalBytesExpected): X1LogHelper.Verbose($"{downloadFile.Url} [Total length]: {downloadFile.TotalBytesExpected}"); break; case nameof(IDownloadFile.TotalBytesWritten): X1LogHelper.Verbose($"{downloadFile.Url} [downloaded]: {downloadFile.TotalBytesWritten}"); break; } // Update UI if download-status changed. if (e.PropertyName == "Status") { switch (((IDownloadFile)sender).Status) { case DownloadFileStatus.COMPLETED: { X1LogHelper.Log($"{downloadFile.Url} [downloaded as ]: [{downloadFile.DestinationPathName}]"); var path = downloadFile.DestinationPathName; if (path.StartsWith(BaobaoModel.LocalPathPrefix)) { path = path.Substring(BaobaoModel.LocalPathPrefix.Length); } OnFileAvailable?.Invoke(this, new StringEventArgs(path)); } break; } } }