private async void syncNewUserGroupMenuItem_Click(object sender, EventArgs e) { var ticket = Session.GetTikect(); if (string.IsNullOrWhiteSpace(ticket)) { return; } var group = (UserGroup)null; var syncDirectory = String.Empty; using (var syncNewUserGroup = new SyncNewUserGroupView(ticket)) { if (syncNewUserGroup.ShowDialog() == DialogResult.OK) { group = syncNewUserGroup.Group; syncDirectory = syncNewUserGroup.SyncDirectory; } else { return; } } var directory = string.Format("{0}\\{1}", syncDirectory, group.name); var fileFolderInfoList = new List <FileFolderInfo>(); var fileFolderInfo = new FileFolderInfo() { GroupId = group.id, Path = directory, SyncFolder = true }; fileFolderInfoList.Add(fileFolderInfo); using (var syncProgress = new SyncProgressView()) { if (syncProgress.SyncNewUserGroup(ticket, directory, group)) { fileFolderInfoList.AddRange(syncProgress.FileFolderList); } } //Detect the synchronizer object state if (_syncing || _synchronizer.Paused) { _synchronizer.Synchronize(fileFolderInfoList); } else { await _synchronizer.SynchronizeAsync(ticket, directory, fileFolderInfoList); } WatchingPath(syncDirectory); }
public async Task SyncANewUserGroupAsync(string p1, string p2, string p3) { var ticket = Session.GetTikect(); if (string.IsNullOrWhiteSpace(ticket)) { return; } var group = new UserGroup() { id = p1, name = p2 }; var syncDirectory = ConfigurationManager.GetValue(Resources.SyncDirectoryPathKey); if (string.IsNullOrWhiteSpace(syncDirectory)) { using (var syncNewUserGroup = new SyncNewUserGroupView(ticket, group)) { if (syncNewUserGroup.ShowDialog() == DialogResult.OK) { syncDirectory = syncNewUserGroup.SyncDirectory; } else { return; } } } if (SyncTableManager.GetByGroupId(p3) != null) { return; } var directory = string.Format("{0}\\{1}", syncDirectory, group.name); var fileFolderInfoList = new List <FileFolderInfo>(); var fileFolderInfo = new FileFolderInfo() { GroupId = group.id, Path = directory, SyncFolder = true }; fileFolderInfoList.Add(fileFolderInfo); using (var syncProgress = new SyncProgressView()) { if (syncProgress.SyncNewUserGroup(ticket, directory, group)) { fileFolderInfoList.AddRange(syncProgress.FileFolderList); } } //Detect the synchronizer object state if (_syncing || _synchronizer.Paused) { _synchronizer.Synchronize(fileFolderInfoList); } else { await _synchronizer.SynchronizeAsync(ticket, directory, fileFolderInfoList); } WatchingPath(syncDirectory); }