public static void PayVideos(string sID) { try { string sql = "select datediff(second,starttime, watching) span,size/422000 secs, datediff(second,starttime, watching)/((SIZE/422000)+.01) pct,* from tip where paid is null and userid is not null"; if (sID != "") { sql += " and userid='" + BMS.PurifySQL(sID, 100) + "'"; } DataTable dt1 = gData.GetDataTable2(sql); for (int i = 0; i < dt1.Rows.Count; i++) { double nPCT = GetDouble(dt1.Rows[i]["Pct"]); double nRew = GetDouble(dt1.Rows[i]["Amount"]); if (nPCT > 1) { nPCT = 1; } double nAmt = nRew * nPCT; string sCategory = dt1.Rows[i]["Category"].ToString(); string sUserID = dt1.Rows[i]["UserID"].ToString(); // Reward the user DataOps.AdjBalance(nAmt, sUserID, "Video Reward for " + Math.Round(nPCT * 100, 2).ToString() + "% for [" + sCategory + "]"); sql = "Update Tip set Paid = getdate() where id = '" + dt1.Rows[i]["id"].ToString() + "'"; gData.Exec(sql); } } catch (Exception ex) { Log("Unable to pay " + ex.Message); } }
public static DACResult Zinc_QueryOrderStatus(string sZincID) { DACResult r = new DACResult(); r.sError = ""; try { Chilkat.Rest rest = ConnectToZinc(); string jsonOrder = ""; string sResponse = rest.FullRequestString("GET", "/v1/orders/" + sZincID, jsonOrder); if (rest.LastMethodSuccess != true) { Log(rest.LastErrorText); r.sError = "Unable to interface with AMAZON."; return(r); } dynamic oJson = JsonConvert.DeserializeObject <dynamic>(sResponse); // Tracking string sDeliveryDate = GetJsonValue(oJson, "delivery_dates", "date"); string sTrackingURL = GetJsonValue(oJson, "merchant_order_ids", "tracking_url"); if (sTrackingURL != "") { sTrackingURL = sZincID; } string sCode = GetJsonValue(oJson, "code", ""); string msg = GetJsonValue(oJson, "message", ""); msg = msg.Replace("'", ""); string sStatus = ""; if (sCode == "aborted_request") { sStatus = "COMPLETED"; sTrackingURL = sCode; } else if (msg == "One of the products you selected is unavailable.") { sStatus = "COMPLETED"; sTrackingURL = "CUSTOMER REFUNDED"; // Credit the user the amount string sMySql = "Select * from Orders where ZincID = '" + BMS.PurifySQL(sZincID, 40) + "'"; DataTable dtRefunded = gData.GetDataTable2(sMySql); if (dtRefunded.Rows.Count > 0) { double nPriceBBP = GetDouble(dtRefunded.Rows[0]["bbpprice"]); string sSql2 = "Select product_id from products where id='" + dtRefunded.Rows[0]["productid"].ToString() + "'"; string sProdID = gData.GetScalarString2(sSql2, "product_id"); string sNotes = "Full refund for unavailable product for product id " + sProdID; DataOps.AdjBalance(1 * nPriceBBP, DataOps.GetUserRecord(dtRefunded.Rows[0]["UserId"].ToString()).UserId.ToString(), sNotes); NotifyOfMissingProduct(DataOps.GetUserRecord(dtRefunded.Rows[0]["UserId"].ToString()).EmailAddress, sProdID); } } else if (sTrackingURL != "") { sStatus = "OUT_FOR_DELIVERY"; if (sDeliveryDate != "") { System.TimeSpan diffResult = System.DateTime.Now - Convert.ToDateTime(sDeliveryDate); if (diffResult.TotalHours > 1) { sStatus = "COMPLETED"; } } } if (r.sResult != "" || true) { string sql = "Update Orders Set Updated=getdate(),DeliveryDate='" + sDeliveryDate + "', TrackingNumber='" + sTrackingURL + "',Message='" + msg + "',Status = '" + sStatus + "' where ZincID = '" + sZincID + "' and status <> 'COMPLETED'"; gData.Exec(sql); } return(r); } catch (Exception ex) { r.sError = "Unable to find product."; return(r); } }