在VUSERCLASS中写方法,在METHOD中写参数调用,等于参数化了。
VuserClass代码如下 :
using System;
using System.Collections;
using System.Diagnostics;
using System.EnterpriseServices;
using System.Runtime.InteropServices;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Data;
using System.Web;
using System.Reflection;
using Common;
using Proxy;
using DAT;
using ShangXin;
using ShangXin.Data;
using ShangXinInterface;
namespace LRQueryCustomer
{
///
/// Summary description for VuserClass.
///
[ClassInterface(ClassInterfaceType.AutoDual)]
public class VuserClass
{
public static string ifCanCreatePuDongOrderWithBiz = "";
Proxy.LoginProxy loginProxy;
Method methodLR = new Method();
LoadRunner.LrApi lr;
public VuserClass()
{
// LoadRunner Standard API Interface :: DO NOT REMOVE!!!
lr = new LoadRunner.LrApi();
}
// ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
public int Initialize()
{
try
{
RemotingConfiguration.Configure(@"D:\Escalade liunx\CODE_20051020100023\Code\OAERP\ShangXin.OAERP.App\bin\Debug\App.exe.config");
lr.start_transaction("init");
lr.start_transaction("GetLoginByLoginNameAndPassword");
loginProxy = new LoginProxy();
LoginData loginData = loginProxy.GetLoginByLoginNameAndPassword("administrator","");
lr.end_transaction("GetLoginByLoginNameAndPassword",lr.PASS);
Proxy.EmployeeProxy employeeProxy = new EmployeeProxy();
CertificationInfo CI = new CertificationInfo();
Common.CertificationInfo ci= PersonalCertificationInfo.GetCertificationInfo();
CI.LoginName = SXConvert.ToString(loginData.Rows[0][LoginData.LOGINNAME]);
CI.Password = SXConvert.ToString(loginData.Rows[0][LoginData.PASSWORD]);
CI.EmployeeId = SXConvert.ToInt32(loginData.Rows[0][LoginData.EMPLOYEEID]);
CI.EmployeeName = employeeProxy.GetEmployeeDataByPKID(SXConvert.ToInt32(loginData.Rows[0][LoginData.EMPLOYEEID])).Rows[0][EmployeeData.NAME].ToString();
CI.RecordCount = SXConvert.ToInt32(loginData.Rows[0][LoginData.RECORDCOUNT]);
lr.start_transaction("GetAllAuthsByLoginId");
int loginID = SXConvert.ToInt32(loginData.Rows[0][LoginData.PKID]);
AuthData ad = loginProxy.GetAllAuthsByLoginId(loginID);
methodLR.SetAuth(ad,CI);
lr.end_transaction("GetAllAuthsByLoginId",lr.PASS);
lr.start_transaction("GetGroupsByLoginID");
GroupData groupData = loginProxy.GetGroupsByLoginID(loginID);
methodLR.GetGroupAuth(groupData,CI);
lr.end_transaction("GetGroupsByLoginID",lr.PASS);
lr.start_transaction("AddToCurrentEmployee");
if (AuthenticationManager.CheckAuthentication(CI,EnumAuthority.AuthLoginSystem))
{
methodLR.AddToCurrentEmployee(ci,CI);
lr.end_transaction("AddToCurrentEmployee",lr.PASS);
DataRow BizDR = new SystemParameterValueProxy().GetSystemParameterValueByParentCode(SystemParametersCode.CANCREATEPUDONGORDERWITHBIZ,Bools.TRUE).Rows[0];
ifCanCreatePuDongOrderWithBiz = BizDR[SystemParameterValueData.OTHER1].ToString();
}
else
{
lr.end_transaction("AddToCurrentEmployee",lr.FAIL);
}
lr.end_transaction("init",lr.PASS);
}
catch(Exception ex)
{
string error = ex.Message;
}
return lr.PASS;
}
// ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
public int Actions()
{
#region 查询客户
//条件为空查询
try
{
lr.start_transaction("GetCustomerCountByCondition");
object[] param = {methodLR.GetQueryCustomerConditions()};
Object obj = System.Activator.CreateInstance(typeof(Proxy.CustomerProxy));
MethodInfo method = obj.GetType().GetMethod("GetCustomerCountByCondition");
DataTable dt = (DataTable)method.Invoke(obj,param);
int count = Convert.ToInt32(dt.Rows[0][0]);
if(count>0)
lr.end_transaction("GetCustomerCountByCondition",lr.PASS);
else
lr.end_transaction("GetCustomerCountByCondition",lr.FAIL);
}
catch(Exception ex)
{
string error = ex.Message;
}
//按客户编号查询
try
{
lr.start_transaction("GetCustomerCountByCode");
object[] param1 = {methodLR.GetQueryCustomerByCodeConditions()};
Object obj1 = System.Activator.CreateInstance(typeof(Proxy.CustomerProxy));
MethodInfo method1 = obj1.GetType().GetMethod("GetCustomerCountByCondition");
DataTable dt1 = (DataTable)method1.Invoke(obj1,param1);
int count1 = Convert.ToInt32(dt1.Rows[0][0]);
if(count1>0)
lr.end_transaction("GetCustomerCountByCode",lr.PASS);
else
lr.end_transaction("GetCustomerCountByCode",lr.FAIL);
}
catch(Exception ex)
{
string error = ex.Message;
}
//按客户名称查询
try
{
lr.start_transaction("GetCustomerCountByCustomerName");
object[] param2 = {methodLR.GetQueryCustomerByCustomerName()};
Object obj2 = System.Activator.CreateInstance(typeof(Proxy.CustomerProxy));
MethodInfo method2 = obj2.GetType().GetMethod("GetCustomerCountByCondition");
DataTable dt2 = (DataTable)method2.Invoke(obj2,param2);
int count2 = Convert.ToInt32(dt2.Rows[0][0]);
if(count2>0)
lr.end_transaction("GetCustomerCountByCustomerName",lr.PASS);
else
lr.end_transaction("GetCustomerCountByCustomerName",lr.FAIL);
}
catch(Exception ex)
{
string error = ex.Message;
}