/// <summary> /// 读取一个数据集 /// </summary> /// <param name="stream">文件流</param> /// <param name="nextData">返回下一个数据集的起点</param> /// <param name="fileBeginOffset">数据集起始位,相对于流的起始位置</param> /// <returns></returns> public virtual FCS ReadDataset(Stream stream, out long nextData, long fileBeginOffset = 0) { if (fileBeginOffset > stream.Length) { throw new Exception("Offset is too big"); } FCS fcs = new FCS(); FCSFileParameter parameter = new FCSFileParameter(); ReadHead(stream, fileBeginOffset, parameter); AnalyseUTF8KeyValue(ReadBytes(stream, fileBeginOffset, parameter.TextBegin, parameter.TextEnd), fcs.TextSegment, parameter.DelimiterByte); FillParameterFromTextSegment(fcs.TextSegment, parameter); if (parameter.STextBegin != 0 && parameter.STextEnd != 0) { AnalyseUTF8KeyValue(ReadBytes(stream, fileBeginOffset, parameter.STextBegin, parameter.STextEnd), fcs.TextSegment, parameter.DelimiterByte); } if (parameter.AnalysisBegin != 0 && parameter.AnalysisEnd != 0) { AnalyseUTF8KeyValue(ReadBytes(stream, fileBeginOffset, parameter.AnalysisBegin, parameter.AnalysisEnd), fcs.AnalysisSegment, parameter.DelimiterByte); } fcs.Measurements = AnalyseParams(fcs.TextSegment, parameter.PAR, parameter.DataType); AnalyseData(stream, fileBeginOffset, parameter.DataBegin, parameter.DataEnd, fcs.Measurements, parameter.TOT, parameter.DataType, parameter.ByteOrd); nextData = parameter.NextData; return(fcs); }
public PowerPointEncryption(Attachment attachment, FCS.Lite.Interface.File file) : base(attachment, file) { switch (file.FileType) { case FileType.PowerPointX: m_ppFileTypeExtension = ".pptx"; break; case FileType.PowerPointMacroX: m_ppFileTypeExtension = ".pptm"; break; case FileType.PowerPointTemplateX: m_ppFileTypeExtension = ".potx"; break; case FileType.PowerPointMacroTemplateX: m_ppFileTypeExtension = ".potm"; break; case FileType.PowerPoint: m_ppFileTypeExtension = ".ppt"; break; case FileType.PowerPointShowX: m_ppFileTypeExtension = ".ppsx"; break; case FileType.PowerPointMacroShowX: m_ppFileTypeExtension = ".ppsm"; break; } }
public void CalcFCS() { string errorMessage; FCS fcs; FCS.TryParse(this.Frame.CalcCRC(), out errorMessage, out fcs); this.Frame.FCS = fcs; this.tbFCS.Text = fcs.ToString(); }
private void tbFCS_TextChanged(object sender, EventArgs e) { TextBox tb = sender as TextBox; string errorMessage; FCS fcs; errorProvider1.SetError(tb, ""); this.Frame.FCS = null; if (!FCS.TryParse(tb.Text, out errorMessage, out fcs)) { errorProvider1.SetError(tb, errorMessage); } else { this.Frame.FCS = fcs; } }
public override void Update(double dt) { // Update atmospheric properties Atmosphere.Position = Translation; Atmosphere.Update(dt); if (Fuselage != null) { Fuselage.Density = Atmosphere.Density; } // Update FCS FCS.HorizonVelocity = Matrix <double> .Build.RotationZ(-Attitude.z()) * (Rotation * Velocity); FCS.Velocity = Velocity; FCS.AngularVelocity = AngularVelocity; FCS.Attitude = Attitude; FCS.Update(dt); PreUpdate(dt); base.Update(dt); PostUpdate(dt); }
private static List<string> GetNodeRegexOccurrences(FCS.Lite.Base.IAbstractTextNode textNode, string regex) { List<string> matches = new List<string>(); FCS.Lite.Regex currentExpression = new FCS.Lite.Regex(regex, true); for (int i = 0; i < textNode.GetInfoCount(); ++i) { FCS.Lite.Base.NodeInfo nodeInfo = textNode.GetInfo(i); System.Collections.ArrayList matchList = currentExpression.Matches(nodeInfo.value); for (int j = 0; j < matchList.Count; ++j) { string currentMatch = matchList[j] as string; if (string.IsNullOrEmpty(currentMatch)) continue; if (currentMatch.Length == 0) matches.Add(nodeInfo.value); else matches.Add(currentMatch); } } return matches; }
private static List<string> GetNodeOccurrences(FCS.Lite.Base.IAbstractTextNode textNode, string[] searchContent) { List<string> matches = new List<string>(); for (int i = 0; i < textNode.GetInfoCount(); ++i) { FCS.Lite.Base.NodeInfo nodeInfo = textNode.GetInfo(i); // Look for the content in the nodeInfo for(int j = 0; j < searchContent.Length; ++j) { string val = nodeInfo.value; int pos = -1; do { pos = val.IndexOf(searchContent[j], pos + 1); if(pos != -1) matches.Add(nodeInfo.value); } while (pos != -1); } } return matches; }
private static Dictionary<FCS.Lite.Base.IAbstractTextNode, List<string>> GetNodesForContexts(FCS.Lite.Base.DocumentText docText, string[] contexts) { Dictionary<FCS.Lite.Base.IAbstractTextNode, List<string>> nodes = new Dictionary<FCS.Lite.Base.IAbstractTextNode, List<string>>(); List<FCS.Lite.Base.IAbstractTextType>.Enumerator enumer = docText.TextTypeEnumerator(); while (enumer.MoveNext()) { FCS.Lite.Base.IAbstractTextType textType = enumer.Current as FCS.Lite.Base.TextType; if (textType == null) continue; for (int i = 0; i < contexts.Length; ++i) { if (enumer.Current.ToString().IndexOf(contexts[i]) != -1) { // Found a textType that I want to check for content. // Need to add all it's children.. for (int j = 0; j < enumer.Current.GetChildCount(); ++j) { FCS.Lite.Base.IAbstractTextNode child = textType.GetChild(j); if (!nodes.ContainsKey(child)) { List<string> types = new List<string>(); types.Add(contexts[i]); nodes.Add(child, types); } else { nodes[child].Add(contexts[i]); } } } } } return nodes; }
private static void ProcessTextType(IDocumentReader reader, string textTypeStringified, FCS.Lite.Base.IAbstractTextType textType) { if (MetadataProcessor.OperMode == MetadataProcessor._OperMode.Professional) { Workshare.FCS.Lite.Base.ContentType type = textType.GetContentType(); if (!((type == Workshare.FCS.Lite.Base.ContentType.TextBox) || (type == Workshare.FCS.Lite.Base.ContentType.CellText) || (type == Workshare.FCS.Lite.Base.ContentType.WorkshareProperty) || (type == Workshare.FCS.Lite.Base.ContentType.SmartTag))) { MetadataProcessor.ProcessType(reader, textTypeStringified, textType); return; } } bool cancel = false; FCS.Lite.Base.IAbstractTextType basicTextType = textType; if (basicTextType == null) return; for (int i = 0; i < textType.GetChildCount(); ++i) { FCS.Lite.Base.IAbstractTextNode textNode = basicTextType.GetChild(i); List<FCS.Lite.Base.NodeInfo>.Enumerator enumer = textNode.InfoEnumerator(); StringBuilder builtString = new StringBuilder(); while (enumer.MoveNext()) { if (((enumer.Current.name == "Content") && (textTypeStringified != "TrackChange")) || ((enumer.Current.name == "Comment") && ((textTypeStringified == "Comment") || (textTypeStringified == "CellText")))) builtString.Append(enumer.Current.value); else if (string.Compare(textTypeStringified, "TrackChange", true, CultureInfo.InvariantCulture) == 0) builtString.Append(enumer.Current.value); } reader.OnContentData(textTypeStringified, builtString.ToString(), ref cancel); } }
private static void ProcessCustomProperties(IDocumentReader reader, FCS.Lite.Base.IAbstractTextType textType) { FCS.Lite.Base.IAbstractTextType basicTextType = textType; if (basicTextType == null) return; for (int i = 0; i < textType.GetChildCount(); ++i) { FCS.Lite.Base.IAbstractTextNode textNode = basicTextType.GetChild(i); List<FCS.Lite.Base.NodeInfo>.Enumerator enumer = textNode.InfoEnumerator(); string name = ""; string value = ""; string type = ""; while (enumer.MoveNext()) { if (enumer.Current.name == "Name") name = enumer.Current.value; else if (enumer.Current.name == "Value") { value = enumer.Current.value; type = enumer.Current.type.ToString(); } } switch (textType.GetContentType()) { case Workshare.FCS.Lite.Base.ContentType.CustomProperty: reader.OnCustomProperty(name, value, type); break; case Workshare.FCS.Lite.Base.ContentType.WorkshareProperty: reader.OnWorkshareProperty(name, value, type); break; default: break; } } }
internal MetadataItem(FCS.Lite.Base.IAbstractTextNode iAbstractTextNode) { details = new DetailCollection(iAbstractTextNode); }
private bool Allocate() { bool result = true; models = new Model[(int)eModels.eNumStandardModels]; // First build the inertial model since some other models are relying on // the inertial model and the ground callback to build themselves. // Note that this does not affect the order in which the models will be // executed later. models[(int)eModels.eInertial] = new Inertial(this); // See the eModels enum specification in the header file. The order of the // enums specifies the order of execution. The Models[] vector is the primary // storage array for the list of models. models[(int)eModels.ePropagate] = new Propagate(this); models[(int)eModels.eInput] = new Input(this); models[(int)eModels.eAtmosphere] = new StandardAtmosphere(this); models[(int)eModels.eWinds] = new Winds(this); models[(int)eModels.eSystems] = new FlightControlSystem(this); models[(int)eModels.eMassBalance] = new MassBalance(this); models[(int)eModels.eAuxiliary] = new Auxiliary(this); models[(int)eModels.ePropulsion] = new Propulsion(this); models[(int)eModels.eAerodynamics] = new Aerodynamics(this); models[(int)eModels.eGroundReactions] = new GroundReactions(this); //PENDING new JSBSIM models[(int)eModels.eExternalReactions] = new ExternalReactions(this); //PENDING new JSBSIM models[(int)eModels.eBuoyantForces] = new BuoyantForces(this); models[(int)eModels.eAircraft] = new Aircraft(this); models[(int)eModels.eAccelerations] = new Accelerations(this); models[(int)eModels.eOutput] = new Output(this); // Assign the Model shortcuts for internal executive use only. propagate = (Propagate)models[(int)eModels.ePropagate]; inertial = (Inertial)models[(int)eModels.eInertial]; atmosphere = (Atmosphere)models[(int)eModels.eAtmosphere]; winds = (Winds)models[(int)eModels.eWinds]; FCS = (FlightControlSystem)models[(int)eModels.eSystems]; massBalance = (MassBalance)models[(int)eModels.eMassBalance]; auxiliary = (Auxiliary)models[(int)eModels.eAuxiliary]; propulsion = (Propulsion)models[(int)eModels.ePropulsion]; aerodynamics = (Aerodynamics)models[(int)eModels.eAerodynamics]; groundReactions = (GroundReactions)models[(int)eModels.eGroundReactions]; //PENDING new JSBSIM externalReactions = (ExternalReactions)models[(int)eModels.eExternalReactions]; //PENDING new JSBSIM buoyantForces = (BuoyantForces)models[(int)eModels.eBuoyantForces]; aircraft = (Aircraft)models[(int)eModels.eAircraft]; accelerations = (Accelerations)models[(int)eModels.eAccelerations]; //PENDING new JSBSIM output = (Output)models[(int)eModels.eOutput]; // Initialize planet (environment) constants LoadPlanetConstants(); // Initialize models for (int i = 0; i < models.Length; i++) { // The Input/Output models must not be initialized prior to IC loading if (i == (int)eModels.eInput || i == (int)eModels.eOutput) { continue; } //PENDING new JSBSIM LoadInputs(i); if (models[i] != null) { models[i].InitModel(); } } ic = new InitialCondition(this); ic.Bind(instance); modelLoaded = false; return(result); //---------------------- old code pending #if DELETEME bool result = true; massBalance = new MassBalance(this); //output = new Output(this); input = new Input(this); //TODO groundCallback = new DefaultGroundCallback(); state = new State(this); // This must be done here, as the State // class needs valid pointers to the above model classes // Initialize models so they can communicate with each other if (!atmosphere.InitModel()) { if (log.IsErrorEnabled) { log.Error("Atmosphere model init failed"); } error += 1; } if (!FCS.InitModel()) { if (log.IsErrorEnabled) { log.Error("FCS model init failed"); } error += 2; } if (!propulsion.InitModel()) { if (log.IsErrorEnabled) { log.Error("Propulsion model init failed"); } error += 4; } if (!massBalance.InitModel()) { if (log.IsErrorEnabled) { log.Error("MassBalance model init failed"); } error += 8; } if (!aerodynamics.InitModel()) { if (log.IsErrorEnabled) { log.Error("Aerodynamics model init failed"); } error += 16; } if (!inertial.InitModel()) { if (log.IsErrorEnabled) { log.Error("Inertial model init failed"); } error += 32; } if (!groundReactions.InitModel()) { if (log.IsErrorEnabled) { log.Error("Ground Reactions model init failed"); } error += 64; } if (!aircraft.InitModel()) { if (log.IsErrorEnabled) { log.Error("Aircraft model init failed"); } error += 128; } if (!propagate.InitModel()) { if (log.IsErrorEnabled) { log.Error("Propagate model init failed"); } error += 256; } if (!auxiliary.InitModel()) { if (log.IsErrorEnabled) { log.Error("Auxiliary model init failed"); } error += 512; } if (!input.InitModel()) { if (log.IsErrorEnabled) { log.Error("Intput model init failed"); } error += 1024; } if (error > 0) { result = false; } ic = new InitialCondition(this); // Schedule a model. The second arg (the integer) is the pass number. For // instance, the atmosphere model gets executed every fifth pass it is called // by the executive. Everything else here gets executed each pass. // IC and Trim objects are NOT scheduled. Schedule(input, 1); Schedule(atmosphere, 1); Schedule(FCS, 1); Schedule(propulsion, 1); Schedule(massBalance, 1); Schedule(aerodynamics, 1); Schedule(inertial, 1); Schedule(groundReactions, 1); Schedule(aircraft, 1); Schedule(propagate, 1); Schedule(auxiliary, 1); //Schedule(output, 1); modelLoaded = false; return(result); #endif }
private void Save(Dictionary <PortfolioPosition, CashFlow> dictionary) { foreach (var x in dictionary) { var transaction = _dbLink.GetConnection().BeginTransaction(IsolationLevel.ReadCommitted); try { var finIdent = x.Key.Ident; var finType = x.Key.FinType; string finTypeIdent = _mapping.GetAI(finType); #region финансовый инструмент fin_instrument finInstrument = new fin_instrument() { ident = finIdent, title = finIdent, ft_id = int.Parse(finTypeIdent) }; if (FinInstrument.FindId(_dbLink, finInstrument.ident) == null) { FinInstrument.Insert(_dbLink, finInstrument); } finInstrument = FinInstrument.FindId(_dbLink, finInstrument.ident); #endregion #region Data_source data_source dataSource = new data_source() { ident = _providerParams[SCALAR].ToString(), }; dataSource = DataSource.FindId(_dbLink, dataSource.ident); #endregion #region fcs fcs ffd = new fcs() { ds_id = dataSource.ds_id, fi_id = finInstrument.fi_id, ct_id = int.Parse(_mapping.GetAI(x.Value.Attribute)) }; if (FCS.Find(_dbLink, ffd.fi_id, ffd.ds_id, ffd.ct_id) == null) { FCS.Insert(_dbLink, ffd); } ffd = FCS.Find(_dbLink, ffd.fi_id, ffd.ds_id, ffd.ct_id); #endregion #region Денежный поток foreach (var z in x.Value.Values) { cashflow cf = new cashflow() { cf_id = ffd.cf_id, dat = z.Key, val = z.Value, valid_dat = (DateTime)_providerParams[REPORTDATE] }; if (Cashflow.FindId(_dbLink, cf.cf_id, cf.dat, cf.valid_dat) == null) { //первое значение, следовательно 01.01.1900 год cf.valid_dat = new DateTime(1900, 01, 01); Cashflow.Insert(_dbLink, cf); } else { Cashflow.Insert(_dbLink, cf); } } #endregion transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); } } }
internal DetailCollection(FCS.Lite.Base.IAbstractTextNode iAbstractTextNode) { // TODO: Complete member initialization this.iAbstractTextNode = iAbstractTextNode; }
internal Detail(FCS.Lite.Base.NodeInfo nodeInfo) { this.nodeInfo = nodeInfo; }
/*public void SendCommand(String Commands, String Address, String Data) * { * string FCS; * string input = "00" + Commands + Address + Data; * char[] values = input.ToCharArray(); * char[] first = "@".ToCharArray(); * int sum = first[0]; * foreach (char letter in values) * { * sum = letter ^ sum; * } * FCS = Convert.ToString(sum, 16); * string sendcommand = "@00" + Commands + Address + Data + FCS + "*\r\n"; * Comports.WriteLine(sendcommand); //写入数据 * }*/ private int CommandTrant2(String Commands, String Address, String Data) { try { //FCS转换 string FCS; int temp; temp = Convert.ToInt32(Data); Data = Convert.ToString(temp, 16); Data = Data.PadLeft(4, '0'); Commands = Commands.ToUpper(); Address = Address.ToUpper(); Data = Data.ToUpper(); string input = "00" + Commands + Address + Data; char[] values = input.ToCharArray(); char[] first = "@".ToCharArray(); int sum = first[0]; foreach (char letter in values) { sum = letter ^ sum; } FCS = Convert.ToString(sum, 16); //发送指令 string sendcommand = "@00" + Commands + Address + Data + FCS.ToUpper() + "*\r\n"; //Console.Write(sendcommand); string FCS2; string input2 = "00" + Commands + "00"; char[] values2 = input2.ToCharArray(); char[] first2 = "@".ToCharArray(); int sum2 = first2[0]; foreach (char letter2 in values2) { sum2 = letter2 ^ sum2; } FCS2 = Convert.ToString(sum2, 16); Comports.WriteLine(sendcommand); result = null; Thread.Sleep(70); Console.Write("正确输出:" + "@00" + Commands + "00" + FCS2.ToUpper() + "*\n"); int count = 0; while (result != "@00" + Commands + "00" + FCS2.ToUpper() + "*") { if (result == "@00WD0152*") { return(0); } //Console.Write("实际输出:" + result); Comports.WriteLine(sendcommand); //Thread.Sleep(20); count++; if (count == 3) { OpenComPortSig = false; return(-1); } // Console.Write("输入命令:" + sendcommand + "\n"); } return(0); //Console.Write("最后输出:" + result); } catch { return(-1); } }
/// <summary> /// 保存一个数据集 /// 头段、文本段、数据段、补充文本段、解析段依次保存 /// </summary> /// <param name="stream">可写入的流</param> /// <param name="fcs">数据集</param> /// <param name="fileBeginOffset">写入的首位位置,相对于流的起始位</param> /// <param name="haveNext">是否有下一个数据集,如果有,该数据集的nextdata不能为0</param> /// <param name="nextOffset">下一个数据集的起始位置,相对于当前数据集的起始位置</param> /// <returns></returns> protected virtual void Save(Stream stream, FCS fcs, long fileBeginOffset, bool haveNext, out long nextOffset) { #region 重置一些基本参数 ResetTextSegment(fcs.TextSegment, fcs.Measurements); if (fcs.TextSegment.ContainsKey(Keys.BeginAnalysisKey)) { fcs.TextSegment.Remove(Keys.BeginAnalysisKey); //移除位置信息,后续计算 } if (fcs.TextSegment.ContainsKey(Keys.EndAnalysisKey)) { fcs.TextSegment.Remove(Keys.EndAnalysisKey); } if (fcs.TextSegment.ContainsKey(Keys.BeginSTextKey)) { fcs.TextSegment.Remove(Keys.BeginSTextKey); } if (fcs.TextSegment.ContainsKey(Keys.EndSTextKey)) { fcs.TextSegment.Remove(Keys.EndSTextKey); } if (fcs.TextSegment.ContainsKey(Keys.BeginDataKey)) { fcs.TextSegment.Remove(Keys.BeginDataKey); } if (fcs.TextSegment.ContainsKey(Keys.EndDataKey)) { fcs.TextSegment.Remove(Keys.EndDataKey); } if (fcs.TextSegment.ContainsKey(Keys.NextDataKey)) { fcs.TextSegment.Remove(Keys.NextDataKey); } #endregion byte[] headBytes = CreateEmptyHeadBytes(); MemoryStream textStream = DictionaryToStream(fcs.TextSegment, Keys.DelimiterByte); //文本段 MemoryStream stextStream = null; //补充文本段 MemoryStream analysisStream = (fcs.AnalysisSegment != null && fcs.AnalysisSegment.Count > 0) ? DictionaryToStream(fcs.AnalysisSegment, Keys.DelimiterByte) : null; //分析段 #region 计算各个段的长度 long headLength = headBytes.Length; long bitLength = 0L; foreach (var item in fcs.Measurements) { bitLength += item.PnB; } long dataLength = (bitLength / 8) * Convert.ToInt32(fcs.TextSegment[Keys.TOTKey]);//数据段总长度 long textLength = textStream.Length; long stextLength = 0L; long analysisLength = analysisStream == null ? 0L : analysisStream.Length; long beginendLength = 0L; long calculationLength = CalculationSegmentTextLength(headLength, textLength + beginendLength, dataLength, stextLength, analysisLength, haveNext);//记录各段位置的文本段长度 while (calculationLength != beginendLength) { beginendLength = calculationLength; calculationLength = CalculationSegmentTextLength(headLength, textLength + beginendLength, dataLength, stextLength, analysisLength, haveNext); } if ((headLength + textLength + beginendLength) > 99999999)//文本段过大,需要拆分到补充文本段 { var texts = SplitTextSegment(fcs.TextSegment, fcs.Measurements.Count); textStream = DictionaryToStream(texts[0], Keys.DelimiterByte); //文本段重新计算 stextStream = DictionaryToStream(texts[1], Keys.DelimiterByte); //计算补充文本段 textLength = textStream.Length; stextLength = stextStream.Length; beginendLength = 0L; calculationLength = CalculationSegmentTextLength(headLength, textLength + beginendLength, dataLength, stextLength, analysisLength, haveNext); while (calculationLength != beginendLength) { beginendLength = calculationLength; calculationLength = CalculationSegmentTextLength(headLength, textLength + beginendLength, dataLength, stextLength, analysisLength, haveNext); } } #endregion #region 保存数据 MemoryStream segmentLocation = new MemoryStream();//记录各段位置的流,跟随文本段保存 var textBegin = Encoding.UTF8.GetBytes(headLength.ToString()); textBegin.CopyTo(headBytes, 18 - textBegin.Length); var textEnd = Encoding.UTF8.GetBytes((headLength + textLength + beginendLength - 1).ToString()); textEnd.CopyTo(headBytes, 26 - textEnd.Length); #region 数据段位置 var dataBegin = Encoding.UTF8.GetBytes((headLength + textLength + beginendLength).ToString()); var dataEnd = Encoding.UTF8.GetBytes((headLength + textLength + beginendLength + dataLength - 1).ToString()); if (dataEnd.Length <= 8) { dataBegin.CopyTo(headBytes, 34 - dataBegin.Length); dataEnd.CopyTo(headBytes, 42 - dataEnd.Length); } segmentLocation.WriteAll(Encoding.UTF8.GetBytes(Keys.BeginDataKey)); segmentLocation.WriteByte(Keys.DelimiterByte); segmentLocation.WriteAll(dataBegin); segmentLocation.WriteByte(Keys.DelimiterByte); segmentLocation.WriteAll(Encoding.UTF8.GetBytes(Keys.EndDataKey)); segmentLocation.WriteByte(Keys.DelimiterByte); segmentLocation.WriteAll(dataEnd); segmentLocation.WriteByte(Keys.DelimiterByte); #endregion if (stextLength > 0)//补充文本段位置 { var stextBegin = (headLength + textLength + beginendLength + dataLength).ToString(); var stextEnd = (headLength + textLength + beginendLength + dataLength + stextLength - 1).ToString(); segmentLocation.WriteAll(KeyValueToByteArray(Keys.BeginSTextKey, stextBegin, Keys.DelimiterByte)); segmentLocation.WriteAll(KeyValueToByteArray(Keys.EndSTextKey, stextEnd, Keys.DelimiterByte)); } if (analysisLength > 0)//解析段位置 { var analysisBegin = Encoding.UTF8.GetBytes((headLength + textLength + beginendLength + dataLength + stextLength).ToString()); var analysisEnd = Encoding.UTF8.GetBytes((headLength + textLength + beginendLength + dataLength + stextLength + analysisLength - 1).ToString()); if (analysisEnd.Length <= 8) { analysisBegin.CopyTo(headBytes, 42 - analysisBegin.Length); analysisEnd.CopyTo(headBytes, 50 - analysisEnd.Length); } segmentLocation.WriteAll(Encoding.UTF8.GetBytes(Keys.BeginAnalysisKey)); segmentLocation.WriteByte(Keys.DelimiterByte); segmentLocation.WriteAll(analysisBegin); segmentLocation.WriteByte(Keys.DelimiterByte); segmentLocation.WriteAll(Encoding.UTF8.GetBytes(Keys.EndAnalysisKey)); segmentLocation.WriteByte(Keys.DelimiterByte); segmentLocation.WriteAll(analysisEnd); segmentLocation.WriteByte(Keys.DelimiterByte); } if (haveNext) { nextOffset = headLength + textLength + beginendLength + dataLength + stextLength + analysisLength + 2; segmentLocation.WriteAll(KeyValueToByteArray(Keys.NextDataKey, nextOffset.ToString(), Keys.DelimiterByte)); } else { nextOffset = 0; segmentLocation.WriteAll(KeyValueToByteArray(Keys.NextDataKey, "0", Keys.DelimiterByte)); } //开始写入流并计算crc stream.Seek(fileBeginOffset, SeekOrigin.Begin); stream.Write(headBytes, 0, headBytes.Length); var crc = CRC16CCITT_Implementation.ComputeCrc(headBytes); textStream.WriteTo(stream); crc = CRC16CCITT_Implementation.ComputeCrc(textStream, crc); textStream.Dispose(); segmentLocation.WriteTo(stream); crc = CRC16CCITT_Implementation.ComputeCrc(segmentLocation, crc); segmentLocation.Dispose(); GC.Collect(); var dataStream = DataSegmentToStream(fcs.Measurements); dataStream.WriteTo(stream); crc = CRC16CCITT_Implementation.ComputeCrc(dataStream, crc); dataStream.Dispose(); if (stextStream != null) { stextStream.WriteTo(stream); crc = CRC16CCITT_Implementation.ComputeCrc(stextStream, crc); stextStream.Dispose(); } if (analysisStream != null) { analysisStream.WriteTo(stream); crc = CRC16CCITT_Implementation.ComputeCrc(analysisStream, crc); analysisStream.Dispose(); } stream.Write(BitConverter.GetBytes(crc), 0, 2); #endregion }
public FCSCoverage() { RI = new RI(); FCS = new FCS(); }
protected static bool ReadContent(IDocumentReader reader, FCS.Lite.Base.DocumentReader docReader) { using (docReader) { FCS.Lite.Base.DocumentText docText; try { docText = docReader.Read(); } catch (FileNotFoundException) { Logger.LogInfo("The reader has failed. The most likely reason is that this is an unknown file type."); return false; } if (docText == null) return false; // nothing we can do here - our reader failed List<FCS.Lite.Base.IAbstractTextType>.Enumerator enumer = docText.TextTypeEnumerator(); while (enumer.MoveNext()) { switch (enumer.Current.GetContentType()) { case Workshare.FCS.Lite.Base.ContentType.Paragraph: ProcessTextType(reader, "Paragraph", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.Header: ProcessTextType(reader, "Header", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.Footer: ProcessTextType(reader, "Footer", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.Comment: ProcessTextType(reader, "Comment", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.Footnote: ProcessTextType(reader, "Footnote", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.Endnote: ProcessTextType(reader, "Endnote", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.TrackChange: ProcessTextType(reader, "TrackChange", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.TextBox: ProcessTextType(reader, "TextBox", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.Reviewer: ProcessTextType(reader, "Reviewer", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.HiddenText: ProcessTextType(reader, "HiddenText", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.SmallText: ProcessTextType(reader, "SmallText", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.WhiteText: ProcessTextType(reader, "WhiteText", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.AttachedTemplate: ProcessTextType(reader, "AttachedTemplate", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.SmartTag: ProcessTextType(reader, "SmartTag", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.Version: ProcessTextType(reader, "Version", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.AutoVersion: ProcessTextType(reader, "AutoVersion", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.Field: ProcessTextType(reader, "Field", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.Hyperlink: ProcessTextType(reader, "Hyperlink", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.RoutingSlip: ProcessTextType(reader, "RoutingSlip", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.Variable: ProcessTextType(reader, "Variable", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.HiddenSlide: ProcessTextType(reader, "HiddenSlide", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.SpeakerNote: ProcessTextType(reader, "SpeakerNote", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.Links: ProcessTextType(reader, "Link", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.HiddenSheet: ProcessTextType(reader, "HiddenSheet", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.HiddenRow: ProcessTextType(reader, "HiddenRow", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.HiddenColumn: ProcessTextType(reader, "HiddenColumn", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.CellText: ProcessTextType(reader, "CellText", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.CustomProperty: ProcessCustomProperties(reader, enumer.Current); // For additional info... ProcessTextType(reader, "CustomProperty", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.WorkshareProperty: ProcessCustomProperties(reader, enumer.Current); // For additional info... ProcessTextType(reader, "WorkshareProperty", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.Macro: ProcessTextType(reader, "Macro", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.RedactedText: ProcessTextType(reader, "RedactedText", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.BuiltInProperty: ProcessTextType(reader, "BuiltInProperty", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.DocumentStatistic: ProcessTextType(reader, "DocumentStatistic", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.InkAnnotation: ProcessTextType(reader, "InkAnnotation", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.PDFProperties: ProcessTextType(reader, "Properties", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.PDFMarkups: ProcessTextType(reader, "Markups", enumer.Current); break; case Workshare.FCS.Lite.Base.ContentType.WorkshareStyle: { if (OptionsHelper.DetectWorkshareStyles) { ProcessTextType(reader, "WorkshareStyle", enumer.Current); } break; } default: throw new ApplicationException("Invalid Content Type in DocumentText! Enums out of date."); } } } return true; }