h:\svn_customer_Customers_NAS\NTIT\wsHundure\wsHundureService.cs
h:\svn_customer_Customers_NAS\NTIT\wsHundure\IwsHundureService.cs
public class wsHundureService : IwsHundureService
public string DeviceAction(string doorID, string CmdID, string CmdValue)
{
//string path = HostingEnvironment.MapPath("~/bin/DevAction.dll");
//string dllfunc = "DeviceAction";
//string s1 = "";
//try
//{
// LoadFun(path, dllfunc);
// doCallDll myDll = (doCallDll)Marshal.GetDelegateForFunctionPointer(farProc, typeof(doCallDll));
// myDll("123", "abc", "hello1234", ref s1);
// }
//catch (Exception ex) { UnLoadDll(); s1 = "catch"; }
//finally {
// UnLoadDll(); s1 = "finally";
//}
//http://www.dotblogs.com.tw/dc690216/archive/2010/08/01/16939.aspx
//http://net-liu.javaeye.com/blog/696770
//Params[7]=@reserve1 //int readerid
//Params[8]=@reserve2 //int nodeid
//Params[9]=@reserve3//address
//Params[10]=@reserve4//addressExt
string address = "172.16.33.100";
string addressext = "4660";
string nodeid = "1";
string readerid = "0";
string strResult = "";
string sdoorID = doorID;// "0";
string smanufid = "";
//Params[6]=@tag // ManufID
//Params[7]=@reserve1 //int readerid
//Params[8]=@reserve2 //int nodeid
//Params[9]=@reserve3//address
//Params[10]=@reserve4//addressExt
//string ssql = string.Format("select tag , doorid, reserve1 as readerid,reserve2 as nodeid,reserve3 as address,reserve4 as addressext from pubdoor where doorid = '{0}'", sdoorID);
string ssql = " select tag , doorid, reserve1 as readerid,reserve2 as nodeid,reserve3 as address,reserve4 as addressext from pubdoor where doorid = '" + sdoorID + "'";
DataSet ds = getData(ssql);
if (ds.Tables[0].Rows.Count == 0)
{
return strResult = "沒有門資料!" + ssql;
}
smanufid = ds.Tables[0].Rows[0]["tag"].ToString();
sdoorID = ds.Tables[0].Rows[0]["doorid"].ToString();
readerid = ds.Tables[0].Rows[0]["readerid"].ToString();
nodeid = ds.Tables[0].Rows[0]["nodeid"].ToString();
address = ds.Tables[0].Rows[0]["address"].ToString();
addressext = ds.Tables[0].Rows[0]["addressext"].ToString();
if (string.IsNullOrEmpty(smanufid)) smanufid = "eric";
if (string.IsNullOrEmpty(nodeid) || string.IsNullOrEmpty(readerid) || string.IsNullOrEmpty(address) || string.IsNullOrEmpty(addressext))
{
return strResult = "沒有足夠連線資料! " + ssql;
}
string pathdll = HostingEnvironment.MapPath("~/bin/" + smanufid + "/HundClassLibrary.dll");
try
{
strResult = pathdll;
Assembly assembly = Assembly.LoadFrom(pathdll);
Type type = assembly.GetType("HundClassLibrary.CDevWorker");
MethodInfo miGetMethod = type.GetMethod("doCom");
object obj = assembly.CreateInstance(type.FullName, true);
strResult = type.FullName;
strResult = (string)miGetMethod.Invoke(obj, new string[] { address, addressext, nodeid, readerid, CmdID, CmdValue }) + "...";// +pathdll;
}
catch (Exception ex)
{
strResult = ex.Message;
}
finally
{
}
return strResult;
}