using System; using System.Collections.Generic; using System.Linq; using System.Text; using Muchinfo.MTPClient.Infrastructure.LinkProxy; using Muchinfo.MTPClient.Infrastructure.Utilities; using Muchinfo.MTPClient.IService; using System.Runtime.InteropServices; namespace Muchinfo.MTPClient.Service { /// /// 风管云平台专用服务 /// public class ErmcpService: IErmcpService { [DllImport("WinDataCollect.dll", EntryPoint = "?CTP_GetSystemInfo@@YAHPADAAH@Z", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] private static extern int CTP_GetSystemInfo(IntPtr pSystemInfo, ref int nLen); /// /// 获取登录ID /// /// 可传入“登录账号”、“登录代码”和“手机号码” /// 成功能回调 /// 失败回调 public void GetLoginId(string username, Action successAction, Action errorAction) { var url = string.Format("{0}{1}?username={2}", LinkManager.Instance.Parameters.GoCommonSearchUrl, "/User/GetLoginID", username); var jsonString = HttpUtility.HttpGet(url); if (jsonString != null) { Dictionary dicJson = Newtonsoft.Json.JsonConvert.DeserializeObject>(jsonString); if (dicJson["code"].ToString() == "200") { successAction(dicJson["data"].ToString()); return; } } successAction(username); } /// /// CTP获取系统信息 /// /// public byte[] GetSystemInfo() { var nLen = 0; byte[] szOutData = null; //创建内存 var pSystemInfo = Marshal.AllocHGlobal(270); var iResult = CTP_GetSystemInfo(pSystemInfo, ref nLen); if (iResult == 0) { //拷贝到数组上面 szOutData = new byte[nLen]; Marshal.Copy(pSystemInfo, szOutData, 0, nLen); } //释放内存 Marshal.FreeHGlobal(pSystemInfo); return szOutData; } } }