public async Task <SshCommand> RunCommandAsync(string command, ConnectionUser user) { SshClient ssh; switch (user) { case ConnectionUser.Admin: ssh = m_sshAdminClient; break; case ConnectionUser.LvUser: ssh = m_sshUserClient; break; default: throw new ArgumentOutOfRangeException(nameof(user), user, null); } var settings = SettingsProvider.ExtensionSettingsPage; bool verbose = settings.Verbose || settings.DebugMode; if (verbose) { await OutputWriter.Instance.WriteLineAsync($"Running command: {command}").ConfigureAwait(false); } return(await Task.Run(() => ssh.RunCommand(command)).ConfigureAwait(false)); }
private void ButtonGolden_Click(object sender, RoutedEventArgs e) { int result = client.CanIBecomeGolden(ConnectionUser.Instance().CurrentUser); if (result == 0) { MessageBox.Show("You dont have enough rented vehicles, you need to rent at least 5 vehicles"); } else if (result == 1) { MessageBox.Show("You as golden member to become a regular member have to return some vehicles"); } else if (result == 2) { MessageBox.Show("You have succesfully send request to become regular member"); } else if (result == 3) { MessageBox.Show("You have succesfully send request to become golden member"); } else { MessageBox.Show("You have already sent request"); } }
internal static async Task <string> AddOrReplaceGroupAsync(this ConnectionUser connectionUser, IGroupManager grops, int groupId, HubGroupTypes groupType, string nativeName, HubGroupPrefix prefix) { var name = CreateGroupName(groupId, groupType, prefix); return(await connectionUser._addOrReplaceGroupAsync(grops, groupId, name, groupType, nativeName)); }
/// <summary> /// при удалении конрневой альянсовой группы удаляет все дочерние группы /// </summary> /// <param name="connectionUser"></param> /// <param name="grops"></param> /// <returns></returns> internal static async Task <string> RemoveAllianceGroupNameAsync(this ConnectionUser connectionUser, IGroupManager grops) { await connectionUser.RemoveAllianceRecrutManagerGroupNameAsync(grops); return(await connectionUser._removeGroupAsync(grops, CreateAllianceGroupName, connectionUser.AllianceId)); }
public async Task <bool> DeployFileAsync(Stream file, string deployLocation, ConnectionUser user) { ScpClient scp; switch (user) { case ConnectionUser.Admin: scp = m_scpAdminClient; break; case ConnectionUser.LvUser: scp = m_scpUserClient; break; default: throw new ArgumentOutOfRangeException(nameof(user), user, null); } var settings = SettingsProvider.ExtensionSettingsPage; bool verbose = settings.Verbose || settings.DebugMode; if (verbose) { await OutputWriter.Instance.WriteLineAsync($"Deploying File: {deployLocation}").ConfigureAwait(false); } await Task.Run(() => scp.Upload(file, deployLocation)).ConfigureAwait(false); return(true); }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ConnectionUser { UserName = model.Email, Email = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); return(RedirectToAction("Index", "Home")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
// ReSharper disable once InconsistentNaming /// <summary> /// </summary> /// <param name="connectionUser"></param> /// <param name="new_alliance_user_Id">Id в таблицы alliance_user</param> /// <param name="newAllianceName"></param> /// <param name="newAllianceRoleId"></param> /// <param name="newAlianceId"></param> internal static void SetNewAllianceData(this ConnectionUser connectionUser, int new_alliance_user_Id, string newAllianceName, byte newAllianceRoleId, int newAlianceId) { connectionUser.AllianceUserId = new_alliance_user_Id; connectionUser.AllianceName = newAllianceName; connectionUser.AllianceRoleId = newAllianceRoleId; connectionUser.AllianceId = newAlianceId; }
internal static async Task <string> AddOrReplaceGroupChannelGroupNameAsync(this ConnectionUser connectionUser, IGroupManager grops, int channelId, string channelNativeName) { return (await connectionUser.AddOrReplaceGroupAsync(grops, channelId, HubGroupTypes.Channel, channelNativeName, HubGroupPrefix.Group)); }
internal static async Task <string> AddOrReplacePrivateChannelGroupNameAsync(this ConnectionUser connectionUser, IGroupManager grops, int channelId) { return (await connectionUser.AddOrReplaceGroupAsync(grops, channelId, HubGroupTypes.Channel, "", HubGroupPrefix.Private)); }
private static async Task <string> _addOrReplaceGroupAsync(this ConnectionUser connectionUser, IGroupManager groups, int groupId, string groupName, HubGroupTypes groupType, string nativeName) { await groups.AddToGroupAsync(connectionUser.ConnectionId, groupName); connectionUser.Groups[groupName] = new HubGroupItem(groupId, (byte)groupType, nativeName, groupName); return(groupName); }
internal static IHubGroupItem GetUserChannelGroup(this ConnectionUser connectionUser, int channelId) { var channelGroup = (byte)HubGroupTypes.Channel; var item = connectionUser.Groups.Values.FirstOrDefault(i => i.GroupId == channelId && i.GroupType == channelGroup); return(item); }
public RegularViewModel(RegularView viewParam, NetTcpBinding binding, EndpointAddress address, string endDate) { this.RentVehicleCommand = new RentVehicleCommand(this, binding, address, endDate, viewParam); WCFClient client = new WCFClient(binding, address, ConnectionUser.Instance().CurrentUser.Username); List = client.ReturnVehicle(1); }
public ConnectionUser AddOrUpdateLocal(ConnectionUser dataModel, bool dataIsCheked) { if (!dataIsCheked && string.IsNullOrWhiteSpace(dataModel?.ConnectionId)) { return(null); } return(_users.AddOrUpdateLazy(dataModel.ConnectionId, key => dataModel, (key, oldValue) => dataModel)); }
public AdminView() { InitializeComponent(); SetProxy(); client = new WCFClient(binding, address, ConnectionUser.Instance().CurrentUser.Username); this.DataContext = new AdminViewModel(this, binding, address); }
// ReSharper disable once SuggestBaseTypeForParameter public void SetUserData(IDbConnection connection, IAllianceService allianceService, AllianceUserDataModel adm, ConnectionUser newCurrentConnectionUser) { NewCurrentConnectionUser = newCurrentConnectionUser; IsCurrentUser = true; if (NewRole.AcceptNewMembers) { AllianceUserRequests = allianceService.GetAllianceUserRequests(connection, adm, NewRole); } }
private AllianceUserDataModel _getAllianceUser(IDbConnection connection, ConnectionUser user) { var au = _allianceService.GetAllianceUserById(connection, user.AllianceUserId); if (au.UserId == user.UserId) { return(au); } throw new HubException(Error.NotPermitted); }
private async Task _cleanDisconnectedUserData(ConnectionUser disconnectedUser, Exception exception) { _gameRunner.OnDisonnected(disconnectedUser.ConnectionId, disconnectedUser.UserId); disconnectedUser.Connected = false; await disconnectedUser.RemoveUserFromAllHubGroups(Groups); await Clients.Others.InvokeAsync("userLeftGame", disconnectedUser); _removeUserFromStorage(disconnectedUser.ConnectionId); await base.OnDisconnectedAsync(exception); }
public AdminViewModel(AdminView viewParam, NetTcpBinding binding, EndpointAddress address) { this.ChangeGoldenCommand = new ChangeGoldenCommand(this, binding, address); this.DeleteVehicleCommand = new DeleteVehicleCommand(this, binding, address); this.EditVehicleCommand = new EditVehicleCommand(this, binding, address, viewParam); WCFClient client = new WCFClient(binding, address, ConnectionUser.Instance().CurrentUser.Username); List = client.ReturnVehicle(0); ListRequest = client.ReturnRequest(); }
public RegularView() { InitializeComponent(); SetProxy(); client = new WCFClient(binding, address, ConnectionUser.Instance().CurrentUser.Username); this.DataContext = new RegularViewModel(this, binding, address, endDate); int result = client.ReturnBill(ConnectionUser.Instance().CurrentUser); billTextBox.Text = result.ToString(); }
internal static async Task RemoveUserFromAllHubGroups(this ConnectionUser connectionUser, IGroupManager groups) { var cGroups = connectionUser.Groups.Keys.ToList(); foreach (var key in cGroups) { await groups.RemoveFromGroupAsync(connectionUser.ConnectionId, key); connectionUser.Groups.Remove(key); } // connectionUser.Groups = null; // connectionUser.Groups = new Dictionary<string, IHubGroupItem>(); }
protected void Page_Load(object sender, EventArgs e) { if (Request.OneAllTokenExists()) { // TODO: Implement your post login logic as below Guid oneAllUserToken = Guid.Empty; Guid oneAllCnToken = Request.OneAllToken(); Response <ConnectionDetail> responseCn = OneAllAPI.Default.ConnectionReadDetails(oneAllCnToken); if (responseCn != null && responseCn.Result != null && responseCn.Result.Data != null) { ConnectionUser oneAllCnUser = responseCn.Result.Data.User; if (oneAllCnUser != null) { oneAllUserToken = oneAllCnUser.UserToken; } } else if (responseCn != null && responseCn.Request != null && responseCn.Request.Status != null) { _labelMessages.Text = string.Format("{0}: {1}: {2}", responseCn.Request.Status.Code, responseCn.Request.Status.Indicator, responseCn.Request.Status.Info); } if (!Guid.Empty.Equals(oneAllUserToken)) { Response <UserResult> responseUser = OneAllAPI.Default.UserReadDetails(oneAllUserToken); if (responseUser != null && responseUser.Result != null && responseUser.Result.Data != null) { User oneAllUser = responseUser.Result.Data.User; if (oneAllUser != null && oneAllUser.Identities != null && oneAllUser.Identities[0] != null) { Identity oneAllId = oneAllUser.Identities[0]; if (oneAllId != null) { _labelSocialName.Text = oneAllId.DisplayName; if (oneAllId.ThumbnailUrl != null) { _imageSocialThum.ImageUrl = oneAllId.ThumbnailUrl.ToString(); } } } } else if (responseUser != null && responseUser.Request != null && responseUser.Request.Status != null) { _labelMessages.Text = string.Format("{0}: {1}: {2}", responseUser.Request.Status.Code, responseUser.Request.Status.Indicator, responseUser.Request.Status.Info); } } } }
internal static async Task UpdateAllianceGroupsByPermitionsAsync(this ConnectionUser connectionUser, IGroupManager groups, AllianceRoleDataModel oldUserRole, AllianceRoleDataModel newRole) { if (oldUserRole.AcceptNewMembers != newRole.AcceptNewMembers) { if (newRole.AcceptNewMembers) { await connectionUser.AddOrReplaceAllianceRecrutManagerGroupAsync(groups); } else { await connectionUser.RemoveAllianceRecrutManagerGroupNameAsync(groups); } } //todo удалить если не потребуется //не удалять коменты! //if (oldUserRole.CanManagePermition != newRole.CanManagePermition) //{ // //todo если пявится группа только для менеджеров //} //if (oldUserRole.DeleteMembers != newRole.DeleteMembers) //{ // //todo если пявится группа //} //if (oldUserRole.EditAllianceInfo != newRole.EditAllianceInfo) //{ // //todo если пявится группа //} //if (oldUserRole.MessageRead != newRole.MessageRead) //{ // //todo когда пявится группа //} //if (oldUserRole.MessageSend != newRole.MessageSend) //{ // //todo когда пявится группа //} //if (oldUserRole.SetTech != newRole.SetTech) //{ // //todo если пявится группа //} //if (oldUserRole.ShowManage != newRole.ShowManage) //{ // //todo если пявится группа //} }
private static async Task <string> _removeGroupAsync(this ConnectionUser connectionUser, IGroupManager grops, Func <int, string> createName, int groupId) { var groupName = createName(groupId); if (!connectionUser.Groups.ContainsKey(groupName)) { return(groupName); } connectionUser.Groups.Remove(groupName); await grops.RemoveFromGroupAsync(connectionUser.ConnectionId, groupName); return(groupName); }
private void Button_Click(object sender, RoutedEventArgs e) { bool logout = client.LogOut(ConnectionUser.Instance().CurrentUser); if (logout) { ConnectionUser.Instance().CurrentUser = null; MainWindow main = new MainWindow(); this.Close(); main.ShowDialog(); } else { MessageBox.Show("You have to LogIn first to LogOut"); } }
public void Add(string connectionId, ConnectionUser connUser) { lock (_connections) { ConnectionUser user; if (!_connections.TryGetValue(connectionId, out user)) { _connections.Add(connectionId, connUser); } else { //overwrite the username for that connection _connections[connectionId] = user; } } }
internal static bool GetVoteRegistred(this ConnectionUser connectionUser) { if (!connectionUser.AdvancedData.ContainsKey(CuAdvancedDataKeys.RegistratedInVote)) { return(false); } var registred = connectionUser.AdvancedData[CuAdvancedDataKeys.RegistratedInVote]; if (registred == null) { return(false); } if (registred is bool) { return((bool)registred); } throw new NotImplementedException(); }
internal static bool GetVoteSended(this ConnectionUser connectionUser) { if (!connectionUser.AdvancedData.ContainsKey(CuAdvancedDataKeys.VoteSended)) { return(false); } var vote = connectionUser.AdvancedData[CuAdvancedDataKeys.VoteSended]; if (vote == null) { return(false); } if (vote is bool) { return((bool)vote); } throw new NotImplementedException(); }
public void Execute(object parameter) { if (viewModel.Selected == null) { return; } WCFClient client = new WCFClient(binding, address, ConnectionUser.Instance().CurrentUser.Username); bool result = client.EditVehicle(view.nameTextBox.Text, view.modelTextBox.Text, Convert.ToInt32(view.yearTextBox.Text), Convert.ToInt32(view.priceTextBox.Text), Convert.ToInt32(view.cenaTextBox.Text), viewModel.Selected); if (result) { MessageBox.Show("You have succesfully edited vehicle"); viewModel.List = client.ReturnVehicle(0); } else { MessageBox.Show("Vehicle is not avalible"); } }
public void Execute(object parameter) { if (viewModel.SelectedRequest == null) { return; } WCFClient client = new WCFClient(binding, address, ConnectionUser.Instance().CurrentUser.Username); bool result = client.DoRequest(viewModel.SelectedRequest); if (result) { MessageBox.Show("You have succesfully change users golden membership"); viewModel.ListRequest = client.ReturnRequest(); } else { MessageBox.Show("Error"); } }
public void Execute(object parameter) { if (viewModel.Selected == null) { return; } WCFClient client = new WCFClient(binding, address, ConnectionUser.Instance().CurrentUser.Username); bool result = client.DeleteVehicle(viewModel.Selected); if (result) { MessageBox.Show("You have succesfully deleted vehicle"); viewModel.List = client.ReturnVehicle(0); } else { MessageBox.Show("Vehicle is not avalible"); } }
public static async Task<bool> DeployFiles(IEnumerable files, string deployLocation, ConnectionUser user) { ConnectionInfo connectionInfo; switch (user) { case ConnectionUser.Admin: connectionInfo = s_adminConnectionInfo; break; case ConnectionUser.LvUser: connectionInfo = s_lvUserConnectionInfo; break; default: throw new ArgumentOutOfRangeException(nameof(user), user, null); } if (connectionInfo == null) return false; using (ScpClient scp = new ScpClient(connectionInfo)) { try { await Task.Run(() => scp.Connect()); } catch (SshOperationTimeoutException) { return false; } var settings = (SettingsPageGrid)Frc_ExtensionPackage.Instance.PublicGetDialogPage(typeof(SettingsPageGrid)); bool verbose = settings.Verbose || settings.DebugMode; foreach (FileInfo fileInfo in from string s in files where File.Exists(s) select new FileInfo(s)) { if (verbose) { OutputWriter.Instance.WriteLine($"Deploying File: {fileInfo.Name}"); } await Task.Run(() => scp.Upload(fileInfo, deployLocation)); } } return true; }
public static async Task<SshCommand> RunCommand(string command, ConnectionUser user) { ConnectionInfo connectionInfo; switch (user) { case ConnectionUser.Admin: connectionInfo = s_adminConnectionInfo; break; case ConnectionUser.LvUser: connectionInfo = s_lvUserConnectionInfo; break; default: throw new ArgumentOutOfRangeException(nameof(user), user, null); } using (SshClient ssh = new SshClient(connectionInfo)) { try { await Task.Run(() => ssh.Connect()); } catch (SshOperationTimeoutException) { return null; } var settings = (SettingsPageGrid)Frc_ExtensionPackage.Instance.PublicGetDialogPage(typeof(SettingsPageGrid)); bool verbose = settings.Verbose || settings.DebugMode; if (verbose) { OutputWriter.Instance.WriteLine($"Running command: {command}"); } return await Task.Run(() => ssh.RunCommand(command)); } }
public static async Task<Dictionary<string, SshCommand>> RunCommands(string[] commands, ConnectionUser user) { ConnectionInfo connectionInfo; switch (user) { case ConnectionUser.Admin: connectionInfo = s_adminConnectionInfo; break; case ConnectionUser.LvUser: connectionInfo = s_lvUserConnectionInfo; break; default: throw new ArgumentOutOfRangeException(nameof(user), user, null); } Dictionary<string, SshCommand> retCommands = new Dictionary<string, SshCommand>(); using (SshClient ssh = new SshClient(connectionInfo)) { try { await Task.Run(() => ssh.Connect()); } catch (SshOperationTimeoutException) { return null; } var settings = (SettingsPageGrid)Frc_ExtensionPackage.Instance.PublicGetDialogPage(typeof(SettingsPageGrid)); bool verbose = settings.Verbose || settings.DebugMode; foreach (string s in commands) { if (verbose) { OutputWriter.Instance.WriteLine($"Running command: {s}"); } await Task.Run(() => { var x = ssh.RunCommand(s); retCommands.Add(s, x); }); } } return retCommands; }