public async Task Connect([NotNull] string path) { var isExist = CheckFileExist(path); if (!isExist) { Logger.Log(LogLevel.Info, "Failed to connect to non-database file: {0}", path); return; } DisposeConnection(); LocalDbContext context; try { context = new LocalDbContext(CreateConnection(path)); var exists = context.Database.Exists(); } catch (Exception e) { Logger.Log(LogLevel.Info, "Failed to connect to database file: {0}", path); Logger.Log(LogLevel.Error, e); throw; } await Migrate(context); this.Context = context; this.CurrentDatabasePath = path; DatabaseChanged?.Invoke(this, path); }
public static void Reconnect(string dataSource) { _instance?._delayedUpdateStart.Dispose(); _instance?.Dispose(); _instance = new GeneralDbContext(dataSource); Init(); DatabaseChanged?.Invoke(_instance, dataSource); }
private void ChangeDatabase() { DatabaseDirty = true; if (DatabaseChanged != null) { DatabaseChanged.Invoke(); } }
private void cmbDatabase_SelectedIndexChanged(object sender, EventArgs e) { cmbTable.Items.Clear(); using (SqlConnection connection = new SqlConnection(ConnectionString)) { Tables = connection.GetTableNames(); Tables.ForEach(x => cmbTable.Items.Add(x)); DatabaseChanged?.Invoke(); } }
private void RaiseDatabaseChanged() { if (_deferedEventCount == 0) { LastModifiedDate = DateTime.UtcNow; DatabaseChanged?.Invoke(this, EventArgs.Empty); _deferedEventCalled = false; } else { _deferedEventCalled = true; } }
// Call this when IsActive has changed. protected void RefreshActive() { if (IsActive) { EditorApplication.update -= AutoRefresh; EditorApplication.update += AutoRefresh; m_LastRefreshTime = EditorApplication.timeSinceStartup; } else { EditorApplication.update -= AutoRefresh; m_Data.Clear(); m_IsReady = false; DatabaseChanged?.Invoke(); } }
private void WaitAndFinishDatabaseUpdate() { if (m_PendingData == null) { return; } if (DoTraceLogs) { Debug.Log($"Finished updating {name} at {EditorApplication.timeSinceStartup:0.00}"); } EditorApplication.update -= WaitAndFinishDatabaseUpdate; m_WorkerThread = null; m_IsReady = true; var pendingData = m_PendingData; m_PendingData = null; m_Data.Clear(); // Mark update as finished. m_PendingUpdate = false; // If preferences were changed while waiting. if (!IsActive) { m_IsReady = false; return; } // Process the gathered data in the main thread, since Unity API is not thread-safe. WaitAndFinishDatabaseUpdate(pendingData); DatabaseChanged?.Invoke(); }
public void UploadFile(RemoteFileInfo request) { // kill target file, if already exists string filePath = Path.Combine(Constants.GetCurrentDirectoryPath, Constants.DB_NAME); if (File.Exists(filePath)) { File.Delete(filePath); } const int chunkSize = 2048; var buffer = new byte[chunkSize]; using (var writeStream = new FileStream(filePath, FileMode.CreateNew, FileAccess.Write)) { do { // read bytes from input stream int bytesRead = request.FileByteStream.Read(buffer, 0, chunkSize); if (bytesRead == 0) { break; } // write bytes to output stream writeStream.Write(buffer, 0, bytesRead); } while (true); writeStream.Close(); } if (DatabaseChanged != null) { DatabaseChanged.Invoke(null, null); } }
private static void OnDatabaseChanged(ModeltypEnum typ) { DatabaseChanged?.Invoke(typ, EventArgs.Empty); }
private void OnDatabaseChange(DataItemEventArgs <T> e) { DatabaseChanged?.Invoke(this, e); }
public void NotifyChange() { DatabaseChanged?.Invoke(); }
private void WaitAndFinishDatabaseUpdate() { if (m_PendingStatuses == null) { return; } if (DoTraceLogs) { Debug.Log($"Finished Update Database at {EditorApplication.timeSinceStartup:0.00}"); } EditorApplication.update -= WaitAndFinishDatabaseUpdate; m_WorkerThread = null; var statuses = m_PendingStatuses; m_PendingStatuses = null; StatusDatas.Clear(); // Mark update as finished. PendingUpdate = false; // If preferences were changed while waiting. if (!IsActive) { return; } // Process the gathered statuses in the main thread, since Unity API is not thread-safe. foreach (var foundStatusData in statuses) { // Because structs can't be modified in foreach. var statusData = foundStatusData; // Meta statuses are also considered. They are shown as the asset status. if (statusData.Path.EndsWith(".meta", StringComparison.OrdinalIgnoreCase)) { statusData.Path = statusData.Path.Substring(0, statusData.Path.LastIndexOf(".meta")); } // Conflicted is with priority. if (statusData.IsConflicted) { statusData.Status = VCFileStatus.Conflicted; } var guid = AssetDatabase.AssetPathToGUID(statusData.Path); if (string.IsNullOrEmpty(guid)) { // Files were added in the background without Unity noticing. // When the user focuses on Unity, it will refresh them as well. continue; } // File was added to the repository but is missing in the working copy. // The proper way to check this is to parse the working revision from the svn output (when used with -u) if (statusData.RemoteStatus == VCRemoteFileStatus.Modified && statusData.Status == VCFileStatus.Normal && string.IsNullOrEmpty(guid) ) { continue; } // TODO: Test tree conflicts. SetStatusData(guid, statusData, false); AddModifiedFolders(statusData); } DatabaseChanged?.Invoke(); }
private void RaiseDatabaseChanged() { Console.WriteLine("DatabaseChanged"); DatabaseChanged?.Invoke(this, EventArgs.Empty); }
public static void OnDatabaseChanged() { DatabaseChanged?.Invoke(null, null); }