Example #1
0
        public ActionResult GetCampaignList()
        {
            GetCampaignListArgs args = RequestArgs<GetCampaignListArgs>();
            if (args == null)
            {
                return RespondResult(false, "参数无效。");
            }

            args.DomainId = DomainContext.Domain.Id;
            args.AppId = DomainContext.AppId;
            //args.Status = EnumCampaignStatus.Ongoing;
            args.OrderBy = "StartTime";
            args.Sort = EnumSort.DESC;

            GetItemListResult result = _campaignManager.GetCampaignList(args);
            return RespondDataResult(result);
        }
        /// <summary>
        /// 获取指定活动的引导落地页面,如果没有设置,则获取域下的引导关注页面
        /// 再没有,就返回默认引导关注页面
        /// </summary>
        /// <param name="campaignId"></param>
        /// <returns></returns>
        //public string GetGuideSubscribeUrl(Guid campaignId, DomainContext domainContext)
        //{
        //    List<CommandParameter> parameterList = new List<CommandParameter>();
        //    parameterList.Add(new CommandParameter("@campaignId", campaignId));

        //    string url = null;
        //    _dataBase.ExecuteScalar<string>("SELECT [GuideSubscribeUrl] FROM [Campaign] WHERE [Id] = @campaignId",
        //        parameterList, (scalarString) => { url = scalarString; });

        //    if (String.IsNullOrEmpty(url) == false)
        //        return url;
        //    else
        //        return domainContext.GuideSubscribeUrl;
        //}

        public GetItemListResult GetCampaignList(GetCampaignListArgs args)
        {
            if (RelationalMappingUnity.IsValidFieldName(args.OrderBy) == false)
            {
                args.OrderBy = GetCampaignListArgs.DefaultOrderBy;
            }

            List <CommandParameter> parameterList = new List <CommandParameter>();

            parameterList.Add(new CommandParameter("@domainId", args.DomainId));
            parameterList.Add(new CommandParameter("@appId", args.AppId));
            parameterList.Add(new CommandParameter("@page", args.Page));
            parameterList.Add(new CommandParameter("@pageSize", args.PageSize));
            parameterList.Add(new CommandParameter("@type", args.Type));
            parameterList.Add(new CommandParameter("@status", args.Status));
            parameterList.Add(new CommandParameter("@orderby", args.OrderBy));
            parameterList.Add(new CommandParameter("@sort", args.Sort.ToString()));

            DataSet dsResult =
                DataBase.ExecuteDataSet(CommandType.StoredProcedure, "GetCampaignList", parameterList, new string[] { "result" });

            if (dsResult.Tables[0].Rows.Count == 0 && args.Page > 1)
            {
                args.Page--;
                return(GetCampaignList(args));
            }

            GetItemListResult result = new GetItemListResult();

            result.ItemList = dsResult.Tables[0];

            int totalCount = int.Parse(dsResult.Tables[1].Rows[0][0].ToString());

            result.TotalPage = totalCount / args.PageSize;
            if (totalCount % args.PageSize > 0)
            {
                result.TotalPage++;
            }
            result.Page = args.Page;

            return(result);
        }
Example #3
0
        public GetItemListResult GetList(GetCampaignListArgs args)
        {
            List <CommandParameter> parameterList = new List <CommandParameter>();

            parameterList.Add(new CommandParameter("@domainId", args.DomainId));
            parameterList.Add(new CommandParameter("@appId", args.AppId));
            parameterList.Add(new CommandParameter("@page", args.Page));
            parameterList.Add(new CommandParameter("@pageSize", args.PageSize));
            if (args.Status.HasValue)
            {
                parameterList.Add(new CommandParameter("@status", args.Status));
            }
            else
            {
                parameterList.Add(new CommandParameter("@status", DBNull.Value));
            }

            DataSet dsResult =
                _campaignManager.DataBase.ExecuteDataSet(CommandType.StoredProcedure, "GetCampaign_ShakingLotteryList", parameterList, new string[] { "result" });

            if (dsResult.Tables[0].Rows.Count == 0 && args.Page > 1)
            {
                args.Page--;
                return(GetList(args));
            }

            GetItemListResult result = new GetItemListResult();

            result.ItemList = dsResult.Tables[0];

            int totalCount = int.Parse(dsResult.Tables[1].Rows[0][0].ToString());

            result.TotalPage = totalCount / args.PageSize;
            if (totalCount % args.PageSize > 0)
            {
                result.TotalPage++;
            }
            result.Page = args.Page;

            return(result);
        }