using DSWeb.Areas.CommMng.DAL; using DSWeb.MvcShipping.Helper; using HcUtility.Comm; using System; using System.Collections.Generic; using System.Data.Entity.Core.Metadata.Edm; using System.Diagnostics.Contracts; using System.Linq; using System.Reflection; using System.Web; using System.Web.Mvc; namespace DSWeb.Areas.CommMng.Controllers { public class PublicInterfaceController { [HttpPost] public InterfaceResult PostInterface(InterfaceParam param) { try { Assembly assembly = Assembly.Load("DSWeb.Areas.CommMng.Controllers"); var type = assembly.GetType("DSWeb.Areas.CommMng.Controllers.InterfaceBase." + param.PORTNAME); Object obj = type.Assembly.CreateInstance(type.ToString()); var doset = type.GetMethod("DoSet"); var _param = new object[]{ param}; InterfaceResult result = (InterfaceResult)doset.Invoke(obj,BindingFlags.Instance|BindingFlags.NonPublic,null, _param, null); return result; } catch (Exception e) { var _r = new InterfaceResult(); _r.errCode = "1"; var msg = e.Message; if (e.InnerException != null && e.InnerException.Message != null) { msg += "//InnerException.Message:" + e.InnerException.Message; } var _rs= BasicDataRefDAL.SaveLog(msg, "", param.PORTNAME, "公开接口"); var _rr = JsonConvert.Deserialize(_rs.Content); _r.errMsg = "未知错误,请联系相关人员,错误日志号【" + _rr.Data.ToString() + "】"; return _r; } } } public class InterfaceResult { public string errCode { get; set; } public string errMsg { get; set; } public InterfaceResult() { } public InterfaceResult(DBResult dbresult) { if (dbresult.Success) { errCode = "0"; } else { errCode = "1"; } errMsg = dbresult.Message + ";Data:" + JsonConvert.Serialize(dbresult.Data); } } public class InterfaceParam { public string PORTNAME { get; set; } public string GID { get; set; } public string Param { get; set; } } public class InterfaceBase { public InterfaceBase() { } public InterfaceResult DoSet(InterfaceParam param) { return new InterfaceResult(); } public class csCust: InterfaceBase { public InterfaceResult DoSet(InterfaceParam param) { return new InterfaceResult(); } } } }