/// <summary> /// /// </summary> /// <param name="model"></param> /// <returns></returns> public bool Notify(OrderSmsInfo model) { int rowsAffected = 0; SqlParameter[] parameters = { new SqlParameter("@linkId", SqlDbType.VarChar, 50), new SqlParameter("@againNotifyUrl", SqlDbType.VarChar, 300), new SqlParameter("@notifycount", SqlDbType.Int, 4), new SqlParameter("@notifystat", SqlDbType.TinyInt, 1), new SqlParameter("@notifycontext", SqlDbType.VarChar, 200), new SqlParameter("@notifytime", SqlDbType.DateTime), new SqlParameter("@userOrder", SqlDbType.VarChar, 30), new SqlParameter("@suppId", SqlDbType.VarChar, 50), new SqlParameter("@issucc", SqlDbType.Bit, 1), //是否成功 new SqlParameter("@errcode", SqlDbType.VarChar, 50) //错误代码 }; parameters[0].Value = model.linkid; //parameters[1].Value = model.notifyurl; parameters[1].Value = model.againNotifyUrl; parameters[2].Value = model.notifycount; parameters[3].Value = model.notifystat; parameters[4].Value = model.notifycontext; parameters[5].Value = DateTime.Now; if (model.issucc) { parameters[6].Value = model.notifycontext; } else { parameters[6].Value = string.Empty; } parameters[7].Value = model.supplierId; parameters[8].Value = model.issucc; parameters[9].Value = model.errcode; rowsAffected = DataBase.ExecuteNonQuery(System.Data.CommandType.StoredProcedure, "proc_ordersms_notify", parameters); if (rowsAffected > 0) { return(true); } else { return(false); } }
/// <summary> /// /// </summary> /// <param name="oclass"></param> /// <param name="obj"></param> /// <returns></returns> public static string GetNotifyUrl(int oclass, object obj) { string notifyUrl = string.Empty; if (oclass == 1)//网银 { OrderBankInfo orderInfo = obj as OrderBankInfo; if (orderInfo == null) { return(string.Empty); } OrderBank bll = new OrderBank(); notifyUrl = ""; //bll.GetCallBackUrl(orderInfo); } else if (oclass == 2) //点卡 { OrderCardInfo orderInfo = obj as OrderCardInfo; if (orderInfo == null) { return(string.Empty); } OrderCard bll = new OrderCard(); //notifyUrl = bll.GetCallBackUrl(orderInfo); } else if (oclass == 3)//短信及声讯 { OrderSmsInfo orderInfo = obj as OrderSmsInfo; if (orderInfo == null) { return(string.Empty); } OrderSms bll = new OrderSms(); notifyUrl = bll.GetCallBackUrl(orderInfo); } return(notifyUrl); }
const int DefaultTimeout = 2 * 60 * 1000; // 2 minutes timeout #region UpdatetoDB /// <summary> /// 将结果返回到数据库 /// </summary> /// <param name="oclass"></param> /// <param name="obj"></param> /// <param name="agurl"></param> /// <param name="times"></param> /// <param name="callbacktext"></param> private static void UpdatetoDB(int oclass, object obj, string agurl, int times, string callbacktext, bool success, string errcode) { if (oclass == 1) { OrderBankInfo orderInfo = obj as OrderBankInfo; if (orderInfo != null) { OrderBank dal = new OrderBank(); //string SuccessFlag = SystemApiHelper.Successflag(orderInfo.version); bool isnotifysucc = SystemApiHelper.CheckCallBackIsSuccess(orderInfo.version, callbacktext); orderInfo.notifystat = isnotifysucc ? 2 : 4; orderInfo.againNotifyUrl = agurl; orderInfo.notifycontext = callbacktext; orderInfo.notifycount = times; orderInfo.notifytime = DateTime.Now; dal.UpdateNotifyInfo(orderInfo); if (orderInfo.notifystat != 2) { //没有成功将发送到异常队列 多次通知 banknotifyQueue.Send(orderInfo); } } } else if (oclass == 2) { OrderCardInfo orderInfo = obj as OrderCardInfo; if (orderInfo != null) { OrderCard dal = new OrderCard(); bool isnotifysucc = SystemApiHelper.CheckCallBackIsSuccess(orderInfo.version, callbacktext); orderInfo.notifystat = isnotifysucc ? 2 : 4; orderInfo.againNotifyUrl = agurl; orderInfo.notifycontext = callbacktext; orderInfo.notifycount = times; orderInfo.notifytime = DateTime.Now; dal.UpdateNotifyInfo(orderInfo); if (orderInfo.notifystat != 2) { //没有成功将发送到异常队列 多次通知 cardnotifyQueue.Send(orderInfo); } } } else if (oclass == 3) { OrderSmsInfo orderInfo = obj as OrderSmsInfo; if (orderInfo != null) { OrderSms dal = new OrderSms(); orderInfo.notifystat = success ? 2:4; orderInfo.issucc = success; orderInfo.errcode = errcode; orderInfo.againNotifyUrl = agurl; orderInfo.notifycontext = callbacktext; orderInfo.notifycount = times; dal.UpdateNotifyInfo(orderInfo); if (orderInfo.notifystat != 2) { //没有成功将发送到异常队列 多次通知 smsnotifyQueue.Send(orderInfo); } } } }
/// <summary> /// 发送完成的订单到队列 /// </summary> /// <param name="orderMessage">All information for an order</param> public void Complete(OrderSmsInfo orderMessage) { // This method does not involve in distributed transaction and optimizes performance using Single type base.transactionType = MessageQueueTransactionType.Single; base.Send(orderMessage); }
/// <summary> /// 增加一条数据 /// </summary> public bool Insert(OrderSmsInfo model) { //try //{ SqlParameter[] parameters = { new SqlParameter("@orderid", SqlDbType.NVarChar, 30), new SqlParameter("@userorder", SqlDbType.NVarChar, 30), new SqlParameter("@supplierId", SqlDbType.Int, 4), new SqlParameter("@userid", SqlDbType.Int, 4), new SqlParameter("@mobile", SqlDbType.VarChar, 20), new SqlParameter("@fee", SqlDbType.Decimal, 9), new SqlParameter("@message", SqlDbType.NVarChar, 50), new SqlParameter("@servicenum", SqlDbType.VarChar, 50), new SqlParameter("@linkid", SqlDbType.VarChar, 50), new SqlParameter("@gwid", SqlDbType.VarChar, 2), new SqlParameter("@payRate", SqlDbType.Decimal, 9), new SqlParameter("@supplierRate", SqlDbType.Decimal, 9), new SqlParameter("@promRate", SqlDbType.Decimal, 9), new SqlParameter("@payAmt", SqlDbType.Decimal, 9), new SqlParameter("@promAmt", SqlDbType.Decimal, 9), new SqlParameter("@supplierAmt", SqlDbType.Decimal, 9), new SqlParameter("@profits", SqlDbType.Decimal, 9), new SqlParameter("@server", SqlDbType.Int, 4), new SqlParameter("@addtime", SqlDbType.DateTime), new SqlParameter("@completetime", SqlDbType.DateTime), new SqlParameter("@status", SqlDbType.TinyInt), new SqlParameter("@manageId", SqlDbType.Int), new SqlParameter("@Cmd", SqlDbType.NVarChar, 10), new SqlParameter("@userMsgContenct", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.orderid; parameters[1].Value = model.userorder; parameters[2].Value = model.supplierId; parameters[3].Value = model.userid; parameters[4].Value = model.mobile; parameters[5].Value = model.fee; parameters[6].Value = model.message; parameters[7].Value = model.servicenum; parameters[8].Value = model.linkid; parameters[9].Value = model.gwid; parameters[10].Value = model.payRate; parameters[11].Value = model.supplierRate; parameters[12].Value = model.promRate; parameters[13].Value = model.payAmt; parameters[14].Value = model.promAmt; parameters[15].Value = model.supplierAmt; parameters[16].Value = model.profits; parameters[17].Value = model.server; parameters[18].Value = model.addtime; parameters[19].Value = model.completetime; parameters[20].Value = model.status; parameters[21].Value = model.manageId; parameters[22].Value = model.Cmd; parameters[23].Value = model.userMsgContenct; DataBase.ExecuteNonQuery(System.Data.CommandType.StoredProcedure, "proc_ordersms_Insert", parameters); return(true); //} //catch (Exception ex) //{ // viviLib.ExceptionHandling.ExceptionHandler.HandleException(ex); // return false; //} }
/// <summary> /// /// </summary> /// <param name="ds"></param> /// <returns></returns> internal OrderSmsInfo GetModelFromDs(DataSet ds) { OrderSmsInfo model = new OrderSmsInfo(); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } model.orderid = ds.Tables[0].Rows[0]["orderid"].ToString(); model.userorder = ds.Tables[0].Rows[0]["userorder"].ToString(); if (ds.Tables[0].Rows[0]["supplierId"].ToString() != "") { model.supplierId = int.Parse(ds.Tables[0].Rows[0]["supplierId"].ToString()); } if (ds.Tables[0].Rows[0]["userid"].ToString() != "") { model.userid = int.Parse(ds.Tables[0].Rows[0]["userid"].ToString()); } model.mobile = ds.Tables[0].Rows[0]["mobile"].ToString(); if (ds.Tables[0].Rows[0]["fee"].ToString() != "") { model.fee = decimal.Parse(ds.Tables[0].Rows[0]["fee"].ToString()); } model.message = ds.Tables[0].Rows[0]["message"].ToString(); model.servicenum = ds.Tables[0].Rows[0]["servicenum"].ToString(); model.linkid = ds.Tables[0].Rows[0]["linkid"].ToString(); model.gwid = ds.Tables[0].Rows[0]["gwid"].ToString(); if (ds.Tables[0].Rows[0]["payRate"].ToString() != "") { model.payRate = decimal.Parse(ds.Tables[0].Rows[0]["payRate"].ToString()); } if (ds.Tables[0].Rows[0]["supplierRate"].ToString() != "") { model.supplierRate = decimal.Parse(ds.Tables[0].Rows[0]["supplierRate"].ToString()); } if (ds.Tables[0].Rows[0]["promRate"].ToString() != "") { model.promRate = decimal.Parse(ds.Tables[0].Rows[0]["promRate"].ToString()); } if (ds.Tables[0].Rows[0]["payAmt"].ToString() != "") { model.payAmt = decimal.Parse(ds.Tables[0].Rows[0]["payAmt"].ToString()); } if (ds.Tables[0].Rows[0]["promAmt"].ToString() != "") { model.promAmt = decimal.Parse(ds.Tables[0].Rows[0]["promAmt"].ToString()); } if (ds.Tables[0].Rows[0]["supplierAmt"].ToString() != "") { model.supplierAmt = decimal.Parse(ds.Tables[0].Rows[0]["supplierAmt"].ToString()); } if (ds.Tables[0].Rows[0]["profits"].ToString() != "") { model.profits = decimal.Parse(ds.Tables[0].Rows[0]["profits"].ToString()); } if (ds.Tables[0].Rows[0]["server"].ToString() != "") { model.server = int.Parse(ds.Tables[0].Rows[0]["server"].ToString()); } if (ds.Tables[0].Rows[0]["addtime"].ToString() != "") { model.addtime = DateTime.Parse(ds.Tables[0].Rows[0]["addtime"].ToString()); } if (ds.Tables[0].Rows[0]["completetime"].ToString() != "") { model.completetime = DateTime.Parse(ds.Tables[0].Rows[0]["completetime"].ToString()); } if (ds.Tables[0].Rows[0]["status"].ToString() != "") { model.status = int.Parse(ds.Tables[0].Rows[0]["status"].ToString()); } model.notifyurl = ds.Tables[0].Rows[0]["notifyurl"].ToString(); model.againNotifyUrl = ds.Tables[0].Rows[0]["againNotifyUrl"].ToString(); if (ds.Tables[0].Rows[0]["notifycount"].ToString() != "") { model.notifycount = int.Parse(ds.Tables[0].Rows[0]["notifycount"].ToString()); } if (ds.Tables[0].Rows[0]["notifystat"].ToString() != "") { model.notifystat = int.Parse(ds.Tables[0].Rows[0]["notifystat"].ToString()); } model.notifycontext = ds.Tables[0].Rows[0]["notifycontext"].ToString(); return(model); } else { return(null); } }