public async Task Leave(string groupId) { var existingGroup = chatGroups.FirstOrDefault(x => x.PublicId == groupId); if (existingGroup == null) { await Clients.Caller.SendAsync(receiveMethodName, MessageConstructor.SystemMessage(ErrorMessages.GroupDoesNotExist(groupId))); return; } if (existingGroup.ClientsConnected.FirstOrDefault(x => x == Context.ConnectionId) == null) { await Clients.Caller.SendAsync(receiveMethodName, MessageConstructor.SystemMessage(ErrorMessages.NotAGroupMember(existingGroup.Name))); return; } existingGroup.ClientsConnected.Remove(Context.ConnectionId); if (existingGroup.ClientsConnected.Count == 0) { chatGroups.Remove(existingGroup); } var clientName = await _processor.OnGroupLeave(groupId, Context.ConnectionId); Task.WaitAll( Groups.RemoveFromGroupAsync(Context.ConnectionId, existingGroup.Name), Clients.Caller .SendAsync(receiveMethodName, MessageConstructor.SystemMessage(InformationMessages.SuccessfullyLeftGroup(existingGroup.Name))), Clients.Group(existingGroup.Name) .SendAsync(receiveMethodName, MessageConstructor.SystemMessage(InformationMessages.ClientHasLeftGroup(clientName)))); }
public void AddMessage(MessageType messageType, string message) { var userMessage = new UserMessage { MessageType = messageType, Message = message }; switch (messageType) { case MessageType.Information: InformationMessages.Add(userMessage); break; case MessageType.Success: SuccessMessages.Add(userMessage); break; case MessageType.Error: ErrorMessages.Add(userMessage); break; case MessageType.Warning: WarningMessages.Add(userMessage); break; } }
public override void Information(int id, object message, Exception exception) { InformationMessages.Add(new LogMessage { Id = id, Message = message, Exception = exception }); }
public async Task Join(string groupId) { var existingGroup = chatGroups.FirstOrDefault(x => x.PublicId == groupId); if (existingGroup == null) { await Clients.Caller.SendAsync(receiveMethodName, MessageConstructor.SystemMessage(ErrorMessages.GroupDoesNotExist(groupId))); return; } var groupName = existingGroup.Name; if (existingGroup.CurrentClientsAmount == existingGroup.MaximumClientsAmount) { await Clients.Caller.SendAsync(receiveMethodName, MessageConstructor.SystemMessage(InformationMessages.ClientsInGroupLimitReached(groupName, _appConfig.MaximumGroupSize))); return; } if (existingGroup.ClientsConnected.FirstOrDefault(x => x == Context.ConnectionId) != null) { await Clients.Caller.SendAsync(receiveMethodName, MessageConstructor.SystemMessage(ErrorMessages.AlreadyAGroupMember(groupName))); return; } var groupHistoryToClientDto = await _processor.OnGroupJoin(existingGroup.PublicId, Context.ConnectionId); var groupMessage = new GroupMessage { GroupName = groupName, GroupId = existingGroup.PublicId }; existingGroup.ClientsConnected.Add(Context.ConnectionId); var exclutionList = new List <string> { Context.ConnectionId }; Task.WaitAll( Groups.AddToGroupAsync(Context.ConnectionId, groupName), Clients.Caller.SendAsync(receiveMethodName, MessageConstructor.SystemMessage(InformationMessages.SuccessfullyJoinedGroup(groupName))), Clients.Caller.SendAsync(GroupMethodNames.OnGroupJoined, groupMessage), Clients.Caller.SendAsync(GroupMethodNames.ReceiveGroupHistory, MessageConstructor.GroupMessageHistory(groupHistoryToClientDto)), Clients.GroupExcept(groupName, exclutionList) .SendAsync(receiveMethodName, MessageConstructor.SystemMessage(InformationMessages.ClientHasJoinedGroup(groupHistoryToClientDto.Client.PublicName)))); }
private void AddRemoteProvidersFromSources(List <IWalkProvider> remoteProviders, List <PackageSource> effectiveSources) { foreach (var source in effectiveSources) { var feed = PackageSourceUtils.CreatePackageFeed( source, FeedOptions.NoCache, FeedOptions.IgnoreFailedSources, Reports); if (feed != null) { remoteProviders.Add(new RemoteWalkProvider(feed)); var list = InformationMessages.GetOrAdd("Feeds used:", _ => new List <string>()); if (!list.Contains(feed.Source)) { list.Add(feed.Source); } } } }
public async Task Create(string groupName) { if (chatGroups.FirstOrDefault(x => x.Name == groupName) != null) { await Clients.Caller.SendAsync(receiveMethodName, MessageConstructor.SystemMessage(ErrorMessages.GroupAlreadyExists(groupName))); return; } var groupDto = new GroupDto { Name = groupName, CurrentClientsAmount = 1, MaximumClientsAmount = _appConfig.MaximumGroupSize, CreatorConnectionId = Context.ConnectionId, ClientsConnected = new List <string> { Context.ConnectionId } }; var publicId = await _processor.OnGroupCreation(groupDto); groupDto.PublicId = publicId; chatGroups.Add(groupDto); await Groups.AddToGroupAsync(Context.ConnectionId, groupName); var message = MessageConstructor.SystemMessage(InformationMessages.GroupSuccessfullyCreated(groupName)); var groupMessage = new GroupMessage { GroupName = groupName, GroupId = groupDto.PublicId, Body = message.Body, SenderName = message.SenderName, Time = message.Time }; await Clients.Caller.SendAsync(receiveMethodName, message); await Clients.Caller.SendAsync(GroupMethodNames.OnGroupJoined, groupMessage); }
public void LogInformation(string data) { Messages.Enqueue(data); InformationMessages.Enqueue(data); DumpMessage("INFO ", data); }
private async Task <bool> Execute(string restoreDirectory) { try { var sw = Stopwatch.StartNew(); var projectJsonFiles = new List <string>(); if (string.Equals( Runtime.Project.ProjectFileName, Path.GetFileName(restoreDirectory), StringComparison.OrdinalIgnoreCase) && File.Exists(restoreDirectory)) { // If the path is a project.json file we don't do recursive search in subfolders projectJsonFiles.Add(restoreDirectory); } else if (Directory.Exists(restoreDirectory)) { var projectJsonFile = Path.Combine(restoreDirectory, Runtime.Project.ProjectFileName); if (File.Exists(projectJsonFile)) { // If the path contains a project.json file we don't do recursive search in subfolders projectJsonFiles.Add(projectJsonFile); } else { projectJsonFiles.AddRange(Directory.EnumerateFiles( restoreDirectory, Runtime.Project.ProjectFileName, SearchOption.AllDirectories)); } } else { var errorMessage = $"The given root {restoreDirectory.Red().Bold()} is invalid."; ErrorMessages.GetOrAdd(restoreDirectory, _ => new List <string>()).Add(errorMessage); Reports.Error.WriteLine(errorMessage); return(false); } var rootDirectory = ProjectResolver.ResolveRootDirectory(restoreDirectory); ReadSettings(rootDirectory); string packagesDirectory = FeedOptions.TargetPackagesFolder; if (string.IsNullOrEmpty(packagesDirectory)) { packagesDirectory = NuGetDependencyResolver.ResolveRepositoryPath(rootDirectory); } var packagesFolderFileSystem = CreateFileSystem(packagesDirectory); var pathResolver = new DefaultPackagePathResolver(packagesFolderFileSystem, useSideBySidePaths: true); int restoreCount = 0; int successCount = 0; Func <string, Task> restorePackage = async projectJsonPath => { Interlocked.Increment(ref restoreCount); var success = await RestoreForProject(projectJsonPath, rootDirectory, packagesDirectory); if (success) { Interlocked.Increment(ref successCount); } }; if (!RestoringInParallel()) { // Restoring in parallel on Mono throws native exception foreach (var projectJsonFile in projectJsonFiles) { await restorePackage(projectJsonFile); } } else { await ForEachAsync( projectJsonFiles, MaxDegreesOfConcurrency, restorePackage); } if (restoreCount > 1) { Reports.Information.WriteLine(string.Format("Total time {0}ms", sw.ElapsedMilliseconds)); } if (_installCount > 0) { InformationMessages.GetOrAdd("Installed:", _ => new List <string>()).Add($"{_installCount} package(s) to {packagesDirectory}"); _installCount = 0; } return(restoreCount == successCount); } catch (Exception ex) { Reports.Information.WriteLine("----------"); Reports.Information.WriteLine(ex.ToString()); Reports.Information.WriteLine("----------"); Reports.Information.WriteLine("Restore failed"); Reports.Information.WriteLine(ex.Message); return(false); } }
protected override void WriteInformation(string message) { InformationMessages.Add(message); }
private void View_Register(object sender, EventArgs e) { repositoryProvider.Repository.Add(new User(view.Username, view.Password)); view.ShowInformation(InformationMessages.UserCreated(view.Username)); }