1 using System;
2 using System.Data;
3 using System.Configuration;
4 using System.Web;
5 using System.Web.Security;
6 using System.Web.UI;
7 using System.Web.UI.WebControls;
8 using System.Web.UI.WebControls.WebParts;
9 using System.Web.UI.HtmlControls;
10 using System.Xml;
11 using System.IO;
12 using System.Data.OracleClient;
13 using System.ComponentModel;//字符串类型转换成枚举类型时引用
14
15 public partial class _Default : System.Web.UI.Page
16 {
17 string m_XmlURL;
18 string m_FunctionName;
19 OracleConnection m_OracleCnn;
20 OracleCommand m_OracleCmmd;
21 OracleDataAdapter m_OracleAdp;
22
23 protected void Page_Load(object sender, EventArgs e)
24 {
25 m_OracleCnn = new OracleConnection(GetDataInfo());
26 //取当前路径
27 string URL = Request.ServerVariables["PATH_TRANSLATED"];
28 m_XmlURL = URL.Substring(0,URL.Length - 17) + "FlashServeConfig.xml";
29
30 string RequestPar ;
31 string RequestDate;
32
33 if (Request.QueryString["Name"] != null)
34 {
35 RequestPar = Request.QueryString["Name"];
36 }
37 else if (Request.Form["Name"] != null)
38 {
39 RequestPar = Request.Form["Name"];
40 }
41 else
42 {
43 RequestPar = "百口泉采油厂";
44 }
45
46 if (Request.QueryString["Date"] != null)
47 {
48 RequestDate = Request.QueryString["Date"];
49 }
50 else if (Request.Form["Date"] != null)
51 {
52 RequestDate = Request.Form["Date"];
53 }
54 else
55 {
56 RequestDate = DateTime.Today.Year.ToString() + "-" + DateTime.Today.Month.ToString() + "-" + DateTime.Today.Day.ToString();
57 }
58
59 string StoreNamed = VisitXML(RequestPar);
60
61 GetDataFormStoreProcedure(StoreNamed, RequestDate, RequestPar);
62 }
63
64 /// <summary>
65 /// 根据实体名称从配置文件中取得存储过程的名称
66 /// </summary>
67 /// <param name="curEntityName"></param>
68 /// <returns>存储过程名称</returns>
69 private string VisitXML(string curEntityName)
70 {
71 string ReturnPName = "store";
72
73 XmlDataDocument doc = new XmlDataDocument();
74 doc.Load(m_XmlURL);
75 XmlNode Root = doc.SelectSingleNode("Config");
76 XmlNode relationNode = Root.ChildNodes[2];
77 XmlNode functionNode = Root.ChildNodes[1];
78 //遍历关系结点,根据实体的名称取得对应的功能项m_FunctionName
79 for (int i = 0; i < relationNode.ChildNodes.Count; i++)
80 {
81 XmlElement XElt = (XmlElement)relationNode.ChildNodes[i];
82 string selectnode = XElt.ChildNodes[0].InnerText;
83 if (selectnode != curEntityName)
84 {
85 continue;
86 }
87 m_FunctionName = XElt.ChildNodes[1].InnerText;
88 break;
89 }
90 //在功能结点中遍历找到功能项m_FunctionName所对应的数据源
91 for (int i = 0; i < functionNode.ChildNodes.Count; i++)
92 {
93 XmlElement curXElt = (XmlElement)functionNode.ChildNodes[i];
94 string functionname = curXElt.Name;
95 if (functionname != m_FunctionName)
96 {
97 continue;
98 }
99 ReturnPName = curXElt.GetElementsByTagName("DataSouce").Item(0).InnerText;
100 return ReturnPName;
101 }
102 return ReturnPName;
103 }
104
105 /// <summary>
106 /// 获取数据库连接信息
107 /// </summary>
108 /// <returns></returns>
109 private string GetDataInfo()
110 {
111 OracleConnectionStringBuilder OS = new OracleConnectionStringBuilder();
112 OS.UserID = "pedis20yx";
113 OS.Password = "scyx";
114 OS.DataSource = "pedis20yx";
115 return OS.ConnectionString;
116 }
117
118 /// <summary>
119 /// 访问存储过程,将结果以XML形式返回
120 /// </summary>
121 /// <param name="SPName"></param>
122 /// <param name="dateTime"></param>
123 /// <param name="organiseName"></param>
124 public void GetDataFormStoreProcedure(string SPName, string dateTime, string organiseName)
125 {
126 if (SPName == null || SPName == "")
127 {
128 Response.Write("<?xml version='1.0' encoding='utf-8'?><RootName>无数据!</RootName>");
129 }
130 else
131 {
132 try
133 {
134 m_OracleCnn.Open();
135 m_OracleCmmd = new OracleCommand(SPName, m_OracleCnn);
136 m_OracleCmmd.CommandType = CommandType.StoredProcedure;
137
138 OracleParameter OraclePar1 = new OracleParameter("P_RQ", OracleType.DateTime);
139 OraclePar1.Direction = ParameterDirection.Input;
140 OraclePar1.Value = dateTime;
141 OracleParameter OraclePar2 = new OracleParameter("p_dw", OracleType.VarChar);
142 OraclePar2.Direction = ParameterDirection.Input;
143 OraclePar2.Value = organiseName;
144 OracleParameter OraclePar3 = new OracleParameter("C", OracleType.Cursor);
145 OraclePar3.Direction = ParameterDirection.Output;
146 m_OracleCmmd.Parameters.Add(OraclePar1);
147 m_OracleCmmd.Parameters.Add(OraclePar2);
148 m_OracleCmmd.Parameters.Add(OraclePar3);
149
150 m_OracleAdp = new OracleDataAdapter(m_OracleCmmd);
151 DataSet DS = new DataSet();
152 m_OracleAdp.Fill(DS);
153 m_OracleCnn.Close();
154
155 string xmlString = DS.GetXml();
156 Response.Write(xmlString);
157 }
158 catch (Exception e1)
159 {
160 Response.Write(e1.Message);
161 }
162 }
163 }
164 }
165
2 using System.Data;
3 using System.Configuration;
4 using System.Web;
5 using System.Web.Security;
6 using System.Web.UI;
7 using System.Web.UI.WebControls;
8 using System.Web.UI.WebControls.WebParts;
9 using System.Web.UI.HtmlControls;
10 using System.Xml;
11 using System.IO;
12 using System.Data.OracleClient;
13 using System.ComponentModel;//字符串类型转换成枚举类型时引用
14
15 public partial class _Default : System.Web.UI.Page
16 {
17 string m_XmlURL;
18 string m_FunctionName;
19 OracleConnection m_OracleCnn;
20 OracleCommand m_OracleCmmd;
21 OracleDataAdapter m_OracleAdp;
22
23 protected void Page_Load(object sender, EventArgs e)
24 {
25 m_OracleCnn = new OracleConnection(GetDataInfo());
26 //取当前路径
27 string URL = Request.ServerVariables["PATH_TRANSLATED"];
28 m_XmlURL = URL.Substring(0,URL.Length - 17) + "FlashServeConfig.xml";
29
30 string RequestPar ;
31 string RequestDate;
32
33 if (Request.QueryString["Name"] != null)
34 {
35 RequestPar = Request.QueryString["Name"];
36 }
37 else if (Request.Form["Name"] != null)
38 {
39 RequestPar = Request.Form["Name"];
40 }
41 else
42 {
43 RequestPar = "百口泉采油厂";
44 }
45
46 if (Request.QueryString["Date"] != null)
47 {
48 RequestDate = Request.QueryString["Date"];
49 }
50 else if (Request.Form["Date"] != null)
51 {
52 RequestDate = Request.Form["Date"];
53 }
54 else
55 {
56 RequestDate = DateTime.Today.Year.ToString() + "-" + DateTime.Today.Month.ToString() + "-" + DateTime.Today.Day.ToString();
57 }
58
59 string StoreNamed = VisitXML(RequestPar);
60
61 GetDataFormStoreProcedure(StoreNamed, RequestDate, RequestPar);
62 }
63
64 /// <summary>
65 /// 根据实体名称从配置文件中取得存储过程的名称
66 /// </summary>
67 /// <param name="curEntityName"></param>
68 /// <returns>存储过程名称</returns>
69 private string VisitXML(string curEntityName)
70 {
71 string ReturnPName = "store";
72
73 XmlDataDocument doc = new XmlDataDocument();
74 doc.Load(m_XmlURL);
75 XmlNode Root = doc.SelectSingleNode("Config");
76 XmlNode relationNode = Root.ChildNodes[2];
77 XmlNode functionNode = Root.ChildNodes[1];
78 //遍历关系结点,根据实体的名称取得对应的功能项m_FunctionName
79 for (int i = 0; i < relationNode.ChildNodes.Count; i++)
80 {
81 XmlElement XElt = (XmlElement)relationNode.ChildNodes[i];
82 string selectnode = XElt.ChildNodes[0].InnerText;
83 if (selectnode != curEntityName)
84 {
85 continue;
86 }
87 m_FunctionName = XElt.ChildNodes[1].InnerText;
88 break;
89 }
90 //在功能结点中遍历找到功能项m_FunctionName所对应的数据源
91 for (int i = 0; i < functionNode.ChildNodes.Count; i++)
92 {
93 XmlElement curXElt = (XmlElement)functionNode.ChildNodes[i];
94 string functionname = curXElt.Name;
95 if (functionname != m_FunctionName)
96 {
97 continue;
98 }
99 ReturnPName = curXElt.GetElementsByTagName("DataSouce").Item(0).InnerText;
100 return ReturnPName;
101 }
102 return ReturnPName;
103 }
104
105 /// <summary>
106 /// 获取数据库连接信息
107 /// </summary>
108 /// <returns></returns>
109 private string GetDataInfo()
110 {
111 OracleConnectionStringBuilder OS = new OracleConnectionStringBuilder();
112 OS.UserID = "pedis20yx";
113 OS.Password = "scyx";
114 OS.DataSource = "pedis20yx";
115 return OS.ConnectionString;
116 }
117
118 /// <summary>
119 /// 访问存储过程,将结果以XML形式返回
120 /// </summary>
121 /// <param name="SPName"></param>
122 /// <param name="dateTime"></param>
123 /// <param name="organiseName"></param>
124 public void GetDataFormStoreProcedure(string SPName, string dateTime, string organiseName)
125 {
126 if (SPName == null || SPName == "")
127 {
128 Response.Write("<?xml version='1.0' encoding='utf-8'?><RootName>无数据!</RootName>");
129 }
130 else
131 {
132 try
133 {
134 m_OracleCnn.Open();
135 m_OracleCmmd = new OracleCommand(SPName, m_OracleCnn);
136 m_OracleCmmd.CommandType = CommandType.StoredProcedure;
137
138 OracleParameter OraclePar1 = new OracleParameter("P_RQ", OracleType.DateTime);
139 OraclePar1.Direction = ParameterDirection.Input;
140 OraclePar1.Value = dateTime;
141 OracleParameter OraclePar2 = new OracleParameter("p_dw", OracleType.VarChar);
142 OraclePar2.Direction = ParameterDirection.Input;
143 OraclePar2.Value = organiseName;
144 OracleParameter OraclePar3 = new OracleParameter("C", OracleType.Cursor);
145 OraclePar3.Direction = ParameterDirection.Output;
146 m_OracleCmmd.Parameters.Add(OraclePar1);
147 m_OracleCmmd.Parameters.Add(OraclePar2);
148 m_OracleCmmd.Parameters.Add(OraclePar3);
149
150 m_OracleAdp = new OracleDataAdapter(m_OracleCmmd);
151 DataSet DS = new DataSet();
152 m_OracleAdp.Fill(DS);
153 m_OracleCnn.Close();
154
155 string xmlString = DS.GetXml();
156 Response.Write(xmlString);
157 }
158 catch (Exception e1)
159 {
160 Response.Write(e1.Message);
161 }
162 }
163 }
164 }
165