zoukankan
html css js c++ java
Tracking_自定义Profile筛选(2)
将
Pofile
对象的
XML
串存入数据库
该方法 调用了
Tacking
数据库的默认存储过程
UpdateTrackingProfile
,也可用自已的方式直接对
Tacking
数据库操作
private
static
void
插入Profile的XML串到数据库(
string
XML字串, Version 版本)
{
string
sql
=
@"
Initial Catalog=Tracking;Data Source=WXWINTER\SQLEXPRESS;Integrated Security=SSPI;
"
;
//
调用存储过程UpdateTrackingProfile
SqlCommand command
=
new
SqlCommand();
command.CommandType
=
CommandType.StoredProcedure;
//
类型是存储过程
command.CommandText
=
"
dbo.UpdateTrackingProfile
"
;
//
操作 的存储过程
command.Connection
=
new
SqlConnection(sql);
//
数据库连接字串
try
{
//
字段---------------------------------------------
SqlParameter typeFullName
=
new
SqlParameter();
typeFullName.ParameterName
=
"
@TypeFullName
"
;
typeFullName.SqlDbType
=
SqlDbType.NVarChar;
//
值为要设置工作流类的类名 : typeof(wxdlzm1).ToString()
typeFullName.SqlValue
=
typeof
(wxdlzm_wxwinter).ToString();
command.Parameters.Add(typeFullName);
//
字段----------------------------------------------------
SqlParameter assemblyFullName
=
new
SqlParameter();
assemblyFullName.ParameterName
=
"
@AssemblyFullName
"
;
assemblyFullName.SqlDbType
=
SqlDbType.NVarChar;
//
值为要设置工作流类的全称名 : typeof(wxdlzm1).Assembly.FullName
assemblyFullName.SqlValue
=
typeof
(wxdlzm_wxwinter).Assembly.FullName;
command.Parameters.Add(assemblyFullName);
//
TrackingProfile表Version字段--------------------------------
SqlParameter versionId
=
new
SqlParameter();
versionId.ParameterName
=
"
@Version
"
;
versionId.SqlDbType
=
SqlDbType.VarChar;
//
值为要指定的片本号的字串:格式"3.0.0.7"
versionId.SqlValue
=
版本.ToString();
command.Parameters.Add(versionId);
//
TrackingProfile表TrackingProfileXml字段-----------------------
SqlParameter trackingProfile
=
new
SqlParameter();
trackingProfile.ParameterName
=
"
@TrackingProfileXml
"
;
trackingProfile.SqlDbType
=
SqlDbType.NVarChar;
//
值为TrackingProfile格式的XML字串
trackingProfile.SqlValue
=
XML字串;
command.Parameters.Add(trackingProfile);
//
-----------------------------------------------------------
command.Connection.Open();
//
打开连接
command.ExecuteNonQuery();
//
执行
Console.WriteLine();
Console.WriteLine(
"
已将Profile插入
"
);
Console.WriteLine();
}
catch
(SqlException e)
{
Console.WriteLine();
Console.WriteLine(
"
插入Profile方法的Try捕获:插入数据出错了:
"
);
Console.WriteLine(e.Message);
Console.WriteLine();
command.Dispose();
return
;
}
finally
{
if
((
null
!=
command)
&&
(
null
!=
command.Connection)
&&
(ConnectionState.Closed
!=
command.Connection.State))
{
command.Connection.Close();
}
}
command.Dispose();
}
查询自定义
Pofile
的版本
该方法 调用了
Tacking
数据库的默认存储过程
GetTrackingProfile
,也可用自已的方式直接对
Tacking
数据库操作
private
static
Version 得到Profile版本()
{
//
调用存储过程GetTrackingProfile
string
sql
=
@"
Initial Catalog=Tracking;Data Source=WXWINTER\SQLEXPRESS;Integrated Security=SSPI;
"
;
TrackingProfile profile
=
null
;
SqlDataReader SQL读取对象
=
null
;
SqlCommand command
=
new
SqlCommand();
command.CommandType
=
CommandType.StoredProcedure;
//
类型是存储过程
command.CommandText
=
"
dbo.GetTrackingProfile
"
;
//
操作的存储过程
command.Connection
=
new
SqlConnection(sql);
//
数据库连接字串
try
{
//
字段
SqlParameter typeFullName
=
new
SqlParameter();
typeFullName.ParameterName
=
"
@TypeFullName
"
;
typeFullName.SqlDbType
=
SqlDbType.NVarChar;
//
值为要查询的工作流类的类名: typeof(wxdlzm1).ToString() 或typeof(wxdlzm1).FullName
typeFullName.SqlValue
=
typeof
(wxdlzm_Wxwinter).FullName;
//
command.Parameters.Add(typeFullName);
//
字段
SqlParameter assemblyFullName
=
new
SqlParameter();
assemblyFullName.ParameterName
=
"
@AssemblyFullName
"
;
assemblyFullName.SqlDbType
=
SqlDbType.NVarChar;
//
值为要查询工作流类的全称名: typeof(wxdlzm1).Assembly.FullName
assemblyFullName.SqlValue
=
typeof
(wxdlzm_Wxwinter).Assembly.FullName;
command.Parameters.Add(assemblyFullName);
//
SqlParameter versionId
=
new
SqlParameter();
versionId.ParameterName
=
"
@Version
"
;
versionId.SqlDbType
=
SqlDbType.VarChar;
command.Parameters.Add(versionId);
//
SqlParameter createDefault
=
new
SqlParameter();
createDefault.ParameterName
=
"
@CreateDefault
"
;
createDefault.SqlDbType
=
SqlDbType.Bit;
createDefault.SqlValue
=
0
;
command.Parameters.Add(createDefault);
command.Connection.Open();
SQL读取对象
=
command.ExecuteReader();
if
(SQL读取对象.Read())
{
string
profile的Xml字串
=
SQL读取对象[
0
]
as
string
;
if
(
null
!=
profile的Xml字串)
{
TrackingProfileSerializer 串行化对象
=
new
TrackingProfileSerializer();
StringReader stringReader对象
=
null
;
try
{
stringReader对象
=
new
StringReader(profile的Xml字串);
profile
=
串行化对象.Deserialize(stringReader对象);
}
finally
{
if
(stringReader对象
!=
null
)
stringReader对象.Close();
}
}
}
}
//
--------以上得到从数据库中得到profile的Xml字串,并将其返串为TrackingProfile对象
finally
{
if
((SQL读取对象
!=
null
)
&&
(
!
SQL读取对象.IsClosed))
SQL读取对象.Close();
if
((command
!=
null
)
&&
(command.Connection
!=
null
)
&&
(ConnectionState.Closed
!=
command.Connection.State))
{
command.Connection.Close();
}
command.Dispose();
}
//
----------------------------------
if
(profile
!=
null
)
{
return
new
Version(profile.Version.ToString());
}
else
{
//
如果数据库中没有,就返回"0.0.0.0"格式,表示没有,此为自定义约定
return
new
Version(
"
0.0.0.0
"
);
}
}
查看全文
相关阅读:
信息安全系统设计基础第一次实验报告
学号20145220《信息安全系统设计基础》第8周学习总结
学号20145220《信息安全系统设计基础》第8周学习总结
学号20145220《信息安全系统设计基础》第7周学习总结
学号20145220《信息安全系统设计基础》第7周学习总结
学号20145220 《信息安全系统设计基础》第6周学习总结
# 学号20145220 《信息安全系统设计基础》第6周学习总结
# 学号 20145220《信息安全系统设计基础》第5周学习总结
java读取文件中每一行字符串的出现次数
【转载】Idea常见问题整理
原文地址:https://www.cnblogs.com/foundation/p/514503.html
最新文章
20145203 《信息安全系统设计基础》期中总结
20145203、20145223 《信息安全系统设计基础》实验一 开发环境的熟悉
20145203 《信息安全系统设计基础》第七周学习总结
20145203 《信息安全系统设计基础》第六周学习总结
20145203 《信息安全系统设计基础》第五周学习总结
20145203 《信息安全系统设计基础》第三周学习总结
20145203 《信息安全系统设计基础》第2周学习总结
20145203 《信息安全系统设计基础》第一周学习总结
20145216 20145330 《信息安全系统设计基础》 实验四
20145216 20145330 《信息安全系统设计基础》 实验二 固件开发
热门文章
20145216史婧瑶《信息安全系统设计基础》第九周学习总结
20145216史婧瑶《信息安全系统设计基础》期中总结
20145216 20145330《信息安全系统设计基础》实验一 开发环境的熟悉
第六章家庭作业
20145216史婧瑶《信息安全系统设计基础》第6周学习总结
20145216史婧瑶《信息安全系统设计基础》第5周学习总结
20145216史婧瑶 《信息安全系统设计基础》第2周学习总结
《信息安全系统设计基础》第二周问题总结
学号20145220《信息安全系统设计基础》第9周学习总结
学号20145220《信息安全系统设计基础》第9周学习总结
Copyright © 2011-2022 走看看