コード例 #1
0
ファイル: HnztcService.cs プロジェクト: 2644783865/Infoztc
        public string GetAdvertisementList(int pageIndex, int pageSize, Guid siteFunId)
        {
            try
            {
                int               totalRecords = 0;
                Advertisement     bll          = new Advertisement();
                AdvertisementLink adlBll       = new AdvertisementLink();
                var               list         = bll.GetListByFunId(pageIndex, pageSize, out totalRecords, siteFunId);
                if (list == null || list.Count == 0)
                {
                    return("");
                }

                StringBuilder sb = new StringBuilder();
                sb.Append("<Rsp>");
                foreach (var model in list)
                {
                    string adLinkAppend = "";
                    var    adLinkList   = adlBll.GetDsByAdId(model.Id);
                    if (adLinkList != null && adLinkList.Tables.Count > 0 && adLinkList.Tables[0].Rows.Count > 0)
                    {
                        adLinkAppend += "<AdImages>";

                        DataRowCollection drc = adLinkList.Tables[0].Rows;

                        foreach (DataRow dr in drc)
                        {
                            string dir     = dr["FileDirectory"] == null ? "" : dr["FileDirectory"].ToString().Trim();
                            string rndCode = dr["RandomFolder"] == null ? "" : dr["RandomFolder"].ToString().Trim();
                            string fileEx  = dr["FileExtension"] == null ? "" : dr["FileExtension"].ToString().Trim();
                            Dictionary <string, string> dic = null;
                            if (!string.IsNullOrWhiteSpace(dir) && !string.IsNullOrWhiteSpace(rndCode) && !string.IsNullOrWhiteSpace(fileEx))
                            {
                                EnumData.Platform platform = EnumData.Platform.Android;
                                dic = PictureUrlHelper.GetUrlByPlatform(dir, rndCode, fileEx, platform);
                            }

                            adLinkAppend += "<AdImageInfo>";
                            adLinkAppend += string.Format(@"<ImageId>{0}</ImageId><AdId>{1}</AdId><ActionType>{2}</ActionType><Url>{3}</Url><Sort>{4}</Sort><OriginalPicture>{5}</OriginalPicture><BPicture>{6}</BPicture><MPicture>{7}</MPicture><SPicture>{8}</SPicture>",
                                                          dr["Id"], dr["AdvertisementId"], dr["ActionTypeCode"], dr["Url"], dr["Sort"], string.Format("{0}{1}", WebSiteHost, dic == null ? "" : dic["OriginalPicture"]), string.Format("{0}{1}", WebSiteHost, dic == null ? "" : dic["BPicture"]), string.Format("{0}{1}", WebSiteHost, dic == null ? "" : dic["MPicture"]), string.Format("{0}{1}", WebSiteHost, dic == null ? "" : dic["SPicture"]));
                            adLinkAppend += "</AdImageInfo>";
                        }
                        adLinkAppend += "</AdImages>";
                    }

                    sb.Append("<AdRes>");
                    sb.AppendFormat(@"<Id>{0}</Id><Title>{1}</Title><SiteFun>{2}</SiteFun><LayoutPosition>{3}</LayoutPosition><Duration>{4}</Duration><VirtualViewCount>{5}</VirtualViewCount><ViewCount>{6}</ViewCount><AdLink>{7}</AdLink>",
                                    model.Id, model.Title, model.SiteFunName, model.LayoutPositionName, model.Timeout, model.VirtualViewCount, model.ViewCount, adLinkAppend);
                    sb.Append("</AdRes>");
                }
                sb.Append("</Rsp>");

                return(sb.ToString());
            }
            catch
            {
                return("");
            }
        }
コード例 #2
0
ファイル: CollectLifeService.cs プロジェクト: xiaopohou/Wuye
        public string GetAdvertisementList(int pageIndex, int pageSize, Guid siteFunId)
        {
            try
            {
                int               totalRecords = 0;
                Advertisement     bll          = new Advertisement();
                AdvertisementLink adlBll       = new AdvertisementLink();
                var               list         = bll.GetListByFunId(pageIndex, pageSize, out totalRecords, siteFunId);
                if (list == null || list.Count == 0)
                {
                    return("");
                }

                StringBuilder sb = new StringBuilder();
                sb.Append("<Rsp>");
                foreach (var model in list)
                {
                    string adLinkAppend = "";
                    var    adLinkList   = adlBll.GetListByAdId(model.Id);
                    if (adLinkList != null && adLinkList.Count > 0)
                    {
                        adLinkAppend += "<AdImages>";

                        foreach (var adlModel in adLinkList)
                        {
                            Dictionary <string, string> dic = null;
                            if (!string.IsNullOrWhiteSpace(adlModel.FileDirectory) && !string.IsNullOrWhiteSpace(adlModel.FileExtension) && !string.IsNullOrWhiteSpace(adlModel.RandomFolder))
                            {
                                EnumData.Platform platform = EnumData.Platform.Android;
                                dic = PictureUrlHelper.GetUrlByPlatform(adlModel.FileDirectory, adlModel.RandomFolder, adlModel.FileExtension, platform);
                            }

                            adLinkAppend += "<AdImageInfo>";

                            adLinkAppend += string.Format(@"<ImageId>{0}</ImageId><AdId>{1}</AdId><ActionType>{2}</ActionType><Url><![CDATA[{3}]]></Url><Sort>{4}</Sort><OriginalPicture>{5}</OriginalPicture><BPicture>{6}</BPicture><MPicture>{7}</MPicture><SPicture>{8}</SPicture>",
                                                          adlModel.Id, adlModel.AdvertisementId, adlModel.ActionTypeName, adlModel.Url, adlModel.Sort, string.Format("{0}{1}", WebSiteHost, dic == null ? "" : dic["OriginalPicture"]), string.Format("{0}{1}", WebSiteHost, dic == null ? "" : dic["BPicture"]), string.Format("{0}{1}", WebSiteHost, dic == null ? "" : dic["MPicture"]), string.Format("{0}{1}", WebSiteHost, dic == null ? "" : dic["SPicture"]));

                            adLinkAppend += "</AdImageInfo>";
                        }
                        adLinkAppend += "</AdImages>";
                    }

                    sb.Append("<AdRes>");
                    sb.AppendFormat("<Id>{0}</Id><Title><![CDATA[{1}]]></Title><SiteFun>{2}</SiteFun><LayoutPosition>{3}</LayoutPosition><Duration>{4}</Duration><AdLink>{5}</AdLink>", model.Id, model.Title, model.SiteFunName, model.LayoutPositionName, model.Timeout, adLinkAppend);
                    sb.Append("</AdRes>");
                }
                sb.Append("</Rsp>");

                return(sb.ToString());
            }
            catch
            {
                return("");
            }
        }