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(""); } }
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(""); } }
public string GetAdvertisementModel(Guid Id) { try { if (Id.Equals(Guid.Empty)) { return(""); } Advertisement bll = new Advertisement(); var model = bll.GetModelByJoin(Id); if (model == null) { return(""); } Regex r = new Regex("(<img)(.*)src=\"([^\"]*?)\"(.*)/>"); AdvertisementLink adlBll = new AdvertisementLink(); 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>"; } StringBuilder sb = new StringBuilder(); sb.Append("<Rsp>"); sb.AppendFormat("<Id>{0}</Id><Title><![CDATA[{1}]]></Title><SiteFun>{2}</SiteFun><LayoutPosition>{3}</LayoutPosition><AdTime>{4}</AdTime><AdLink>{5}</AdLink><Descr>{6}</Descr><Content><![CDATA[{7}]]></Content>", model.Id, model.Title, model.SiteFunName, model.LayoutPositionName, model.LastUpdatedDate.ToString("yyyy-MM-dd HH:mm"), adLinkAppend, model.Descr, r.Replace(model.ContentText, "$1$2src=\"" + WebSiteHost + "$3\" />")); sb.Append("</Rsp>"); return(sb.ToString()); } catch { return(""); } }
public string GetServiceContentById(Guid Id) { try { if (Id.Equals(Guid.Empty)) { return(""); } ServiceContent scBll = new ServiceContent(); var model = scBll.GetModelByJoin(Id); if (model == null) { return(""); } Regex r = new Regex("(<img)(.*)src=\"([^\"]*?)\"(.*)/>"); model.ContentText = r.Replace(model.ContentText, "$1$2src=\"" + WebSiteHost + "$3\" />"); StringBuilder sb = new StringBuilder(3000); sb.Append("<Rsp>"); IList <object> listArr = new List <object>(); Dictionary <string, string> dic = null; if (!string.IsNullOrWhiteSpace(model.FileDirectory) && !string.IsNullOrWhiteSpace(model.RandomFolder) && !string.IsNullOrWhiteSpace(model.FileExtension)) { EnumData.Platform platform = EnumData.Platform.Android; dic = PictureUrlHelper.GetUrlByPlatform(model.FileDirectory, model.RandomFolder, model.FileExtension, platform); } listArr.Add(dic == null ? "" : WebSiteHost + dic["OriginalPicture"]); listArr.Add(dic == null ? "" : WebSiteHost + dic["BPicture"]); listArr.Add(dic == null ? "" : WebSiteHost + dic["MPicture"]); listArr.Add(dic == null ? "" : WebSiteHost + dic["SPicture"]); sb.AppendFormat("<Id>{0}</Id><Name>{1}</Name><Descr>{2}</Descr><Content><![CDATA[{3}]]></Content><LastUpdatedDate>{4}</LastUpdatedDate>", model.Id, model.Named, model.Descr, model.ContentText, model.LastUpdatedDate.ToString("yyyy-MM-dd HH:mm")); sb.AppendFormat("<OriginalPicture>{0}</OriginalPicture><BPicture>{1}</BPicture><MPicture>{2}</MPicture><SPicture>{3}</SPicture>", listArr.ToArray()); sb.Append("</Rsp>"); return(sb.ToString()); } catch (Exception ex) { new CustomException(string.Format("服务-接口:string GetServiceContentById,异常:{0}", ex.Message), ex); return(""); } }
public string GetServiceLinkById(Guid Id) { try { if (Id.Equals(Guid.Empty)) { return(""); } ServiceLink scBll = new ServiceLink(); var model = scBll.GetModelByJoin(Id); if (model == null) { return(""); } IList <object> listArr = new List <object>(); Dictionary <string, string> dic = null; if (!string.IsNullOrWhiteSpace(model.FileDirectory) && !string.IsNullOrWhiteSpace(model.RandomFolder) && !string.IsNullOrWhiteSpace(model.FileExtension)) { EnumData.Platform platform = EnumData.Platform.Android; dic = PictureUrlHelper.GetUrlByPlatform(model.FileDirectory, model.RandomFolder, model.FileExtension, platform); } listArr.Add(dic == null ? "" : WebSiteHost + dic["OriginalPicture"]); listArr.Add(dic == null ? "" : WebSiteHost + dic["BPicture"]); listArr.Add(dic == null ? "" : WebSiteHost + dic["MPicture"]); listArr.Add(dic == null ? "" : WebSiteHost + dic["SPicture"]); StringBuilder sb = new StringBuilder(3000); sb.Append("<Rsp>"); sb.AppendFormat("<Id>{0}</Id><Name>{1}</Name><Url>{2}</Url><LastUpdatedDate>{3}</LastUpdatedDate>", model.Id, model.Named, model.Url, model.LastUpdatedDate.ToString("yyyy-MM-dd HH:mm")); sb.AppendFormat("<OriginalPicture>{0}</OriginalPicture><BPicture>{1}</BPicture><MPicture>{2}</MPicture><SPicture>{3}</SPicture>", listArr.ToArray()); sb.Append("</Rsp>"); return(sb.ToString()); } catch (Exception ex) { new CustomException(string.Format("服务-接口:string GetServiceLinkById,异常:{0}", ex.Message), ex); return(""); } }
private void GetDatagridForServiceVote(HttpContext context) { context.Response.ContentType = "text/plain"; int totalRecords = 0; int pageIndex = 1; int pageSize = 10; int.TryParse(context.Request.Form["page"], out pageIndex); int.TryParse(context.Request.Form["rows"], out pageSize); Guid serviceItemId = Guid.Empty; if (!string.IsNullOrWhiteSpace(context.Request.Form["serviceItemId"])) { Guid.TryParse(context.Request.Form["serviceItemId"], out serviceItemId); } if (serviceItemId.Equals(Guid.Empty)) { context.Response.Write("{\"total\":0,\"rows\":[]}"); return; } string keyword = context.Request.Form["keyword"]; string sqlWhere = string.Empty; ParamsHelper parms = null; if (!serviceItemId.Equals(Guid.Empty)) { sqlWhere += "and sv.ServiceItemId = @ServiceItemId "; SqlParameter parm = new SqlParameter("@ServiceItemId", SqlDbType.UniqueIdentifier); parm.Value = serviceItemId; if (parms == null) { parms = new ParamsHelper(); } parms.Add(parm); } if (!string.IsNullOrWhiteSpace(keyword)) { if (parms == null) { parms = new ParamsHelper(); } sqlWhere += "and (sv.Named like @Named or sv.Descr like @Descr) "; SqlParameter parm = new SqlParameter("@Named", SqlDbType.NVarChar, 30); parm.Value = "%" + keyword.Trim() + "%"; parms.Add(parm); parm = new SqlParameter("@Descr", SqlDbType.NVarChar, 300); parm.Value = "%" + keyword.Trim() + "%"; parms.Add(parm); } ServiceVote bll = new ServiceVote(); var list = bll.GetListByJoin(pageIndex, pageSize, out totalRecords, sqlWhere, parms == null ? null : parms.ToArray()); if (list == null || list.Count == 0) { ServiceItem siBll = new ServiceItem(); var oldModel = siBll.GetModel(serviceItemId); if (oldModel != null && oldModel.HasVote) { siBll.UpdateHasVote(serviceItemId, false); } context.Response.Write("{\"total\":0,\"rows\":[]}"); return; } StringBuilder sb = new StringBuilder(); foreach (var model in list) { Dictionary <string, string> dic = null; if (!string.IsNullOrWhiteSpace(model.FileDirectory) && !string.IsNullOrWhiteSpace(model.RandomFolder) && !string.IsNullOrWhiteSpace(model.FileExtension)) { EnumData.Platform platform = EnumData.Platform.Android; dic = PictureUrlHelper.GetUrlByPlatform(model.FileDirectory, model.RandomFolder, model.FileExtension, platform); } string sOriginalPicture = dic == null ? "" : dic["OriginalPicture"]; string sBPicture = dic == null ? "" : dic["BPicture"]; string sMPicture = dic == null ? "" : dic["MPicture"]; string sSPicture = dic == null ? "" : dic["SPicture"]; sb.Append("{\"Id\":\"" + model.Id + "\",\"ServiceItemId\":\"" + model.ServiceItemId + "\",\"ServiceItemName\":\"" + model.ServiceItemName + "\",\"Named\":\"" + model.Named + "\",\"Descr\":\"" + model.Descr + "\",\"Sort\":\"" + model.Sort + "\""); sb.Append(",\"OriginalPicture\":\"" + sOriginalPicture + "\",\"BPicture\":\"" + sBPicture + "\",\"MPicture\":\"" + sMPicture + "\",\"SPicture\":\"" + sSPicture + "\",\"LastUpdatedDate\":\"" + model.LastUpdatedDate.ToString("yyyy-MM-dd HH:mm") + "\"},"); } context.Response.Write("{\"total\":" + totalRecords + ",\"rows\":[" + sb.ToString().Trim(',') + "]}"); }
public string GetServiceListByServiceItemId(string username, int pageIndex, int pageSize, Guid serviceItemId) { try { object userId = Guid.Empty; if (!string.IsNullOrWhiteSpace(username)) { MembershipUser user = Membership.GetUser(username); if (user != null) { userId = user.ProviderUserKey; } } int totalRecords = 0; ServiceUnion suBll = new ServiceUnion(); StringBuilder sb = new StringBuilder(3000); sb.Append("<Rsp>"); var list = suBll.GetListByService(userId, pageIndex, pageSize, out totalRecords, serviceItemId); if (list == null || list.Count == 0) { return(""); } IList <object> listArr = new List <object>(); foreach (var suModel in list) { sb.Append("<N>"); listArr.Clear(); listArr.Add(suModel.Id); listArr.Add(suModel.Named); listArr.Add(suModel.Descr); listArr.Add(suModel.LastUpdatedDate.ToString("yyyy-MM-dd HH:mm")); listArr.Add(suModel.Flag); listArr.Add(suModel.TotalPraise); listArr.Add(suModel.TotalVole); sb.AppendFormat("<Id>{0}</Id><Name>{1}</Name><Descr>{2}</Descr><LastUpdatedDate>{3}</LastUpdatedDate><Flag>{4}</Flag><TotalPraise>{5}</TotalPraise><TotalVole>{6}</TotalVole>", listArr.ToArray()); listArr.Clear(); Dictionary <string, string> dic = null; if (!string.IsNullOrWhiteSpace(suModel.FileDirectory) && !string.IsNullOrWhiteSpace(suModel.RandomFolder) && !string.IsNullOrWhiteSpace(suModel.FileExtension)) { EnumData.Platform platform = EnumData.Platform.Android; dic = PictureUrlHelper.GetUrlByPlatform(suModel.FileDirectory, suModel.RandomFolder, suModel.FileExtension, platform); } listArr.Add(dic == null ? "" : WebSiteHost + dic["OriginalPicture"]); listArr.Add(dic == null ? "" : WebSiteHost + dic["BPicture"]); listArr.Add(dic == null ? "" : WebSiteHost + dic["MPicture"]); listArr.Add(dic == null ? "" : WebSiteHost + dic["SPicture"]); sb.AppendFormat("<OriginalPicture>{0}</OriginalPicture><BPicture>{1}</BPicture><MPicture>{2}</MPicture><SPicture>{3}</SPicture>", listArr.ToArray()); sb.Append("</N>"); } sb.Append("</Rsp>"); return(sb.ToString()); } catch (Exception ex) { new CustomException(string.Format("服务-接口:string GetServiceListByServiceItemId,异常:{0}", ex.Message), ex); return(""); } }
public string GetAdvertisementModel(Guid Id) { try { if (Id.Equals(Guid.Empty)) { return(""); } Advertisement bll = new Advertisement(); var model = bll.GetModelByJoin(Id); if (model == null) { return(""); } AccessStatisticQueueClient queueClient = new AccessStatisticQueueClient(); Services.HnztcQueueService.AccessStatisticInfo accessStatisticInfo = new Services.HnztcQueueService.AccessStatisticInfo(); accessStatisticInfo.TableName = "Advertisement"; accessStatisticInfo.Id = Id; queueClient.SaveAccessStatistic(accessStatisticInfo); Regex r = new Regex("(<img)(.*)src=\"([^\"]*?)\"(.*)/>"); AdvertisementLink adlBll = new AdvertisementLink(); 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>"; } StringBuilder sb = new StringBuilder(); sb.Append("<Rsp>"); sb.AppendFormat(@"<Id>{0}</Id><Title>{1}</Title><SiteFun>{2}</SiteFun><LayoutPosition>{3}</LayoutPosition><AdTime>{4}</AdTime><AdLink>{5}</AdLink><Descr>{6}</Descr><Content><![CDATA[{7}]]></Content><VirtualViewCount>{8}</VirtualViewCount><ViewCount>{9}</ViewCount>", model.Id, model.Title, model.SiteFunName, model.LayoutPositionName, model.LastUpdatedDate.ToString("yyyy-MM-dd HH:mm"), adLinkAppend, model.Descr, r.Replace(model.ContentText, "$1$2src=\"" + WebSiteHost + "$3\" />"), model.VirtualViewCount, model.ViewCount); sb.Append("</Rsp>"); return(sb.ToString()); } catch (Exception ex) { new CustomException(ex.Message, ex); return(""); } }