//toggle done state of an order and inform the server. private void toggleOrderDone(Order order, Docket ownerDocket, BindingList<object> partialDocket) { bool curState = getPartialDocketState(partialDocket); order.ToggleDone(); this.sendDoneCommand(ownerDocket, order); bool newState = getPartialDocketState(partialDocket); if (curState != newState) { setPartialDocketState(newState, partialDocket); this.refreshPage(); this.refreshListDataSource(); } }
//send done command of an order private void sendDoneCommand(Docket docket, Order order) { List<byte> data = new List<byte>(); int docketNumber = docket.DocketNumber; int index = docket.Orders.IndexOf(order); DoneCommand command = new DoneCommand(docketNumber, index); IFormatter formatter = new BinaryFormatter(); Stream stream = new MemoryStream(); formatter.Serialize(stream, command); byte[] res = ((MemoryStream)stream).ToArray(); int sendLength = res.Length; byte[] length = BitConverter.GetBytes(sendLength); data.AddRange(length); data.AddRange(res); this.state.WorkSocket.Send(data.ToArray()); }