using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System .IO ;
using System .Text .RegularExpressions;
namespace WindowsApplication1
{
public class DataContext
{
public string _date;
public string _day;
public string _price;
public string _from;
public string _to;
public string _from_desc;
public string _to_desc;
public string _zk;
}
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(16, 40);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(1072, 952);
this.label1.TabIndex = 0;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(1120, 1009);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
StreamReader sr=new StreamReader ("D://ETPASSPROJECT//Data//CAN_lowest.inc");
string strTemp=sr.ReadToEnd();
sr.Close();
strTemp=strTemp.Substring(strTemp.IndexOf("{")+1);
strTemp=strTemp.Substring(strTemp.IndexOf("{")+1);
strTemp=strTemp.Substring(0,strTemp.LastIndexOf("}")-1);
string pattern = "{(?<key>[^}]*)}";
MatchCollection matchs = Regex.Matches(strTemp, pattern);
ArrayList al=new ArrayList ();
if (matchs != null)
{
int i=0;
foreach (Match match in matchs)
{
i++;
if (match != null)
{
string strRet = match.Groups["key"].Value;
al.Add(strRet);
}
}
}
ArrayList al2=new ArrayList ();
for (int i=0;i<al.Count;i++)
{
string[] str=al[i].ToString().Split(';');
string aaa="";
for(int j=0;j<str.Length;j++)
{
aaa +=str[j].ToString();
}
al2.Add(aaa);
}
for (int i=0;i<al2.Count;i++)
{
string str2=al2[i].ToString();
string str4=str2.Substring(0,str2.LastIndexOf(":")+1);
string str3=str2.Substring(str2.LastIndexOf(":")+1);
if(str3.IndexOf('"')<0)
str3='"'+str3+'"';
str2=str4+str3;
al2[i]=str2;
}
ArrayList al3=new ArrayList ();
for (int i=0;i<al2.Count;i++)
{
string pattern2 ="/".+?/"";
MatchCollection flights = Regex.Matches(al2[i].ToString(),pattern2);
int aa=0;
string bbb="";
foreach(Match m in flights)
{
string[] c=m.Value.Split('"');
for(int j=0;j<c.Length;j++)
{
bbb+=c[j].ToString();
}
aa++;
}
al3.Add(bbb);
}
ArrayList arrAll=new ArrayList();
for(int i=0;i<al3.Count;i++)
{
DataContext dc=new DataContext ();
dc._date=al3[i].ToString().Substring(al3[i].ToString().IndexOf("date")+4).Substring(0,al3[i].ToString().Substring(al3[i].ToString().IndexOf("date")+4).IndexOf("day"));
dc._day =al3[i].ToString().Substring(al3[i].ToString().IndexOf("day")+3).Substring(0,al3[i].ToString().Substring(al3[i].ToString().IndexOf("day")+3).IndexOf("price"));
dc._price =al3[i].ToString().Substring(al3[i].ToString().IndexOf("price")+5).Substring(0,al3[i].ToString().Substring(al3[i].ToString().IndexOf("price")+5).IndexOf("from"));
dc._from=al3[i].ToString().Substring(al3[i].ToString().IndexOf("from")+4).Substring(0,al3[i].ToString().Substring(al3[i].ToString().IndexOf("from")+4).IndexOf("to"));
dc._to =al3[i].ToString().Substring(al3[i].ToString().IndexOf("to")+2).Substring(0,al3[i].ToString().Substring(al3[i].ToString().IndexOf("to")+2).IndexOf("from_desc"));
dc._from_desc =al3[i].ToString().Substring(al3[i].ToString().IndexOf("from_desc")+9).Substring(0,al3[i].ToString().Substring(al3[i].ToString().IndexOf("from_desc")+9).IndexOf("to_desc"));
dc._to_desc =al3[i].ToString().Substring(al3[i].ToString().IndexOf("to_desc")+7).Substring(0,al3[i].ToString().Substring(al3[i].ToString().IndexOf("to_desc")+7).IndexOf("zk"));
dc._zk =al3[i].ToString().Substring(al3[i].ToString().IndexOf("zk")+2);
arrAll.Add(dc);
//label1 .Text +=dc._date+"____"+dc._day+"____"+dc._price+"____"+dc._from+"____"+dc._to+"____"+dc._from_desc+"____"+dc._to_desc+"____"+dc._zk+"/n/n";
}
foreach (DataContext dcc in arrAll)
{
label1 .Text +=dcc._date+"____"+dcc._day+"____"+dcc._price+"____"+dcc._from+"____"+dcc._to+"____"+dcc._from_desc+"____"+dcc._to_desc+"____"+dcc._zk+"/n/n";
}
}
}
}