/// <summary> /// FrsUpdateStructToByteArray is used to convert frsUpdate structure to byte array. /// </summary> /// <param name="frsUpdate"></param> /// <returns></returns> public static byte[] FrsUpdateStructToByteArray(_FRS_UPDATE frsUpdate) { byte[] buff = new byte[688]; int count = 0; BitConverter.GetBytes((uint)frsUpdate.present).CopyTo(buff, count); count = count + BitConverter.GetBytes((uint)frsUpdate.present).Length; BitConverter.GetBytes(frsUpdate.nameConflict).CopyTo(buff, count); count = count + BitConverter.GetBytes(frsUpdate.nameConflict).Length; BitConverter.GetBytes(frsUpdate.attributes).CopyTo(buff, count); count = count + BitConverter.GetBytes(frsUpdate.attributes).Length; BitConverter.GetBytes(frsUpdate.fence.dwLowDateTime).CopyTo(buff, count); count = count + BitConverter.GetBytes(frsUpdate.fence.dwLowDateTime).Length; BitConverter.GetBytes(frsUpdate.fence.dwHighDateTime).CopyTo(buff, count); count = count + BitConverter.GetBytes(frsUpdate.fence.dwHighDateTime).Length; BitConverter.GetBytes(frsUpdate.clock.dwLowDateTime).CopyTo(buff, count); count = count + BitConverter.GetBytes(frsUpdate.clock.dwLowDateTime).Length; BitConverter.GetBytes(frsUpdate.clock.dwHighDateTime).CopyTo(buff, count); count = count + BitConverter.GetBytes(frsUpdate.clock.dwHighDateTime).Length; BitConverter.GetBytes(frsUpdate.createTime.dwLowDateTime).CopyTo(buff, count); count = count + BitConverter.GetBytes(frsUpdate.createTime.dwLowDateTime).Length; BitConverter.GetBytes(frsUpdate.createTime.dwHighDateTime).CopyTo(buff, count); count = count + BitConverter.GetBytes(frsUpdate.createTime.dwHighDateTime).Length; //ContentsetId frsUpdate.contentSetId.ToByteArray().CopyTo(buff, count); count = count + frsUpdate.contentSetId.ToByteArray().Length; frsUpdate.hash.CopyTo(buff, count); count = count + frsUpdate.hash.Length; frsUpdate.rdcSimilarity.CopyTo(buff, count); count = count + frsUpdate.rdcSimilarity.Length; //uidDBGuid frsUpdate.uidDbGuid.ToByteArray().CopyTo(buff, count); count = count + frsUpdate.uidDbGuid.ToByteArray().Length; BitConverter.GetBytes(frsUpdate.uidVersion).CopyTo(buff, count); count = count + BitConverter.GetBytes(frsUpdate.uidVersion).Length; //gvsnDBGuid frsUpdate.gvsnDbGuid.ToByteArray().CopyTo(buff, count); count = count + frsUpdate.gvsnDbGuid.ToByteArray().Length; BitConverter.GetBytes(frsUpdate.gvsnVersion).CopyTo(buff, count); count = count + BitConverter.GetBytes(frsUpdate.gvsnVersion).Length; //parentDbGuid frsUpdate.parentDbGuid.ToByteArray().CopyTo(buff, count); count = count + frsUpdate.parentDbGuid.ToByteArray().Length; BitConverter.GetBytes(frsUpdate.parentVersion).CopyTo(buff, count); count = count + BitConverter.GetBytes(frsUpdate.parentVersion).Length; for (int i = 0; i < frsUpdate.name.Length; i++) { BitConverter.GetBytes(frsUpdate.name[0]); count = count + 2; } BitConverter.GetBytes((uint)frsUpdate.flags).CopyTo(buff, count); count = count + BitConverter.GetBytes((uint)frsUpdate.flags).Length; return(buff); }
/// <summary> /// From updateptr(frsUpdate) returned by the server. FRSUpdate structures are /// filled and returned. /// </summary> /// <param name="updateptr"></param> /// <param name="updateCount"></param> /// <param name="frsUpdate"></param> public static void getUpdates(IntPtr updateptr, uint updateCount, out _FRS_UPDATE[] frsUpdate) { frsUpdate = new _FRS_UPDATE[updateCount]; long updatesAddress = (long)updateptr; byte[] contentguid = new byte[16]; //From updateptr(frsUpdate) returned by the server. FRSUpdate structures are //filled and returned. for (int i = 0; i < updateCount; i++) { frsUpdate[i].present = (present_Values)Marshal.ReadInt32((IntPtr)updatesAddress); updatesAddress = updatesAddress + 4; frsUpdate[i].nameConflict = Marshal.ReadInt32((IntPtr)updatesAddress); updatesAddress = updatesAddress + 4; frsUpdate[i].attributes = (uint)Marshal.ReadInt32((IntPtr)updatesAddress); updatesAddress = updatesAddress + 4; frsUpdate[i].fence = (_FILETIME)Marshal.PtrToStructure((IntPtr)updatesAddress, typeof(_FILETIME)); updatesAddress = updatesAddress + 8; frsUpdate[i].clock = (_FILETIME)Marshal.PtrToStructure((IntPtr)updatesAddress, typeof(_FILETIME)); updatesAddress = updatesAddress + 8; frsUpdate[i].createTime = (_FILETIME)Marshal.PtrToStructure((IntPtr)updatesAddress, typeof(_FILETIME)); updatesAddress = updatesAddress + 8; for (int j = 0; j < 16; j++) { contentguid[j] = Marshal.ReadByte((IntPtr)updatesAddress); updatesAddress = updatesAddress + 1; } frsUpdate[i].contentSetId = new Guid(contentguid); frsUpdate[i].hash = new byte[20]; for (int j = 0; j < 20; j++) { frsUpdate[i].hash[j] = Marshal.ReadByte((IntPtr)updatesAddress); updatesAddress = updatesAddress + 1; } frsUpdate[i].rdcSimilarity = new byte[16]; for (int j = 0; j < 16; j++) { frsUpdate[i].rdcSimilarity[j] = Marshal.ReadByte((IntPtr)updatesAddress); updatesAddress = updatesAddress + 1; } byte[] uiddbguid = new byte[16]; for (int j = 0; j < 16; j++) { uiddbguid[j] = Marshal.ReadByte((IntPtr)updatesAddress); updatesAddress = updatesAddress + 1; } frsUpdate[i].uidDbGuid = new Guid(uiddbguid); frsUpdate[i].uidVersion = (ulong)Marshal.ReadInt64((IntPtr)updatesAddress); updatesAddress = updatesAddress + 8; byte[] gvsndbguid = new byte[16]; for (int j = 0; j < 16; j++) { gvsndbguid[j] = Marshal.ReadByte((IntPtr)updatesAddress); updatesAddress = updatesAddress + 1; } frsUpdate[i].gvsnDbGuid = new Guid(gvsndbguid); frsUpdate[i].gvsnVersion = (ulong)Marshal.ReadInt64((IntPtr)updatesAddress); updatesAddress = updatesAddress + 8; byte[] parentdbguid = new byte[16]; for (int j = 0; j < 16; j++) { parentdbguid[j] = Marshal.ReadByte((IntPtr)updatesAddress); updatesAddress = updatesAddress + 1; } frsUpdate[i].parentDbGuid = new Guid(parentdbguid); frsUpdate[i].parentVersion = (ulong)Marshal.ReadInt64((IntPtr)updatesAddress); updatesAddress = updatesAddress + 8; frsUpdate[i].name = new short[262]; for (int j = 0; j < 262; j++) { frsUpdate[i].name[j] = (short)Marshal.ReadInt16((IntPtr)updatesAddress); updatesAddress += sizeof(short); } var nameRaw = new byte[frsUpdate[i].name.Length * 2]; Buffer.BlockCopy(frsUpdate[i].name, 0, nameRaw, 0, frsUpdate[i].name.Length * 2); string fname = Encoding.Unicode.GetString(nameRaw); if (-1 != fname.IndexOf('\0')) { fname = fname.Substring(0, fname.IndexOf('\0')); } TestSite.Log.Add(LogEntryKind.Checkpoint, "Received FRS_UPDATE with name: {0}", fname); frsUpdate[i].flags = (flags_Values)Marshal.ReadInt32((IntPtr)updatesAddress); updatesAddress += sizeof(Int32); } }
/// <summary> /// frsUpdate byte array is filled into the FRS_UPDATE_PTR structure to /// give it as input parameter to Initializefiletransferasync. /// </summary> /// <param name="frsUpdate"></param> /// <returns></returns> public static FRS_UPDATE_PTR updateFrs(_FRS_UPDATE frsUpdate) { FRS_UPDATE_PTR frsUpdatePtr = new FRS_UPDATE_PTR(frsUpdate); return(frsUpdatePtr); }
public static extern uint InitializeFileDataTransfer(System.IntPtr bindingHandle, System.Guid connectionId, ref _FRS_UPDATE frsUpdate, out System.IntPtr?serverContext, ulong offset, ulong length, [Inline()][Length("*sizeRead")][Size("bufferSize")] out byte[] dataBuffer, uint bufferSize, out System.UInt32?sizeRead, out System.Int32?isEndOfFile);