public void TickNetCollectRequest(DataNormalizatorMessageFactory.TickNetCollectRequest request) { if (OnCollectRequest != null) Task.Factory.StartNew(() => OnCollectRequest(request)); }
public void Login(DataNormalizatorMessageFactory.LoginMessage msg) { // var users = DataManager.GetUsers(); var clientProxy = CurrentClient.GetClientProxy<IDataNormalizatorService>(); var client = CurrentClient; var collectorClient = new CollectorClient(msg.Username, 1, CurrentClient, clientProxy) { IndexInAdminList = (int) client.ClientId }; Clients[client.ClientId] = collectorClient; //Register to Disconnected event to know when user connection is closed client.Disconnected += ClientDisconnected; //Start a new task to send user list to mainform }
public void TickNetCollectRequest(DataNormalizatorMessageFactory.TickNetCollectRequest request) { }
public void Login(DataNormalizatorMessageFactory.LoginMessage msg) { }
private void CollectRequest(DataNormalizatorMessageFactory.TickNetCollectRequest msg) { lock (_thisNLock) { try { _users = DataManager.GetUsers(); IEnumerable<SymbolModel> symbolsInRequest; if (msg.IsGroup) { var groups = DataManager.GetGroups(); var idGr = groups.Find(a => a.GroupId == msg.GroupId).GroupId; var listSmb = DataManager.GetSymbolsInGroup(idGr); symbolsInRequest = listSmb; } else symbolsInRequest = from simb in _symbols where simb.SymbolName == msg.Symbol select simb; AddUserToSymbolAccessRank(symbolsInRequest, msg); } catch (Exception ex) { Console.WriteLine(ex.Message); } } }
private void AddUserToSymbolAccessRank(IEnumerable<SymbolModel> symbolsInRequest, DataNormalizatorMessageFactory.TickNetCollectRequest msg) { var user = _adminService.Clients.GetAllItems().Find(o => o.UserName == msg.UserName); user.DepthValue = msg.DepthValue; foreach (var smb in symbolsInRequest) { if (!_adminService.TickNetSymbolAccesRank.ContainsKey(smb.SymbolName)) { _adminService.TickNetSymbolAccesRank.Add(smb.SymbolName, new List<CollectorClient>()); AddUserAndActivate(user, smb); } else if (_adminService.TickNetSymbolAccesRank[smb.SymbolName].Count == 0) { AddUserAndActivate(user, smb); } else { var rankList = _adminService.TickNetSymbolAccesRank[smb.SymbolName]. OrderByDescending(o => o.DepthValue). ToList(); if (!rankList.Exists(a => a.DBId == msg.UserID)) { var tempuser = rankList[0].UserName; var depthValue = rankList[0].DepthValue; if (depthValue < user.DepthValue) { _adminService.TickNetSymbolAccesRank[smb.SymbolName].Add(user); _userQueue.Add(smb.SymbolName, user.UserName); var currstorer = _adminService.Clients.GetAllItems().Find(oo => oo.UserName == tempuser); try { var smb1 = smb; Task.Factory.StartNew( () => currstorer.TickNetProxy.DeactivateClient("", smb1.SymbolName)); } catch (Exception ex) { Console.WriteLine(ex); ClientDeactivated(smb.SymbolName); } } else _adminService.TickNetSymbolAccesRank[smb.SymbolName].Add(user); AddSymbolToBusySymbols(smb); } } /*Refresh the symbols ui*/ } }