internal EnumCampaignStatus?GetStatus(Guid id) { List <CommandParameter> parameterList = new List <CommandParameter>(); parameterList.Add(new CommandParameter("@id", id)); int intStatus = 0; if (DataBase.ExecuteScalar <int>("SELECT [Status] FROM [Campaign] WHERE [Id] = @id", parameterList, (scalarValue) => { intStatus = scalarValue; })) { return((EnumCampaignStatus)intStatus); } else { return(null); } }
/// <summary> /// 返回调整后的最新库存数量 /// </summary> /// <param name="args"></param> /// <returns></returns> public int StockIncrement(PointCommodityStockAdjustmentArgs args) { List <CommandParameter> parameterList = new List <CommandParameter>(); parameterList.Add(new CommandParameter("@id", args.Id)); parameterList.Add(new CommandParameter("@quantity", args.Quantity)); _dataBase.ExecuteNonQuery("UPDATE [PointCommodity] SET [Stock] = [Stock] + @quantity WHERE [Id] = @id", parameterList); object objStock = _dataBase.ExecuteScalar("SELECT [Stock] FROM [PointCommodity] WHERE [Id] = @id", parameterList); if (objStock == null || objStock == DBNull.Value) { return(0); } else { return(int.Parse(objStock.ToString())); } }
/// <summary> /// 推送component_verify_ticket协议 /// </summary> /// <param name="xml"></param> private void ProcessComponentVerifyTicket(XElement xml) { string componentVerifyTicket = xml.XPathSelectElement("ComponentVerifyTicket").Value; if (String.IsNullOrEmpty(componentVerifyTicket)) { return; } //写缓存 //_caching.Set("ComponentVerifyTicket", componentVerifyTicket); _componentVerifyTicket = componentVerifyTicket; //写数据库 try { List <CommandParameter> parameterList = new List <CommandParameter>(); parameterList.Add(new CommandParameter("@componentVerifyTicket", componentVerifyTicket)); object objCount = _dataBase.ExecuteScalar("SELECT Count(1) FROM [ThirdParty]"); if (objCount == null || objCount == DBNull.Value || int.Parse(objCount.ToString()) == 0) { _dataBase.ExecuteNonQuery("INSERT INTO [ThirdParty] ([ComponentVerifyTicket]) VALUES (@componentVerifyTicket)", parameterList); } else { _dataBase.ExecuteNonQuery("UPDATE [ThirdParty] SET [ComponentVerifyTicket] = @componentVerifyTicket", parameterList); } } catch (Exception ex) { _logService.Write("ComponentVerifyTicket", "写入数据库失败。" + ex.Message, TraceEventType.Error); } }
public int GetTotalCount(DomainContext domainContext) { List <CommandParameter> parameterList = new List <CommandParameter>(); parameterList.Add(new CommandParameter("@domainId", domainContext.Domain.Id)); parameterList.Add(new CommandParameter("@appId", domainContext.AppId)); int intCount = 0; _dataBase.ExecuteScalar <int>( "SELECT Count(1) FROM [ScenicQRCode] WHERE [Domain] = @domainId AND [AppId] = @appId", parameterList, (scalarValue) => { intCount = scalarValue; }); return(intCount); }
/// <summary> /// 是否存在尚未结束的订单 /// </summary> /// <param name="domainId"></param> /// <param name="appId"></param> /// <param name="memberId"></param> /// <param name="type"></param> /// <returns></returns> public bool ExistUnfinishedOrder(Guid domainId, string appId, Guid memberId, EnumPayOrderType type) { List <CommandParameter> parameterList = new List <CommandParameter>(); parameterList.Add(new CommandParameter("@domainId", domainId)); parameterList.Add(new CommandParameter("@appId", appId)); parameterList.Add(new CommandParameter("@memberId", memberId)); parameterList.Add(new CommandParameter("@type", type)); int intStatus = 0; _dataBase.ExecuteScalar <int>( "SELECT Count(1) FROM [PayOrder] WHERE [Domain] = @domainId AND [AppId] = @appId AND [Member] = @memberId AND [Type] = @type AND ( [TradeState] = 2 OR [TradeState] = 5 )", parameterList, (scalarValue) => { intStatus = scalarValue; }); return(intStatus != 0); }
public string GetAuthorizerRefreshToken(string appId) { List <CommandParameter> parameterList = new List <CommandParameter>(); parameterList.Add(new CommandParameter("@appId", appId)); object objRefreshToken = _dataBase.ExecuteScalar( "SELECT [RefreshToken] FROM [Authorizer] WHERE [AppId] = @appId", parameterList); if (objRefreshToken == null || objRefreshToken == DBNull.Value) { return(null); } else { return(objRefreshToken.ToString()); } }
public string GetArticleMaterialMediaId(Guid id) { List <CommandParameter> parameterList = new List <CommandParameter>(); parameterList.Add(new CommandParameter("@id", id)); object objMediaId = _dataBase.ExecuteScalar("SELECT [MediaId] FROM ArticleMaterial WHERE [Id] = @id", parameterList); if (objMediaId != null && objMediaId != DBNull.Value) { return(objMediaId.ToString()); } else { return(String.Empty); } }
/// <summary> /// 根据AppId获取所属DomainId /// </summary> /// <param name="appId"></param> /// <returns></returns> public Guid?GetDomainId(string appId) { if (String.IsNullOrEmpty(appId)) { return(null); } if (_appIdDomainIdMapping.ContainsKey(appId)) { return((Guid)_appIdDomainIdMapping[appId]); } else { lock (_appIdDomainIdMappingLockObj) { if (_appIdDomainIdMapping.ContainsKey(appId)) { return((Guid)_appIdDomainIdMapping[appId]); } List <CommandParameter> parameterList = new List <CommandParameter>(); parameterList.Add(new CommandParameter("@appId", appId)); Guid domainId = Guid.Empty; if (_dataBase.ExecuteScalar <Guid>( "SELECT [Domain] FROM [Authorizer] WHERE [AppId] = @appId AND [Online] = 1", parameterList, (scalarValue) => { domainId = scalarValue; })) { _appIdDomainIdMapping.Add(appId, domainId); return(domainId); } else { return(null); } } } }