本文整理汇总了C#中OracleParameter.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# OracleParameter.ToArray方法的具体用法?C# OracleParameter.ToArray怎么用?C# OracleParameter.ToArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OracleParameter
的用法示例。
在下文中一共展示了OracleParameter.ToArray方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PointRecord
//.........这里部分代码省略.........
string month = System.DateTime.Now.Month.ToString();
//日
string day = System.DateTime.Now.Day.ToString();
//程序所在目录
string path = HttpRuntime.AppDomainAppPath.ToString();
//判断当前文件是否存在(文件格式:年+月)
if (!Directory.Exists(path + year + "." + month))
{
//不存在则创建文件夹
Directory.CreateDirectory(path + year + "." + month);
}
if (!File.Exists(path + year + "." + month + "//" + year + "." + month + "." + day + " " + "log.txt"))
{
//如果不存在则创建txt
FileStream fs = File.Create(path + year + "." + month + "//" + year + "." + month + "." + day + " " + "log.txt");
fs.Close();
}
StreamWriter sr = new StreamWriter(path + year + "." + month + "//" + year + "." + month + "." + day + " " + "log.txt", true,
System.Text.Encoding.Default);
sr.WriteLine("采集时间: {0}", time);
sr.WriteLine("平台ID:{0}", platId.ToString());
sr.WriteLine("Xml: {0}", pointRecordXml);
sr.Close();
#endregion
try
{
XmlDocument xd = new XmlDocument();
xd.LoadXml(pointRecordXml);
foreach (XmlNode node in xd.SelectNodes("/datapacket/rowdata/row"))
{
string FROM_ID = node.Attributes["FROM_ID"].Value;
string MAC_ID = node.Attributes["MAC_ID"].Value;
string MAC_NAME = node.Attributes["MAC_NAME"].Value;
string TAKE_TIME = node.Attributes["TAKE_TIME"].Value;
string VALUE_TEMP = node.Attributes["VALUE_TEMP"].Value;
string MAX_TEMP = node.Attributes["MAX_TEMP"].Value;
string MIN_TEMP = node.Attributes["MIN_TEMP"].Value;
string VALUE_HUMI = node.Attributes["VALUE_HUMI"].Value;
string MAX_HUMI = node.Attributes["MAX_HUMI"].Value;
string MIN_HUMI = node.Attributes["MIN_HUMI"].Value;
string JINGDU = node.Attributes["JINGDU"].Value;
string WEIDU = node.Attributes["WEIDU"].Value;
string SPEED = node.Attributes["SPEED"].Value;
string TAKE_MEMO = node.Attributes["TAKE_MEMO"].Value;
#region 执行数据库操作
var sqlBuilder = new StringBuilder();
using (var conn = AppConfigSetting.DatabaseConfig.GetOraConnection())
{
sqlBuilder.AppendFormat("INSERT INTO CDC_TRANS_PATH VALUES (:FROM_ID,:MAC_ID,:MAC_NAME,:TAKE_TIME,:VALUE_TEMP,:MAX_TEMP,:MIN_TEMP,:VALUE_HUMI,:MAX_HUMI,:MIN_HUMI,:JINGDU,:WEIDU,:SPEED,:TAKE_MEMO,:CREATEDATE)");
OracleParameter[] op = new OracleParameter[15];
op[0] = new OracleParameter(":FROM_ID", OracleType.VarChar) { Value = FROM_ID };
op[1] = new OracleParameter(":MAC_ID", OracleType.VarChar) { Value = MAC_ID };
op[2] = new OracleParameter(":MAC_NAME", OracleType.VarChar);
op[2].Value = MAC_NAME;
op[3] = new OracleParameter(":TAKE_TIME", OracleType.DateTime);
op[3].Value = TAKE_TIME;
op[4] = new OracleParameter(":VALUE_TEMP", OracleType.VarChar);
op[4].Value = VALUE_TEMP;
op[5] = new OracleParameter(":MAX_TEMP", OracleType.VarChar);
op[5].Value = MAX_TEMP;
op[6] = new OracleParameter(":MIN_TEMP", OracleType.VarChar);
op[6].Value = MIN_TEMP;
op[7] = new OracleParameter(":VALUE_HUMI", OracleType.VarChar);
op[7].Value = VALUE_HUMI;
op[8] = new OracleParameter(":MAX_HUMI", OracleType.VarChar);
op[8].Value = MAX_HUMI;
op[9] = new OracleParameter(":MIN_HUMI", OracleType.VarChar);
op[9].Value = MIN_HUMI;
op[10] = new OracleParameter(":JINGDU", OracleType.VarChar);
op[10].Value = JINGDU;
op[11] = new OracleParameter(":WEIDU", OracleType.VarChar);
op[11].Value = WEIDU;
op[12] = new OracleParameter(":SPEED", OracleType.VarChar);
op[12].Value = SPEED;
op[13] = new OracleParameter(":TAKE_MEMO", OracleType.VarChar);
op[13].Value = TAKE_MEMO;
op[14] = new OracleParameter(":CREATEDATE", OracleType.DateTime);
op[14].Value = time;
using (var oracmd = new OracleCommand(sqlBuilder.ToString(), conn))
{
oracmd.Parameters.AddRange(op.ToArray());
conn.Open();
oracmd.ExecuteNonQuery();
}
}
}
return "<?xml version=\"1.0\" encoding=\"utf-8\"?><dataset><Record resultcode=\"0\" resultmessage=\"上传成功\"></Record><frequency time=\"15\"></frequency></dataset>";
#endregion
}
catch (Exception e)
{
string error = e.ToString();
string errorMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?><dataset><Record resultcode=\"1\" resultmessage=\"" + error + "\"></Record><frequency time=\"15\"></frequency></dataset>";
return errorMessage;
}
}