Exemplo n.º 1
0
        /// <summary>
        /// 获取活动相册信息
        /// </summary>
        public string GetEventAlbum()
        {
            string content = string.Empty;

            var respData = new GetEventAlbumRespData();

            try
            {
                string reqContent = Request["ReqContent"];
                var    reqObj     = reqContent.DeserializeJSONTo <GetEventAlbumReqData>();

                string eventId    = reqObj.special.eventId;                     //活动ID
                string moduleType = (reqObj.special.eventType ?? 1).ToString(); //1: 活动

                if (string.IsNullOrEmpty(eventId))
                {
                    throw new Exception("活动ID不能为空");
                    //eventId = "3DD35B9A122F41C8A0E5D5B78D72CE65";
                }

                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format("GetEventAlbum: {0}", reqContent)
                });

                //判断客户ID是否传递
                if (!string.IsNullOrEmpty(reqObj.common.customerId))
                {
                    customerId = reqObj.common.customerId;
                }
                var loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1");

                respData.content           = new GetEventAlbumRespContentData();
                respData.content.albumList = new List <AlbumEntity>();

                var eventList = new LEventsBLL(loggingSessionInfo).QueryByEntity(new LEventsEntity {
                    EventID = eventId
                }, null);

                if (eventList != null && eventList.Length > 0)
                {
                    var eventEntity = eventList.FirstOrDefault();

                    respData.content.title       = eventEntity.Title;
                    respData.content.description = eventEntity.Description;
                    respData.content.imageUrl    = eventEntity.ImageURL;

                    #region 相册信息

                    LEventsAlbumBLL albumService = new LEventsAlbumBLL(loggingSessionInfo);

                    var albumList = albumService.QueryByEntity(new LEventsAlbumEntity {
                        ModuleId = eventId, ModuleType = moduleType
                    },
                                                               new OrderBy[] { new OrderBy {
                                                                                   FieldName = " SortOrder ", Direction = OrderByDirections.Asc
                                                                               } });

                    if (albumList != null && albumList.Length > 0)
                    {
                        foreach (var item in albumList)
                        {
                            var entity = new AlbumEntity()
                            {
                                albumId    = item.AlbumId,
                                albumTitle = item.Title,
                                albumType  = item.Type,
                                imageUrl   = item.ImageUrl,
                                count      = item.Count
                            };

                            respData.content.albumList.Add(entity);
                        }
                    }

                    #endregion
                }
            }
            catch (Exception ex)
            {
                respData.code        = "103";
                respData.description = "数据库操作错误";
                //respData.exception = ex.ToString();
            }
            content = respData.ToJSON();
            return(content);
        }