static void Main() { DataBase db = new DataBase(); //创建必要的存储过程 string strSQL1 = " if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[DataProduct_KJ128N_Shanxi_Process]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) " + " begin " + " drop procedure [dbo].[DataProduct_KJ128N_Shanxi_Process] " + " end "; string strSQL = "CREATE procedure DataProduct_KJ128N_Shanxi_Process as " + "declare @SQLHis nvarchar(2000) " + "set @SQLHis = 'SELECT ''0'' flag,case when TerritorialNO is null then ''00'' else TerritorialNO end as TerritorialNO, dbo.Station_Head_Info.StationHeadNO, replace(str(His.CodeSenderAddress),'' '','''') codesenderaddress, "+ "replace(replace(replace(convert(nvarchar(20),InStationHeadTime,120),''-'',''''),'' '',''''),'':'','''') time " + "FROM (select * from dbo.His_InOutStationHead_'+replace((str(datepart(year,getdate()))+str(datepart(MONTH,GETDATE()))),' ','') +' " + "where datediff(minute,InStationHeadTime,getdate())<2) as His " + "left JOIN dbo.Station_Head_Info ON dbo.Station_Head_Info.StationAddress = His.StationAddress " + "AND dbo.Station_Head_Info.StationHeadAddress = His.StationHeadAddress " + "left JOIN dbo.Territorial_Set ON dbo.Station_Head_Info.StationHeadID = dbo.Territorial_Set.StationHeadID " + "left JOIN dbo.Territorial_Info ON dbo.Territorial_Set.TerritorialID = dbo.Territorial_Info.TerritorialID " + "union " + "SELECT case when Shi.StationHeadType=''上井口接收器'' then ''0'' else ''1'' end AS flag, " + "case when TerritorialNO is null then ''00'' else TerritorialNO end as TerritorialNO,StationHeadNO," + "replace(str(CodeSenderAddress),'' '','''') CodeSenderAddress,replace(replace(replace(convert(nvarchar(20),getdate(),120),''-'',''''),'' '',''''),'':'','''') time " + "FROM dbo.RT_InStationHeadInfo RTIS " + "left join dbo.Station_Head_Info Shi on RTIS.StationHeadID = Shi.StationHeadID " + "LEFT JOIN dbo.Territorial_Set TS ON Shi.StationHeadID = Shi.StationHeadID " + "left join dbo.Territorial_Info TI on TS.TerritorialID=TI.TerritorialID " + "union " + "select ''x'' flag,''xxxxxxxxxxxxx'' TerritorialNO,''xxxxxxxxxxxxxxx'' StationHeadNO,''xxxxxxxxxxxxxxxx'' CodeSenderAddress," + "replace(replace(replace(convert(nvarchar(20),getdate(),120),''-'',''''),'' '',''''),'':'','''') time' " + "exec (@SQLHis)"; db.ExcuteSqlReturnNull(strSQL1); db.ExcuteSqlReturnNull(strSQL); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new DataProduct_MainShow()); }
public void GetProcessFile() { DataTable DT = null; DataBase DB = new DataBase(); DT = DB.ExcuteProcedure("DataProduct_KJ128N_Shanxi_Process"); MyDataTable MYDT = new MyDataTable(DT, DateTime.Now.ToString("yyyyMMddHHmmss"), "process", FilePath); if (txtShow.Lines.Length > 27) { txtShow.Text = ""; txtShow.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " ������������ ʵʱ���������ļ�" + Environment.NewLine; } else { txtShow.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " ������������ ʵʱ���������ļ�" + Environment.NewLine; } }
//д�ļ����� public void XMLToDataSetChange() { DataBase db = new DataBase(); DataTable dtTemp = db.ExcuteProcedure("select case when StationHeadState<1 then 0 else 1 end,StationHeadNO from Station_Head_Info"); //DataTable DS = new DataTable(); //for(int x=0;x<9;x++) //{ // DataColumn dc = new DataColumn(x.ToString()); // DS.Columns.Add(dc); //} XmlDocument doc = new XmlDocument(); doc.Load(strXMLPath); //�趨XML�ļ�����Ϊ����ṹ XmlNodeList nodelist = doc.FirstChild.NextSibling.ChildNodes; string strContent = string.Empty; //����XML���ѱ�������������м��Ҫ�任���任֮��д�뵽�ļ����� for (int i = 0; i < nodelist.Count; i++) { //DataRow dr = DS.NewRow(); for (int j = 0; j < nodelist[i].ChildNodes.Count; j++) { if (nodelist[i].ChildNodes[j].InnerText != "x" & j == 5) { //if (dtTemp.Select("StationHeadNO='" + nodelist[i].ChildNodes[j].InnerText.Substring(13) + "'").Length != 0) //{ // strContent += nodelist[i].ChildNodes[j].InnerText.ToString() + "\t"+dtTemp.Select("StationHeadNO='" + nodelist[i].ChildNodes[j].InnerText.Substring(13) + "'")[0][0].ToString() + "\t"; //} //else //{ // strContent += nodelist[i].ChildNodes[j].InnerText.ToString() + "\t"; //} strContent += dtTemp.Select("StationHeadNO='" + nodelist[i].ChildNodes[3].InnerText.Substring(13) + "'")[0][0].ToString() + "\t"; } else { strContent += nodelist[i].ChildNodes[j].InnerText.ToString() + "\t"; } } strContent = strContent + "\r\n"; } DataWrite dw = new DataWrite(XmlDocName, strDateTime, strContent,strFileRoot); }