public override void ExecuteCommand(string userId, string command) { ServerLoginReply loginData = deserialize.Deserialize <ServerLoginReply>(command); if (loginData == null) { return; } // calculate the actual size of server desktop (might have multiple monitors) int minPosX = 0; int minPosY = 0; int maxPosX = 0; int maxPosY = 0; foreach (MonitorInfo monitor in loginData.ServerLayout.MonitorAttributes) { minPosX = Math.Min(monitor.LeftPos, minPosX); minPosY = Math.Min(monitor.TopPos, minPosY); maxPosX = Math.Max(monitor.RightPos, maxPosX); maxPosY = Math.Max(monitor.BottomPos, maxPosY); } UserInfoModel userInfo = new UserInfoModel() { UserId = loginData.UserId, DisplayName = loginData.LoginName }; ServerLayoutModel layoutInfo = new ServerLayoutModel() { DesktopLayout = new WindowsModel() { PosLeft = minPosX, PosTop = minPosY, Width = maxPosX - minPosX, Height = maxPosY - minPosY }, LayoutColumn = loginData.ServerLayout.MatrixCol, LayoutRow = loginData.ServerLayout.MatrixRow, }; // update the gui client.RefreshLayout(userInfo, layoutInfo); // update the application priviledge ServerAppStatusCmdImpl appCmdImpl = new ServerAppStatusCmdImpl(client); appCmdImpl.ExecuteCommand(userId, loginData.UserApplications.getCommandString()); // update the maintenance priviledge ServerMaintenanceCmdImpl maintenanceCmdImpl = new ServerMaintenanceCmdImpl(client); maintenanceCmdImpl.ExecuteCommand(userId, loginData.UserMaintenance.getCommandString()); // update presets saved ServerPresetCmdImpl presetCmdImpl = new ServerPresetCmdImpl(client); presetCmdImpl.ExecuteCommand(userId, loginData.UserPresets.getCommandString()); }
private void sendLoginReply(Server.Model.ClientInfoModel model, int dekstopRow, int desktopCol) { // get server's monitor info List <Session.Data.SubData.MonitorInfo> monitorList = new List <MonitorInfo>(); int desktopLeft = 0; int desktopTop = 0; int desktopRight = 0; int desktopBottom = 0; foreach (WindowsHelper.MonitorInfo monitor in Utils.Windows.WindowsHelper.GetMonitorList()) { if (desktopLeft > monitor.WorkArea.Left) { desktopLeft = monitor.MonitorArea.Left; } if (desktopTop > monitor.WorkArea.Top) { desktopTop = monitor.MonitorArea.Top; } if (desktopRight < monitor.WorkArea.Right) { desktopRight = monitor.MonitorArea.Right; } if (desktopBottom < monitor.WorkArea.Bottom) { desktopBottom = monitor.MonitorArea.Bottom; } monitorList.Add(new Session.Data.SubData.MonitorInfo() { LeftPos = monitor.MonitorArea.Left, TopPos = monitor.MonitorArea.Top, RightPos = monitor.MonitorArea.Right, BottomPos = monitor.MonitorArea.Bottom }); } // send user data to client UserSettingData settingData = Server.ServerDbHelper.GetInstance().GetUserSetting(model.DbUserId); Session.Data.ServerUserSetting userSetting = new ServerUserSetting() { UserSetting = new UserSetting() { gridX = settingData.gridX, gridY = settingData.gridY, isSnap = settingData.isSnap, } }; // get user's application list ServerApplicationStatus serverAppStatus = new ServerApplicationStatus(); serverAppStatus.UserApplicationList = new List <ApplicationEntry>(); foreach (ApplicationData appData in Server.ServerDbHelper.GetInstance().GetAppsWithUserId(model.DbUserId)) { serverAppStatus.UserApplicationList.Add(new ApplicationEntry() { Identifier = appData.id, Name = appData.name }); } // get user's preset list ServerPresetsStatus serverPresetStatus = new ServerPresetsStatus(); serverPresetStatus.UserPresetList = new List <PresetsEntry>(); foreach (PresetData presetData in Server.ServerDbHelper.GetInstance().GetPresetByUserId(model.DbUserId)) { List <ApplicationEntry> presetAppEntries = new List <ApplicationEntry>(); foreach (ApplicationData appData in presetData.AppDataList) { presetAppEntries.Add(new ApplicationEntry() { Identifier = appData.id, Name = appData.name }); } List <VncEntry> presetVncEntries = new List <VncEntry>(); foreach (RemoteVncData vncData in presetData.VncDataList) { presetVncEntries.Add(new VncEntry() { Identifier = vncData.id, DisplayName = vncData.name, IpAddress = vncData.remoteIp, Port = vncData.remotePort, }); } // get all vision inputs List <InputAttributes> allInputList = Server.ServerVisionHelper.getInstance().GetAllVisionInputsAttributes(); List <InputAttributes> inputEntries = new List <InputAttributes>(); foreach (VisionData inputData in presetData.InputDataList) { inputEntries.Add(new InputAttributes() { InputId = inputData.id, DisplayName = allInputList.First(inputAtt => inputAtt.InputId == inputData.id).DisplayName, }); } serverPresetStatus.UserPresetList.Add(new PresetsEntry() { Identifier = presetData.Id, Name = presetData.Name, ApplicationList = presetAppEntries, VncList = presetVncEntries, InputList = inputEntries, }); } // get user's priviledge ServerMaintenanceStatus maintenanceStatus = new ServerMaintenanceStatus(); GroupData groupData = Server.ServerDbHelper.GetInstance().GetGroupByUserId(model.DbUserId); maintenanceStatus.AllowMaintenance = groupData.allow_maintenance; maintenanceStatus.AllowRemoteControl = groupData.allow_remote; MonitorInfo allowViewingArea = new MonitorInfo(); if (groupData.share_full_desktop) { // same as full desktop allowViewingArea.LeftPos = desktopLeft; allowViewingArea.TopPos = desktopTop; allowViewingArea.RightPos = desktopRight; allowViewingArea.BottomPos = desktopBottom; } else { // get monitor info MonitorData monitorData = Server.ServerDbHelper.GetInstance().GetMonitorByGroupId(groupData.id); allowViewingArea.LeftPos = monitorData.Left; allowViewingArea.TopPos = monitorData.Top; allowViewingArea.RightPos = monitorData.Right; allowViewingArea.BottomPos = monitorData.Bottom; } // prepare the VNC list ServerVncStatus vncStatus = new ServerVncStatus(); List <VncEntry> vncEntries = new List <VncEntry>(); vncStatus.UserVncList = vncEntries; foreach (RemoteVncData vncData in ServerDbHelper.GetInstance().GetRemoteVncList()) { vncEntries.Add(new VncEntry() { Identifier = vncData.id, DisplayName = vncData.name, IpAddress = vncData.remoteIp, Port = vncData.remotePort, }); } ServerLoginReply reply = new ServerLoginReply() { LoginName = model.Name, UserId = model.DbUserId, ServerLayout = new ServerScreenInfo() { MatrixCol = desktopCol, MatrixRow = dekstopRow, ServerMonitorsList = monitorList }, // UserApplications UserApplications = serverAppStatus, // UserPresets UserPresets = serverPresetStatus, // UserMaintenance UserMaintenance = maintenanceStatus, // allowed viewing area ViewingArea = allowViewingArea, // Current vnc list VncStatus = vncStatus, // user settings UserSetting = userSetting, }; connectionMgr.SendData( (int)CommandConst.MainCommandServer.UserPriviledge, (int)CommandConst.SubCommandServer.DisplayInfo, reply, new List <string>() { model.SocketUserId }); // send Input info to client Session.Data.ServerInputStatus inputStatus = new Session.Data.ServerInputStatus() { InputAttributesList = Server.ServerVisionHelper.getInstance().GetAllVisionInputsAttributes(), }; connectionMgr.SendData( (int)CommandConst.MainCommandServer.Presents, (int)CommandConst.SubCommandServer.VisionInput, inputStatus, new List <string>() { model.SocketUserId }); }
public override void ExecuteCommand(string userId, string command) { ServerLoginReply loginData = deserialize.Deserialize <ServerLoginReply>(command); if (loginData == null) { return; } // calculate the actual size of server desktop (might have multiple monitors) int minPosX = 0; int minPosY = 0; int maxPosX = 0; int maxPosY = 0; foreach (MonitorInfo monitor in loginData.ServerLayout.ServerMonitorsList) { minPosX = Math.Min(monitor.LeftPos, minPosX); minPosY = Math.Min(monitor.TopPos, minPosY); maxPosX = Math.Max(monitor.RightPos, maxPosX); maxPosY = Math.Max(monitor.BottomPos, maxPosY); } UserInfoModel userInfo = new UserInfoModel() { UserId = loginData.UserId, DisplayName = loginData.LoginName }; ServerLayoutModel layoutInfo = new ServerLayoutModel() { DesktopLayout = new WindowsModel() { PosLeft = minPosX, PosTop = minPosY, Width = maxPosX - minPosX, Height = maxPosY - minPosY }, LayoutColumn = loginData.ServerLayout.MatrixCol, LayoutRow = loginData.ServerLayout.MatrixRow, }; WindowsModel viewingArea = new WindowsModel() { PosLeft = loginData.ViewingArea.LeftPos, PosTop = loginData.ViewingArea.TopPos, Width = loginData.ViewingArea.RightPos - loginData.ViewingArea.LeftPos, Height = loginData.ViewingArea.BottomPos - loginData.ViewingArea.TopPos }; // save to settings ServerSettings.GetInstance().DesktopLeft = layoutInfo.DesktopLayout.PosLeft; ServerSettings.GetInstance().DesktopTop = layoutInfo.DesktopLayout.PosTop; ServerSettings.GetInstance().DesktopWidth = layoutInfo.DesktopLayout.Width; ServerSettings.GetInstance().DesktopHeight = layoutInfo.DesktopLayout.Height; ServerSettings.GetInstance().ViewingAreaLeft = viewingArea.PosLeft; ServerSettings.GetInstance().ViewingAreaTop = viewingArea.PosTop; ServerSettings.GetInstance().ViewingAreaWidth = viewingArea.Width; ServerSettings.GetInstance().ViewingAreaHeight = viewingArea.Height; ServerSettings.GetInstance().DesktopRow = layoutInfo.LayoutRow; ServerSettings.GetInstance().DesktopColumn = layoutInfo.LayoutColumn; UserSettings.GetInstance().UserId = userInfo.UserId; UserSettings.GetInstance().DisplayName = userInfo.DisplayName; // update the gui client.RefreshLayout(userInfo, layoutInfo, viewingArea); ServerUserSettingCmdImpl userSettingImpl = new ServerUserSettingCmdImpl(client); userSettingImpl.ExecuteCommand(userId, loginData.UserSetting.getCommandString()); // update the application priviledge ServerAppStatusCmdImpl appCmdImpl = new ServerAppStatusCmdImpl(client); appCmdImpl.ExecuteCommand(userId, loginData.UserApplications.getCommandString()); // update the maintenance priviledge ServerMaintenanceCmdImpl maintenanceCmdImpl = new ServerMaintenanceCmdImpl(client); maintenanceCmdImpl.ExecuteCommand(userId, loginData.UserMaintenance.getCommandString()); // update presets saved ServerPresetCmdImpl presetCmdImpl = new ServerPresetCmdImpl(client); presetCmdImpl.ExecuteCommand(userId, loginData.UserPresets.getCommandString()); // update vnc saved ServerVncStatusCmdImpl vncCmdImp = new ServerVncStatusCmdImpl(client); vncCmdImp.ExecuteCommand(userId, loginData.VncStatus.getCommandString()); }