110,566
社区成员
发帖
与我相关
我的任务
分享
public class mystart
{
public mystart() { }
Hashtable HMainTable = new Hashtable();
protected string strSN = "";
protected string strDate = "";
public string SN
{
set { strSN = value; }
get { return strSN; }
}
public string Date
{
set { strDate = value; }
get { return strDate; }
}
}
public class myStep
{
public myStep() { }
protected string strStep = "";
protected string strResult = "";
protected string strParams = "";
public string CheckStep
{
set { strStep = value; }
get { return strStep; }
}
public string CheckResult
{
set { strResult = value; }
get { return strResult; }
}
public string Params
{
set { strParams = value; }
get { return strParams; }
}
}
private void button1_Click(object sender, EventArgs e)
{
try
{
string strLine = "";
StreamReader read = new StreamReader("c:\\testlog.txt",Encoding.Default);
do
{
mystart s1 = null;
strLine = read.ReadLine();
if (strLine.Contains("{=start="))
{
s1 = new mystart();
}
if (strLine.Contains("#产品序列号"))
{
}
}
while (strLine != null);
}
catch (Exception err)
{
MessageBox.Show(err.Message.ToString());
}
}
string content = File.ReadAllText(@"D:\data.txt");
foreach (Match match in Regex.Matches(content, @"{=start=(?<start>[\s\S]*)=start=}", RegexOptions.Multiline))
{
string productSN = Regex.Match(match.Groups["start"].Value, @"\#产品序列号\s*=\s*(?<sn>[^;]*);").Groups["sn"].Value;
foreach (Match mat in Regex.Matches(match.Groups["start"].Value, @"{=step=(?<step>[\s\S]*?)}=step;"))
{
string step = Regex.Match(mat.Groups["step"].Value, @"\#检验步骤\s*=\s*(?<step>[^;]*);").Groups["step"].Value;
string result = Regex.Match(mat.Groups["step"].Value, @"\#结果\s*=\s*(?<result>[^;]*);").Groups["result"].Value;
foreach (Match ma in Regex.Matches(mat.Groups["step"].Value, @"\#详细参数\s*=\s*\((?<params>[^;]*)\);"))
{
foreach (Match m in Regex.Matches(ma.Groups["params"].Value, @"\((?<detail>[^,]*),[^,]*,(?<result>[^\)]*)\s*\)"))
{
string param = m.Groups["detail"].Value;
string paramResult = m.Groups["result"].Value;
//这里就自己写入数据库了
}
}
}
}