7、中间层开发
HelloWorld.BLL下添加Messenger.cs(类),因需要调用统一平台提供的数据服务,引用平台核心库JYSoft.Platform.Core.dll,将JYSoft.Platform.Core.dll复制到C:\Inetpub\wwwroot\HelloWorld\bin下,将C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322下的System.Data.OracleClient.dll也复制到C:\Inetpub\wwwroot\HelloWorld\bin下。
using System;
using System.Data;
using System.Data.OracleClient;
using Hello.Data;
using JYSoft.Platform.Core.Services.Data;
using JYSoft.Platform.Core.Services.Data.Oracle;
namespace Hello.BLL
{
/// <summary>
/// Messenger 的摘要说明。
/// </summary>
public class Messenger
{
private const string GetUserAccount = @"Select UserAccount From ACM_USER Where UserID=:UserID";
public Messenger()
{
}
/// <summary>
/// 构造函数
/// </summary>
/// <returns>HelloWorld</returns>
public GreetingMessage GetGreetingMessage()
{
string userAccount = GetUserAccountByUserID( 0 );
///定义content
GreetingMessage msg = new GreetingMessage(userAccount);
return msg;
}
private string GetUserAccountByUserID(int userID)
{
DbCore dbService = new DbCore("-1");
OracleCommandWrapper cmdWrapper = dbService.GetSqlStringCommandWrapper(GetUserAccount) as OracleCommandWrapper;
cmdWrapper.AddInParameter(":USERID",OracleType.Number,10,userID);
return Convert.ToString(dbService.ExecuteScalar( cmdWrapper ));
}
}
}
using System.Data;
using System.Data.OracleClient;
using Hello.Data;
using JYSoft.Platform.Core.Services.Data;
using JYSoft.Platform.Core.Services.Data.Oracle;
namespace Hello.BLL
{
/// <summary>
/// Messenger 的摘要说明。
/// </summary>
public class Messenger
{
private const string GetUserAccount = @"Select UserAccount From ACM_USER Where UserID=:UserID";
public Messenger()
{
}
/// <summary>
/// 构造函数
/// </summary>
/// <returns>HelloWorld</returns>
public GreetingMessage GetGreetingMessage()
{
string userAccount = GetUserAccountByUserID( 0 );
///定义content
GreetingMessage msg = new GreetingMessage(userAccount);
return msg;
}
private string GetUserAccountByUserID(int userID)
{
DbCore dbService = new DbCore("-1");
OracleCommandWrapper cmdWrapper = dbService.GetSqlStringCommandWrapper(GetUserAccount) as OracleCommandWrapper;
cmdWrapper.AddInParameter(":USERID",OracleType.Number,10,userID);
return Convert.ToString(dbService.ExecuteScalar( cmdWrapper ));
}
}
}