private void LoadBusinessObjects(ISearchQuery query) { try { var srv = new DataLoadingService { Repository = Repository }; srv.ProgressChanged += (sender, tuple) => { SetProgress(tuple); if (tuple.Item3 != null) { BusinessObjectList.Add(tuple.Item3 as BusinessObject); } }; srv.Finished += (sender, isSucceed) => { if (!isSucceed) { AlertError(srv.Error); } ResetProgress(); }; BusinessObjectList.Clear(); srv.Execute(query); } catch (Exception ex) { AlertError(ex.Message); } }
private void ExecuteLoadDatabaseCommand(object o) { var dbFileOpener = new OpenFileService() { AcceptNonExistingFiles = true }; if (!dbFileOpener.OpenFile(OpenFileService.SqliteDatabaseFilter)) { return; } Connection.Connect(dbFileOpener.SelectedFile); if (!dbFileOpener.SelectedFileExists) { new DatabaseService { Connection = Connection }.InitializeDatabase(); } Repository = new Repository() { Connection = Connection }; BusinessObjectList.Clear(); LoadAllDataFromDatabase(); LoadTags(SearchQuery.NoFilter); IsReady = true; }
private void ExecuteNewBusinessObject(object o) { var obj = new BusinessObject(); if (EditBusinessObject(obj)) { BusinessObjectList.Add(obj); } }
private void RefreshRegexList(LinkRegex itemToSelect) { _lbxRegexes.Items.Clear(); BusinessObjectList <LinkRegex> repList = Core.ResourceStore.GetAllResources(LinkRegex.ResourceType); foreach (LinkRegex res in repList) { _lbxRegexes.Items.Add(res); } if (itemToSelect != null) { _lbxRegexes.SelectedItem = itemToSelect; } if (_lbxRegexes.SelectedItem == null && _lbxRegexes.Items.Count > 0) { _lbxRegexes.SelectedItem = _lbxRegexes.Items [0]; } UpdateRegexButtons(); }
private void ExecuteDeleteBusinessObjectCommand(object o) { var obj = o as BusinessObject; if (obj == null) { return; } try { Repository.Delete(obj.Id); BusinessObjectList.Remove(obj); MessageBox.Show($"Objekt {obj.Id} gelöscht", "Erfolg", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error); } }
/// <summary> /// Locates or, if necessary, creates the Omea contact for the specified Perforce /// user, and links the resource to it. /// </summary> /// <param name="resource">The changeset resource.</param> /// <param name="user">The Perforce user ID.</param> protected void LinkChangeSetToContact(IResource repository, IResource resource, string user) { if (!Core.ResourceStore.IsOwnerThread()) { Core.ResourceAP.RunJob("Linking changeset to contact", () => LinkChangeSetToContact(repository, resource, user)); return; } BusinessObjectList <UserToRepositoryMap> userRepMapList = Core.ResourceStore.FindResources(UserToRepositoryMap.ResourceType, Props.UserId, user); userRepMapList = userRepMapList.Intersect(repository.GetLinksOfType(UserToRepositoryMap.ResourceType, Props.UserRepository)); if (userRepMapList.Count == 0) { string email, fullName; GetUserDetails(repository, user, out email, out fullName); IContact contact = Core.ContactManager.FindOrCreateContact(email, fullName); IResource contactRes = contact.Resource; UserToRepositoryMap userRepMap = UserToRepositoryMap.Create(); userRepMap.UserId = user; userRepMap.UserRepository = repository; userRepMap.UserContact = contactRes; userRepMap.Save(); Core.ContactManager.LinkContactToResource(Core.ContactManager.Props.LinkFrom, contactRes, resource, email, fullName); } else { IResource contactRes = userRepMapList [0].UserContact; IContact contact = Core.ContactManager.GetContact(contactRes); Core.ContactManager.LinkContactToResource(Core.ContactManager.Props.LinkFrom, contactRes, resource, contact.DefaultEmailAddress, contactRes.DisplayName); } }