// Token: 0x06000207 RID: 519 RVA: 0x0000AEEC File Offset: 0x000090EC public static void ComputeHash(T_CimRecord cimRecord, List <Pair <int, bool> > keyColumnIndexes) { if (cimRecord != null) { uint theStartingCRC = 0u; uint theStartingCRC2 = 0u; if (cimRecord.CimValueFields != null) { int index; for (index = 0; index < cimRecord.CimValueFields.Length; index++) { string text = cimRecord.CimValueFields[index]; if (text != null) { theStartingCRC2 = CRC32.Crc32(theStartingCRC2, text); Pair <int, bool> pair = keyColumnIndexes.Find((Pair <int, bool> x) => x.Item1 == index); if (pair != null) { theStartingCRC = CRC32.Crc32(theStartingCRC, pair.Item2 ? text : text.ToLower()); } } } } cimRecord.Recordid = theStartingCRC.ToString("x2"); cimRecord.ContentHash = theStartingCRC2.ToString("x2"); } }
public static void ComputeHash(T_CimData cimData) { if (cimData != null) { uint theStartingCRC = 0u; if (cimData.CimRecords != null) { foreach (T_CimRecord t_CimRecord in cimData.CimRecords) { if (t_CimRecord.ContentHash != null) { theStartingCRC = CRC32.Crc32(theStartingCRC, t_CimRecord.ContentHash); } } } if (cimData.CimTableName != null) { theStartingCRC = CRC32.Crc32(theStartingCRC, cimData.CimTableName); } cimData.ContentHash = theStartingCRC.ToString("x2"); } }
/// <summary> /// 序列化成Frame /// </summary> /// <param name="priority"></param> /// <param name="frameType"></param> /// <param name="buffer"></param> /// <param name="length"></param> /// <returns></returns> public static Frame Create( Int32 priority, FrameType frameType, Byte[] buffer, Int32 length) { Frame temp = null; lock (sIdleFrameList) { foreach (Frame frame in sIdleFrameList) { if (frame.mFrameData.Length >= (HeaderLength + length + TailLength)) { temp = frame; sIdleFrameList.Remove(frame); break; } } } if (temp == null) { temp = new Frame(); temp.mFrameData = new Byte[HeaderLength + length + TailLength]; } temp.mFrameType = frameType; temp.mPriority = priority; temp.mFrameID = sFrameID++; temp.mLength = HeaderLength + length + TailLength; Int32 len = 0; // 头部 Array.Copy(BitConverter.GetBytes(HeadMagicNumber), 0, temp.mFrameData, len, MagicNumberLength); len += sizeof(Int32); // 帧序号 Array.Copy(BitConverter.GetBytes(temp.mFrameID), 0, temp.mFrameData, len, sizeof(Int32)); len += sizeof(UInt32); // 帧类型 Array.Copy(BitConverter.GetBytes((Int32)frameType), 0, temp.mFrameData, len, 1); len += 1; // 数据长度 Array.Copy(BitConverter.GetBytes(length), 0, temp.mFrameData, len, sizeof(Int32)); len += sizeof(Int32); // 数据 Array.Copy(buffer, 0, temp.mFrameData, len, length); len += length; // CRC Int32 crc = CRC32.Crc32(temp.mFrameData, 0, HeaderLength); Array.Copy(BitConverter.GetBytes(crc), 0, temp.mFrameData, len, sizeof(Int32)); len += sizeof(Int32); // 尾部 Array.Copy(BitConverter.GetBytes(TailMagicNumber), 0, temp.mFrameData, len, MagicNumberLength); return(temp); }