private void ShowEntries(DriveInfo drive, List <UsnEntry> data) { if (data != null && data.Count() > 0) { foreach (var d in data) { TBResult.AppendText(string.Format("{0}\t\t{1}\t\t{2}", d.Usn, d.FileReferenceNumber, d.FileName)); TBResult.AppendText(Environment.NewLine); } } }
private void MainForm_Load(object sender, EventArgs e) { //获取所有NTFS磁盘 var drives = FileQueryEngine.GetReadyNtfsDrives(); CBDrives.Items.AddRange(drives.ToArray()); CBDrives.SelectedIndex = 0; TBResult.Text = "Usn\t\tReferenceNumber\t\tFileName"; TBResult.AppendText(Environment.NewLine); }
//_________________________________________________________________________ private void TestFtpWebRequest() { FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://127.0.0.1/"); request.Method = WebRequestMethods.Ftp.ListDirectoryDetails; request.Credentials = new NetworkCredential("ftp", ""); FtpWebResponse response = (FtpWebResponse)request.GetResponse(); //Console.WriteLine ("Содержимое сервера:"); Stream responseStream = response.GetResponseStream(); StreamReader reader = new StreamReader(responseStream); TBResult.AppendText(reader.ReadToEnd()); reader.Close(); responseStream.Close(); response.Close(); //Console.Read (); }
//_________________________________________________________________________ private void GetParFromHTM() { string asE = "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n<!-- saved from url=(0032)http://10.8.12.181/dynkoo_38.htm -->\n<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\">\n<script src=\"./dynkoo_38_files/jquery.js.Без названия\"></script><script src=\"./dynkoo_38_files/svn_rev_js.js.Без названия\"></script><script src=\"./dynkoo_38_files/ajax_skripte.js.Без названия\"></script>\n <style type=\"text/css\">\n h1 {font-size: 17pt; font-family: verdana,helvetica; text-decoration: none; white-space:nowrap;}\n h2 {font-size: 15pt; font-family: verdana,helvetica; text-decoration: none; white-space:nowrap;}\n h3 {font-size: 13pt; font-family: verdana,helvetica; text-decoration: none; white-space:nowrap;}\n tr {font-size: 10pt; font-family: verdana,helvetica; text-decoration: none; white-space:nowrap;}\n td {font-size: 10pt; font-family: verdana,helvetica; text-decoration: none; white-space:nowrap;}\n p {font-size: 10pt; font-family: verdana,helvetica; text-decoration: none; white-space:nowrap;}\n ul {font-size: 10pt; font-family: verdana,helvetica; text-decoration: none; white-space:nowrap;}\n a {font-family: verdana,helvetica;}\n td.gross {font-size: 12pt; font-weight:bold; font-family: verdana, helvetica; text-decoration: none; white-space:nowrap;}\n td.Blau {color: blue; font-family: verdana, helvetica; text-decoration: none; white-space:nowrap;}\n </style>\n<meta http-equiv=\"expires\" content=\"0\">\n\n<meta http-equiv=\"cache-control\" content=\"no-cache\">\n<meta http-equiv=\"pragma\" content=\"no-cache\">\n<link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"http://10.8.12.181/rmg.ico\">\n<title>Parameterization drkaDim\n</title>\n</head><body>\n<table class=\"tabWithoutEvents\" border=\"0\" bgcolor=\"#EEEEEE\"><tbody><tr bgcolor=\"#E4E4E4\">\n<td id=\"hersteller\">RMG Messtechnik</td>\n<td id=\"gerSerie\">ERZ 2000-NG</td>\n<td id=\"versionAP\">1.7.0</td>\n<td id=\"baujahr\">2018</td>\n<td id=\"schiene\">Ultrasonicmeter</td>\n<td id=\"messort\">ГРС Ельск</td>\n<td id=\"fabrikNr\">607428</td>\n<td id=\"now_2\">04-03-2019 15:56:42</td>\n</tr><tr bgcolor=\"#E4E4E4\"><td><input class=\"button\" type=\"button\" value=\"Print\" onclick=\"print();\"></td>\n<td id=\"actAccess2\">Closed</td>\n<td id=\"profil\">Service</td>\n<td><a href=\"http://10.8.12.181/dynerrs.htm\">Fault display</a></td>\n<td></td><td id=\"actErr_2\">no error</td>\n<td id=\"actAjaxConn\">1</td>\n<td align=\"right\"><input class=\"button\" type=\"button\" value=\"Refresh\" onclick=\"history.go(0);\"></td>\n</tr></tbody></table>\n<form action=\"http://10.8.12.181/dyndoparm_2\" method=\"post\" name=\"param\">\n<table bgcolor=\"#EEEEEE\">\n<tbody><tr><th>Access</th><th>Line</th><th>Designation</th><th>Value</th><th>Unit</th></tr><tr bgcolor=\"#DA70D6\"><td>G *</td><td>4</td><td>Unit</td><td id=\"drkaDim\" align=\"right\" class=\"gross\">MPa</td>\n<td></td></tr>\n</tbody></table>\n</form><script>function AjaxSpalteSetzen(){g_spalte=-3;g_sessionId=169604;}; function SVNRev_Setzen(){g_SVN_ERZ=1219};</script>\n\n</body></html>"; //Regex regex = new Regex ($"(?<=drkaDim)>[*]<"); //Regex regex = new Regex ($"(?<=drkaDim[.*])MPa"); //Regex regex = new Regex ($"(?<=drkaDim\" align=\"right\" class=\"gross\")>(?<name>.*)<");//[.*] work //<td id=\"drkaDim\" align=\"right\" class=\"gross\">MPa</td> Regex regex = new Regex("(?<=td id=\"drkaDim\"[\\w\\s\\W]*>)(?<name>.*)</td>"); MatchCollection matches = regex.Matches(asE); List <string> ListFiles = null; if (matches.Count > 0) { string asLine = matches[0].Groups[1].ToString(); ListFiles = new List <string> (matches.Count); int iMatch = 0; foreach (Match match in matches) { if (match.Success) { ++iMatch; //string asLine = match.Groups[0].Value;// SyncRoot.ToString (); //string asLine = match.Groups[0].ToString (); string asLine1 = match.Groups[1].ToString(); //string asLine1 = match.Groups["name"].ToString (); ListFiles.Add(asLine1); TBResult.AppendText(asLine1 + Environment.NewLine); } } TBResult.AppendText("Всего совпадений " + iMatch.ToString()); } else { TBResult.Text = "Нет данных"; } }
//......................................................................... private void BTest_Click(object sender, EventArgs e) { //int iVal = Global.BCDtoInt(0x25); try { HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument(); htmlDoc.Load(@"d:\archives\NG\localhost\dynparm_158.htm"); var NodePar = htmlDoc.DocumentNode.SelectNodes("//tr").Descendants().Where(x => x.Name == "td"); //HtmlNodeCollection links = NodePar.DocumentNode.SelectNodes (".//h2/a"); if (NodePar == null) { return; } bool bReadVal = false; foreach (HtmlNode link in NodePar) { TBResult.AppendText($"{link.InnerText}{Environment.NewLine}"); //if (bReadVal) //{ // TBResult.AppendText ($"{link.InnerText}{Environment.NewLine}"); // break; //} //if (link.InnerText.Equals ("Тип счётчика"))//zwkPrinzip //{ // bReadVal = true; // TBResult.AppendText ($"{link.InnerText}{Environment.NewLine}"); //} } //List<string> FileNames = new List<string> { "1", "2", "3" }; //TBResult.Text = string.Join (Environment.NewLine, FileNames); //GetParFromHTM (); //Str_Byte_Str (); //TestService (); //TestRdFilesFromHttp (); //TestFtpWebRequest (); //TestNameColToNum (); //TestEK270 (); //string asPart = "(0x8104)(CRC Ok) ";//(0.9967)(0)(114.74)(0)(0)(0)(0)(0) //TstEK (Encoding.ASCII.GetBytes (asPart), 0); //CreateComByWr ("5:432", BitConverter.GetBytes (1.234567)); //AllocationValsDT (new byte[] { 2, 0x31, 0x3A, 0x34, 0x30, 0x30, 0x2E, 0x32, 0x28, 0x32, 0x30, 0x31, 0x38, 0x2D, 0x31, 0x31, 0x2D, 0x30, 0x31, 0x2C, 0x31, 0x30, 0x3A, 0x35, 0x36, 0x3A, 0x30, 0x36, 0x29, 3, 3 }); //int Error = 123, HandleClient = 456; //StringBuilder sb = new StringBuilder (" ", 256); //sb.AppendFormat ("{0:x} {1:x}", Error, HandleClient); //TBOut.Text = sb.ToString () + " : "; //StringBuilder sb2 = new StringBuilder ($"{Error:x} {HandleClient:x}", 256); //TBOut.AppendText (sb2.ToString ()); //string asV = $"{Error:0:x} {HandleClient:1:x}"; ////TBOut.Text = string.Format ("20{2,2:X2}-{1,X2}-{0,2:X2}", (byte)UDDay.Value, (byte)UDMonth.Value, (byte)UDYear.Value);//System.Globalization.NumberStyles //DateTime DT = DateTime.Now; //DT = DT.AddDays(-1); //DT = DT.AddHours ((double)UDDay.Value); //double dNextTime = DT.Day; //DateTime DT = DateTime.Now.AddHours ((double)UDMonth.Value); //uint uiContractHour = (uint)UDDay.Value; //double dNextTime = uiContractHour > DT.Hour ? uiContractHour - DT.Hour : uiContractHour + 24 - DT.Hour; //dNextTime = dNextTime * 60 * 60000 + IncAddInterval (); /*+ (65 - DT.Minute) * 60000 + Dev.AddInterval*/ //TBOut.Text = dNextTime.ToString (); //TimeSpan TS = TimeSpan.Zero; //DateTime DTDev; //bool bConv = DateTime.TryParse ("2017-02-14 12:28:12", out DTDev); //if (bConv) //{ // TS = DTDev - DateTime.Now; //} //TBOut.Text = TS.ToString (); //DTDev = DateTime.Now + TS; //DateTime DT = DateTime.Now.AddHours(-7); //DT = DT.AddDays (-1); //uint uiContractHour = (uint)UDDay.Value; //DT = DT.AddHours (-uiContractHour); //TBOut.Text = DT.ToString(); //DateTime DTDev = DateTime.Now; //string asDate = DTDev.ToString ("s").Replace ('T', ' '); } catch (Exception exc) { MessageBox.Show(exc.Message + ". " + exc.StackTrace); } }
private void BTLine_Click(object sender, EventArgs e) { TBResult.AppendText(new string('-', 50)); TBResult.AppendText(Environment.NewLine); }
private void BClear_Click(object sender, EventArgs e) { TBResult.Clear(); }
private void Demonstrator_DisplayEvent(object sender, DisplayEventArgs e) { TBResult?.Invoke((MethodInvoker)( () => TBResult.AppendText((++count) + ") " + e.Result + Environment.NewLine))); }