57 lines
2.1 KiB
C#
57 lines
2.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Cef3;
|
|
|
|
namespace Sashulin.common
|
|
{
|
|
class CwbJsExtendHandler : CefV8Handler
|
|
{
|
|
CefBrowser activeBrowser;
|
|
public CwbJsExtendHandler(CefBrowser browser)
|
|
{
|
|
activeBrowser = browser;
|
|
}
|
|
protected override bool Execute(string name, CefV8Value obj, CefV8Value[] arguments, out CefV8Value returnValue, out string exception)
|
|
{
|
|
exception = null;
|
|
switch (name)
|
|
{
|
|
case "CallCSharpMethod":
|
|
string methodName = arguments[0].GetStringValue();
|
|
string values = arguments[1].GetStringValue();
|
|
string res = Global.CallMethod(activeBrowser, methodName, values);
|
|
returnValue = CefV8Value.CreateString(res);
|
|
return true;
|
|
case "Connect":
|
|
string dbName = arguments[0].GetStringValue();
|
|
Global.cacheDB.Connect(dbName);
|
|
returnValue = CefV8Value.CreateString("0");
|
|
return true;
|
|
case "Execute":
|
|
string commandSql = arguments[0].GetStringValue();
|
|
int recordCount = Global.cacheDB.Execute(commandSql);
|
|
returnValue = CefV8Value.CreateInt(recordCount);
|
|
return true;
|
|
case "Query":
|
|
string querySql = arguments[0].GetStringValue();
|
|
string records = Global.cacheDB.Query(querySql);
|
|
returnValue = CefV8Value.CreateString(records);
|
|
return true;
|
|
case "Close":
|
|
Global.cacheDB.Close();
|
|
returnValue = CefV8Value.CreateString("0");
|
|
return true;
|
|
case "PageFinished":
|
|
Global.instance.OnPageFinished();
|
|
returnValue = CefV8Value.CreateString("0");
|
|
return true;
|
|
}
|
|
|
|
returnValue = null;
|
|
return false;
|
|
}
|
|
}
|
|
}
|