private ExtendedClient GetSelectedClient() { if (clientsGrid.SelectedRows.Count == 1) { ExtendedClient client = clientsGrid.SelectedRows[0].DataBoundItem as ExtendedClient; return(client); } else { return(null); } }
protected override void EditRecord() { ExtendedClient selectedClient = GetSelectedClient(); if (selectedClient != null) { FormClientDetail form = new FormClientDetail(); if (form.OpenRecord(selectedClient.ClientId)) { form.ShowDialog(); RefreshData(); } } }
public void CheckDownloadUrl(bool isCanceled, bool force = false) { if (Download.FileCache.DataLoaded && !force && Download.FileCache.Urlchecked) { return; } if (isCanceled) { return; } InitializeUrl(force); using (ExtendedClient exist = new ExtendedClient { HeadOnly = true }) { try { bool fduNull = Download.FullDownloadUrl == null; if (!fduNull) { exist.DownloadStringAsync(Download.FullDownloadUrl, isCanceled); } Download.FileCache.DownloadUrl = Download.FullDownloadUrl; Download.FileCache.ProductId = ProductId; Download.FileCache.Urlchecked = true; if (!fduNull) { Download.FileCache.Reason = "True"; } Download.FileCache.Save(); } catch (Exception e) { Console.WriteLine(e.ToString()); Download.FileCache.DownloadUrl = Download.FullDownloadUrl; Download.FileCache.ProductId = ProductId; Download.FileCache.Urlchecked = true; Download.FileCache.Reason = "Invalid"; Download.FileCache.Save(); } finally { exist.Dispose(); } } }
public void ToSimpleEntity_WhenComplexEntityAndExtendedComplex_ExpectMapSuccess() { // Arrange var mockClaimsMapper = new Mock<IMapper<SimpleClaim, Claim>>(); var mockPropertyMapper = new Mock<IPropertyGetSettersTyped<ExtendedClient>>(); mockClaimsMapper.Setup(r => r.ToSimpleEntity(It.IsAny<IEnumerable<Claim>>())).Returns(new List<SimpleClaim> { new SimpleClaim() }); var mockGetters = new Dictionary<string, Func<ExtendedClient, object>> { { "CustomDate", typeof(ExtendedClient).GetProperty("CustomDate").GetGetter<ExtendedClient>() } }; mockPropertyMapper.Setup(r => r.GetGetters(It.IsAny<Type>())).Returns(mockGetters); var clientMappers = new ClientMappers<ExtendedClient>(mockClaimsMapper.Object, mockPropertyMapper.Object); var secret = new Secret("Value", "Description", new DateTimeOffset(new DateTime(2016, 1, 1))) { Type = "Type" }; var client = new ExtendedClient { Claims = new List<Claim>(), Enabled = true, AccessTokenType = AccessTokenType.Jwt, AbsoluteRefreshTokenLifetime = 1, AccessTokenLifetime = 1, AllowAccessToAllCustomGrantTypes = true, AllowAccessToAllScopes = true, AllowRememberConsent = true, EnableLocalLogin = true, AllowAccessTokensViaBrowser = true, LogoutSessionRequired = true, Flow = Flows.AuthorizationCode, AlwaysSendClientClaims = true, PrefixClientClaims = true, ClientSecrets = new List<Secret> { secret }, RefreshTokenExpiration = TokenExpiration.Absolute, RequireSignOutPrompt = true, RefreshTokenUsage = TokenUsage.OneTimeOnly, IdentityTokenLifetime = 1, SlidingRefreshTokenLifetime = 1, RequireConsent = true, AllowClientCredentialsOnly = true, IncludeJwtId = true, AuthorizationCodeLifetime = 1, UpdateAccessTokenClaimsOnRefresh = true, ClientName = "ClientName", LogoutUri = "LogoutUri", RedirectUris = new List<string>(), ClientUri = "ClientUri", AllowedCustomGrantTypes = new List<string>(), AllowedScopes = new List<string>(), ClientId = "ClientId", PostLogoutRedirectUris = new List<string>(), AllowedCorsOrigins = new List<string>(), IdentityProviderRestrictions = new List<string>(), LogoUri = "LogoUri", CustomDate = new DateTime(2016, 1, 1) }; // Act var stopwatch = Stopwatch.StartNew(); var simpleEntity = clientMappers.ToSimpleEntity(client); stopwatch.Stop(); // Assert this.WriteTimeElapsed(stopwatch); Assert.That(simpleEntity, Is.Not.Null); Assert.That(simpleEntity.DataBag["CustomDate"], Is.EqualTo(new DateTime(2016, 1, 1))); }