public void MessageFile(FileDownloadQueueWithMediaIdResult args) { Guid messageId = Guid.Parse(args.Tag); SqlStructureBuild sqlBuild = new SqlStructureBuild(); sqlBuild.Table = "Message"; sqlBuild.Type = SqlExpressionType.Update; sqlBuild.AddParameter("Id", messageId, true); sqlBuild.AddParameter("ContentType", args.ContentType); sqlBuild.AddParameter("FileUrl", _fileService.FileServiceUri + args.OutputFile); sqlBuild.AddParameter("FileLength", args.FileLength); _dataBase.ExcuteSqlExpression(sqlBuild.GetSqlExpression()); }
public string MoveMemberListToGroup(DomainContext domainContext, MoveMemberListToGroupArgs args) { WeixinSetUserListGroupArgs weixinArgs = new WeixinSetUserListGroupArgs(); weixinArgs.OpenIdList = args.OpenIdList; weixinArgs.GroupId = args.GroupId; //先往微信后台更新,成功后写数据库 RequestApiResult removeResult = GroupApiWrapper.SetUserListGroup(domainContext, weixinArgs); if (removeResult.Success == false) { return(removeResult.Message); } List <SqlExpression> _sqlList = new List <SqlExpression>(); //将此分组下的用户分到默认分组下面 foreach (var openId in args.OpenIdList) { SqlStructureBuild sqlBuild = new SqlStructureBuild(); sqlBuild.Type = SqlExpressionType.Update; sqlBuild.Table = "Member"; sqlBuild.AddParameter("Domain", domainContext.Domain.Id, true); sqlBuild.AddParameter("AppId", domainContext.AppId, true); sqlBuild.AddParameter("OpenId", openId, true); sqlBuild.AddParameter("GroupId", args.GroupId); _sqlList.Add(sqlBuild.GetSqlExpression()); } _dataBase.ExcuteSqlExpression(_sqlList); return(null); }
public NormalResult UpdatePointCommodity(PointCommodityEntity pointCommodity) { if (pointCommodity == null) { Debug.Assert(false, "pointCommodity 为空"); return(new NormalResult("参数错误")); } SqlStructureBuild sqlBuild = new SqlStructureBuild(); sqlBuild.Table = "PointCommodity"; sqlBuild.Type = SqlExpressionType.Update; sqlBuild.AddParameter("Id", pointCommodity.Id, true); sqlBuild.AddParameter("Domain", pointCommodity.Domain, true); sqlBuild.AddParameter("AppId", pointCommodity.AppId, true); sqlBuild.AddParameter("Name", pointCommodity.Name); sqlBuild.AddParameter("Price", pointCommodity.Price); sqlBuild.AddParameter("ForSale", pointCommodity.ForSale); sqlBuild.AddParameter("ImageUrl", pointCommodity.ImageUrl); sqlBuild.AddParameter("ImageList", JsonHelper.Serializer(pointCommodity.ImageList)); sqlBuild.AddParameter("Introduction", pointCommodity.Introduction); _dataBase.ExcuteSqlExpression(sqlBuild.GetSqlExpression()); return(new NormalResult()); }
public NormalResult UpdateCommodity(OneDollarBuyingCommodityEntity commodity) { if (commodity == null) { Debug.Assert(false, "commodity 为空"); return(new NormalResult("参数错误")); } SqlStructureBuild sqlBuild = new SqlStructureBuild(); sqlBuild.Table = "OneDollarBuyingCommodity"; sqlBuild.Type = SqlExpressionType.Update; sqlBuild.AddParameter("Id", commodity.Id, true); sqlBuild.AddParameter("Name", commodity.Name); sqlBuild.AddParameter("Price", commodity.Price); sqlBuild.AddParameter("ForSale", commodity.ForSale); sqlBuild.AddParameter("InfiniteStock", commodity.InfiniteStock); sqlBuild.AddParameter("ImageUrl", commodity.ImageUrl); sqlBuild.AddParameter("Introduction", commodity.Introduction); _dataBase.ExcuteSqlExpression(sqlBuild.GetSqlExpression()); PutOnSale(commodity.Id); return(new NormalResult()); }
public NormalResult UpdateAuthorizerAccountInfo(Guid domainId, string appId) { //获取公众号帐户信息 RequestApiResult <WeixinThirdPartyGetAuthorizerAccountInfoResult> accountInfoResult = ThirdPartyApiWrapper.GetAuthorizerAccountInfo(appId); if (accountInfoResult.Success) { WeixinThirdPartyAuthorizerAccountInfo account = accountInfoResult.ApiResult.AccountInfo; //微信返回的二维码图片不允许外部引用,此处必须把图片下载到本地 FileDownloadAgentArgs downloadAgentArgs = new FileDownloadAgentArgs(); downloadAgentArgs.Domain = domainId; downloadAgentArgs.Url = account.QRCodeUrl; FileDownloadAgentResult result = _fileService.DownloadAgent(downloadAgentArgs); string qrCodeUrl; if (result.Success) { _log.Write("下载二维码返回", JsonConvert.SerializeObject(result), TraceEventType.Verbose); qrCodeUrl = _fileService.FileServiceUri + result.OutputFile; } else { qrCodeUrl = account.QRCodeUrl; } SqlStructureBuild sqlBuild = new SqlStructureBuild(); sqlBuild.Table = "Authorizer"; sqlBuild.Type = SqlExpressionType.Update; sqlBuild.AddParameter("AppId", appId, true); sqlBuild.AddParameter("Domain", domainId, true); sqlBuild.AddParameter("NickName", account.NickName); sqlBuild.AddParameter("HeadImg", account.HeadImg); sqlBuild.AddParameter("ServiceType", account.ServiceType.Id); sqlBuild.AddParameter("VerifyType", account.VerifyType.Id); sqlBuild.AddParameter("UserName", account.UserName); sqlBuild.AddParameter("Alias", account.Alias); sqlBuild.AddParameter("QRCodeUrl", qrCodeUrl); sqlBuild.AddParameter("Store", account.Business.Store); sqlBuild.AddParameter("Scan", account.Business.Scan); sqlBuild.AddParameter("Pay", account.Business.Pay); sqlBuild.AddParameter("Card", account.Business.Card); sqlBuild.AddParameter("Shake", account.Business.Shake); sqlBuild.AddParameter("FuncScopeCategory", accountInfoResult.ApiResult.AuthorizationInfo.FuncScopeCategoryList.ToString()); _dataBase.ExcuteSqlExpression(sqlBuild.GetSqlExpression()); //更新LastUpdateTime DomainManager.Instance.UpdateLastUpdateTime(domainId); } NormalResult normalResult = new NormalResult(); normalResult.Success = accountInfoResult.Success; normalResult.Message = accountInfoResult.Message; return(normalResult); }
public void UpdateMemberCenterQRCodeImageUrl(Guid memberId, string url) { SqlStructureBuild sqlBuild = new SqlStructureBuild(); sqlBuild.Table = "Member"; sqlBuild.Type = SqlExpressionType.Update; sqlBuild.AddParameter("Id", memberId, true); sqlBuild.AddParameter("MemberCenterQRCodeImageUrl", url); _dataBase.ExcuteSqlExpression(sqlBuild.GetSqlExpression()); }
/// <summary> /// 返回 0 成功 1 登录名被占用 /// 在用户管理中更新用户信息,全面更新 /// </summary> /// <param name="user"></param> /// <returns></returns> public NormalResult UpdateUser(UserEntity user) { NormalResult result = new NormalResult(false); if (user == null) { result.Message = "参数错误。"; return(result); } lock (_lockUserObj) { List <CommandParameter> parameterList = new List <CommandParameter>(); parameterList.Add(new CommandParameter("@id", user.Id)); parameterList.Add(new CommandParameter("@account", user.Account)); int accountCount = int.Parse(_dataBase.ExecuteScalar( "SELECT Count(Id) FROM [User] WHERE [Account] = @account AND [Id] <> @id", parameterList).ToString()); if (accountCount > 0) { result.Reason = 1; return(result); } SqlStructureBuild sqlBuild = new SqlStructureBuild(); sqlBuild.Table = "User"; sqlBuild.Type = SqlExpressionType.Update; sqlBuild.AddParameter("Id", user.Id, true); sqlBuild.AddParameter("Account", user.Account); sqlBuild.AddParameter("Name", user.Name); sqlBuild.AddParameter("Email", user.Email); sqlBuild.AddParameter("Telphone", user.Telphone); sqlBuild.AddParameter("MemberId", user.MemberId); sqlBuild.AddParameter("Remark", user.Remark); _dataBase.ExcuteSqlExpression(sqlBuild.GetSqlExpression()); } result.Success = true; return(result); }
public NormalResult UpdateCoupon(CouponEntity coupon) { if (coupon == null) { Debug.Assert(false, "coupon 为空"); return(new NormalResult("参数错误")); } SqlStructureBuild sqlBuild = new SqlStructureBuild(); sqlBuild.Table = "Coupon"; sqlBuild.Type = SqlExpressionType.Update; sqlBuild.AddParameter("Id", coupon.Id, true); sqlBuild.AddParameter("Name", coupon.Name); sqlBuild.AddParameter("ImageUrl", coupon.ImageUrl); sqlBuild.AddParameter("Condition", coupon.Condition); sqlBuild.AddParameter("Description", coupon.Description); sqlBuild.AddParameter("InfiniteStock", coupon.InfiniteStock); sqlBuild.AddParameter("Remark", coupon.Remark); _dataBase.ExcuteSqlExpression(sqlBuild.GetSqlExpression()); return(new NormalResult()); }
/// <summary> /// 保存样式设置,但是不包括 PortalCustomTemplate /// </summary> /// <param name="domainId"></param> /// <param name="args"></param> public void SavePortalStyleSettings_Template(Guid domainId, PortalStyleSettingsEntity args) { if (args == null) { Debug.Assert(false, "PortalStyleSettingsEntity 为空"); return; } //_dataBase.Update(args); //不能直接update,会把 PortalCustomTemplate 覆盖掉 SqlStructureBuild sqlBuild = new SqlStructureBuild(); sqlBuild.Table = "StyleSettings"; sqlBuild.Type = SqlExpressionType.Update; sqlBuild.AddParameter("Domain", args.Domain, true); sqlBuild.AddParameter("AppId", args.AppId, true); sqlBuild.AddParameter("PortalMode", args.PortalMode); sqlBuild.AddParameter("PortalImageUrl", args.PortalImageUrl); sqlBuild.AddParameter("PortalPresetTemplateId", args.PortalPresetTemplateId); _dataBase.ExcuteSqlExpression(sqlBuild.GetSqlExpression()); _domainManager.UpdateLastUpdateTime(domainId); }
public NormalResult Update(ScenicQRCodeEntity scenicQRCode) { if (scenicQRCode == null) { Debug.Assert(false, "scenicQRCode 为空"); return(new NormalResult("参数错误")); } SqlStructureBuild sqlBuild = new SqlStructureBuild(); sqlBuild.Table = "ScenicQRCode"; sqlBuild.Type = SqlExpressionType.Update; sqlBuild.AddParameter("Id", scenicQRCode.Id, true); sqlBuild.AddParameter("Name", scenicQRCode.Name); sqlBuild.AddParameter("Remark", scenicQRCode.Remark); _dataBase.ExcuteSqlExpression(sqlBuild.GetSqlExpression()); return(new NormalResult()); }
public NormalResult SaveSettings(Guid domainId, MovieSettingsEntity args) { if (args == null) { Debug.Assert(false, "args 为空"); return(new NormalResult("参数错误")); } SqlStructureBuild sqlBuild = new SqlStructureBuild(); sqlBuild.Table = "MovieSettings"; sqlBuild.Type = SqlExpressionType.Update; sqlBuild.AddParameter("Domain", args.Domain, true); sqlBuild.AddParameter("AppId", args.AppId, true); sqlBuild.AddParameter("ShareImageUrl", args.ShareImageUrl); sqlBuild.AddParameter("ShareTimelineTitle", args.ShareTimelineTitle); sqlBuild.AddParameter("ShareAppMessageTitle", args.ShareAppMessageTitle); sqlBuild.AddParameter("ShareAppMessageDescription", args.ShareAppMessageDescription); _dataBase.ExcuteSqlExpression(sqlBuild.GetSqlExpression()); return(new NormalResult()); }
public NormalResult Notify(string xml, AuthorizerPayConfig config) { _log.Write("收到支付结果通知", xml, TraceEventType.Verbose); NormalResult result = new NormalResult(); WxPayArgs wxPayArgs = config.GetWxPayArgs(false); RequestPayApiResult <WeixinPayNotify> notifyResult = WxPayApi.Notify(xml, wxPayArgs); if (notifyResult.Success == false) { _log.Write("支付结果通知显示失败", notifyResult.Message, TraceEventType.Verbose); result.Success = false; result.Message = notifyResult.Message; return(result); } WeixinPayNotify notify = notifyResult.ApiResult; Guid payOrderId; if (Guid.TryParse(notify.Attach, out payOrderId) == false) { string attacth = String.Empty; if (notify.Attach != null) { attacth = notify.Attach; } _log.Write("Attach 无法转为本地订单Id" + attacth, notify.OutTradeNo, TraceEventType.Verbose); result.Success = false; result.Message = "Attach 无法转为本地订单Id。" + attacth; return(result); } bool updateNotifyStatus = UpdateNotifyStatus(payOrderId); if (updateNotifyStatus == false) { //已经处理过了 //处理过的还是返回true,防止微信服务器反复推送通知 //微信文档上说通知频率为15/15/30/180/1800/1800/1800/1800/3600,单位:秒 //但是实测支付成功后连续推送通知过来 result.Success = true; result.Message = "已经接收到过此订单的支付通知。"; return(result); } SqlStructureBuild sqlBuild = new SqlStructureBuild(); sqlBuild.Table = "PayOrder"; sqlBuild.Type = SqlExpressionType.Update; sqlBuild.AddParameter("Id", payOrderId, true); sqlBuild.AddParameter("Notify", true); if (notify.ReturnCode == "SUCCESS" && notify.ResultCode == "SUCCESS") { sqlBuild.AddParameter("TradeState", EnumPayTradeState.SUCCESS); } else { sqlBuild.AddParameter("TradeState", EnumPayTradeState.PAYERROR); } sqlBuild.AddParameter("BankType", notify.BankType); sqlBuild.AddParameter("FeeType", notify.FeeType); sqlBuild.AddParameter("CouponFee", notify.CouponFee); sqlBuild.AddParameter("CouponCount", notify.CouponCount); sqlBuild.AddParameter("TransactionId", notify.TransactionId); sqlBuild.AddParameter("TimeEnd", WeixinApiHelper.ConvertStringToDateTime(notify.TimeEnd)); sqlBuild.AddParameter("Notify_ReturnCode", notify.ReturnCode); sqlBuild.AddParameter("Notify_ReturnMsg", notify.ReturnMsg); sqlBuild.AddParameter("Notify_ResultCode", notify.ResultCode); sqlBuild.AddParameter("Notify_ErrCode", notify.ErrCode); sqlBuild.AddParameter("Notify_ErrCodeDes", notify.ErrCodeDes); int affectedRowCount = _dataBase.ExcuteSqlExpression(sqlBuild.GetSqlExpression()); if (affectedRowCount == 0) { _log.Write("本地订单不存在", notify.OutTradeNo, TraceEventType.Verbose); result.Success = false; result.Message = "本地订单不存在。"; return(result); } PayOrderEntity payOrder = GetPayOrder(payOrderId); if (notify.CouponCount > 0) { foreach (WeixinPayNotify_Coupon coupon in notify.CouponList) { coupon.PayOrderId = payOrder.Id; _dataBase.Insert(coupon); } } if (notify.ReturnCode == "SUCCESS" && notify.ResultCode == "SUCCESS") { switch (payOrder.Type) { case EnumPayOrderType.Unknow: _log.Write("收到支付结果通知", "未知订单类型", TraceEventType.Warning); break; case EnumPayOrderType.Deposit: ProcessDepositPayNotify(payOrder); break; case EnumPayOrderType.PointCommodity: ProcessPointCommodityPayNotify(payOrder); break; case EnumPayOrderType.Donation: ProcessDonationPayNotify(payOrder); break; default: _log.Write("收到支付结果通知", "订单类型未处理:" + payOrder.Type.ToString(), TraceEventType.Warning); break; } } //更新一下订单状态 RefreshPayOrder(payOrder.OutTradeNo, config); result.Success = true; return(result); }
private void Consume(DatabaseSyncConfig_Consumer consumer, DatabaseSyncConfig_Producer producer, DatabaseSyncCommand command) { DatabaseWrapper consumerDatabase = _dataBaseList[consumer.Connection]; DatabaseWrapper producerDatabase = _dataBaseList[producer.Connection]; List <SqlExpression> sqlExpressionList = new List <SqlExpression>(); foreach (DatabaseSyncItem syncItem in command.SyncItemList) { List <DatabaseSyncConfig_Table> tableList = (from c in producer.TableDefinition.TableList where c.Name == syncItem.Table select c).ToList(); foreach (DatabaseSyncConfig_Table table in tableList) { List <CommandParameter> parameterList = new List <CommandParameter>(); parameterList.Add(new CommandParameter("@primaryKeyValue", syncItem.PrimaryKeyValue)); DataSet dataSet = producerDatabase.ExecuteDataSet( $"SELECT * FROM [{table.Name}] WHERE [{table.PrimaryKey}] = @primaryKeyValue", parameterList, new string[] { table.Name }); if (dataSet.Tables[0].Rows.Count == 0) { continue; } foreach (DataRow row in dataSet.Tables[0].Rows) { SqlStructureBuild sqlStructureBuild = new SqlStructureBuild(); sqlStructureBuild.Table = table.ConsumerTable; switch (syncItem.Action) { case DatabaseSyncAction.Add: sqlStructureBuild.Type = SqlExpressionType.Insert; break; case DatabaseSyncAction.Update: sqlStructureBuild.Type = SqlExpressionType.Update; break; case DatabaseSyncAction.Delete: sqlStructureBuild.Type = SqlExpressionType.Delete; break; default: break; } foreach (DatabaseSyncConfig_Field field in table.Field) { sqlStructureBuild.AddParameter(field.ConsumerField, row[field.Name], field.ConsumerField == table.ConsumerTablePrimaryKey); } SqlExpression sqlExpression = sqlStructureBuild.GetSqlExpression(); sqlExpressionList.Add(sqlExpression); } } } consumerDatabase.ExcuteSqlExpression(sqlExpressionList); }