日期:2011-12-05 浏览次数:20505 次
set c = CreateObject("VB6Soap.Calc")for i = 1 to 10 WScript.Echo i & " " & c.Add(i,i) & " " & Timenext
using System;using System.Reflection;using System.Runtime.InteropServices;using System.EnterpriseServices;using System.Data;using System.Data.SqlClient;[assembly: ApplicationName("SCTrans")][assembly: ApplicationActivation(ActivationOption.Server, SoapVRoot="SCTrans")][assembly: AssemblyKeyFile("SCTrans.snk")]namespace SCTrans{ public interface ISCTrans { string CountUp (string Key); } [ObjectPooling(MinPoolSize=0, MaxPoolSize=25)] [JustInTimeActivation(true)] [ClassInterface(ClassInterfaceType.AutoDual)] [TransactionAttribute(TransactionOption.RequiresNew)] public class SCTransSQLNC : ServicedComponent, ISCTrans { [AutoComplete] public string CountUp (string Key) { _command = new SqlCommand("", _connection); _command.CommandType = CommandType.Text; _command.Connection.Open(); _command.CommandText = "UPDATE CallCount WITH (ROWLOCK) SET CallCount = CallCount + 1 WHERE Machine='" + Key + "'"; _command.ExecuteNonQuery(); _command.Connection.Close(); _numcalls++; return (_numcalls + " NC " + _guid); } protected override bool CanBePooled() { return true; } private int _numcalls = 0; private string _guid = Guid.NewGuid().ToString(); private SqlConnection _connection = new SqlConnection("user id=MyUser;password=My!Password; database=SoapTest;server=MyServer"); private SqlCommand _command; }}