Не код пути возвращают значение
public JsonResult Refunded(string activity, string DCID, string DCN, string from, string to, string remark, string rid, DateTime dor, string sts, string pid) { string merchantCode = string.Empty; string status = string.Empty; string code = string.Empty; var DOR = ""; if (!string.IsNullOrEmpty(sts) && sts == "F") { DOR = dor.ToString("yyyyMMdd"); } pid = pid.TrimEnd(','); rid = rid.TrimEnd(','); if (rid == "") { rid = "0"; } Exception ex; var rowsF = CDbManager.ExecuteNonQuery("APConnection", @"UPDATE [Refund] SET [RefundedDate] = @dor, [RefundStatus] = @sts WHERE [Id] in (SELECT items FROM dbo.Split(@rid,','))", CommandType.Text, new Dictionary<string, object> { {"@dor", DOR}, {"@sts", sts}, {"@rid", rid} }, out ex); if (rowsF > 0){ var sendMail = true; if (!string.IsNullOrEmpty(sts) && sts == "F") { var listPID = pid.TrimEnd(',').Split(','); var listRID = rid.TrimEnd(',').Split(','); for (var j = 0; j < listPID.Length; j++) { sendMail = sendMail && SendMail(Convert.ToInt32(listPID[j]), Convert.ToInt32(listRID[j])); if (((_merchantCode == "M17648") && (_merchantCode == "M27399_S0001"))) { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; string backendpostPayid = getRefundPayId(Convert.ToInt32(listRID[j]), Convert.ToInt32(listPID[j])); string MailStatus = string.Empty; try { string QString = "getRefundPayId=" + backendpostPayid.ToString(); WebRequest request = WebRequest.Create(System.Configuration.ConfigurationManager.AppSettings["refund_backendpost_url"].ToString()); request.Method = "POST"; byte[] byteArray = Encoding.UTF8.GetBytes(QString); request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = byteArray.Length; Stream dataStream = request.GetRequestStream(); dataStream.Write(byteArray, 0, byteArray.Length); dataStream.Close(); WebResponse response = request.GetResponse(); dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); string BackendStatus = reader.ReadToEnd(); reader.Close(); dataStream.Close(); response.Close(); if (string.IsNullOrEmpty(BackendStatus)) { this.DicParam.Clear(); this.DicParam.Add("@Detail", "MHWebservice-BackendPostRefundNotSent:PayId:" + backendpostPayid.ToString() + ""); CDbManager.ExecuteSP("APConnection", "sp_epay_InsertM2UTemp", this.DicParam); } else if (BackendStatus == "BackendPostRefundSent") { this.DicParam.Clear(); this.DicParam.Add("@Detail", "MHWebservice-BackendPostRefundSent:PayId:" + backendpostPayid.ToString() + "|Status:" + BackendStatus.ToString()); CDbManager.ExecuteSP("APConnection", "sp_epay_InsertM2UTemp", this.DicParam); } } catch (Exception ex1){ this.DicParam.Clear(); this.DicParam.Add("@Detail", "MHWebservice-BackendPostRefundNotSent:PayId:" + backendpostPayid.ToString() + "|Status:" + ex1.ToString()); CDbManager.ExecuteSP("APConnection", "sp_epay_InsertM2UTemp", this.DicParam); } } } } else { code = "0"; status = ex != null ? ex.Message : "Failed to connect to database."; } AuditTrail(activity, DCID, DCN, from, to, remark); return Json(new { code, status }); } }
//Я столкнулся с этой ошибкой, из-за которой он не вернул значение.
Что я уже пробовал:
<pre><pre><pre> public JsonResult Refunded(string activity, string DCID, string DCN, string from, string to, string remark, string rid, DateTime dor, string sts, string pid) { string merchantCode = string.Empty; string status = string.Empty; string code = string.Empty; var DOR = ""; if (!string.IsNullOrEmpty(sts) && sts == "F") { DOR = dor.ToString("yyyyMMdd"); } pid = pid.TrimEnd(','); rid = rid.TrimEnd(','); if (rid == "") { rid = "0"; } Exception ex; var rowsF = CDbManager.ExecuteNonQuery("APConnection", @"UPDATE [Refund] SET [RefundedDate] = @dor, [RefundStatus] = @sts WHERE [Id] in (SELECT items FROM dbo.Split(@rid,','))", CommandType.Text, new Dictionary<string, object> { {"@dor", DOR}, {"@sts", sts}, {"@rid", rid} }, out ex); if (rowsF > 0){ var sendMail = true; if (!string.IsNullOrEmpty(sts) && sts == "F") { var listPID = pid.TrimEnd(',').Split(','); var listRID = rid.TrimEnd(',').Split(','); for (var j = 0; j < listPID.Length; j++) { sendMail = sendMail && SendMail(Convert.ToInt32(listPID[j]), Convert.ToInt32(listRID[j])); if (((_merchantCode == "M17648") && (_merchantCode == "M27399_S0001"))) { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; string backendpostPayid = getRefundPayId(Convert.ToInt32(listRID[j]), Convert.ToInt32(listPID[j])); string MailStatus = string.Empty; try { string QString = "getRefundPayId=" + backendpostPayid.ToString(); WebRequest request = WebRequest.Create(System.Configuration.ConfigurationManager.AppSettings["refund_backendpost_url"].ToString()); request.Method = "POST"; byte[] byteArray = Encoding.UTF8.GetBytes(QString); request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = byteArray.Length; Stream dataStream = request.GetRequestStream(); dataStream.Write(byteArray, 0, byteArray.Length); dataStream.Close(); WebResponse response = request.GetResponse(); dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); string BackendStatus = reader.ReadToEnd(); reader.Close(); dataStream.Close(); response.Close(); if (string.IsNullOrEmpty(BackendStatus)) { this.DicParam.Clear(); this.DicParam.Add("@Detail", "MHWebservice-BackendPostRefundNotSent:PayId:" + backendpostPayid.ToString() + ""); CDbManager.ExecuteSP("APConnection", "sp_epay_InsertM2UTemp", this.DicParam); } else if (BackendStatus == "BackendPostRefundSent") { this.DicParam.Clear(); this.DicParam.Add("@Detail", "MHWebservice-BackendPostRefundSent:PayId:" + backendpostPayid.ToString() + "|Status:" + BackendStatus.ToString()); CDbManager.ExecuteSP("APConnection", "sp_epay_InsertM2UTemp", this.DicParam); } } catch (Exception ex1){ this.DicParam.Clear(); this.DicParam.Add("@Detail", "MHWebservice-BackendPostRefundNotSent:PayId:" + backendpostPayid.ToString() + "|Status:" + ex1.ToString()); CDbManager.ExecuteSP("APConnection", "sp_epay_InsertM2UTemp", this.DicParam); } } } } else { code = "0"; status = ex != null ? ex.Message : "Failed to connect to database."; } AuditTrail(activity, DCID, DCN, from, to, remark); return Json(new { code, status }); } }