private void btnUpdate_Click(object sender, EventArgs e) { if (dgViewFileList.SelectedRows == null || dgViewFileList.SelectedCells.Count == 0) { return; } SyncFile syncFile; var row = dgViewFileList.SelectedCells[0].OwningRow; int id = Convert.ToInt32(row.Cells["colID"].Value); if (SycerSQLiteHelper.GetSyncFile(_conn, id, out syncFile) && syncFile != null) { string latestPath; DateTime updateTime; if (!FileSyncHelper.UpdateFilesToNewest(syncFile.ListFullName, out latestPath, out updateTime) || string.IsNullOrEmpty(latestPath)) { MessageBox.Show(@"同步数据失败!"); } else //更新数据库文件 { FileSyncHelper.FreshSyncFile(ref syncFile, latestPath, updateTime, 1); if (!SycerSQLiteHelper.UpdateSyncFile(_conn, syncFile)) { MessageBox.Show(@"文件已更新,但更新同步信息失败!"); } } } else { MessageBox.Show(@"读取同步文件信息失败!"); } ReadDataBase(); }
/// <summary>更新SyncFile</summary> /// <param name="conn">数据库连接</param> /// <param name="fileSetName">文件集名称</param> /// <param name="listFileInfo">链接文件信息列表</param> /// <param name="id">文件集序号</param> /// <returns>操作是否成功</returns> public static bool UpdateSyncFile(SQLiteConnection conn, string fileSetName, List <FileInfoLite> listFileInfo, int id) { SyncFile syncFile; if (!FileSyncHelper.CreateSyncFile(fileSetName, listFileInfo, out syncFile, id) || syncFile == null) { return(false); } return(UpdateSyncFile(conn, syncFile)); }