public void CustomAttributesMatchingPatternMustSucceedTest() { EntityMetadata entity = new EntityMetadata() { SchemaName = "Account", }; entity.SetSealedPropertyValue("IsManaged", true); entity.SetSealedPropertyValue("IsCustomEntity", false); var field1Metadata = new StringAttributeMetadata("foo_CustomField"); field1Metadata.SetSealedPropertyValue("IsManaged", false); field1Metadata.SetSealedPropertyValue("IsCustomAttribute", true); var attributes = new List <AttributeMetadata> { field1Metadata }; var isOwnedBySolution = false; var validSolutionEntity = new SolutionEntity(entity, attributes, isOwnedBySolution); var regexPattern = @"^[A-Za-z]+_[A-Z]{1}[a-z]{1}[A-Za-z]*$"; var scope = RuleScope.Attribute; var ruleToTest = new RegexRule(regexPattern, scope); var results = ruleToTest.Validate(validSolutionEntity); Assert.True(results.Passed); }
public void CustomLookupOnCustomUnmanagedEntityConformingRuleResultStringIsCorrect() { var entity = new EntityMetadata() { SchemaName = "foo_MyEntity", DisplayName = new Label() { UserLocalizedLabel = new LocalizedLabel("My Entity", 1033) } }; entity.SetSealedPropertyValue("IsManaged", false); entity.SetSealedPropertyValue("IsCustomEntity", true); var scope = RuleScope.Lookup; var lookupAttr = new LookupAttributeMetadata(LookupFormat.None) { SchemaName = "foo_MyCustomLookupId" }; lookupAttr.SetSealedPropertyValue("IsCustomAttribute", true); lookupAttr.SetSealedPropertyValue("IsManaged", false); var attributes = new List <AttributeMetadata> { lookupAttr }; var solutionEntity = new SolutionEntity(entity, attributes, true); var rule = new RegexRule(_REGEX_PATTERN, scope); var results = rule.Validate(solutionEntity); Assert.Equal($"Rule: {rule.Description} Succeeded for entity \"My Entity\" (foo_MyEntity).", results.FormatValidationResult()); }
public void CustomLookupOnCustomUnmanagedEntityNotConformingRuleValidationMessage() { var entity = new EntityMetadata() { SchemaName = "foo_MyEntity", DisplayName = new Label() { UserLocalizedLabel = new LocalizedLabel("My Entity", 1033) } }; entity.SetSealedPropertyValue("IsManaged", false); entity.SetSealedPropertyValue("IsCustomEntity", true); var scope = RuleScope.Lookup; var lookupAttr = new LookupAttributeMetadata(LookupFormat.None) { SchemaName = "foo_MyCustomLookup" }; lookupAttr.SetSealedPropertyValue("IsCustomAttribute", true); lookupAttr.SetSealedPropertyValue("IsManaged", false); var attributes = new List <AttributeMetadata> { lookupAttr }; var solutionEntity = new SolutionEntity(entity, attributes, true); var rule = new RegexRule(_REGEX_PATTERN, scope); var results = rule.Validate(solutionEntity); Assert.Equal($"Rule failed: {rule.Description} Following lookups do not match given pattern: foo_MyCustomLookup.", results.FormatValidationResult()); }
public ActionResult Submit(Int32 id, FormCollection form) { ContestEntity contest = ViewData["Contest"] as ContestEntity; ProblemEntity problem = ContestProblemManager.GetProblem(contest.ContestID, id); SolutionEntity entity = new SolutionEntity() { ProblemID = problem.ProblemID, ContestID = contest.ContestID, ContestProblemID = id, SourceCode = form["code"], LanguageType = LanguageType.FromLanguageID(form["lang"]) }; Dictionary <String, Byte> supportLanguages = LanguageManager.GetSupportLanguages(contest.SupportLanguage); if (!supportLanguages.ContainsValue(entity.LanguageType.ID)) { return(RedirectToErrorMessagePage("This contest does not support this programming language.")); } String userip = this.GetCurrentUserIP(); if (!SolutionManager.InsertSolution(entity, userip)) { return(RedirectToErrorMessagePage("Failed to submit your solution!")); } return(RedirectToAction("List", "Status", new { area = "Contest", cid = contest.ContestID })); }
public void EnsureEntityFirstLetterIsCapitalLetterFailsTest() { EntityMetadata entity = new EntityMetadata() { SchemaName = "foobar_myMagnificientEntity", }; entity.SetSealedPropertyValue("IsManaged", false); entity.SetSealedPropertyValue("IsCustomEntity", true); List <AttributeMetadata> attributes = null; var isOwnedBySolution = true; var validSolutionEntity = new SolutionEntity(entity, attributes, isOwnedBySolution); var regexPattern = @"^[A-Za-z]+_[A-Z]{1}[a-z]{1}[A-Za-z]*$"; var scope = RuleScope.Entity; var ruleToTest = new RegexRule(regexPattern, scope); var results = ruleToTest.Validate(validSolutionEntity); Assert.False(results.Passed); }
public void ExcludeEntityFromCheck() { EntityMetadata entity = new EntityMetadata() { SchemaName = "foobar_myNotSoMagnificientEntity", }; entity.SetSealedPropertyValue("IsManaged", false); entity.SetSealedPropertyValue("IsCustomEntity", true); List <AttributeMetadata> attributes = null; var isOwnedBySolution = true; var validSolutionEntity = new SolutionEntity(entity, attributes, isOwnedBySolution); var regexPattern = @"^[A-Za-z]+_[A-Z]{1}[a-z]{1}[A-Za-z]*$"; var scope = RuleScope.Entity; var excludedEntities = new List <string> { "foobar_123", "foobar_myNotSoMagnificientEntity", "foobar_mySecondNotSoGreatAgainEntity" }; var ruleToTest = new RegexRule(regexPattern, scope, excludedEntities); var results = ruleToTest.Validate(validSolutionEntity); Assert.True(results.Passed); }
public void CustomLookupOnCustomUnmanagedEntityConformingRule() { var entity = new EntityMetadata() { SchemaName = "foo_MyEntity", }; entity.SetSealedPropertyValue("IsManaged", false); entity.SetSealedPropertyValue("IsCustomEntity", true); var scope = RuleScope.Lookup; var lookupAttr = new LookupAttributeMetadata(LookupFormat.None) { SchemaName = "foo_MyCustomLookupId" }; lookupAttr.SetSealedPropertyValue("IsCustomAttribute", true); lookupAttr.SetSealedPropertyValue("IsManaged", false); var attributes = new List <AttributeMetadata> { lookupAttr }; var solutionEntity = new SolutionEntity(entity, attributes, true); var rule = new RegexRule(_REGEX_PATTERN, scope); var results = rule.Validate(solutionEntity); Assert.True(results.Passed); }
public ActionResult Submit(Int32 id, FormCollection form) { SolutionEntity entity = new SolutionEntity() { ProblemID = id, SourceCode = form["code"], LanguageType = LanguageType.FromLanguageID(form["lang"]) }; Dictionary <String, Byte> supportLanguages = LanguageManager.MainSubmitSupportLanguages; if (!supportLanguages.ContainsValue(entity.LanguageType.ID)) { return(RedirectToErrorMessagePage("This problem does not support this programming language.")); } String userip = this.GetCurrentUserIP(); if (!SolutionManager.InsertSolution(entity, userip)) { return(RedirectToErrorMessagePage("Failed to submit your solution!")); } return(RedirectToAction("List", "Status")); }
/// <summary> /// 根据ID得到一个提交实体 /// </summary> /// <param name="id">提交ID</param> /// <returns>提交实体</returns> public static SolutionEntity GetSourceCode(Int32 id) { if (id <= 0) { throw new InvalidRequstException(RequestType.Solution); } SolutionEntity solu = SolutionRepository.Instance.GetEntity(id); if (solu == null) { throw new NullResponseException(RequestType.Solution); } else { solu.SourceCode = HtmlEncoder.HtmlEncode(solu.SourceCode); } if (!SolutionManager.CanViewSource(solu.UserName)) { throw new NoPermissionException("You have no privilege to view the code!"); } return(solu); }
public void ManagedCustomEntityMustBeSkippedTest() { EntityMetadata entity = new EntityMetadata() { SchemaName = "new_notconforming", }; entity.SetSealedPropertyValue("IsManaged", true); entity.SetSealedPropertyValue("IsCustomEntity", true); List <AttributeMetadata> attributes = null; var isOwnedBySolution = true; var validSolutionEntity = new SolutionEntity(entity, attributes, isOwnedBySolution); var regexPattern = @"^[A-Za-z]+_[A-Z]{1}[a-z]{1}[A-Za-z]*$"; var scope = RuleScope.Entity; var ruleToTest = new RegexRule(regexPattern, scope); var results = ruleToTest.Validate(validSolutionEntity); Assert.True(results.Passed); }
public static async Task ThenSolutionsHaveTheFollowingDetails(Table table) { var expectedSolutionDetails = table.CreateSet <SolutionTable>().Select(m => new { m.SolutionId, AboutUrl = string.IsNullOrWhiteSpace(m.AboutUrl) ? null : m.AboutUrl, Features = string.IsNullOrWhiteSpace(m.Features) ? null : m.Features, Summary = string.IsNullOrWhiteSpace(m.SummaryDescription) ? null : m.SummaryDescription, FullDescription = string.IsNullOrWhiteSpace(m.FullDescription) ? null : m.FullDescription, RoadMap = string.IsNullOrWhiteSpace(m.RoadMap) ? null : m.RoadMap, IntegrationsUrl = string.IsNullOrWhiteSpace(m.IntegrationsUrl) ? null : m.IntegrationsUrl, ImplementationDetail = string.IsNullOrWhiteSpace(m.ImplementationDetail) ? null : m.ImplementationDetail, ClientApplication = string.IsNullOrWhiteSpace(m.ClientApplication) ? null : JToken.Parse(m.ClientApplication).ToString(), Hosting = string.IsNullOrWhiteSpace(m.Hosting) ? null : JToken.Parse(m.Hosting).ToString(), }); var solutionDetails = await SolutionEntity.FetchAllAsync(); solutionDetails.Select(m => new { m.SolutionId, m.AboutUrl, m.Features, m.Summary, m.FullDescription, m.RoadMap, m.IntegrationsUrl, m.ImplementationDetail, ClientApplication = string.IsNullOrWhiteSpace(m.ClientApplication) ? null : JToken.Parse(m.ClientApplication).ToString(), Hosting = string.IsNullOrWhiteSpace(m.Hosting) ? null : JToken.Parse(m.Hosting).ToString(), }).Should().BeEquivalentTo(expectedSolutionDetails); }
/// <summary> /// 更新一条提交(更新所有评测信息) /// </summary> /// <param name="entity">对象实体</param> /// <param name="error">编译错误信息</param> /// <returns>是否成功更新</returns> public static Boolean JudgeUpdateSolutionAllResult(SolutionEntity entity, String error) { if (entity == null) { return(false); } lock (_updateLock) { entity.JudgeTime = DateTime.Now; if (SolutionRepository.Instance.UpdateEntity(entity, error) > 0) { if (entity.Result == ResultType.Accepted) { UserCache.RemoveUserTop10Cache(); } SolutionCache.RemoveAcceptedCodesCache(entity.UserName); SolutionCache.RemoveProblemIDListCache(entity.UserName, false); SolutionCache.RemoveProblemIDListCache(entity.UserName, true); return(true); } else { return(false); } } }
public async Task ShouldUpdateSupplierStatus() { await SolutionEntityBuilder.Create() .WithName("Solution1") .WithId(_solution1Id) .WithOnLastUpdated(_lastUpdated) .WithOrganisationId(_org1Id) .WithSupplierId(_supplierId) .WithSupplierStatusId(1) .Build() .InsertAsync() .ConfigureAwait(false); var mockUpdateSolutionSupplierStatusRequest = new Mock <IUpdateSolutionSupplierStatusRequest>(); mockUpdateSolutionSupplierStatusRequest.Setup(m => m.Id).Returns(_solution1Id); mockUpdateSolutionSupplierStatusRequest.Setup(m => m.SupplierStatusId).Returns(2); _solutionRepository.CheckExists(_solution1Id, new CancellationToken()).Result.Should().BeTrue(); await _solutionRepository.UpdateSupplierStatusAsync(mockUpdateSolutionSupplierStatusRequest.Object, new CancellationToken()).ConfigureAwait(false); var solution = await SolutionEntity.GetByIdAsync(_solution1Id) .ConfigureAwait(false); solution.Id.Should().Be(_solution1Id); (await solution.LastUpdated.SecondsFromNow().ConfigureAwait(false)).Should().BeLessOrEqualTo(5); solution.SupplierStatusId.Should().Be(2); }
public async Task ShouldUpdateSupplierStatus() { await CatalogueItemEntityBuilder .Create() .WithCatalogueItemId(_solution1Id) .WithName(_solution1Id) .WithPublishedStatusId((int)PublishedStatus.Published) .WithSupplierId(_supplierId) .Build() .InsertAsync(); await SolutionEntityBuilder.Create() .WithId(_solution1Id) .WithOnLastUpdated(_lastUpdated) .Build() .InsertAsync(); var mockUpdateSolutionSupplierStatusRequest = new Mock <IUpdateSolutionSupplierStatusRequest>(); mockUpdateSolutionSupplierStatusRequest.Setup(m => m.Id).Returns(_solution1Id); mockUpdateSolutionSupplierStatusRequest.Setup(m => m.SupplierStatusId).Returns(2); _solutionRepository.CheckExists(_solution1Id, new CancellationToken()).Result.Should().BeTrue(); await _solutionRepository.UpdateSupplierStatusAsync(mockUpdateSolutionSupplierStatusRequest.Object, new CancellationToken()); var solution = await SolutionEntity.GetByIdAsync(_solution1Id); solution.Id.Should().Be(_solution1Id); (await solution.LastUpdated.SecondsFromNow()).Should().BeLessOrEqualTo(5); }
private RegexValidationResult ValidateAttributes( SolutionEntity solutionEntity, IEnumerable <AttributeMetadata> attributesToCheck) { var failingAttributes = new List <AttributeMetadata>(); foreach (var attribute in attributesToCheck) { var attrFullname = $"{solutionEntity.Entity.SchemaName}.{attribute.SchemaName}"; if (_excludedSchemaNames.Contains(attrFullname)) { continue; } var pass = Pattern.IsMatch(attribute.SchemaName); if (!pass) { failingAttributes.Add(attribute); } } return(new RegexValidationResult(solutionEntity.Entity, failingAttributes, this)); }
/// <summary> /// See <see cref="CustomizationRuleBase.ValidateRule(SolutionEntity)"/>. /// </summary> protected override ValidationResult ValidateRule( SolutionEntity solutionEntity) { RegexValidationResult validationResult = null; switch (Scope) { case RuleScope.Entity: validationResult = ValidateEntityScope(solutionEntity); break; case RuleScope.Attribute: validationResult = ValidateAttributeScope(solutionEntity); break; case RuleScope.Lookup: validationResult = ValidateLookupScope(solutionEntity); break; default: throw new NotImplementedException( $"Implementation is missing for scope {Scope}."); } return(validationResult as ValidationResult); }
public void EntityFirstLetterIsCapitalLetterFailureDescriptionIsCorrectTest() { EntityMetadata entity = new EntityMetadata() { SchemaName = "foobar_myMagnificientEntity", DisplayName = new Label() { UserLocalizedLabel = new LocalizedLabel("Suurenmoinen entiteetti", 1035) } }; entity.SetSealedPropertyValue("IsManaged", false); entity.SetSealedPropertyValue("IsCustomEntity", true); List <AttributeMetadata> attributes = null; var isOwnedBySolution = true; var validSolutionEntity = new SolutionEntity(entity, attributes, isOwnedBySolution); var regexPattern = @"^[A-Za-z]+_[A-Z]{1}[a-z]{1}[A-Za-z]*$"; var scope = RuleScope.Entity; var ruleToTest = new RegexRule(regexPattern, scope); var results = ruleToTest.Validate(validSolutionEntity); Assert.Equal($"Rule failed: {ruleToTest.Description} Entity schema name {entity.SchemaName} doesn't match given pattern \"{regexPattern}\".", results.FormatValidationResult()); }
public static async Task ThenFieldSolutionSupplierStatusIdShouldCorrespondTo(string solutionId, string supplierStatusName) { var status = await SolutionSupplierStatusEntity.GetByNameAsync(supplierStatusName).ConfigureAwait(false); var solution = await SolutionEntity.GetByIdAsync(solutionId).ConfigureAwait(false); solution.SupplierStatusId.Should().Be(status.Id); }
/// <summary> /// 更新评测状态 /// </summary> /// <param name="sid">提交ID</param> /// <param name="pid">题目ID</param> /// <param name="username">用户名</param> /// <param name="result">评测结果</param> /// <param name="detail">出错信息</param> /// <param name="tcost">花费时间</param> /// <param name="mcost">花费内存</param> /// <param name="error">错误信息</param> /// <returns>是否更新成功</returns> public static Boolean TryUpdateSolutionStatus(String sid, String pid, String username, String result, String detail, String tcost, String mcost, out String error) { try { error = JudgeStatusManager.GetJudgeServerLoginStatus(); if (!String.IsNullOrEmpty(error)) { return(false); } SolutionEntity entity = new SolutionEntity() { SolutionID = Int32.Parse(sid), ProblemID = pid.ToInt32(0), UserName = username, Result = (ResultType)result.ToByte(0), TimeCost = tcost.ToInt32(0), MemoryCost = mcost.ToInt32(0) }; if (entity.Result > ResultType.Accepted)//评测失败 { Boolean hasProblemData = !String.IsNullOrEmpty(ProblemDataManager.GetProblemDataRealPath(entity.ProblemID)); //没有题目的不重新评测 Boolean canAutoRejudge = hasProblemData; Int32 triedTimes = 0; if (!_rejudgeTimesMap.TryGetValue(entity.SolutionID, out triedTimes)) { triedTimes = 0; } if (triedTimes > AUTO_REJUDGE_MAX_TIMES) { _rejudgeTimesMap.Remove(entity.SolutionID); canAutoRejudge = false; } else { _rejudgeTimesMap[entity.SolutionID] = triedTimes + 1; } entity.Result = canAutoRejudge ? ResultType.RejudgePending : ResultType.JudgeFailed; } SolutionManager.JudgeUpdateSolutionAllResult(entity, detail); return(true); } catch (System.Exception ex) { error = ex.Message; return(false); } }
private RegexValidationResult ValidateAttributeScope( SolutionEntity solutionEntity) { var attributesToCheck = solutionEntity.Attributes .Where(a => a.IsManaged != true && a.IsCustomAttribute == true); return(ValidateAttributes(solutionEntity, attributesToCheck)); }
public void RemoveSolution(SolutionEntity solution) { if (solution.Type == "Farm Solution") { var apps = _utility.GetAllWebApplications(); (solution.InternalObject as SPSolution).RetractLocal(apps); } }
public static async Task ThenSolutionsExist(Table table) { var expectedSolutions = table.CreateSet <SolutionUpdatedTable>(); var solutions = await SolutionEntity.FetchAllAsync(); solutions.Select(s => new { SolutionId = s.SolutionId, SolutionName = s.Name, }).Should().BeEquivalentTo(expectedSolutions); }
public void UnmanagedAttributesOnOobEntityWithIncorrectNamesFailureDescriptionIsCorrectTest() { EntityMetadata entity = new EntityMetadata() { SchemaName = "Account", DisplayName = new Label() { UserLocalizedLabel = new LocalizedLabel("Asiakas", 1035) } }; entity.SetSealedPropertyValue("IsManaged", true); entity.SetSealedPropertyValue("IsCustomEntity", false); var field1Metadata = new StringAttributeMetadata("foo_customField"); field1Metadata.SetSealedPropertyValue("IsManaged", false); field1Metadata.SetSealedPropertyValue("IsCustomAttribute", true); var field2Metadata = new StringAttributeMetadata("foo_c"); field2Metadata.SetSealedPropertyValue("IsManaged", false); field2Metadata.SetSealedPropertyValue("IsCustomAttribute", true); var field3Metadata = new StringAttributeMetadata("foo_CustomField"); field3Metadata.SetSealedPropertyValue("IsManaged", false); field3Metadata.SetSealedPropertyValue("IsCustomAttribute", true); var attributes = new List <AttributeMetadata> { field1Metadata, field2Metadata, field3Metadata }; var isOwnedBySolution = false; var validSolutionEntity = new SolutionEntity(entity, attributes, isOwnedBySolution); var regexPattern = @"^[A-Za-z]+_[A-Z]{1}[a-z]{1}[A-Za-z]*$"; var scope = RuleScope.Attribute; var ruleToTest = new RegexRule(regexPattern, scope); var results = ruleToTest.Validate(validSolutionEntity); Assert.Equal($"Rule failed: {ruleToTest.Description} " + "Following attributes do not match given pattern: " + "foo_customField, foo_c.", results.FormatValidationResult()); }
/// <summary> /// 增加一条提交 /// </summary> /// <param name="entity">对象实体</param> /// <param name="userip">用户IP</param> /// <returns>是否成功增加</returns> public static Boolean InsertSolution(SolutionEntity entity, String userip) { if (!UserManager.IsUserLogined) { throw new UserUnLoginException(); } if (String.IsNullOrEmpty(entity.SourceCode) || entity.SourceCode.Length < SolutionRepository.SOURCECODE_MINLEN) { throw new InvalidInputException("Code is too short!"); } if (entity.SourceCode.Length > SolutionRepository.SOURCECODE_MAXLEN) { throw new InvalidInputException("Code is too long!"); } if (LanguageType.IsNull(entity.LanguageType)) { throw new InvalidInputException("Language Type is INVALID!"); } if (!UserSubmitStatus.CheckLastSubmitSolutionTime(UserManager.CurrentUserName)) { throw new InvalidInputException(String.Format("You can not submit code more than twice in {0} seconds!", ConfigurationManager.SubmitInterval.ToString())); } ProblemEntity problem = ProblemManager.InternalGetProblemModel(entity.ProblemID); if (problem == null)//判断题目是否存在 { throw new NullResponseException(RequestType.Problem); } if (entity.ContestID <= 0 && problem.IsHide && !AdminManager.HasPermission(PermissionType.ProblemManage))//非竞赛下判断是否有权访问题目 { throw new NoPermissionException("You have no privilege to submit the problem!"); } entity.UserName = UserManager.CurrentUserName; entity.SubmitTime = DateTime.Now; entity.SubmitIP = userip; Boolean success = SolutionRepository.Instance.InsertEntity(entity) > 0; if (success) { ProblemCache.UpdateProblemCacheSubmitCount(entity.ProblemID, -1);//更新缓存 SolutionCache.RemoveProblemIDListCache(entity.UserName, true); } return(success); }
public SolutionEntityBuilder() { const string id = "SolutionId"; solutionEntity = new SolutionEntity { SolutionId = id, Version = "1.0.0", ServiceLevelAgreement = null, WorkOfPlan = null }; }
public void ExcludeUnmanagedAttributesWithIncorrectNamesFromValidationTest() { EntityMetadata entity = new EntityMetadata() { SchemaName = "Account", }; entity.SetSealedPropertyValue("IsManaged", true); entity.SetSealedPropertyValue("IsCustomEntity", false); var field1Metadata = new StringAttributeMetadata("foo_customField"); field1Metadata.SetSealedPropertyValue("IsManaged", false); field1Metadata.SetSealedPropertyValue("IsCustomAttribute", true); var field2Metadata = new StringAttributeMetadata("foo_c"); field2Metadata.SetSealedPropertyValue("IsManaged", false); field2Metadata.SetSealedPropertyValue("IsCustomAttribute", true); var field3Metadata = new StringAttributeMetadata("foo_CustomField"); field3Metadata.SetSealedPropertyValue("IsManaged", false); field3Metadata.SetSealedPropertyValue("IsCustomAttribute", true); var attributes = new List <AttributeMetadata> { field1Metadata, field2Metadata, field3Metadata }; var isOwnedBySolution = false; var validSolutionEntity = new SolutionEntity(entity, attributes, isOwnedBySolution); var regexPattern = @"^[A-Za-z]+_[A-Z]{1}[a-z]{1}[A-Za-z]*$"; var scope = RuleScope.Attribute; var excludedAttributes = new List <string> { "Account.foo_customField", "Account.foo_c" }; var ruleToTest = new RegexRule(regexPattern, scope, excludedAttributes); var results = ruleToTest.Validate(validSolutionEntity); Assert.True(results.Passed); }
/// <summary> /// See <see cref="CustomizationRuleBase.ValidateRule(SolutionEntity)"/>. /// </summary> protected override ValidationResult ValidateRule( SolutionEntity solutionEntity) { var customAttributes = solutionEntity.Attributes .Where(a => a.IsManaged == false && a.IsCustomAttribute == true); var attributeFailures = customAttributes.Where(a => !a.SchemaName .StartsWith(_schemaPrefix + "_")); return(new AttributeValidationResult(solutionEntity.Entity, attributeFailures, this)); }
/// <summary> /// See <see cref="CustomizationRuleBase.ValidateRule(SolutionEntity)"/>. /// </summary> protected override ValidationResult ValidateRule(SolutionEntity solutionEntity) { var result = true; if (!_allowSolutionToOwnManagedEntities && solutionEntity.IsOwnedBySolution && solutionEntity.Entity.IsManaged == true) { result = false; } return(new ValidationResult(solutionEntity.Entity, result, this)); }
private void GetFarmSolutions(string url, IList <SolutionEntity> result) { foreach (SPSolution s in SPFarm.Local.Solutions) { SolutionEntity entity = new SolutionEntity(); entity.Name = s.Name; entity.Type = "Farm Solution"; entity.SolutionGuid = s.Id; entity.Status = s.Status.ToString(); entity.InternalObject = s; entity.Site = "(none)"; result.Add(entity); } }
public static async Task GivenSolutionsAreLinkedToCapabilities(Table table) { var solutions = await SolutionEntity.FetchAllAsync().ConfigureAwait(false); var capabilities = await CapabilityEntity.FetchAllAsync().ConfigureAwait(false); foreach (var solutionCapabilityTable in table.CreateSet <SolutionCapabilityTable>()) { await SolutionCapabilityEntityBuilder.Create() .WithSolutionId(solutions.First(s => s.Name == solutionCapabilityTable.Solution).Id) .WithCapabilityId(capabilities.First(s => s.Name == solutionCapabilityTable.Capability).Id) .Build() .InsertAsync() .ConfigureAwait(false); } }