public virtual void AddAllowedUser(int enviromentId, System.Guid userId) { if (AllowedUsers.Count(x => x.EnviromentId == enviromentId && x.UserId == userId.ToString()) == 0) { AllowedUsers.Add(new AllowedUser() { ApplicationId = this.Id, EnviromentId = enviromentId, UserId = userId.ToString() }); } }
public async Task InitializeAuthorizedUsers() { allUsers = await _azureDataService.GetAllUsers(); _authUsers = await _azureDataService.GetAllAuthUsers(); foreach (var currUserID in _authUsers) { var currUser = allUsers.Where(item => item.id == currUserID.AuthorizedToViewUserID).ToList(); if (currUser != null && currUser.Count > 0) { AllowedUsers.Add(currUser[0]); } } }
/// <summary> /// try add allowed user /// </summary> /// <returns>true if request is success,else returns false</returns> private async Task <bool> TryAddAllowedUser(string username, Test test) { var request = JsonConvert.SerializeObject(new AddTestAccessRequest(username, test)); var response = await StaticProperties.Client.PostAsync("/test/addTestAllowedUser/", new StringContent(request, Encoding.UTF8, "application/json")); if (response.IsSuccessStatusCode) { AllowedUsers.Add(username); UpdateFilteredAllowedUserList(AllowedUsersFilter); return(true); } else { return(false); } }
/// <summary> /// /// </summary> /// <param name="Document"></param> public override void ReadXml(XmlDocument Document) { // read baseclass part base.ReadXml(Document); ushort val_ushort; uint val_uint; XmlNode node; AdminCommands.Clear(); AllowedUsers.Clear(); RelayBots.Clear(); // bot node = Document.DocumentElement.SelectSingleNode( '/' + XMLTAG_CONFIGURATION + '/' + XMLTAG_BOT); if (node != null) { IRCServer = (node.Attributes[XMLATTRIB_IRCSERVER] != null) ? node.Attributes[XMLATTRIB_IRCSERVER].Value : DEFAULTVAL_IRCBOT_IRCSERVER; IRCPort = (node.Attributes[XMLATTRIB_IRCPORT] != null && UInt16.TryParse(node.Attributes[XMLATTRIB_IRCPORT].Value, out val_ushort)) ? val_ushort : DEFAULTVAL_IRCBOT_IRCPORT; Channel = (node.Attributes[XMLATTRIB_CHANNEL] != null) ? node.Attributes[XMLATTRIB_CHANNEL].Value : DEFAULTVAL_IRCBOT_CHANNEL; NickName = (node.Attributes[XMLATTRIB_NICKNAME] != null) ? node.Attributes[XMLATTRIB_NICKNAME].Value : DEFAULTVAL_IRCBOT_NICKNAME; IRCPassword = (node.Attributes[XMLATTRIB_IRCPASSWORD] != null) ? node.Attributes[XMLATTRIB_IRCPASSWORD].Value : DEFAULTVAL_IRCBOT_IRCPASSWORD; ChatPrefix = (node.Attributes[XMLATTRIB_CHATPREFIX] != null) ? node.Attributes[XMLATTRIB_CHATPREFIX].Value : DEFAULTVAL_IRCBOT_CHATPREFIX; MaxBurst = (node.Attributes[XMLATTRIB_MAXBURST] != null && UInt32.TryParse(node.Attributes[XMLATTRIB_MAXBURST].Value, out val_uint)) ? val_uint : DEFAULTVAL_IRCBOT_MAXBURST; Refill = (node.Attributes[XMLATTRIB_REFILL] != null && UInt32.TryParse(node.Attributes[XMLATTRIB_REFILL].Value, out val_uint)) ? val_uint : DEFAULTVAL_IRCBOT_REFILL; Banner = (node.Attributes[XMLATTRIB_BANNER] != null) ? node.Attributes[XMLATTRIB_BANNER].Value : DEFAULTVAL_IRCBOT_BANNER; } else { IRCServer = DEFAULTVAL_IRCBOT_IRCSERVER; IRCPort = DEFAULTVAL_IRCBOT_IRCPORT; Channel = DEFAULTVAL_IRCBOT_CHANNEL; NickName = DEFAULTVAL_IRCBOT_NICKNAME; IRCPassword = DEFAULTVAL_IRCBOT_IRCPASSWORD; ChatPrefix = DEFAULTVAL_IRCBOT_CHATPREFIX; MaxBurst = DEFAULTVAL_IRCBOT_MAXBURST; Refill = DEFAULTVAL_IRCBOT_REFILL; Banner = DEFAULTVAL_IRCBOT_BANNER; } // admincommands list node = Document.DocumentElement.SelectSingleNode( '/' + XMLTAG_CONFIGURATION + '/' + XMLTAG_BOT + '/' + XMLTAG_ADMINCOMMANDS); if (node != null) { foreach (XmlNode child in node.ChildNodes) { if (child.Name != XMLTAG_ITEM) { continue; } string name = (child.Attributes[XMLATTRIB_NAME] != null) ? child.Attributes[XMLATTRIB_NAME].Value : null; if (name != null) { AdminCommands.Add(name); } } } // Allowed users (can broadcast) node = Document.DocumentElement.SelectSingleNode( '/' + XMLTAG_CONFIGURATION + '/' + XMLTAG_BOT + '/' + XMLTAG_ALLOWEDUSERS); if (node != null) { foreach (XmlNode child in node.ChildNodes) { if (child.Name != XMLTAG_ITEM) { continue; } string name = (child.Attributes[XMLATTRIB_NAME] != null) ? child.Attributes[XMLATTRIB_NAME].Value : null; if (name != null) { AllowedUsers.Add(name); } } } // Relay bots (bots we pass on messages from) node = Document.DocumentElement.SelectSingleNode( '/' + XMLTAG_CONFIGURATION + '/' + XMLTAG_BOT + '/' + XMLTAG_RELAYBOTS); if (node != null) { foreach (XmlNode child in node.ChildNodes) { if (child.Name != XMLTAG_ITEM) { continue; } string name = (child.Attributes[XMLATTRIB_NAME] != null) ? child.Attributes[XMLATTRIB_NAME].Value : null; string banner = (child.Attributes[XMLATTRIB_BANNER] != null) ? child.Attributes[XMLATTRIB_BANNER].Value : null; string systemregex = (child.Attributes[XMLATTRIB_IGNORESYSREGEX].Value != null) ? child.Attributes[XMLATTRIB_IGNORESYSREGEX].Value : null; string allregex = (child.Attributes[XMLATTRIB_IGNOREALLREGEX].Value != null) ? child.Attributes[XMLATTRIB_IGNOREALLREGEX].Value : null; if (name != null && banner != null && systemregex != null && allregex != null) { RelayBots.Add(new RelayConfig(name, banner, systemregex, allregex)); } } } }