public payMethod inTimePaymentResultHelp(string reqId, string payResult, payMethod syncOrNot) { //var t = Task.Factory.StartNew<string>(() => //{ // return subscribeSelfFilter(reqId, timeOut, (ele) => !ele.Equals(pubValue)); //}); //act(); //pubValue = JsonSerializer.SerializeToString(new { result = payResult, payMethod = syncOrNot }); var subNum = publish(reqId, payResult); if (subNum > 0) { return(syncOrNot); } else { return(payMethod.async); } //var flag = act(); //var res = string.Empty; //if (flag) //{ // res = t.Result; //} //else //{ //} //return res; }
public paymentEntity realCreateBill(inTimeReqPara para, Action<bankEntity, int, string> req, payMethod method = payMethod.sync, int processTime = 2000, string result = "ok") { var billNoTmp = para.ReqId + DateTime.Now.Ticks; var res = new paymentEntity { BillNo = billNoTmp }; var bankEnt = new bankEntity { PayId = billNoTmp }; var t = Task.Factory.StartNew(() => { req(bankEnt, processTime, result); }); var ip = "jimmyMStation";//"172.16.144.70"; var port = 6379; using (var help = helpBase.init(ip, port, new TimeSpan(0, 5, 0))) { var setItem = JsonSerializer.SerializeToString(new { reqId = para.ReqId, payMethod = method }); var ts = new TimeSpan(0, 5, 0); help.set(bankEnt.PayId, setItem, ts); //help.set(bankEnt.PayId, para.ReqId, ts); } t.Wait(100); return res; }
//public HttpPostedFileBase fImage { get; set; } public ActionResult Create(tProduct x) { payMethod pm = new payMethod(); pm.pm(x); if (x.fImage != null) { string name = Guid.NewGuid().ToString() + Path.GetExtension(x.fImage.FileName); var path = Path.Combine(Server.MapPath("~/Content"), name); x.fImage.SaveAs(path); x.fProductImage = "/Content/" + name; } db.tProduct.Add(x); db.SaveChanges(); return(RedirectToAction("productList")); }
//public static payMethod inTimePaymentResultHelp(this IhelpBase help,string reqId, string payResult, payMethod syncOrNot) //{ // var subNum = help.publish(reqId, payResult); // if (subNum > 0) // { // return syncOrNot; // } // else // { // return payMethod.async; // } //} /// <summary> /// help to sync the payment method and result /// </summary> /// <param name="help">ihelpbase object</param> /// <param name="billNo">bill number</param> /// <param name="payResult">the payresult Serialized as string</param> /// <param name="syncOrNot">the enum type to set the payment method</param> /// <param name="resultExpiry">how long(minutes) does result exist in redis</param> /// <returns>the final payment method the payService and paySoa will ack</returns> public static payMethod inTimePaymentResultHelpWithSetnx(this IhelpBase help, string billNo, string payResult, payMethod syncOrNot,int resultExpiry=1) { bool flag = help.setnx(billNo, payResult, new TimeSpan(0,resultExpiry,0)); if (flag) { var subNum = help.publish(billNo, payResult); return syncOrNot; } else { var expiryTime = 1000; var ts = new TimeSpan(expiryTime); help.setnx(billNo, "", ts); return payMethod.async; } }
public inTimeRes realPayRequestHelp(string reqId, Func<payMethod, int, string, paymentEntity> req, int waitTime = 5000, payMethod method = payMethod.sync, int processTime = 2000, string result = "ok") { var ip = "jimmyMStation";//"172.16.144.70"; var port = 6379; var res = string.Empty; var billRes = req(method, processTime, result); if (!string.IsNullOrEmpty(billRes.BillNo)) { using (var help = helpBase.init(ip, port, new TimeSpan(0, 5, 0))) { res = help.inTimePaymentMethodHelpWithSetnx(reqId, waitTime); } } else { } return res.FromJson<inTimeRes>(); }
public ActionResult Edit(tProduct c) { payMethod pm = new payMethod(); if (c == null) { return(RedirectToAction("productList")); } ; tProduct t = db.tProduct.FirstOrDefault(z => z.fProductId == c.fProductId); if (t != null) { pm.pm(c); t.fPayByArrive = c.fPayByArrive; t.fPayByCard = c.fPayByCard; t.fPayByJKO = c.fPayByJKO; t.fPayByLinePay = c.fPayByLinePay; t.fDelivery = c.fDelivery; t.fInstallment = c.fInstallment; t.fInstallmentRate = c.fInstallmentRate; t.fProductBrand = c.fProductBrand; t.fProductName = c.fProductName; t.fProductPrice = c.fProductPrice; t.fStock = c.fStock; if (c.fImage != null) { string name = Guid.NewGuid().ToString() + Path.GetExtension(c.fImage.FileName); var path = Path.Combine(Server.MapPath("~/Content"), name); c.fImage.SaveAs(path); t.fProductImage = "/Content/" + name; } db.SaveChanges(); } return(RedirectToAction("productList")); }
public payMethod inTimePaymentResultHelp(string reqId, string payResult, payMethod syncOrNot) { //var t = Task.Factory.StartNew<string>(() => //{ // return subscribeSelfFilter(reqId, timeOut, (ele) => !ele.Equals(pubValue)); //}); //act(); //pubValue = JsonSerializer.SerializeToString(new { result = payResult, payMethod = syncOrNot }); var subNum = publish(reqId, payResult); if (subNum > 0) { return syncOrNot; } else { return payMethod.async; } //var flag = act(); //var res = string.Empty; //if (flag) //{ // res = t.Result; //} //else //{ //} //return res; }