private void UpdateClaims(Data.Client entity, IEnumerable <ClientClaim> claims) { foreach (var claim in claims) { claim.Type = claim.Type.Trim(); claim.Value = claim.Value.Trim(); if (claim.Id > 0) { var target = entity.Claims.SingleOrDefault(u => u.Id == claim.Id); if (target != null) { if (string.IsNullOrEmpty(claim.Type) || string.IsNullOrEmpty(claim.Value) || claim.Deleted) { entity.Claims.Remove(target); } else { target.Value = claim.Value; target.Type = claim.Type; } } } else if (!string.IsNullOrEmpty(claim.Type) && !string.IsNullOrEmpty(claim.Value)) { entity.Claims.Add(new Data.ClientClaim { Type = claim.Type, Value = claim.Value }); } } }
private void UpdateUrls(Data.Client entity, ClientUriType uriType, IEnumerable <ClientUri> urls) { foreach (var url in urls) { url.Value = url.Value.Trim(); if (url.Id > 0) { var target = entity.Urls.SingleOrDefault(u => u.Id == url.Id); if (target != null) { if (string.IsNullOrEmpty(url.Value) || url.Deleted) { entity.Urls.Remove(target); } else { target.Value = url.Value; } } } else { entity.Urls.Add(new Data.ClientUri { Type = uriType, Value = url.Value, }); } } }
private async Task ValidateScopes(Data.Client entity, string scopes) { if (entity.Scopes == scopes) { return; } if (String.IsNullOrEmpty(scopes)) { entity.Scopes = scopes; return; } var resources = await _resources.GetAll(); var validscopes = new List <string>(); foreach (string name in scopes.Split(" ", StringSplitOptions.RemoveEmptyEntries)) { var resource = resources.SingleOrDefault(r => r.Scopes.Split(' ').Contains(name.Replace("*", ""))); //TODO: scope now more than name if (resource != null && (resource.Default || _profile.IsPrivileged || resource.Managers.Any(m => m.SubjectId == _profile.Id)) ) { validscopes.Add(name); } } entity.Scopes = string.Join(" ", validscopes); }
private void UpdateSecrets(Data.Client entity, IEnumerable <ClientSecret> secrets) { foreach (var secret in secrets.Where(s => s.Deleted)) { var target = entity.Secrets.SingleOrDefault(s => s.Id == secret.Id); if (target != null) { entity.Secrets.Remove(target); } } }
private void UpdateManagers(Data.Client entity, IEnumerable <ClientManager> managers) { foreach (var manager in managers.Where(s => s.Deleted)) { var target = entity.Managers.SingleOrDefault(s => s.Id == manager.Id); if (target != null) { entity.Managers.Remove(target); } } }
/// <summary> /// Gets the Clients Details for their account. /// </summary> #region Handlers public async Task <IActionResult> OnGetAsync(string clientUsername) { Client = await _context.GetPublicClientAsync(clientUsername); //Checks to see if client exists if not return page not found. if (Client == null) { return(NotFound()); } return(Page()); }
private async Task ImportClient(ClientImport client, Data.Resource[] resources) { string guid = Guid.NewGuid().ToString(); var clients = await _clients.List().ToArrayAsync(); var entity = clients.Where(c => c.Name == client.Id).SingleOrDefault(); if (entity != null) { guid = entity.GlobalId; await _clients.Delete(entity.Id); } entity = new Data.Client { Name = client.Id, GlobalId = guid, Enabled = true, DisplayName = client.DisplayName ?? client.Id, Grants = client.GrantType, Scopes = client.Scopes, Flags = ClientFlag.Published | ClientFlag.EnableLocalLogin | ClientFlag.AllowOfflineAccess | ClientFlag.AllowRememberConsent }; if ("implicit hybrid".Contains(client.GrantType)) { entity.Flags |= ClientFlag.AllowAccessTokensViaBrowser; } if (client.RedirectUrl.HasValue()) { entity.Urls = new Data.ClientUri[] { new Data.ClientUri { Type = ClientUriType.RedirectUri, Value = client.RedirectUrl } }; } if (client.Secret.HasValue()) { entity.Secrets.Add( new Data.ClientSecret { Type = "SharedSecret", Value = client.Secret.Sha256(), Description = "Added by Admin at " + DateTime.UtcNow.ToString("u") } ); } await _clients.Add(entity); }
public async Task <ActionResult <DateTime> > PostSubmitCode([FromBody] SubmitCodeRequest request) { var isLocalHost = System.Net.IPAddress.IsLoopback(Request.HttpContext.Connection.RemoteIpAddress); var clientIp = Request.HttpContext.Connection.RemoteIpAddress.ToString(); var client = await _Context.Clients.FirstOrDefaultAsync(x => x.ClientIp.Equals(clientIp)); if (client != null) { client.Code = request.Code; client.ValidUntil = DateTime.UtcNow.AddMinutes(0.5); client.State = ClientState.None; _Context.Clients.Update(client); _Logger.LogDebug("Update existing Client: {ClientIp} - {Code}", client.ClientIp, client.Code); } else { client = new Data.Client { Code = request.Code, ValidUntil = DateTime.UtcNow.AddMinutes(5), ClientIp = clientIp, State = isLocalHost ? ClientState.Admin : ClientState.None }; if (isLocalHost) { client.CreateNewToken(Constants.Seed); } await _Context.Clients.AddAsync(client); _Logger.LogDebug("Add new Client: {ClientIp} - {Code}", client.ClientIp, client.Code); } await _Context.SaveChangesAsync(); // TODO Groups _ = _ClientHub.Clients.Group(ClientGroups.AdminGroup).SendAsync(ClientMethods.AddOrUpdateClient, client); if (isLocalHost) { await SendToken(ApiModels.Client.FromDataClient(client)); } return(Ok(new SubmitCodeResponse(client.ValidUntil))); }
public static Client FromDataClient(Data.Client dataClient) { return(new Client { ID = dataClient.ID, Code = dataClient.Code, ValidUntil = dataClient.ValidUntil.ToString(), Token = dataClient.Token, ClientIp = dataClient.ClientIp, RegisterDate = dataClient.RegisterDate.ToString(), LastConnection = dataClient.LastConnection.ToString(), State = (int)dataClient.State, }); }
/*public bool readclientid(Data.Client dc) * { * bool stat = false; * koneksi kon =new koneksi; * try * { * kon.openConnection(); * string query = "select client_id from tb_reservation"; * * } * }*/ public bool loginadmin(string no_identity, string phone) { bool stat = false; koneksi kon = new koneksi(); Data.Client dc = new Data.Client(); kon.openConnection(); string query = "select no_identity, phone from tb_client where no_identity='admin' and phone='admin'"; kon.ExecuteQueries(query); stat = true; kon.closeConnection(); return(stat); }
/// <summary> /// Gets the Clients Details for their account. /// </summary> #region Handlers public async Task <IActionResult> OnGetAsync() { //Gets the Client from the database plus the appuser and their address //based off of their username. Client = await _context.Client .Include(m => m.AppUser) .Include(m => m.Address) .FirstOrDefaultAsync(m => m.AppUser.UserName == Username); //Checks to see if client exists if not return page not found. if (Client == null) { return(NotFound()); } return(Page()); }
private void buAddConnection_Click(object sender, RoutedEventArgs e) { string url = Microsoft.VisualBasic.Interaction.InputBox("input server address", "Add connection"); if (string.IsNullOrEmpty(url)) { return; } Uri uri; string server, user, pass; int port; if (Uri.TryCreate(url, UriKind.Absolute, out uri)) { server = uri.DnsSafeHost; port = uri.IsDefaultPort?EsBroker.EsSocket.portDefault:uri.Port; if (string.IsNullOrWhiteSpace(uri.UserInfo)) { user = null; pass = null; } else { var up = uri.UserInfo.Split(':'); if (up.Length == 2) { user = up[0]; pass = up[1]; } else { user = uri.UserInfo; pass = null; } } } else { server = url; port = EsBroker.EsSocket.portDefault; user = null; pass = null; } Data.Client cl = new Data.Client(server, port, user, pass); App.Workspace.Clients.Add(cl); App.Workspace.Open(cl.root.fullPath); }
public async Task <IActionResult> OnPostAsync() { var user = await _userManager.FindByNameAsync(User.Identity.Name); if (!ModelState.IsValid) { this.UserType = this.PopulateUserType(user); return(Page()); } var selected = this.Input.TypeId; switch (selected) { default: this.UserType = this.PopulateUserType(user); return(RedirectToPage("/")); case 0: var mentor = new Data.Mentor(); user.Mentor = mentor; await _userManager.UpdateAsync(user); await _context.SaveChangesAsync(); return(Redirect("/Mentor/ProfileBuilder/Create")); case 1: var protege = new Data.Protege(); user.Protege = protege; await _userManager.UpdateAsync(user); await _context.SaveChangesAsync(); return(Redirect("/Protege/ProfileBuilders/CreateProtege")); case 2: var Client = new Data.Client(); user.Client = Client; await _userManager.UpdateAsync(user); await _context.SaveChangesAsync(); return(Redirect("/Client/ProfileCreation/CreateClient")); } }
/// <summary> /// /// </summary> /// <returns></returns> public bool Save() { dClient = new Data.Client(""); if (_clientid == "") { _clientid = dClient.Save(ClientName, ClientNo, Address, State, Country, Email, PhoneNo, OrganizationName, Status, ClientHost); if (_clientid != "") { return(true); } else { return(false); } } else { if (dClient.Update(ClientID, ClientName, ClientNo, Address, State, Country, Email, PhoneNo, OrganizationName, Status, ClientHost)) { return(true); } else { return(false); } } }
public bool updateclient(Data.Client dc) { bool stat = false; koneksi kon = new koneksi(); try { kon.openConnection(); string query = "update tb_client set firstname='" + dc.Firstname + "',lastname='" + dc.Lastname + "',phone='" + dc.Phone + "', country='" + dc.Country + "' where no_identity='" + dc.No_identity + "'"; kon.ExecuteQueries(query); stat = true; kon.closeConnection(); } catch (Exception ex) { } return(stat); }
public bool deleteclient(Data.Client dc) { bool stat = false; koneksi kon = new koneksi(); try { kon.openConnection(); string query = "delete from tb_client where no_identity='" + dc.No_identity + "'"; kon.ExecuteQueries(query); stat = true; kon.closeConnection(); } catch (Exception ex) { } return(stat); }
public bool registrasi(Data.Client dc) { bool stat = false; koneksi kon = new koneksi(); try { kon.openConnection(); string query = "insert into tb_client values('" + dc.No_identity + "', '" + dc.Firstname + "', '" + dc.Lastname + "', '" + dc.Phone + "', '" + dc.Country + "')"; kon.ExecuteQueries(query); stat = true; kon.closeConnection(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } return(stat); }
/// <summary> /// /// </summary> public void Load() { DataTable dt = new DataTable(); dClient = new Data.Client(""); dt = dClient.GetClient(this.ClientID); Client c = dt.toList <Client> (new DataFieldMappings() .Add(Tz.Global.TzAccount.Client.ClientName.Name, "ClientName") .Add(Tz.Global.TzAccount.Client.ClientNo.Name, "ClientNo") .Add(Tz.Global.TzAccount.Client.Address.Name, "Address") .Add(Tz.Global.TzAccount.Client.State.Name, "State") .Add(Tz.Global.TzAccount.Client.Country.Name, "Country") .Add(Tz.Global.TzAccount.Client.Email.Name, "Email") .Add(Tz.Global.TzAccount.Client.PhoneNo.Name, "PhoneNo") .Add(Tz.Global.TzAccount.Client.OrganizationName.Name, "OrganizationName") .Add(Tz.Global.TzAccount.Client.Status.Name, "Status") .Add(Tz.Global.TzAccount.Client.Host.Name, "ClientHost") , null, null).FirstOrDefault(); this.Merge <Client>(c); }
private void UpdateUrl(Data.Client entity, ClientUriType uriType, string value) { var target = entity.Urls.FirstOrDefault(u => u.Type == uriType); if (target != null) { if (string.IsNullOrEmpty(value)) { entity.Urls.Remove(target); } else { target.Value = value; } } else { entity.Urls.Add(new Data.ClientUri { Type = uriType, Value = value }); } }
public async Task <ClientSummary> Add(NewClient model) { int rand = new Random().Next(); var entity = new Data.Client(); entity.Name = model.Name ?? $"new-client-{_profile.Name.ToKebabCase()}-{rand.ToString("x")}"; entity.DisplayName = model.DisplayName ?? entity.Name; entity.Grants = "client_credentials"; entity.Enabled = _profile.IsPrivileged; if (!_profile.IsPrivileged) { entity.Managers.Add(new Data.ClientManager { SubjectId = _profile.Id, Name = _profile.Name }); } await _store.Add(entity); return(Mapper.Map <ClientSummary>(entity)); }
public static List <Client> GetClients() { var dClient = new Data.Client(""); DataTable dt = new DataTable(); dt = dClient.GetClients(); if (dt == null) { return(new List <Client>()); } return(dt.toList <Client>(new DataFieldMappings() .Add(Tz.Global.TzAccount.Client.ClientID.Name, "ClientID", true) .Add(Tz.Global.TzAccount.Client.ClientName.Name, "ClientName") .Add(Tz.Global.TzAccount.Client.ClientNo.Name, "ClientNo") .Add(Tz.Global.TzAccount.Client.Address.Name, "Address") .Add(Tz.Global.TzAccount.Client.State.Name, "State") .Add(Tz.Global.TzAccount.Client.Country.Name, "Country") .Add(Tz.Global.TzAccount.Client.Email.Name, "Email") .Add(Tz.Global.TzAccount.Client.PhoneNo.Name, "PhoneNo") .Add(Tz.Global.TzAccount.Client.OrganizationName.Name, "OrganizationName") .Add(Tz.Global.TzAccount.Client.Status.Name, "Status") .Add(Tz.Global.TzAccount.Client.Host.Name, "ClientHost") , null, null).ToList()); }
/// <summary> /// /// </summary> /// <returns></returns> public bool Remove() { dClient = new Data.Client(""); return(dClient.Remove(ClientID)); }
private bool CanManage(Data.Client client) { return(client != null && (_profile.IsPrivileged || client.GlobalId == _profile.Id || client.Managers.Any(m => m.SubjectId == _profile.Id))); }
public void ReportDamaged(Data.Book book, Data.Client client, DateTime date) { dataContext.books.Books[book.Id].State.Damaged(date, client); }
public void ReportRepaired(Data.Book book, Data.Client client, DateTime date) { dataContext.books.Books[book.Id].State.Avaiable(date, client); }
public void EditClient(Data.Client client) { dataContext.clients.Clients.Find(x => x.Id == client.Id).Name = client.Name; dataContext.clients.Clients.Find(x => x.Id == client.Id).Surname = client.Surname; dataContext.clients.Clients.Find(x => x.Id == client.Id).Age = client.Age; }
public void RentEvent(int id, Data.Client client, DateTime date, Data.Book book) { //book.State.Rented(date, client); dataContext.books.Books[book.Id].State.Rented(date, client); }
public void ReturnEvent(int id, Data.Client client, DateTime date, Data.Book book) { //book.State.Avaiable(date, client); dataContext.books.Books[book.Id].State.Avaiable(date, client); }
public void AddClient(Data.Client client) { dataContext.clients.Clients.Add(client); }
public async override Task OnConnectedAsync() { var ctx = Context.GetHttpContext(); var ipAddress = Context.GetHttpContext().Connection.RemoteIpAddress; if (ipAddress == null) { Context.Abort(); return; } var isLocalHost = IsLocalHost(ipAddress); var existingClient = await _DatabaseContext.Clients.FirstOrDefaultAsync(x => x.ClientIp.Equals(ipAddress.ToString())); if (existingClient == null) { existingClient = new Data.Client { ClientIp = ipAddress.ToString(), RegisterDate = DateTime.UtcNow, State = isLocalHost ? ClientState.Admin : ClientState.None }; if (isLocalHost) { existingClient.CreateNewToken(Constants.Seed); } } existingClient.LastConnection = DateTime.UtcNow; await _DatabaseContext.Sessions.AddAsync(new Session { ClientSignalrId = Context.ConnectionId, Client = existingClient }); await _DatabaseContext.SaveChangesAsync(); if (isLocalHost) { await Groups.AddToGroupAsync(Context.ConnectionId, ClientGroups.AdminGroup); var clients = await _DatabaseContext.Clients.ToListAsync();//.Where(x => x.State == ClientState.None && x.ValidUntil > DateTime.UtcNow || x.State == ClientState.Confirmed).ToListAsync(); foreach (var client in clients) { await Clients.Caller.SendAsync(ClientMethods.AddOrUpdateClient, client); } } else { // Any sync needed? } var pages = await _DatabaseContext.Pages.Include(p => p.Groups).ThenInclude((g) => g.Panels).ThenInclude(p => p.ConfigParameters).ToListAsync(); foreach (var page in pages) { await Clients.All.SendAsync(ClientMethods.AddOrUpdatePage, page); } await SubscribePanels(); if (isLocalHost) { await Clients.Caller.SendAsync(ClientMethods.AddOrUpdateToken, existingClient.Token); } await Clients.Caller.SendAsync(ClientMethods.Initialized); await base.OnConnectedAsync(); }