private Project GetProjectById(string id) { if (!connector.IsConnected) { return(null); } if (CurrentProjectId == null) { Logger.Error("Current project is not selected"); throw new DataLayerException("Current project is not selected"); } var query = new Query(Oid.FromToken(id, connector.MetaModel)); AddSelection(query, Entity.ProjectType); try { var result = connector.Services.Retrieve(query); return(result.TotalAvaliable == 1 ? WorkitemFactory.CreateProject(result.Assets[0], null) : null); } catch (MetaException ex) { connector.IsConnected = false; throw new DataLayerException("Unable to get projects", ex); } catch (Exception ex) { throw new DataLayerException("Unable to get projects", ex); } }
public IList <Project> GetProjectTree() { try { var scopeQuery = new Query(ProjectType, ProjectType.GetAttributeDefinition("Parent")); var stateTerm = new FilterTerm(ProjectType.GetAttributeDefinition("AssetState")); stateTerm.NotEqual(AssetState.Closed); scopeQuery.Filter = stateTerm; AddSelection(scopeQuery, Entity.ProjectType); var result = connector.Services.Retrieve(scopeQuery); var roots = result.Assets.Select(asset => WorkitemFactory.CreateProject(asset, null)).ToList(); return(roots); } catch (WebException ex) { connector.IsConnected = false; Logger.Error("Can't get projects list.", ex); return(null); } catch (Exception ex) { Logger.Error("Can't get projects list.", ex); return(null); } }
public Workitem CreateWorkitem(string assetType, Workitem parent, IEntityContainer entityContainer) { var assetFactory = new AssetFactory(this, CurrentProject, LoggerFactory, AttributesToQuery); return(WorkitemFactory.CreateWorkitem(assetFactory, assetType, parent, entityContainer)); }
public IList <Workitem> GetWorkitems(bool showAll) { return(AllAssets.Where(asset => showAll || dataLayer.AssetPassesShowMyTasksFilter(asset)) .Select(asset => WorkitemFactory.CreateWorkitem(asset, null, this)) .ToList()); }