本文整理汇总了C#中Westwind.Utilities.Data.SqlDataAccess.CloseConnection方法的典型用法代码示例。如果您正苦于以下问题:C# SqlDataAccess.CloseConnection方法的具体用法?C# SqlDataAccess.CloseConnection怎么用?C# SqlDataAccess.CloseConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Westwind.Utilities.Data.SqlDataAccess
的用法示例。
在下文中一共展示了SqlDataAccess.CloseConnection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetResourceSetNormalizedForLocaleId
//.........这里部分代码省略.........
/// </summary>
/// <param name="cultureName"></param>
/// <param name="resourceSet"></param>
/// <returns></returns>
public Dictionary<string, object> GetResourceSetNormalizedForLocaleId(string cultureName, string resourceSet)
{
if (cultureName == null)
cultureName = string.Empty;
Dictionary<string, object> resDictionary = new Dictionary<string, object>();
SqlDataAccess data = new SqlDataAccess(DbResourceConfiguration.Current.ConnectionString);
DbDataReader reader = null;
string sql =
@"select resourceId, LocaleId, Value, Type, BinFile, TextFile, FileName
from " + DbResourceConfiguration.Current.ResourceTableName + @"
where [email protected] and (LocaleId = '' {0} )
order by ResourceId, LocaleId DESC";
// use like parameter or '' if culture is empty/invariant
string localeFilter = string.Empty;
List<DbParameter> parameters = new List<DbParameter>();
parameters.Add(data.CreateParameter("@ResourceSet", resourceSet));
if (!string.IsNullOrEmpty(cultureName))
{
localeFilter += " OR LocaleId = @LocaleId";
parameters.Add(data.CreateParameter("@LocaleId", cultureName));
// *** grab shorter version
if (cultureName.Contains("-"))
{
localeFilter += " OR LocaleId = @LocaleId1";
parameters.Add(data.CreateParameter("@LocaleId1", cultureName.Split('-')[0]));
}
}
sql = string.Format(sql, localeFilter);
reader = data.ExecuteReader(sql, parameters.ToArray());
if (reader == null)
{
SetError(data.ErrorMessage);
return resDictionary;
}
try
{
string lastResourceId = "xxxyyy";
while (reader.Read())
{
// only pick up the first ID returned - the most specific locale
string resourceId = reader["ResourceId"].ToString();
if (resourceId == lastResourceId)
continue;
lastResourceId = resourceId;
// Read the value into this
object resourceValue = null;
resourceValue = reader["Value"] as string;
string resourceType = reader["Type"] as string;
if (!string.IsNullOrWhiteSpace(resourceType))
{
// FileResource is a special type that is raw file data stored
// in the BinFile or TextFile data. Value contains
// filename and type data which is used to create: String, Bitmap or Byte[]
if (resourceType == "FileResource")
resourceValue = LoadFileResource(reader);
else
{
LosFormatter Formatter = new LosFormatter();
resourceValue = Formatter.Deserialize(resourceValue as string);
}
}
else
{
if (resourceValue == null)
resourceValue = string.Empty;
}
resDictionary.Add(resourceId, resourceValue);
}
}
catch { }
finally
{
// close reader and connection
reader.Close();
data.CloseConnection();
}
return resDictionary;
}