private SPRecordExtendInfoWrapper GetExtendInfo() { List <SPRecordExtendInfoWrapper> spRecordExtends = SPRecordExtendInfoWrapper.FindAllByRecordID(this); if (spRecordExtends != null && spRecordExtends.Count > 0) { return(spRecordExtends[0]); } return(null); }
public static bool InsertPayment(SPRecordWrapper record, SPRecordExtendInfoWrapper spRecordExtendInfo, out RequestErrorType requestError, out string errorMessage) { return(businessProxy.InsertPayment(record.Entity, spRecordExtendInfo.Entity, out requestError, out errorMessage)); }
public string GenerateSendMOUrl(SPRecordWrapper record) { if (!this.SyncData) { return(""); } if (this.SyncDataSetting == null) { return(""); } SPRecordExtendInfoWrapper spRecordExtendInfo = record.ExtendInfo; NameValueCollection queryString = HttpUtility.ParseQueryString(string.Empty); List <SPChannelSycnParamsWrapper> channelSycnParams = record.ChannelID.GetAllSycnParams(); foreach (SPChannelSycnParamsWrapper channelSycnParam in channelSycnParams) { switch (channelSycnParam.MappingParams) { case DictionaryConst.Dictionary_SPField_LinkID_Key: BulidParams(queryString, channelSycnParam.Name, record.LinkID); break; case DictionaryConst.Dictionary_SPField_MO_Key: BulidParams(queryString, channelSycnParam.Name, record.Mo); break; case DictionaryConst.Dictionary_SPField_Mobile_Key: BulidParams(queryString, channelSycnParam.Name, record.Mobile); break; case DictionaryConst.Dictionary_SPField_SpNumber_Key: BulidParams(queryString, channelSycnParam.Name, record.SpNumber); break; case DictionaryConst.Dictionary_SPField_CreateDate_Key: BulidParams(queryString, channelSycnParam.Name, record.CreateDate.ToString("yyyyMMddhhmmss")); break; case DictionaryConst.Dictionary_SPField_City_Key: BulidParams(queryString, channelSycnParam.Name, record.City); break; case DictionaryConst.Dictionary_SPField_Province_Key: BulidParams(queryString, channelSycnParam.Name, record.Province); break; case DictionaryConst.Dictionary_SPField_FeeTime_Key: BulidParams(queryString, channelSycnParam.Name, "1"); break; case DictionaryConst.Dictionary_SPField_StartTime_Key: BulidParams(queryString, channelSycnParam.Name, spRecordExtendInfo.StartTime); break; case DictionaryConst.Dictionary_SPField_EndTime_Key: BulidParams(queryString, channelSycnParam.Name, spRecordExtendInfo.EndTime); break; case DictionaryConst.Dictionary_SPField_ExtendField1_Key: BulidParams(queryString, channelSycnParam.Name, spRecordExtendInfo.ExtendField1); break; case DictionaryConst.Dictionary_SPField_ExtendField2_Key: BulidParams(queryString, channelSycnParam.Name, spRecordExtendInfo.ExtendField2); break; case DictionaryConst.Dictionary_SPField_ExtendField3_Key: BulidParams(queryString, channelSycnParam.Name, spRecordExtendInfo.ExtendField3); break; case DictionaryConst.Dictionary_SPField_ExtendField4_Key: BulidParams(queryString, channelSycnParam.Name, spRecordExtendInfo.ExtendField4); break; case DictionaryConst.Dictionary_SPField_ExtendField5_Key: BulidParams(queryString, channelSycnParam.Name, spRecordExtendInfo.ExtendField5); break; case DictionaryConst.Dictionary_SPField_ExtendField6_Key: BulidParams(queryString, channelSycnParam.Name, spRecordExtendInfo.ExtendField6); break; case DictionaryConst.Dictionary_SPField_ExtendField7_Key: BulidParams(queryString, channelSycnParam.Name, spRecordExtendInfo.ExtendField7); break; case DictionaryConst.Dictionary_SPField_ExtendField8_Key: BulidParams(queryString, channelSycnParam.Name, spRecordExtendInfo.ExtendField8); break; case DictionaryConst.Dictionary_SPField_ExtendField9_Key: BulidParams(queryString, channelSycnParam.Name, spRecordExtendInfo.ExtendField9); break; case DictionaryConst.Dictionary_SPField_ExtendField10_Key: BulidParams(queryString, channelSycnParam.Name, spRecordExtendInfo.ExtendField10); break; } } Uri uri = new Uri(this.SyncDataSetting.SycnMOUrl); if (string.IsNullOrEmpty(queryString.ToString())) { return(this.SyncDataSetting.SycnMOUrl); } if (!string.IsNullOrEmpty(uri.Query.Trim())) { return(string.Format("{0}&{1}", this.SyncDataSetting.SycnMOUrl, queryString.ToString())); } return(string.Format("{0}?{1}", this.SyncDataSetting.SycnMOUrl, queryString.ToString())); }
public bool ProcessRequest(IDataAdapter httpRequestLog, bool statusOk, out RequestErrorType requestError, out string errorMessage) { requestError = RequestErrorType.NoError; errorMessage = ""; string linkid = GetLinkID(httpRequestLog); if (string.IsNullOrEmpty(linkid)) { requestError = RequestErrorType.NoLinkID; errorMessage = " 通道 ‘" + Name + "’ 请求失败:没有LinkID ."; return(false); } if (this.CheckLinkIDIsExisted(linkid)) { requestError = RequestErrorType.RepeatLinkID; errorMessage = " 通道 ‘" + Name + "’ 请求失败:重复的LinkID (缓存检查) ."; return(false); } string mo = this.ChannelParams.MoFromRequset(httpRequestLog); if (this.ChannelType == DictionaryConst.Dictionary_ChannelType_IVRChannel_Key) { mo = "ivr"; } string spcode = this.ChannelParams.SPCodeFromRequset(httpRequestLog); string mobile = this.ChannelParams.MobileFromRequset(httpRequestLog); string province = ""; string city = ""; string mobileOperator = ""; PhoneArea phoneArea = this.GetProvinceAndCity(mobile); if (phoneArea != null) { if (!string.IsNullOrEmpty(phoneArea.Province)) { province = phoneArea.Province; } else { province = ""; } if (!string.IsNullOrEmpty(phoneArea.City)) { city = phoneArea.City; } else { city = ""; } if (!string.IsNullOrEmpty(phoneArea.OperatorType)) { mobileOperator = phoneArea.OperatorType; } else { mobileOperator = ""; } } SPCodeWrapper matchCode = null; if (this.ChannelType == DictionaryConst.Dictionary_ChannelType_IVRChannel_Key) { matchCode = this.GetMatchCodeFromIVRRequest(httpRequestLog, spcode, province, city); } else { matchCode = this.GetMatchCodeFromRequest(httpRequestLog, mo, spcode, province, city); } if (matchCode == null) { requestError = RequestErrorType.NoChannelClientSetting; errorMessage = "请求失败:通道‘" + Name + "’请求未能找到匹配的代码设置。"; return(false); } SPClientCodeRelationWrapper clientCodeRelation = matchCode.GetRelateClientCodeRelation(); //如果存在指令,但是不存在对应的分配关系,转到默认匹配 if (clientCodeRelation == null) { clientCodeRelation = this.GetDefaultClientCodeRelation(); //如果是指令没有分配下家如何处理。 //matchCode = clientCodeRelation.CodeID; } SPRecordWrapper record = new SPRecordWrapper(); record.ChannelID = this; record.CodeID = matchCode; record.ClientID = clientCodeRelation.ClientID; record.ClientCodeRelationID = clientCodeRelation; record.Mo = mo; record.Mobile = mobile; record.LinkID = linkid; record.SpNumber = spcode; record.Province = province; record.City = city; record.OperatorType = mobileOperator; record.CreateDate = GetRecordTime(httpRequestLog); record.IsReport = false; record.IsStatOK = statusOk; record.IsIntercept = this.CaculteIsIntercept(matchCode, clientCodeRelation); if (record.IsIntercept) { record.IsSycnToClient = false; record.IsSycnSuccessed = false; record.SycnRetryTimes = 0; } else { if (!clientCodeRelation.SyncData) { record.IsSycnToClient = false; record.IsSycnSuccessed = false; record.SycnRetryTimes = 0; } else { record.IsSycnToClient = true; record.IsSycnSuccessed = false; record.SycnRetryTimes = 0; } } record.Price = clientCodeRelation.Price; record.Count = GetRecordCount(httpRequestLog); SPRecordExtendInfoWrapper spRecordExtendInfo = new SPRecordExtendInfoWrapper(); spRecordExtendInfo.StartTime = this.ChannelParams.StartTimeFromRequset(httpRequestLog); spRecordExtendInfo.EndTime = this.ChannelParams.EndTimeFromRequset(httpRequestLog); spRecordExtendInfo.FeeTime = this.ChannelParams.FeeTimeFromRequset(httpRequestLog); spRecordExtendInfo.State = this.ChannelParams.StateFromRequset(httpRequestLog); spRecordExtendInfo.Ip = httpRequestLog.RequestIp; spRecordExtendInfo.RequestContent = httpRequestLog.RequestData; spRecordExtendInfo.ExtendField1 = this.ChannelParams.ExtendField1FromRequset(httpRequestLog); spRecordExtendInfo.ExtendField2 = this.ChannelParams.ExtendField2FromRequset(httpRequestLog); spRecordExtendInfo.ExtendField3 = this.ChannelParams.ExtendField3FromRequset(httpRequestLog); spRecordExtendInfo.ExtendField4 = this.ChannelParams.ExtendField4FromRequset(httpRequestLog); spRecordExtendInfo.ExtendField5 = this.ChannelParams.ExtendField5FromRequset(httpRequestLog); spRecordExtendInfo.ExtendField6 = this.ChannelParams.ExtendField6FromRequset(httpRequestLog); spRecordExtendInfo.ExtendField7 = this.ChannelParams.ExtendField7FromRequset(httpRequestLog); spRecordExtendInfo.ExtendField8 = this.ChannelParams.ExtendField8FromRequset(httpRequestLog); spRecordExtendInfo.ExtendField9 = this.ChannelParams.ExtendField9FromRequset(httpRequestLog); spRecordExtendInfo.ExtendField10 = this.ChannelParams.ExtendField10FromRequset(httpRequestLog); try { bool result = SPRecordWrapper.InsertPayment(record, spRecordExtendInfo, out requestError, out errorMessage); if (!result && requestError == RequestErrorType.RepeatLinkID) { requestError = RequestErrorType.RepeatLinkID; errorMessage = " 通道 ‘" + Name + "’ 请求失败:重复的LinkID(查询排重 异常排重) ."; return(false); } requestError = RequestErrorType.NoError; errorMessage = ""; try { CacheProviderFactory.GetLinkIDCache().AddLinkIDs(linkid, this.Id); } catch (Exception ex) { Logger.Error(ex.Message); } record.SycnToClient(); return(true); } catch (Exception ex) { requestError = RequestErrorType.DataSaveError; errorMessage = "请求失败:插入数据失败,错误信息:" + ex.Message; return(false); } }