using System; using System.IO; using System.ServiceModel; using System.ServiceModel.Activation; using System.ServiceModel.Web; using System.Text; using System.Web; using FangYar.BLL; using FangYar.Common; using FireWebAPIApp.Models; namespace FireWebAPIApp { [ServiceContract] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)] public class DaHuaAPIService { #region 根据编码获机构信息 /// /// 根据编码获机构信息 /// /// /// [WebInvoke(UriTemplate = "GetOrgInfo", Method = "POST", ResponseFormat = WebMessageFormat.Json)] public ResultMo GetOrgInfo() { // 记录操作日志 SysOperationLogHelp.AddSysOperationLog(HttpContext.Current, EnumOperationLogType.Other, "大华消防接口请求", ""); ResultMo retMo = new ResultMo() { Value = new DaHuaOrgQueryMo(), Message = "", State = 0 }; try { var code = HttpContext.Current.Request.Params["code"] + ""; //判断是否URL编码数据 if (code.IndexOf("%") > 0) { code = System.Web.HttpUtility.UrlDecode(code.Trim(), Encoding.GetEncoding("GB2312")); } var str = AesHelper.Decrypt(code); if (str.IndexOf("&") > 0) { var arr = str.Split(new string[] { "&" }, StringSplitOptions.RemoveEmptyEntries); if (arr.Length == 2) { retMo.State = 1; retMo.Message = "Success"; retMo.Value = new DaHuaOrgQueryMo() { OrgId = WebCommonUtil.GetOrgIdDownLevelToUpLevel(arr[0]), UserId = arr[1] }; } else { retMo.State = 2; retMo.Message = "参数异常"; } } else { retMo.State = 2; retMo.Message = "参数异常"; } } catch (Exception ex) { retMo.State = -1; retMo.Message = "参数无效,或者尚未对参数进行URL编码"; string str = "大华消防接口请求异常:" + ex; FangYar.Common.MyLogHelper.WriteMsg(new FangYar.Common.LogInfoMo() { message = str, msgType = FangYar.Common.EnumLogMsgTypeEnum.Error, path = "DaHuaXFAPI" }); } return retMo; } #endregion } }