示例#1
0
        public void ReFresh(object sender, EventArgs e)
        {
            if (IsDateLimited.Checked)
            {
                StartDateRow.Visible = true;
                EndDateRow.Visible   = true;
            }
            else
            {
                StartDateRow.Visible = false;
                EndDateRow.Visible   = false;
            }

            PositionType.Items.Clear();
            var rollingType = ERollingTypeUtils.GetEnumType(RollingType.SelectedValue);

            EPositionTypeUtils.AddListItems(PositionType, rollingType);
            ControlUtils.SelectListItems(PositionType, EPositionTypeUtils.GetValue(ePositionType));
        }
示例#2
0
        public IHttpActionResult Get()
        {
            try
            {
                var request         = Context.AuthenticatedRequest;
                var siteId          = request.GetQueryInt("siteId");
                var advertisementId = request.GetQueryInt("advertisementId");

                if (!request.IsAdminLoggin ||
                    !request.AdminPermissions.HasSitePermissions(siteId, Utils.PluginId))
                {
                    return(Unauthorized());
                }

                var advertisementInfo = advertisementId > 0
                    ? AdvertisementManager.Repository.Get(advertisementId)
                    : new AdvertisementInfo
                {
                    AdvertisementType = EAdvertisementTypeUtils.GetValue(EAdvertisementType.FloatImage),
                    StartDate         = DateTime.Now,
                    EndDate           = DateTime.Now.AddMonths(1),
                    RollingType       = ERollingTypeUtils.GetValue(ERollingType.FollowingScreen),
                    PositionType      = EPositionTypeUtils.GetValue(EPositionType.LeftTop),
                    PositionX         = 10,
                    PositionY         = 120,
                    IsCloseable       = true
                };

                var advertisementTypes = new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>(EAdvertisementTypeUtils.GetValue(EAdvertisementType.FloatImage),
                                                      EAdvertisementTypeUtils.GetText(EAdvertisementType.FloatImage)),
                    new KeyValuePair <string, string>(EAdvertisementTypeUtils.GetValue(EAdvertisementType.ScreenDown),
                                                      EAdvertisementTypeUtils.GetText(EAdvertisementType.ScreenDown)),
                    new KeyValuePair <string, string>(EAdvertisementTypeUtils.GetValue(EAdvertisementType.OpenWindow),
                                                      EAdvertisementTypeUtils.GetText(EAdvertisementType.OpenWindow))
                };

                var channels        = new List <KeyValuePair <int, string> >();
                var channelIdList   = Context.ChannelApi.GetChannelIdList(siteId);
                var isLastNodeArray = new bool[channelIdList.Count];
                foreach (var theChannelId in channelIdList)
                {
                    var channelInfo = Context.ChannelApi.GetChannelInfo(siteId, theChannelId);

                    var title = GetChannelListBoxTitle(siteId, channelInfo.Id, channelInfo.ChannelName, channelInfo.ParentsCount, channelInfo.LastNode, isLastNodeArray);
                    channels.Add(new KeyValuePair <int, string>(channelInfo.Id, title));
                }

                var positionTypes = new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>(EPositionTypeUtils.GetValue(EPositionType.LeftTop),
                                                      EPositionTypeUtils.GetText(EPositionType.LeftTop)),
                    new KeyValuePair <string, string>(EPositionTypeUtils.GetValue(EPositionType.LeftBottom),
                                                      EPositionTypeUtils.GetText(EPositionType.LeftBottom)),
                    new KeyValuePair <string, string>(EPositionTypeUtils.GetValue(EPositionType.RightTop),
                                                      EPositionTypeUtils.GetText(EPositionType.RightTop)),
                    new KeyValuePair <string, string>(EPositionTypeUtils.GetValue(EPositionType.RightBottom),
                                                      EPositionTypeUtils.GetText(EPositionType.RightBottom))
                };

                var rollingTypes = new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>(ERollingTypeUtils.GetValue(ERollingType.FollowingScreen),
                                                      ERollingTypeUtils.GetText(ERollingType.FollowingScreen)),
                    new KeyValuePair <string, string>(ERollingTypeUtils.GetValue(ERollingType.Static),
                                                      ERollingTypeUtils.GetText(ERollingType.Static)),
                    new KeyValuePair <string, string>(ERollingTypeUtils.GetValue(ERollingType.FloatingInWindow),
                                                      ERollingTypeUtils.GetText(ERollingType.FloatingInWindow))
                };

                var adminToken = Context.AdminApi.GetAccessToken(request.AdminId, request.AdminName, TimeSpan.FromDays(1));

                return(Ok(new
                {
                    Value = advertisementInfo,
                    AdvertisementTypes = advertisementTypes,
                    Channels = channels,
                    PositionTypes = positionTypes,
                    RollingTypes = rollingTypes,
                    AdminToken = adminToken
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }