public void SendFileDownloadMessage(FileIdentifier dataType, string userName, bool reRequest, DateTime date) { var fdh = new FileDownloadHeader(); fdh.WhichFile = (byte)dataType; fdh.LastPieceOfChunk = false; fdh.AnotherSetToCome = reRequest; fdh.Action = 0; fdh.SpecificRecord = 0; fdh.Date = new MitsDate(date); connection.Send(MessageType.MESSAGE_36_START_OF_DAY_DOWNLOAD, userName, fdh); }
private void HandleFileDownloadChunk(MessageDetails des) { FileDownloadHeader fdh = Utilities.OnPacket <FileDownloadHeader>(des.data); int dataLength = des.data.Length; int length = dataLength - Marshal.SizeOf <FileDownloadHeader>(); byte[] compressedData = new byte[length]; if (fileDownloadStore.ContainsKey(fdh.WhichFile)) { Buffer.BlockCopy(des.data, Marshal.SizeOf <FileDownloadHeader>(), fileDownloadStore[fdh.WhichFile], fileDownloadStoreLength[fdh.WhichFile], length); fileDownloadStoreLength[fdh.WhichFile] += length; compressedData = new byte[fileDownloadStoreLength[fdh.WhichFile]]; } if (!fdh.LastPieceOfChunk) { if (!fileDownloadStore.ContainsKey(fdh.WhichFile)) { fileDownloadStore[fdh.WhichFile] = new byte[100000]; Buffer.BlockCopy(des.data, Marshal.SizeOf <FileDownloadHeader>(), fileDownloadStore[fdh.WhichFile], 0, length); fileDownloadStoreLength.Add(fdh.WhichFile, length); } return; } if (!fileDownloadStore.ContainsKey(fdh.WhichFile)) { fileDownloadStore[fdh.WhichFile] = new byte[length]; Buffer.BlockCopy(des.data, Marshal.SizeOf <FileDownloadHeader>(), fileDownloadStore[fdh.WhichFile], 0, length); fileDownloadStoreLength.Add(fdh.WhichFile, length); } if (!fileDownloadStoreLength.ContainsKey(fdh.WhichFile)) { fileDownloadStoreLength.Add(fdh.WhichFile, length); } Buffer.BlockCopy(fileDownloadStore[fdh.WhichFile], 0, compressedData, 0, fileDownloadStoreLength[fdh.WhichFile]); if (fdh.AnotherSetToCome) { _avventoApi.SendFileDownloadMessage((FileIdentifier)fdh.WhichFile, Utilities.ConvertFromDelphiString(des.header.UserName), true, DateTime.Today); } fileDownloadStore.Remove(fdh.WhichFile); fileDownloadStoreLength.Remove(fdh.WhichFile); HandleFileDownload(compressedData, (FileIdentifier)fdh.WhichFile, (ActionType)fdh.Action, (MessageType)des.header.MessageType, (MessageType)des.header.MessageType == MessageType.MESSAGE_36_START_OF_DAY_DOWNLOAD, fdh.AnotherSetToCome); }
public void SendFileDownloadMessage(FileDownloadHeader header, string username) { log.Debug("Sending File Download Message"); connection.Send(MessageType.MESSAGE_36_START_OF_DAY_DOWNLOAD, username, header); }