/// <summary> /// 获取 商户数据库链接 /// </summary> public ResponseModel <CC_Connection> GetConnection(CC_Connection request) { base.Remote.Action = "GetConnection"; base.Remote.Content = request.JsonSerialize(); _JSON = base.Remote.GetRemoteData(); return(_JSON.JsonDeserialize <ResponseModel <CC_Connection> >()); }
public HttpResponseMessage GetConnection([FromBody] CC_Connection connection) { try { var db = new RedisOperation(_RedisDB); var key = RedisKeys.CCConnectionKey(connection.CustomerID); var result = db.SelectString <CC_Connection>(key); if (result.Customer_Name.IsNullStr() || result.ConnectionStr.IsNullStr()) { return(Request.CreateResponse(HttpStatusCode.OK, new ResponseModel { Code = ResponseCode.DataNotFound, Message = "success" })); } return(Request.CreateResponse(HttpStatusCode.OK, new ResponseModel <CC_Connection> { Code = ResponseCode.Success, Message = "success", Result = result })); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.OK, new ResponseModel { Code = ResponseCode.Fail, Message = "fail:" + ex.Message })); } }
public void GetContact() { try { var numCount = 30; var customerIDs = CustomerBLL.Instance.GetCustomerList(); CC_Connection connection = new CC_Connection(); LoggingSessionInfo _loggingSessionInfo = new LoggingSessionInfo(); LoggingManager CurrentLoggingManager = new LoggingManager(); foreach (var customer in customerIDs) { var count = RedisOpenAPI.Instance.CCContact().GetContactLength(new CC_Contact { CustomerId = customer.Key }); if (count.Code != ResponseCode.Success) { continue; } if (count.Result <= 0) { continue; } _loggingSessionInfo.ClientID = customer.Key; CurrentLoggingManager.Connection_String = customer.Value; _loggingSessionInfo.CurrentLoggingManager = CurrentLoggingManager; var lPrizeBll = new LPrizesBLL(_loggingSessionInfo); if (count.Result < numCount) { numCount = Convert.ToInt32(count.Result); } BaseService.WriteLog("触点:" + customer.Key + "_" + customer.Value + ",数量" + numCount.ToString()); for (var i = 0; i < numCount; i++) { var response = RedisOpenAPI.Instance.CCContact().GetContact(new CC_Contact { CustomerId = customer.Key }); if (response.Code == ResponseCode.Success) { lPrizeBll.CheckIsWinnerForShareForRedis(response.Result.VipId, response.Result.EventId, response.Result.ContactType, _loggingSessionInfo); } } BaseService.WriteLog("触点结束"); } } catch (Exception ex) { BaseService.WriteLog("触点异常" + ex.Message.ToString()); } }
/// <summary> /// 定时全量种植 /// </summary> public void TimeSetBasicSetting() { CC_Connection connection = new CC_Connection(); LoggingSessionInfo _loggingSessionInfo = new LoggingSessionInfo(); LoggingManager CurrentLoggingManager = new LoggingManager(); var customerIDs = CustomerBLL.Instance.GetCustomerList(); foreach (var customer in customerIDs) { connection = new RedisConnectionBLL().GetConnection(customer.Key); BasicSettingBLL redisBasicSettingBll = new BasicSettingBLL(); redisBasicSettingBll.DelBasicSetting(customer.Key); redisBasicSettingBll.SetBasicSetting(customer.Key); } }
public HttpResponseMessage DelConnection([FromBody] CC_Connection Connection) { try { var db = new RedisOperation(_RedisDB); var key = RedisKeys.CCConnectionKey(Connection.CustomerID);//根据CustomerID生成对应的key db.DeleteString(key); return(Request.CreateResponse(HttpStatusCode.OK, new ResponseModel { Code = ResponseCode.Success, Message = "success" })); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.OK, new ResponseModel { Code = ResponseCode.Fail, Message = "fail:" + ex.Message })); } }
public HttpResponseMessage SetConnection([FromBody] CC_Connection Connection)//FromBody代表接收的是form提交过来的方式,默认不填写时是get的方式 { try { var db = new RedisOperation(_RedisDB); var key = RedisKeys.CCConnectionKey(Connection.CustomerID); //key的定义格式:Connection.CustomerID db.InsertString(key, Connection); //会把Connection转换成json字符串来存储 return(Request.CreateResponse(HttpStatusCode.OK, new ResponseModel { Code = ResponseCode.Success, Message = "success" })); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.OK, new ResponseModel { Code = ResponseCode.Fail, Message = "fail:" + ex.Message })); } }
/// <summary> /// 下载二维码 /// </summary> /// <param name="coupon"></param> /// <param name="strCon"></param> /// <returns></returns> public DataTable DownloadCoupon(CC_Coupon coupon, string strCustomerid, int downLoadNum, int intIsNotLimitQty) { var count = RedisOpenAPI.Instance.CCCoupon().GetCouponListLength(coupon); DataTable dtCoupon = new DataTable(); LoggingSessionInfo loggingSessionInfo = CustomerBLL.Instance.GetBSLoggingSession(strCustomerid, "RedisSystem"); dtCoupon.Columns.Add("CouponID", typeof(string)); dtCoupon.Columns.Add("CouponCode", typeof(string)); dtCoupon.Columns.Add("CouponDesc", typeof(string)); dtCoupon.Columns.Add("BeginDate", typeof(DateTime)); dtCoupon.Columns.Add("EndDate", typeof(DateTime)); dtCoupon.Columns.Add("CouponUrl", typeof(string)); dtCoupon.Columns.Add("ImageUrl", typeof(string)); dtCoupon.Columns.Add("Status", typeof(Int32)); dtCoupon.Columns.Add("CreateTime", typeof(DateTime)); dtCoupon.Columns.Add("CreateBy", typeof(string)); dtCoupon.Columns.Add("LastUpdateTime", typeof(DateTime)); dtCoupon.Columns.Add("LastUpdateBy", typeof(string)); dtCoupon.Columns.Add("IsDelete", typeof(Int32)); dtCoupon.Columns.Add("CouponTypeID", typeof(string)); dtCoupon.Columns.Add("CoupnName", typeof(string)); dtCoupon.Columns.Add("DoorID", typeof(string)); dtCoupon.Columns.Add("CouponPwd", typeof(string)); dtCoupon.Columns.Add("CollarCardMode", typeof(string)); dtCoupon.Columns.Add("CustomerID", typeof(string)); DataTable dtCouponExport = new DataTable(); dtCouponExport.Columns.Add("CouponCode", typeof(string)); CC_Connection connection = new CC_Connection(); string strCon = string.Empty; if (count.Code == ResponseCode.Success) { if (count.Result > 0) { connection = new RedisConnectionBLL().GetConnection(strCustomerid); if (connection.ConnectionStr == null) { strCon = GetCustomerConn(strCustomerid); } else { strCon = connection.ConnectionStr; } long num = 0; if (downLoadNum > count.Result) { if (intIsNotLimitQty == 1) { var bllCouponType = new CouponTypeBLL(loggingSessionInfo); bllCouponType.UpdateCouponTypeIssuedQty(coupon.CouponTypeId, downLoadNum); coupon.CouponLenth = downLoadNum; RedisOpenAPI.Instance.CCCoupon().SetCouponList(coupon); num = downLoadNum; } else { num = count.Result; } } else { num = downLoadNum; } for (int i = 0; i < num; i++) { var response = RedisGetCoupon(coupon); if (response.Code == ResponseCode.Success) { String uperStr = StringUtil.GetRandomUperStr(4); String strInt = StringUtil.GetRandomStrInt(8); string strCouponCode = uperStr + "-" + strInt; DataRow dr_Coupon = dtCoupon.NewRow(); dr_Coupon["CouponID"] = Guid.NewGuid().ToString(); dr_Coupon["CouponCode"] = strCouponCode; dr_Coupon["CouponDesc"] = response.Result.CouponTypeDesc; if (response.Result.ServiceLife > 0) { dr_Coupon["BeginDate"] = DateTime.Now; dr_Coupon["EndDate"] = DateTime.Now.Date.AddDays(response.Result.ServiceLife - 1).ToShortDateString() + " 23:59:59.998"; } else { dr_Coupon["BeginDate"] = response.Result.BeginTime; dr_Coupon["EndDate"] = response.Result.EndTime; } dr_Coupon["CouponUrl"] = ""; dr_Coupon["ImageUrl"] = ""; dr_Coupon["Status"] = 0; dr_Coupon["CreateTime"] = DateTime.Now; dr_Coupon["CreateBy"] = "Redis"; dr_Coupon["LastUpdateTime"] = DateTime.Now; dr_Coupon["LastUpdateBy"] = "Redis"; dr_Coupon["IsDelete"] = 0; dr_Coupon["CouponTypeID"] = response.Result.CouponTypeId; dr_Coupon["CoupnName"] = response.Result.CouponTypeName; dr_Coupon["DoorID"] = ""; dr_Coupon["CouponPwd"] = ""; dr_Coupon["CollarCardMode"] = ""; dr_Coupon["CustomerID"] = coupon.CustomerId; dtCoupon.Rows.Add(dr_Coupon); DataRow dr_CouponExport = dtCouponExport.NewRow(); dr_CouponExport["CouponCode"] = strCouponCode; dtCouponExport.Rows.Add(dr_CouponExport); } } if (dtCoupon != null && dtCoupon.Rows.Count > 0) { SqlBulkCopy(strCon, dtCoupon, "Coupon"); var bllCouponType = new CouponTypeBLL(loggingSessionInfo); bllCouponType.UpdateCouponTypeIsVoucher(strCustomerid); } } } return(dtCouponExport); }