private async Task OnFinish(EditContext editContext) { Console.WriteLine("开始提交表单[" + userEntity + "]."); messageStore = new ValidationMessageStore(editContext); await this.ValidatorByUsername(editContext); await this.ValidatorByPassword(editContext); if (editContext.GetValidationMessages().Any()) { editContext.NotifyValidationStateChanged(); messageStore.Clear(); return; } if (StringUtils.IsBlank(userId)) { userEntity.Password = DigestUtils.Md5Hex(userEntity.PasswordNew); } await this.userService.SaveAsync(userEntity); _ = base.FeedbackRef.CloseAsync(); }
public void ShouldAggregateAndFilter() { var result = ExecuteScan("bookId=1&bizDate-granularity=daily"); var objs = SortByBizDateAndBook(result); var expected = new JArray( JObject.FromObject(new { version = DigestUtils.Md5Hex("v1" + "v4"), attributes = new { bizDate = "2010-01-15", bookId = "1" } }), JObject.FromObject(new { version = DigestUtils.Md5Hex("v2"), attributes = new { bizDate = "2010-01-16", bookId = "1" } }) ); AssertJsonEqual(expected, objs); }
public void ShouldBucketByHundreds() { var buckets = new Dictionary <string, string> { { "someInt", "100s" } }; var builder = new DigestBuilder(buckets); builder.Add("id1", new Dictionary <string, string> { { "someInt", "123" } }, "vsn1"); builder.Add("id2", new Dictionary <string, string> { { "someInt", "234" } }, "vsn2"); builder.Add("id3", new Dictionary <string, string> { { "someInt", "125" } }, "vsn3"); var expected = new List <AggregateDigest> { new AggregateDigest(new List <string> { "100" }, DigestUtils.Md5Hex("vsn1" + "vsn3")), new AggregateDigest(new List <string> { "200" }, DigestUtils.Md5Hex("vsn2")) }; var aggregateDigests = builder.GetDigests(); // TODO fudged because Assert.AreEqual did not seem to work as expected on the actual AggregateDigest objects Assert.AreEqual(expected[0].Attributes, aggregateDigests[0].Attributes); Assert.AreEqual(expected[0].Digest, aggregateDigests[0].Digest); Assert.AreEqual(expected[1].Attributes, aggregateDigests[1].Attributes); Assert.AreEqual(expected[1].Digest, aggregateDigests[1].Digest); }
/// <summary> /// Returns a tracking identifier that can be used to associate usages of a /// token across multiple client sessions. /// </summary> /// <remarks> /// Returns a tracking identifier that can be used to associate usages of a /// token across multiple client sessions. /// Currently, this function just returns an MD5 of { /// <see cref="GetBytes()"/> /// . /// </remarks> /// <returns>tracking identifier</returns> public virtual string GetTrackingId() { if (trackingId == null) { trackingId = DigestUtils.Md5Hex(GetBytes()); } return(trackingId); }
public ScanResultEntry ToScanResultEntry() { if (_digest == null) { _digest = DigestUtils.Md5Hex(_builder.ToString()); } return(ScanResultEntry.ForAggregate(Attributes, _digest)); }
public AggregateDigest ToDigest() { if (_digest == null) { _digest = DigestUtils.Md5Hex(_builder.ToString()); } var keys = Attributes.Keys.ToArray(); Array.Sort(keys); var attributes = keys.Select(key => Attributes[key]).ToList(); return(new AggregateDigest(attributes, _digest)); }
public void ShouldBucketByMonth() { var buckets = new Dictionary <string, string> { { "bizDate", "monthly" } }; var builder = new DigestBuilder(buckets); var lastUpdated = DateTime.Parse("2011-02-02T14:23:44.426Z"); builder.Add("id1", new Dictionary <string, string> { { "bizDate", "2010-08-16" } }, "vsn1"); builder.Add("id2", new Dictionary <string, string> { { "bizDate", "2010-07-14" } }, "vsn2"); builder.Add("id3", new Dictionary <string, string> { { "bizDate", "2010-08-09" } }, "vsn3"); var expected = new List <AggregateDigest> { new AggregateDigest(new List <string> { "2010-07" }, DigestUtils.Md5Hex("vsn2")), new AggregateDigest(new List <string> { "2010-08" }, DigestUtils.Md5Hex("vsn1" + "vsn3")) }; var aggregateDigests = builder.GetDigests(); // TODO fudged because Assert.AreEqual did not seem to work as expected on the actual AggregateDigest objects Assert.AreEqual(expected[0].Attributes, aggregateDigests[0].Attributes); Assert.AreEqual(expected[0].Digest, aggregateDigests[0].Digest); Assert.AreEqual(expected[1].Attributes, aggregateDigests[1].Attributes); Assert.AreEqual(expected[1].Digest, aggregateDigests[1].Digest); }