protected void Page_Load(object sender, EventArgs args) { KnowledgeBaseQuery.Attributes["placeholder"] = Html.SnippetLiteral("Knowledge Base Search Query Placeholder", "Search the knowledge base"); if (IsPostBack) { return; } KnowledgeBaseQuery.Text = Request.QueryString["kbquery"]; Tuple <string, Guid, SubjectSource> subjectName; if (TryGetSubjectName(out subjectName)) { SubjectId = subjectName.Item2; SubjectName = subjectName.Item1; KnowledgeBaseSubjectFilter.Items.Add(new ListItem(SubjectName, SubjectId.ToString()) { Selected = true }); KnowledgeBaseSubjectFilter.Items.Add(new ListItem(Html.SnippetLiteral("Knowledge Base Default Search Filter Text", "All Articles"), string.Empty)); Subject.Visible = true; } }
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary> /// <param name="isNew">是否插入</param> public override void Valid(Boolean isNew) { // 如果没有脏数据,则不需要进行任何处理 if (!HasDirty) { return; } // 这里验证参数范围,建议抛出参数异常,指定参数名,前端用户界面可以捕获参数异常并聚焦到对应的参数输入框 if (Key.IsNullOrEmpty()) { throw new ArgumentNullException(nameof(Key), "Key不能为空!"); } if (Type.IsNullOrEmpty()) { throw new ArgumentNullException(nameof(Type), "Type不能为空!"); } if (SubjectId.IsNullOrEmpty()) { throw new ArgumentNullException(nameof(SubjectId), "SubjectId不能为空!"); } if (ClientId.IsNullOrEmpty()) { throw new ArgumentNullException(nameof(ClientId), "ClientId不能为空!"); } if (Data.IsNullOrEmpty()) { throw new ArgumentNullException(nameof(Data), "Data不能为空!"); } // 在新插入数据或者修改了指定字段时进行修正 }
public override int GetHashCode() { int hash = 1; if (SubjectId.Length != 0) { hash ^= SubjectId.GetHashCode(); } if (Username.Length != 0) { hash ^= Username.GetHashCode(); } if (Message.Length != 0) { hash ^= Message.GetHashCode(); } if (created_ != null) { hash ^= Created.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public override int GetHashCode() { return(Tenant.GetHashCode() ^ SubjectId.GetHashCode() ^ ActionId.GetHashCode() ^ (ObjectId ?? string.Empty).GetHashCode() ^ Reaction.GetHashCode()); }
/// <inheritdoc /> protected override void AddAttributesToRender(HtmlTextWriter writer) { long uid = 0; long.TryParse(Uid, out uid); if (Uid == "0" && Uid != "profileowner" && Uid != "loggedinuser") { throw new MissingRequiredAttribute("FbUserID", Uid); } writer.AddAttribute("uid", Uid.ToString(CultureInfo.InvariantCulture)); if (!Linked) { writer.AddAttribute("linked", FbmlConstants.FALSE); } if (FirstNameOnly) { writer.AddAttribute("firstnameonly", FbmlConstants.TRUE); } else if (LastNameOnly) { writer.AddAttribute("lastnameonly", FbmlConstants.TRUE); } if (Possessive) { writer.AddAttribute("possessive", FbmlConstants.TRUE); } if (Reflexive) { writer.AddAttribute("reflexive", FbmlConstants.TRUE); } if (ShowNetwork) { writer.AddAttribute("shownetwork", FbmlConstants.TRUE); } if (!UseYou) { writer.AddAttribute("useyou", FbmlConstants.FALSE); } if (!string.IsNullOrEmpty(DisplayIfUserIsInaccessible)) { writer.AddAttribute("ifcantsee", DisplayIfUserIsInaccessible, true); } if (CapitalizeYou) { writer.AddAttribute("capitalize", FbmlConstants.TRUE); } if (SubjectId != 0) { writer.AddAttribute("subjectid", SubjectId.ToString(CultureInfo.InvariantCulture)); } base.AddAttributesToRender(writer); }
public static SubjectId GetSubjectId(long subjectId) { var subjectExistenceValidatorMock = new Mock <ISubjectExistenceValidator>(); subjectExistenceValidatorMock .Setup(validator => validator.Exist(It.IsAny <long>())) .Returns(true); return(SubjectId.Create(subjectId, subjectExistenceValidatorMock.Object).Value); }
private CreateExamCommand(SubjectId subjectId, LocationId locationId, UtcDateTime examDateTime, Capacity capacity, UtcDate registrationStartDate, UtcDate registrationEndDate) { SubjectId = subjectId; LocationId = locationId; ExamDateTime = examDateTime; Capacity = capacity; RegistrationStartDate = registrationStartDate; RegistrationEndDate = registrationEndDate; }
public override int GetHashCode() { var code = ClientId.GetHashCode() ^ CreationTime.GetHashCode() ^ Data.GetHashCode() ^ Expiration.GetHashCode() ^ Key.GetHashCode() ^ SubjectId.GetHashCode() ^ Type.GetHashCode(); return(code); }
private int GenerateHashCode() { unchecked { int hash = 17; hash = hash * 92821 + SubjectId.GetHashCode( ); hash = hash * 92821 + PermissionId.GetHashCode( ); return(hash); } }
private Exam(SubjectId subjectId, LocationId locationId, UtcDateTime examDateTime, Capacity capacity, UtcDate registrationStartDate, UtcDate registrationEndDate, ISystemTimeProvider systemTimeProvider) : this(systemTimeProvider) { LocationId = locationId; Capacity = capacity; Booked = Booked.Zero; SubjectId = subjectId; RegistrationStartDate = registrationStartDate; RegistrationEndDate = registrationEndDate; ExamDateTime = examDateTime; Status = ExamStatus.Planned; }
public bool Equals(PublishedItem other) { if (other == null || other.Publisher == null) { return(false); } return(SubjectId.Equals(other.SubjectId) && Identifier.Equals(other.Identifier) && PublisherTypeName.Equals(GetPublisherTypeName(other)) && PublisherIdentifier.Equals(other.Publisher.Identifier) && (PublisherAdditionalInfo?.Equals(other.Publisher.AdditionalInfo) ?? true)); }
public void Scenario(SubjectId subjectId, Action action) { "Given a subject identifier" .f(() => subjectId = new SubjectId { Value = "subjectId" }); "When a subject is created with that identifier" .f(() => action = () => new Subject(subjectId)); "Then that actions should throw an exception" .f(() => action.ShouldThrow <RuntimeException>()); }
public override int GetHashCode() { int hashCode = 552405456; hashCode = hashCode * -1521134295 + Id.GetHashCode(); hashCode = hashCode * -1521134295 + StudentId.GetHashCode(); hashCode = hashCode * -1521134295 + SubjectId.GetHashCode(); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Result); hashCode = hashCode * -1521134295 + WorkTypeId.GetHashCode(); hashCode = hashCode * -1521134295 + SessionSheduleId.GetHashCode(); return(hashCode); }
public void SetUp() { _subjectId = ValueObjectProvider.GetSubjectId(10); _locationId = ValueObjectProvider.GetLocationId(11); _capacity = Capacity.Create(15).Value; _systemTimeProvider = new Mock <ISystemTimeProvider>(); _systemTimeProvider.Setup(provider => provider.UtcNow) .Returns(new DateTime(2020, 02, 01, 00, 00, 00, DateTimeKind.Utc)); _examRepository = new Mock <IExamRepository>(); _examRepository.Setup(repository => repository.SaveAsync(It.IsAny <Exam>())) .Returns <Exam>(exam => Task.FromResult(Result.Ok(exam))); }
public override int GetHashCode() { int hash = 1; if (SubjectId.Length != 0) { hash ^= SubjectId.GetHashCode(); } hash ^= votes_.GetHashCode(); if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public static Task <Result <Exam> > CreateAsync(SubjectId subjectId, LocationId locationId, UtcDateTime examDateTime, Capacity capacity, UtcDate registrationStartDate, UtcDate registrationEndDate, ISystemTimeProvider systemTimeProvider, IExamRepository examRepository) { return(Result.Create(() => systemTimeProvider.UtcNow < registrationStartDate.Value, ExamCreationErrors.RegistrationStartDateHasToBeInTheFuture.Build()) .AndEnsure(() => registrationStartDate.Value < registrationEndDate.Value, ExamCreationErrors.RegistrationEndDateHasToBeAfterRegistrationStartDate.Build()) .AndEnsure(() => registrationEndDate.Value < examDateTime.Value.Date, ExamCreationErrors.RegistrationEndDateHasToBeBeforeExamDate.Build()) .OnSuccess(() => new Exam(subjectId, locationId, examDateTime, capacity, registrationStartDate, registrationEndDate, systemTimeProvider)) .OnSuccess(examRepository.SaveAsync) .OnSuccess(exam => exam.RaiseEvent(new ExamPlanned(exam.Id, systemTimeProvider.UtcNow)))); }
public void ShouldReturnExpectedResult(long subjectId, bool exist, bool isSuccess) { var subjectExistenceValidatorMock = new Mock <ISubjectExistenceValidator>(); subjectExistenceValidatorMock .Setup(validator => validator.Exist(It.IsAny <long>())) .Returns(exist); var subjectIdResult = SubjectId.Create(subjectId, subjectExistenceValidatorMock.Object); subjectIdResult.IsSuccess.Should().Be(isSuccess); if (isSuccess) { subjectIdResult.Value.Value.Should().Be(subjectId); } }
public IEnumerable <string> GetTags() { var subjectId = string.IsNullOrWhiteSpace(SubjectId) ? " " : SubjectId.Trim(); var clientId = string.IsNullOrWhiteSpace(ClientId) ? " " : ClientId.Trim(); var type = string.IsNullOrWhiteSpace(Type) ? " " : Type.Trim(); return(new List <string> { $"{subjectId}", $"{clientId}", $"{type}", "PersistedGrant" }.AsEnumerable()); }
public override int GetHashCode() { int hash = 1; if (SubjectId.Length != 0) { hash ^= SubjectId.GetHashCode(); } if (OptionName.Length != 0) { hash ^= OptionName.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary> /// <param name="isNew">是否插入</param> public override void Valid(Boolean isNew) { // 如果没有脏数据,则不需要进行任何处理 if (!HasDirty) { return; } // 这里验证参数范围,建议抛出参数异常,指定参数名,前端用户界面可以捕获参数异常并聚焦到对应的参数输入框 if (DeviceCode.IsNullOrEmpty()) { throw new ArgumentNullException(nameof(DeviceCode), "DeviceCode不能为空!"); } if (UserCode.IsNullOrEmpty()) { throw new ArgumentNullException(nameof(UserCode), "UserCode不能为空!"); } if (SubjectId.IsNullOrEmpty()) { throw new ArgumentNullException(nameof(SubjectId), "SubjectId不能为空!"); } if (ClientId.IsNullOrEmpty()) { throw new ArgumentNullException(nameof(ClientId), "ClientId不能为空!"); } if (CreationTime.IsNullOrEmpty()) { throw new ArgumentNullException(nameof(CreationTime), "CreationTime不能为空!"); } if (Expiration.IsNullOrEmpty()) { throw new ArgumentNullException(nameof(Expiration), "Expiration不能为空!"); } if (Data.IsNullOrEmpty()) { throw new ArgumentNullException(nameof(Data), "Data不能为空!"); } // 在新插入数据或者修改了指定字段时进行修正 // 检查唯一索引 // CheckExist(isNew, __.DeviceCode); // CheckExist(isNew, __.UserCode); }
/// <summary> /// Creates an IdentityServer claims principal /// </summary> /// <returns></returns> /// <exception cref="ArgumentNullException"></exception> public ClaimsPrincipal CreatePrincipal() { if (SubjectId.IsMissing()) { throw new ArgumentException("SubjectId is mandatory", nameof(SubjectId)); } var claims = new List <Claim> { new Claim(JwtClaimTypes.Subject, SubjectId) }; if (DisplayName.IsPresent()) { claims.Add(new Claim(JwtClaimTypes.Name, DisplayName)); } if (IdentityProvider.IsPresent()) { claims.Add(new Claim(JwtClaimTypes.IdentityProvider, IdentityProvider)); } if (Tenant.IsPresent()) { claims.Add(new Claim(IdentityServerConstants.ClaimTypes.Tenant, Tenant)); } if (AuthenticationTime.HasValue) { claims.Add(new Claim(JwtClaimTypes.AuthenticationTime, new DateTimeOffset(AuthenticationTime.Value).ToUnixTimeSeconds().ToString())); } if (AuthenticationMethods.Any()) { foreach (var amr in AuthenticationMethods) { claims.Add(new Claim(JwtClaimTypes.AuthenticationMethod, amr)); } } claims.AddRange(AdditionalClaims); var id = new ClaimsIdentity(claims.Distinct(new ClaimComparer()), Constants.IdentityServerAuthenticationType, JwtClaimTypes.Name, JwtClaimTypes.Role); return(new ClaimsPrincipal(id)); }
public override bool Equals(object obj) { var other = obj as PersistedGrantModel; if (other == null) { return(false); } var result = ClientId.SafeEquals(other.ClientId) && CreationTime.SafeEquals(other.CreationTime) && Data.SafeEquals(other.Data) && Expiration.SafeEquals(other.Expiration) && Key.SafeEquals(other.Key) && SubjectId.SafeEquals(other.SubjectId) && Type.SafeEquals(other.Type); return(result); }
/// <inheritdoc/> public string ToDelimitedString() { CultureInfo culture = CultureInfo.CurrentCulture; return(string.Format( culture, StringHelper.StringFormatSequence(0, 32, Configuration.FieldSeparator), Id, SetIdCer.HasValue ? SetIdCer.Value.ToString(culture) : null, SerialNumber, Version, GrantingAuthority?.ToDelimitedString(), IssuingAuthority?.ToDelimitedString(), Signature?.ToDelimitedString(), GrantingCountry, GrantingStateProvince?.ToDelimitedString(), GrantingCountyParish?.ToDelimitedString(), CertificateType?.ToDelimitedString(), CertificateDomain?.ToDelimitedString(), SubjectId?.ToDelimitedString(), SubjectName, SubjectDirectoryAttributeExtension != null ? string.Join(Configuration.FieldRepeatSeparator, SubjectDirectoryAttributeExtension.Select(x => x.ToDelimitedString())) : null, SubjectPublicKeyInfo?.ToDelimitedString(), AuthorityKeyIdentifier?.ToDelimitedString(), BasicConstraint, CrlDistributionPoint != null ? string.Join(Configuration.FieldRepeatSeparator, CrlDistributionPoint.Select(x => x.ToDelimitedString())) : null, JurisdictionCountry, JurisdictionStateProvince?.ToDelimitedString(), JurisdictionCountyParish?.ToDelimitedString(), JurisdictionBreadth != null ? string.Join(Configuration.FieldRepeatSeparator, JurisdictionBreadth.Select(x => x.ToDelimitedString())) : null, GrantingDate.HasValue ? GrantingDate.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null, IssuingDate.HasValue ? IssuingDate.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null, ActivationDate.HasValue ? ActivationDate.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null, InactivationDate.HasValue ? InactivationDate.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null, ExpirationDate.HasValue ? ExpirationDate.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null, RenewalDate.HasValue ? RenewalDate.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null, RevocationDate.HasValue ? RevocationDate.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null, RevocationReasonCode?.ToDelimitedString(), CertificateStatusCode?.ToDelimitedString() ).TrimEnd(Configuration.FieldSeparator.ToCharArray())); }
public static Result <CreateExamCommand> Create(CreateExamRequest request, ISubjectExistenceValidator subjectExistenceValidator, ILocationExistenceValidator locationExistenceValidator) { var subjectId = SubjectId.Create(request.SubjectId, subjectExistenceValidator) .BindErrorsTo(nameof(request.SubjectId)); var locationId = LocationId.Create(request.LocationId, locationExistenceValidator) .BindErrorsTo(nameof(request.LocationId)); var examDateTime = UtcDateTime.Create(request.ExamDateTime) .BindErrorsTo(nameof(request.ExamDateTime)); var capacity = Capacity.Create(request.Capacity) .BindErrorsTo(nameof(request.Capacity)); var registrationStartDate = UtcDate.Create(request.RegistrationStartDate) .BindErrorsTo(nameof(request.RegistrationStartDate)); var registrationEndDate = UtcDate.Create(request.RegistrationEndDate) .BindErrorsTo(nameof(request.RegistrationEndDate)); return(Result.Combine(subjectId, locationId, examDateTime, capacity, registrationStartDate, registrationEndDate) .OnSuccess(() => new CreateExamCommand(subjectId.Value, locationId.Value, examDateTime.Value, capacity.Value, registrationStartDate.Value, registrationEndDate.Value))); }
private void updateDisplay() { if (courseId == "") { DisplayText = ""; return; } if (courseId.Length > 14) { DisplayText = "S: " + courseId.Substring(0, 12) + "..\n"; } else { DisplayText = "S: " + courseId + "\n"; } if (subjectId.Length > 14) { DisplayText += "P: " + SubjectId.Substring(0, 12) + ".."; } else { DisplayText += "P: " + SubjectId; } }
internal Subject(SubjectId id, string name) { Id = id; Name = name; }
public bool Equals(RuleSubject other) { return (SubjectId.Equals(other.SubjectId) && SubjectType == other.SubjectType); }
public Subject(SubjectId id) { this.Apply(Map.ValueObject(id).ToEvent <NewSubject>()); }
//--------------------------------------------------------------------------------------------------------------------- public override void Store() { string sql = null; string valuesPrefix = String.Format("{0}, {1}{2}", Service.Id, StringUtils.EscapeSql(ServiceParameter.Name), SubjectType == ConfigurationSubjectType.Group || SubjectType == ConfigurationSubjectType.User ? ", " + SubjectId.ToString() : String.Empty ); if (values != null) { if (ServiceParameter.IsConstant) { sql = String.Format("({0}, {1})", valuesPrefix, StringUtils.EscapeSql(values) ); } else { string pair; int line = 0; StringReader valueReader = new StringReader(values); while ((pair = valueReader.ReadLine()) != null) { line++; int pos = pair.IndexOf('='); string caption = pair.Substring(0, pos).Trim(); string value = pair.Substring(pos + 1).Trim(); if (sql == null) { sql = String.Empty; } else { sql += ", "; } sql += String.Format("({0}, {1}, {2})", valuesPrefix, StringUtils.EscapeSql(caption), StringUtils.EscapeSql(value) ); } } } context.Execute( String.Format("DELETE FROM serviceconfig WHERE id_service={0} AND name={1} AND {2}", Service.Id, StringUtils.EscapeSql(ServiceParameter.Name), SubjectType == ConfigurationSubjectType.Group ? "id_grp=" + SubjectId : SubjectType == ConfigurationSubjectType.User ? "id_usr="******"true" ) ); if (sql != null) { sql = String.Format("INSERT INTO serviceconfig (id_service, name{0}, {1}value) VALUES {2};", SubjectType == ConfigurationSubjectType.Group ? ", id_grp" : SubjectType == ConfigurationSubjectType.User ? ", id_usr" : String.Empty, ServiceParameter.IsConstant ? String.Empty : "caption, ", sql ); //context.AddError(sql); context.Execute(sql); } }
private void Handle(NewSubject @event) { this.Id = Map.Event(@event).ToValueObject <SubjectId>(); }