/// <summary> /// Generates this instance. /// </summary> /// <returns></returns> public bool Generate() { _enumerationTypes = GetEnumerationTypes(); _enumerationLanguages = GetEnumerationLanguages(); _existingEnumerations = ExplorerRepositoryAgentFactory.CreateEnumerationRepositoryAgent().SelectAll(); _existingPerspectives = ExplorerRepositoryAgentFactory.CreatePerspectiveRepositoryAgent().SelectAll(); using (var scope = new TransactionScope(TransactionScopeOption.Required)) { try { if (GenerateTypes() && GenerateLanguages() && GenerateEnumerationItemRoot() && GeneratePerspective()) { scope.Complete(); return(true); } } catch (Exception ex) { return(false); throw ex; } } return(false); }
private bool GenerateEnumerationItemRoot() { if (_existingEnumerations.Select(en => en.Id).Contains(WorkspaceRoot.Id)) { return(true); } string typeId = ExplorerDomainGenerator.GetEnumerationTypeId(ExplorerDomainGenerator.EnumBaseType.TreeViewFolder); var enumRoot = new Enumeration { Id = WorkspaceRootItem.Id, SortOrder = 0, Title = WorkspaceRootItem.Title, TypeId = typeId, Image = new byte[] { }, DateModified = DateTime.Now }; var result = ExplorerRepositoryAgentFactory .CreateEnumerationRepositoryAgent() .Insert(enumRoot); return(!result.HasErrors); }
/// <summary> /// Saves the enumeration. /// </summary> /// <param name="enumeration">The enumeration.</param> /// <returns></returns> private bool SaveEnumeration(Enumeration enumeration) { //if (EnumerationExists(enumeration.Id)) return true; if (_existingEnumerations.Select(en => en.Id).Contains(enumeration.Id)) { return(true); } IEnumerationRepositoryAgent agent = ExplorerRepositoryAgentFactory.CreateEnumerationRepositoryAgent(); try { agent.Insert(enumeration); return(true); } catch (Exception ex) { _logger.Error("agent.Insert throws exception\n" + ex); return(false); } }