void Run() { while (ready) { if (works.IsEmpty) { Thread.Sleep(500); continue; } WorkCompare work; works.TryDequeue(out work); if (work != null) { try { lock (lock_) { InfoResultSearchFile iresult = new InfoResultSearchFile(); iresult.fileName = work.isearch.FileName; iresult.fileNameCompare = work.isearch.Filecompare; iresult.fileName_brief = work.isearch.FileName_brief; iresult.Size = work.GetFileSize(work.isearch.FileName); iresult.CompareCharacterize = "--fulling-- compare | "; iresult.CompareCharacterize += ((work.CompareFilesWithHash(work.isearch.Filecompare, work.isearch.FileName))?"hash not equal": "hash equal") + " | "; int _numByteWithBitErrors = 0; bool bitErr = work.CompareFilesByte(out _numByteWithBitErrors, work.isearch.Filecompare, work.isearch.FileName); iresult.CompareCharacterize += ((bitErr) ? "byte not equal" : "byte equal") + " | "; iresult.BitError = (!bitErr) ? "0": _numByteWithBitErrors.ToString(); //iresult.BitError = "0"; iresult.Date = DateTime.Now; //if (iresult.Size > 30000 && iresult.Size < 40000) //Util.message("[" + nameWorker + "] -- " + Util.message( iresult.fileName_brief + " | " + iresult.CompareCharacterize + " | " + iresult.BitError + " | " + iresult.Size.ToString()); //if (iresult.Size > 30000 && iresult.Size < 40000) dam.AddResponse(iresult); //if (iresult.Size > 30000 && iresult.Size < 40000) work.SavetoFile(iresult); //work.GetBytesFromFile(); } } catch (Exception err) { Util.errorMessage(err.Message, work.isearch.FileName_brief); } } } }
public void SavetoFile(InfoResultSearchFile iresult) { //DateTime tm = DateTime.Now; //string rndStr = "";//Path.GetRandomFileName(); string fileNameData = Util.fn; XDocument xd = File.Exists(fileNameData) ? XDocument.Load(fileNameData) : new XDocument(new XElement("table")); xd.Root.Add(new XElement("records", // измерение оcновным блоком new XElement("data", "data", new XAttribute("fileName", iresult.fileName), new XAttribute("fileNameCompare", iresult.fileNameCompare), new XAttribute("CompareCharacterize", iresult.CompareCharacterize), new XAttribute("Size", iresult.Size.ToString()), new XAttribute("Date", iresult.Date.ToString()), new XAttribute("BitError", iresult.BitError)) )); xd.Save(fileNameData); }
public void AddResponse(InfoResultSearchFile iresult) { responses.Enqueue(iresult); }