/// <summary> /// 匹对指令 /// </summary> /// <param name="dBase"></param> /// <param name="m"></param> /// <returns></returns> public static LightDataModel.tbl_troneItem FillToneId(Shotgun.Database.IBaseDataClass2 dBase, Logical.ISMS_DataItem m) { var cmds = LightDataModel.tbl_troneItem.QueryTronesByPort(dBase, m.sp_api_url_id, m.ori_trone); if (cmds == null && cmds.Count() == 0) return null;//没有可用通道 var mMsg = m.ori_order; if (mMsg == null) mMsg = string.Empty; m.trone_id = C_TM_NOT_Order; LightDataModel.tbl_troneItem trone = null; int iCount = 0; foreach (var cmd in cmds) { var cMsg = cmd.orders; if (string.IsNullOrEmpty(cMsg) && string.IsNullOrEmpty(mMsg)) { trone = cmd; iCount++; continue; } if (cmd.match_price) {//无规则指令,直接匹配价格 if (cmd.price == (m.price / 100m)) { trone = cmd; iCount++; continue; } } else if (cmd.is_dynamic) {//模糊指令 var rx = Library.GetRegex(cmd.orders); if (rx.IsMatch(mMsg)) { trone = cmd; iCount++; continue; } } else {//精确指令 if (mMsg.Equals(cMsg, StringComparison.OrdinalIgnoreCase)) { trone = cmd; iCount++; continue; } } } if (iCount == 0) return null; if (iCount > 1) { m.trone_id = C_TM_MULTI_TRONE; return null; } if (m.price > 0) {//SP价格校验 防止配置错 if (trone.price != (m.price / 100m)) { m.trone_id = C_TM_PRICE_NOT_EQUQLS; return null; } } m.trone_id = trone.id; var sp_trone = LightDataModel.tbl_sp_troneItem.GetRowById(dBase, trone.sp_trone_id, null); if (sp_trone == null) return null; m.trone_type = sp_trone.trone_type; if (m is LightDataModel.tbl_mrItem) { var mr = (LightDataModel.tbl_mrItem)m; mr.sp_trone_id = sp_trone.id; if (mr.ivr_time > 20) { m.trone_id = C_IVR_TIME_CFG_ERROR; return null; } else if (mr.ivr_time > 0) { if (m.trone_type != C_IVR_TRONE_TYPE) { //通道类型检查 m.trone_id = C_IVR_TRONE_TYPE_ERROR; return null; } } } return trone; }
public static LightDataModel.tbl_cityItem FillAreaInfo(IBaseDataClass2 dBase, Logical.ISMS_DataItem m) { return n8wan.Public.Library.GetCityInfo(dBase, m.mobile, m.imsi); }