public void RemovePreset(Client.Model.PresetModel presetModel) { ClientPresetsCmd presetCmd = new ClientPresetsCmd() { ControlType = ClientPresetsCmd.EControlType.Delete, PresetDataEntry = new PresetDataEntry { Identifier = presetModel.PresetId } }; connectionMgr.BroadcastMessage( (int)CommandConst.MainCommandClient.Functionality, (int)CommandConst.SubCommandClient.Preset, presetCmd); }
private void LaunchPreset(string clientId, int dbUserId, ClientPresetsCmd presetData) { if (Properties.Settings.Default.Debug) { MessageBox.Show("before clear wall"); } // 1. Clean all launched applications ClearWall(dbUserId); if (Properties.Settings.Default.Debug) { MessageBox.Show("after clear wall"); } // 2. trigger the apps in the preset by giving preset's id LaunchPresetExternal(dbUserId, presetData.PresetDataEntry.Identifier); }
public override void ExecuteCommand(string userId, string command) { ClientPresetsCmd presetData = deserialize.Deserialize <ClientPresetsCmd>(command); if (presetData == null) { return; } bool broadcastChanges = false; switch (presetData.ControlType) { case ClientPresetsCmd.EControlType.Add: AddPreset(userId, clientId, presetData); broadcastChanges = true; break; case ClientPresetsCmd.EControlType.Delete: RemovePreset(presetData); broadcastChanges = true; break; case ClientPresetsCmd.EControlType.Launch: LaunchPreset(userId, clientId, presetData); break; case ClientPresetsCmd.EControlType.Modify: ModifyPreset(clientId, presetData); break; default: break; } if (broadcastChanges) { // TODO: broadcast changes to user who login using the owner's account // get user's preset list ServerPresetsStatus serverPresetStatus = new ServerPresetsStatus(); serverPresetStatus.UserPresetList = new List <PresetsEntry>(); foreach (PresetData data in Server.ServerDbHelper.GetInstance().GetPresetByUserId(clientId)) { List <ApplicationEntry> presetAppEntries = new List <ApplicationEntry>(); foreach (ApplicationData appData in data.AppDataList) { presetAppEntries.Add(new ApplicationEntry() { Identifier = appData.id, Name = appData.name }); } List <VncEntry> presetVncEntries = new List <VncEntry>(); foreach (RemoteVncData vncData in data.VncDataList) { presetVncEntries.Add(new VncEntry() { Identifier = vncData.id, DisplayName = vncData.name, IpAddress = vncData.remoteIp, Port = vncData.remotePort, }); } List <InputAttributes> presetInputEntries = new List <InputAttributes>(); foreach (VisionData inputData in data.InputDataList) { presetInputEntries.Add( ServerVisionHelper.getInstance().GetAllVisionInputsAttributes().First(InputAttributes => InputAttributes.InputId == inputData.id)); } serverPresetStatus.UserPresetList.Add(new PresetsEntry() { Identifier = data.Id, Name = data.Name, ApplicationList = presetAppEntries, VncList = presetVncEntries, InputList = presetInputEntries, }); } // should get all connected client with same login List <string> connectedClientSocketList; if (ConnectedClientHelper.GetInstance().GetConnectedUsersGroupByDB().TryGetValue(clientId, out connectedClientSocketList)) { server.GetConnectionMgr().SendData( (int)CommandConst.MainCommandServer.UserPriviledge, (int)CommandConst.SubCommandServer.PresetList, serverPresetStatus, connectedClientSocketList); } else { // Should not happen, just in case Trace.WriteLine("ERROR: cannot get connected user socket list by user db id: " + clientId); server.GetConnectionMgr().SendData( (int)CommandConst.MainCommandServer.UserPriviledge, (int)CommandConst.SubCommandServer.PresetList, serverPresetStatus, new List <string>() { userId }); } } }
private void ModifyPreset(int userId, ClientPresetsCmd presetData) { // no implementation yet }
private void RemovePreset(ClientPresetsCmd presetData) { // remove preset from database Server.ServerDbHelper.GetInstance().RemovePreset(presetData.PresetDataEntry.Identifier); }
private void AddPreset(string socketId, int dbUserId, ClientPresetsCmd presetData) { AddPresetExternal(dbUserId, presetData.PresetDataEntry.Name); }
public void AddPreset(string name, Dictionary <ControlAttributes, Client.Model.ApplicationModel> appDic, Dictionary <ControlAttributes, Client.Model.VncModel> vncDic, Dictionary <ControlAttributes, InputAttributes> visionDic) { PresetDataEntry dataEntry = new PresetDataEntry(); dataEntry.Name = name; dataEntry.PresetAppList = new List <ApplicationEntry>(); dataEntry.PresetAppPos = new List <WndPos>(); dataEntry.PresetVisionInputList = new List <InputAttributes>(); dataEntry.PresetVisionInputPos = new List <WndPos>(); dataEntry.PresetVncList = new List <VncEntry>(); dataEntry.PresetVncPos = new List <WndPos>(); foreach (KeyValuePair <ControlAttributes, Client.Model.ApplicationModel> pair in appDic) { ApplicationEntry appEntry = new ApplicationEntry() { Identifier = pair.Value.AppliationId, Name = pair.Value.ApplicationName, }; WndPos wndPos = new WndPos() { posX = pair.Key.Xpos, posY = pair.Key.Ypos, width = pair.Key.Width, height = pair.Key.Height, style = pair.Key.Style, }; dataEntry.PresetAppList.Add(appEntry); dataEntry.PresetAppPos.Add(wndPos); } foreach (KeyValuePair <ControlAttributes, Client.Model.VncModel> pair in vncDic) { VncEntry vncEntry = new VncEntry() { Identifier = pair.Value.Identifier, DisplayName = pair.Value.DisplayName, IpAddress = pair.Value.VncServerIp, Port = pair.Value.VncServerPort, }; WndPos wndPos = new WndPos() { posX = pair.Key.Xpos, posY = pair.Key.Ypos, width = pair.Key.Width, height = pair.Key.Height, style = pair.Key.Style, }; dataEntry.PresetVncList.Add(vncEntry); dataEntry.PresetVncPos.Add(wndPos); } foreach (KeyValuePair <ControlAttributes, InputAttributes> pair in visionDic) { WndPos wndPos = new WndPos() { posX = pair.Key.Xpos, posY = pair.Key.Ypos, width = pair.Key.Width, height = pair.Key.Height, style = pair.Key.Style, }; dataEntry.PresetVisionInputList.Add(pair.Value); dataEntry.PresetVisionInputPos.Add(wndPos); } ClientPresetsCmd presetCmd = new ClientPresetsCmd() { ControlType = ClientPresetsCmd.EControlType.Add, PresetDataEntry = dataEntry, }; connectionMgr.BroadcastMessage( (int)CommandConst.MainCommandClient.Functionality, (int)CommandConst.SubCommandClient.Preset, presetCmd); }