Ejemplo n.º 1
0
 public void SetProjectIds(IEnumerable <int> ids)
 {
     ProjectIds.Clear();
     if (ids != null && ids.Any())
     {
         ProjectIds.AddRange(ids);
     }
     else
     {
         ProjectIds.Add(-1);
     }
 }
Ejemplo n.º 2
0
        private async Task <SolutionStateChecksums> ComputeChecksumsAsync(CancellationToken cancellationToken)
        {
            using (Logger.LogBlock(FunctionId.SolutionState_ComputeChecksumsAsync, FilePath, cancellationToken))
            {
                // get states by id order to have deterministic checksum
                var projectChecksumTasks = ProjectIds.Select(id => ProjectStates[id].GetChecksumAsync(cancellationToken));

                var serializer   = new Serializer(_solutionServices.Workspace);
                var infoChecksum = serializer.CreateChecksum(SolutionInfo.Attributes, cancellationToken);

                var projectChecksums = await Task.WhenAll(projectChecksumTasks).ConfigureAwait(false);

                return(new SolutionStateChecksums(infoChecksum, new ProjectChecksumCollection(projectChecksums)));
            }
        }
Ejemplo n.º 3
0
        private IEnumerable <VSTSRepository> CreateRepositories(int count)
        {
            return(Enumerable.Range(0, count)
                   .Select(i =>
            {
                var projectToTake = _random.Next(1, ProjectIds.Count() + 1);
                var projectId = ProjectIds.Any() ? ProjectIds.Take(projectToTake).Last() : Guid.Empty;

                return new VSTSRepository
                {
                    Id = Guid.NewGuid(),
                    Name = $"Repository {i}",
                    Project = projectId
                };
            }).ToList());
        }
Ejemplo n.º 4
0
 public bool IsEmpty()
 {
     if (AllProjects && !AllArtifacts && (ArtifactIds == null || !ArtifactIds.Any()))
     {
         return(true);
     }
     else if (AllArtifacts && !AllProjects && (ProjectIds == null || !ProjectIds.Any()))
     {
         return(true);
     }
     else if (!AllArtifacts && !AllProjects &&
              ((ArtifactIds == null || !ArtifactIds.Any()) ||
               (ProjectIds == null || !ProjectIds.Any())))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 5
0
        public virtual IQueryable <T> ApplyFilter(IQueryable <T> query)
        {
            query = query.Where(Query);
            if (Ids.Count > 0)
            {
                query = query.Where(d => Ids.Contains(d.Id));
            }
            if (_isOwnedByOrganization && OrganizationIds.Count > 0)
            {
                query = query.Where(d => OrganizationIds.Contains(((IOwnedByOrganization)d).OrganizationId));
            }
            if (_isOwnedByProject && ProjectIds.Count > 0)
            {
                query = query.Where(d => ProjectIds.Contains(((IOwnedByProject)d).ProjectId));
            }
            if (_isOwnedByStack && StackIds.Count > 0)
            {
                query = query.Where(d => StackIds.Contains(((IOwnedByStack)d).StackId));
            }

            return(query);
        }
Ejemplo n.º 6
0
        private async Task <SolutionStateChecksums> ComputeChecksumsAsync(CancellationToken cancellationToken)
        {
            try
            {
                using (Logger.LogBlock(FunctionId.SolutionState_ComputeChecksumsAsync, FilePath, cancellationToken))
                {
                    // get states by id order to have deterministic checksum
                    var orderedProjectIds    = ChecksumCache.GetOrCreate(ProjectIds, _ => ProjectIds.OrderBy(id => id.Id).ToImmutableArray());
                    var projectChecksumTasks = orderedProjectIds.Select(id => ProjectStates[id])
                                               .Where(s => RemoteSupportedLanguages.IsSupported(s.Language))
                                               .Select(s => s.GetChecksumAsync(cancellationToken));

                    var serializer         = _solutionServices.Workspace.Services.GetRequiredService <ISerializerService>();
                    var attributesChecksum = serializer.CreateChecksum(SolutionAttributes, cancellationToken);
                    var optionsChecksum    = serializer.CreateChecksum(Options, cancellationToken);

                    var frozenSourceGeneratedDocumentIdentityChecksum = Checksum.Null;
                    var frozenSourceGeneratedDocumentTextChecksum     = Checksum.Null;

                    if (FrozenSourceGeneratedDocumentState != null)
                    {
                        frozenSourceGeneratedDocumentIdentityChecksum = serializer.CreateChecksum(FrozenSourceGeneratedDocumentState.Identity, cancellationToken);
                        frozenSourceGeneratedDocumentTextChecksum     = (await FrozenSourceGeneratedDocumentState.GetStateChecksumsAsync(cancellationToken).ConfigureAwait(false)).Text;
                    }

                    var analyzerReferenceChecksums = ChecksumCache.GetOrCreate <ChecksumCollection>(AnalyzerReferences,
                                                                                                    _ => new ChecksumCollection(AnalyzerReferences.Select(r => serializer.CreateChecksum(r, cancellationToken)).ToArray()));

                    var projectChecksums = await Task.WhenAll(projectChecksumTasks).ConfigureAwait(false);

                    return(new SolutionStateChecksums(attributesChecksum, optionsChecksum, new ChecksumCollection(projectChecksums), analyzerReferenceChecksums, frozenSourceGeneratedDocumentIdentityChecksum, frozenSourceGeneratedDocumentTextChecksum));
                }
            }
            catch (Exception e) when(FatalError.ReportAndPropagateUnlessCanceled(e, cancellationToken))
            {
                throw ExceptionUtilities.Unreachable;
            }
        }
        /// <param name="projectsToInclude">Cone of projects to compute a checksum for.  Pass in <see langword="null"/>
        /// to get a checksum for the entire solution</param>
        private async Task <SolutionStateChecksums> ComputeChecksumsAsync(
            HashSet <ProjectId>?projectsToInclude,
            SerializableOptionSet options,
            CancellationToken cancellationToken)
        {
            try
            {
                using (Logger.LogBlock(FunctionId.SolutionState_ComputeChecksumsAsync, FilePath, cancellationToken))
                {
                    // get states by id order to have deterministic checksum.  Limit expensive computation to the
                    // requested set of projects if applicable.
                    var orderedProjectIds    = ChecksumCache.GetOrCreate(ProjectIds, _ => ProjectIds.OrderBy(id => id.Id).ToImmutableArray());
                    var projectChecksumTasks = orderedProjectIds
                                               .Select(id => (state: ProjectStates[id], mustCompute: projectsToInclude == null || projectsToInclude.Contains(id)))
                                               .Where(t => RemoteSupportedLanguages.IsSupported(t.state.Language))
                                               .Select(async t =>
                    {
                        // if it's a project that's specifically in the sync'ed cone, include this checksum so that
                        // this project definitely syncs over.
                        if (t.mustCompute)
                        {
                            return(await t.state.GetChecksumAsync(cancellationToken).ConfigureAwait(false));
                        }

                        // If it's a project that is not in the cone, still try to get the latest checksum for it if
                        // we have it.  That way we don't send over a checksum *without* that project, causing the
                        // OOP side to throw that project away (along with all the compilation info stored with it).
                        if (t.state.TryGetStateChecksums(out var stateChecksums))
                        {
                            return(stateChecksums.Checksum);
                        }

                        // We have never computed the checksum for this project.  Don't send anything for it.
                        return(null);
                    })
                                               .ToArray();

                    var serializer         = _solutionServices.Workspace.Services.GetRequiredService <ISerializerService>();
                    var attributesChecksum = serializer.CreateChecksum(SolutionAttributes, cancellationToken);

                    var optionsChecksum = serializer.CreateChecksum(options, cancellationToken);

                    var frozenSourceGeneratedDocumentIdentityChecksum = Checksum.Null;
                    var frozenSourceGeneratedDocumentTextChecksum     = Checksum.Null;

                    if (FrozenSourceGeneratedDocumentState != null)
                    {
                        frozenSourceGeneratedDocumentIdentityChecksum = serializer.CreateChecksum(FrozenSourceGeneratedDocumentState.Identity, cancellationToken);
                        frozenSourceGeneratedDocumentTextChecksum     = (await FrozenSourceGeneratedDocumentState.GetStateChecksumsAsync(cancellationToken).ConfigureAwait(false)).Text;
                    }

                    var analyzerReferenceChecksums = ChecksumCache.GetOrCreate <ChecksumCollection>(AnalyzerReferences,
                                                                                                    _ => new ChecksumCollection(AnalyzerReferences.Select(r => serializer.CreateChecksum(r, cancellationToken)).ToArray()));

                    var projectChecksums = await Task.WhenAll(projectChecksumTasks).ConfigureAwait(false);

                    return(new SolutionStateChecksums(
                               attributesChecksum,
                               optionsChecksum,
                               new ChecksumCollection(projectChecksums.WhereNotNull().ToArray()),
                               analyzerReferenceChecksums,
                               frozenSourceGeneratedDocumentIdentityChecksum,
                               frozenSourceGeneratedDocumentTextChecksum));
                }
            }
            catch (Exception e) when(FatalError.ReportAndPropagateUnlessCanceled(e, cancellationToken))
            {
                throw ExceptionUtilities.Unreachable;
            }
        }
Ejemplo n.º 8
0
        public IQueryable <ITask> Where(IQueryable <ITask> tasks)
        {
            #region Фильтры

            tasks = tasks.Where(x => x.BoardId == BoardId);

            if (!IsAllIn(ExecutorIds, _AllUserIds))
            {
                tasks = from t in tasks
                        where ExecutorIds.Contains(t.ExecutorUserId)
                        select t;
            }

            if (!IsAllIn(CreatorIds, _AllUserIds))
            {
                tasks = from t in tasks
                        where CreatorIds.Contains(t.CreatorUserId)
                        select t;
            }

            if (!IsAllIn(ProjectIds, _AllProjectIds))
            {
                tasks = from t in tasks
                        where ProjectIds.Contains(t.ProjectId)
                        select t;
            }

            if (!IsAllIn(ColorIds, _AllColorIds))
            {
                tasks = from t in tasks
                        where ColorIds.Contains(t.ColorId)
                        select t;
            }

            if (!IsAllIn(Statuses, _AllStatuses))
            {
                if (Statuses.Any(x => x == TimezStatus.ArchiveStatusId || x <= 0))
                {
                    throw new ArgumentOutOfRangeException();
                }

                tasks = from t in tasks
                        where Statuses.Contains(t.TaskStatusId)
                        select t;
            }

            if (!string.IsNullOrWhiteSpace(Search))
            {
                tasks = from t in tasks
                        where t.Name.ToUpper().Contains(Search.Trim().ToUpper())
                        select t;
            }

            #endregion

            #region Ограничение по роли пользователя в доске

            UserRole role = _Settings.GetUserRole();
            if (!role.HasTheFlag(UserRole.Owner) && !role.HasTheFlag(UserRole.Observer))
            {
                // владелец и наблюдатель получают все задачи
                // исполнитель и заказчик только свои
                if (role.HasAnyFlag(UserRole.Executor | UserRole.Customer))
                {
                    // есть обе роли, значит нужно оба типа задач
                    tasks = from t in tasks
                            where t.ExecutorUserId == _Settings.UserId ||                          // назначенные на пользователя
                            t.CreatorUserId == _Settings.UserId                                // назначенные пользоватем
                            select t;
                }
                else if (role.HasTheFlag(UserRole.Executor))
                {
                    tasks = from t in tasks
                            where t.ExecutorUserId == _Settings.UserId                             // только назначенные на пользователя
                            select t;
                }
                else if (role.HasTheFlag(UserRole.Customer))
                {
                    tasks = from t in tasks
                            where t.CreatorUserId == _Settings.UserId                             // только назначенные пользоватем
                            select t;
                }
                else
                {
                    throw new AccessDeniedException();
                }
            }

            #endregion

            return(tasks);
        }
Ejemplo n.º 9
0
        public virtual IMongoQuery GetQuery(Func <string, BsonValue> getIdValue = null)
        {
            if (getIdValue == null)
            {
                getIdValue = id => new BsonObjectId(new ObjectId(id));
            }

            IMongoQuery query = Query;

            if (Ids.Count > 0)
            {
                query = query.And(MongoDB.Driver.Builders.Query.In(CommonFieldNames.Id, Ids.Select(id => getIdValue(id))));
            }
            if (OrganizationIds.Count > 0)
            {
                query = query.And(MongoDB.Driver.Builders.Query.In(CommonFieldNames.OrganizationId, OrganizationIds.Select(id => new BsonObjectId(new ObjectId(id)))));
            }
            if (ProjectIds.Count > 0)
            {
                query = query.And(MongoDB.Driver.Builders.Query.In(CommonFieldNames.ProjectId, ProjectIds.Select(id => new BsonObjectId(new ObjectId(id)))));
            }
            if (StackIds.Count > 0)
            {
                query = query.And(MongoDB.Driver.Builders.Query.In(CommonFieldNames.StackId, StackIds.Select(id => new BsonObjectId(new ObjectId(id)))));
            }

            return(query);
        }
Ejemplo n.º 10
0
        private async Task <SolutionStateChecksums> ComputeChecksumsAsync(CancellationToken cancellationToken)
        {
            using (Logger.LogBlock(FunctionId.SolutionState_ComputeChecksumsAsync, FilePath, cancellationToken))
            {
                // get states by id order to have deterministic checksum
                var orderedProjectIds    = ChecksumCache.GetOrCreate(ProjectIds, _ => ProjectIds.OrderBy(id => id.Id).ToImmutableArray());
                var projectChecksumTasks = orderedProjectIds.Select(id => ProjectStates[id])
                                           .Where(s => RemoteSupportedLanguages.IsSupported(s.Language))
                                           .Select(s => s.GetChecksumAsync(cancellationToken));

                var serializer   = _solutionServices.Workspace.Services.GetService <ISerializerService>();
                var infoChecksum = serializer.CreateChecksum(SolutionAttributes, cancellationToken);

                var projectChecksums = await Task.WhenAll(projectChecksumTasks).ConfigureAwait(false);

                return(new SolutionStateChecksums(infoChecksum, new ProjectChecksumCollection(projectChecksums)));
            }
        }
Ejemplo n.º 11
0
 public void Delete(ProjectIds projectIds)
 {
     Repository.DeleteByIds(projectIds.Ids);
 }
Ejemplo n.º 12
0
        }                                                 //Injected by IOC

        public object Get(ProjectIds projectIds)
        {
            return(projectIds.Ids.IsEmpty()
                       ? Repository.GetAll()
                       : Repository.GetByIds(projectIds.Ids));
        }
Ejemplo n.º 13
0
 public object Get(ProjectIds projectIds)
 {
     return projectIds.Ids.IsEmpty()
                ? Repository.GetAll()
                : Repository.GetByIds(projectIds.Ids);
 }
Ejemplo n.º 14
0
 public void Delete(ProjectIds projectIds)
 {
     Repository.DeleteByIds(projectIds.Ids);
 }
        private async Task <SolutionStateChecksums> ComputeChecksumsAsync(CancellationToken cancellationToken)
        {
            try
            {
                using (Logger.LogBlock(FunctionId.SolutionState_ComputeChecksumsAsync, FilePath, cancellationToken))
                {
                    // get states by id order to have deterministic checksum
                    var orderedProjectIds    = ChecksumCache.GetOrCreate(ProjectIds, _ => ProjectIds.OrderBy(id => id.Id).ToImmutableArray());
                    var projectChecksumTasks = orderedProjectIds.Select(id => ProjectStates[id])
                                               .Where(s => RemoteSupportedLanguages.IsSupported(s.Language))
                                               .Select(s => s.GetChecksumAsync(cancellationToken));

                    var serializer      = _solutionServices.Workspace.Services.GetService <ISerializerService>();
                    var infoChecksum    = serializer.CreateChecksum(SolutionAttributes, cancellationToken);
                    var optionsChecksum = serializer.CreateChecksum(Options, cancellationToken);

                    var analyzerReferenceChecksums = ChecksumCache.GetOrCreate <AnalyzerReferenceChecksumCollection>(AnalyzerReferences,
                                                                                                                     _ => new AnalyzerReferenceChecksumCollection(AnalyzerReferences.Select(r => serializer.CreateChecksum(r, cancellationToken)).ToArray()));

                    var projectChecksums = await Task.WhenAll(projectChecksumTasks).ConfigureAwait(false);

                    return(new SolutionStateChecksums(infoChecksum, optionsChecksum, new ProjectChecksumCollection(projectChecksums), analyzerReferenceChecksums));
                }
            }
            catch (Exception e) when(FatalError.ReportWithoutCrashUnlessCanceledAndPropagate(e))
            {
                throw ExceptionUtilities.Unreachable;
            }
        }
Ejemplo n.º 16
0
        public DataSet SearchLessonsLearned()
        {
            ICustomDataAdapter da      = DataAccess.GetCustomDataAdapter();
            DataSet            results = new DataSet(); //make sure we use a loosely typed dataset as there will be more columns returned than just from the hedge table

            IDbCommand cmd;

            cmd             = DBConnection.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "LL_LEARNED_PKG.SEARCH_RECORD";

            CreateParameter(ref cmd, "userId", ParameterDirection.Input, DbType.String, "USER_ID");
            CreateParameter(ref cmd, "pkeywords", ParameterDirection.Input, DbType.String, "KEY_WORDS");
            CreateParameter(ref cmd, "psbuids", ParameterDirection.Input, DbType.String, "SBU_IDS");
            CreateParameter(ref cmd, "pbuids", ParameterDirection.Input, DbType.String, "BU_IDS");
            CreateParameter(ref cmd, "pprojectids", ParameterDirection.Input, DbType.String, "PROJECT_IDS");
            CreateParameter(ref cmd, "pprocessids", ParameterDirection.Input, DbType.String, "PROCESS_IDS");
            CreateParameter(ref cmd, "pdisciplineids", ParameterDirection.Input, DbType.String, "DISCIPLINE_IDS");
            CreateParameter(ref cmd, "pstageids", ParameterDirection.Input, DbType.String, "STAGE_IDS");
            CreateParameter(ref cmd, "pcategoryids", ParameterDirection.Input, DbType.String, "CATEGORY_IDS");

            ((IDbDataParameter)cmd.Parameters["userId"]).Value         = CurrentUser;
            ((IDbDataParameter)cmd.Parameters["pkeywords"]).Value      = KeyWords.ToString();
            ((IDbDataParameter)cmd.Parameters["psbuids"]).Value        = SBUIds.ToString();
            ((IDbDataParameter)cmd.Parameters["pbuids"]).Value         = BUIds.ToString();
            ((IDbDataParameter)cmd.Parameters["pprojectids"]).Value    = ProjectIds.ToString();
            ((IDbDataParameter)cmd.Parameters["pprocessids"]).Value    = ProcessIds.ToString();
            ((IDbDataParameter)cmd.Parameters["pdisciplineids"]).Value = DisciplineIds.ToString();
            ((IDbDataParameter)cmd.Parameters["pstageids"]).Value      = StageIds.ToString();
            ((IDbDataParameter)cmd.Parameters["pcategoryids"]).Value   = CategoryIds.ToString();

            try
            {
                da.SelectCommand = cmd;
                da.Fill(results);
            }
            catch (Exception ex)
            {
                //If we get an error opening the result for the stored
                //procedure, we likely have a a farily major problem.
                //Permissions issues or something of the kind.  We will
                //percolate the call back up the stack so the front end
                //may report it and thus the user can log the error
                //for repair.
                throw ex;
            }
            finally
            {
                if (cmd != null)
                {
                    cmd.Connection.Close();
                    cmd.Connection.Dispose();
                    cmd.Dispose();
                    cmd = null;
                }

                if (da != null)
                {
                    da.Dispose();
                    da = null;
                }
            }

            return(results);
        }