Exemplo n.º 1
0
        private void InitAlternateCDNAddress(AMSChannel channel, AMSEvent eventData)
        {
            if (channel != null && eventData != null && channel.AlternateCDNEndpoint.IsNotEmpty())
            {
                VideoAddressType videoAddressType = WebHelper.GetVideoAddressType();
                VideoAddressType targetType       = VideoAddressType.AlternateCDN;
                string           buttonText       = this.switchVideoAddressType.InnerText;

                switch (videoAddressType)
                {
                case VideoAddressType.Default:
                    targetType = VideoAddressType.AlternateCDN;
                    buttonText = "切换到备用CDN";
                    break;

                case VideoAddressType.AlternateCDN:
                    targetType = VideoAddressType.Default;
                    buttonText = "切换到默认地址";
                    break;
                }

                this.targetAddressType.Value          = targetType.ToString();
                this.switchVideoAddressType.InnerText = buttonText;
                this.videoAddressType.Value           = videoAddressType.ToString();
            }
            else
            {
                this.switchVideoAddressType.Attributes["class"] = "btn btn-default disabled";
            }
        }
Exemplo n.º 2
0
        public void AddChannelInEventExecutor()
        {
            AMSEventSqlAdapter.Instance.ClearAll();
            AMSChannelSqlAdapter.Instance.ClearAll();

            AMSChannel channel = DataHelper.PrepareChannelData();

            AMSChannelSqlAdapter.Instance.Update(channel);

            AMSEvent eventData = DataHelper.PrepareEventData(channel.ID);

            AMSEventSqlAdapter.Instance.Update(eventData);

            AMSChannel newChannel = DataHelper.PrepareChannelData();

            AMSChannelSqlAdapter.Instance.Update(newChannel);

            AMSAddChannelInEventExecutor executor = new AMSAddChannelInEventExecutor(eventData.ID, newChannel.ID);

            executor.Execute();

            AMSChannelCollection channels = AMSEventSqlAdapter.Instance.LoadRelativeChannels(eventData.ID);

            channels.Output();
            Assert.AreEqual(2, channels.Count);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 启动事件中的一个频道和节目
        /// </summary>
        /// <param name="eventData"></param>
        /// <param name="ec"></param>
        /// <param name="cancellationToken"></param>
        private static void StartOneChannelAndProgram(AMSEvent eventData, AMSEventChannel ec, CancellationToken cancellationToken)
        {
            try
            {
                if (ec.State == AMSEventState.NotStart)
                {
                    AMSEventSqlAdapter.Instance.UpdateEventChannelState(ec.EventID, ec.ChannelID, AMSEventState.Starting);
                }

                AMSChannel channel = StartChannel(ec.ChannelID, cancellationToken);

                if (cancellationToken.IsCancellationRequested == false)
                {
                    if (channel != null && channel.State == AMSChannelState.Running)
                    {
                        LockHelper.ExtendLockTime(eventData);

                        StartProgram(eventData, channel, ec, cancellationToken);
                    }
                }
            }
            catch (System.Exception ex)
            {
                TraceHelper.AMSTaskTraceSource.TraceEvent(TraceEventType.Error, 60020, ex.ToString());
            }
        }
Exemplo n.º 4
0
        public void IncludeCompletedAndNeedStartEventsLoadNeedStopChannels()
        {
            AMSEventSqlAdapter.Instance.ClearAll();
            AMSChannelSqlAdapter.Instance.ClearAll();

            AMSChannel channel = DataHelper.PrepareChannelData();

            AMSChannelSqlAdapter.Instance.Update(channel);

            AMSEvent prevEventData = DataHelper.PrepareEventData(channel.ID);

            prevEventData.StartTime = DateTime.Now.AddHours(-2);
            prevEventData.EndTime   = DateTime.Now.AddHours(-1);

            AMSEventSqlAdapter.Instance.Update(prevEventData);

            AMSEvent nextEventData = DataHelper.PrepareEventData(channel.ID);

            nextEventData.StartTime = DateTime.Now.AddMinutes(30);
            nextEventData.EndTime   = DateTime.Now.AddHours(3);

            AMSEventSqlAdapter.Instance.Update(prevEventData);

            AMSChannelCollection needToStopChannels = AMSChannelSqlAdapter.Instance.LoadNeedStopChannels(TimeSpan.FromHours(1));

            needToStopChannels.Output();
            Assert.AreEqual(1, needToStopChannels.Count);
        }
Exemplo n.º 5
0
        public void CheckAddChannelIntersectEvent()
        {
            AMSEventSqlAdapter.Instance.ClearAll();
            AMSChannelSqlAdapter.Instance.ClearAll();

            AMSChannel originalChannel = DataHelper.PrepareChannelData();

            AMSChannelSqlAdapter.Instance.Update(originalChannel);

            AMSEvent originalEvent = DataHelper.PrepareEventData(originalChannel.ID);

            AMSEventSqlAdapter.Instance.Update(originalEvent);

            AMSChannel theSecondChannel = DataHelper.PrepareChannelData();

            AMSChannelSqlAdapter.Instance.Update(theSecondChannel);

            AMSEventSqlAdapter.Instance.AddChannel(originalEvent.ID, new string[] { theSecondChannel.ID });

            AMSChannel theThirdChannel = DataHelper.PrepareChannelData();

            AMSChannelSqlAdapter.Instance.Update(theThirdChannel);

            AMSEvent newEvent = DataHelper.PrepareEventData(theThirdChannel.ID);

            AMSEventSqlAdapter.Instance.Update(newEvent);

            Assert.IsTrue(AMSEventSqlAdapter.Instance.HaveIntersectEvents(newEvent, theSecondChannel.ID));
        }
Exemplo n.º 6
0
        public static void AddEvent(params string[] channelNames)
        {
            AMSEvent eventData = new AMSEvent();

            eventData.ID = UuidHelper.NewUuidString();

            eventData.Name      = string.Format("新建节目在\"{0}\"{1:yyyy-MM-dd HH:mm:ss.fff}", channelNames[0], DateTime.UtcNow);
            eventData.State     = AMSEventState.NotStart;
            eventData.StartTime = DateTime.Now.AddMinutes(5);
            eventData.EndTime   = DateTime.Now.AddMinutes(35);

            eventData.ChannelID = GetChannelByName(channelNames[0]).ID;

            if (channelNames.Length > 1)
            {
                for (int i = 1; i < channelNames.Length; i++)
                {
                    AMSChannel channel = GetChannelByName(channelNames[i]);

                    AMSEventSqlAdapter.Instance.AddChannel(eventData.ID, new string[] { channel.ID });
                }
            }

            AMSEventSqlAdapter.Instance.Update(eventData);
        }
Exemplo n.º 7
0
        public static void AddEvent(params string[] channelNames)
        {
            AMSEvent eventData = new AMSEvent();

            eventData.ID = UuidHelper.NewUuidString();

            eventData.Name = string.Format("新建节目在\"{0}\"{1:yyyy-MM-dd HH:mm:ss.fff}", channelNames[0], DateTime.UtcNow);
            eventData.State = AMSEventState.NotStart;
            eventData.StartTime = DateTime.Now.AddMinutes(5);
            eventData.EndTime = DateTime.Now.AddMinutes(35);

            eventData.ChannelID = GetChannelByName(channelNames[0]).ID;

            if (channelNames.Length > 1)
            {
                for (int i = 1; i < channelNames.Length; i++)
                {
                    AMSChannel channel = GetChannelByName(channelNames[i]);

                    AMSEventSqlAdapter.Instance.AddChannel(eventData.ID, new string[] { channel.ID });
                }
            }

            AMSEventSqlAdapter.Instance.Update(eventData);
        }
Exemplo n.º 8
0
        public static void StopProgram(AMSChannel channel, AMSEvent eventData, IProgramRelativeEntity retProgramInfo)
        {
            if (channel != null && channel.AMSID.IsNotEmpty())
            {
                CloudMediaContext context = MediaServiceAccountSettings.GetConfig().Accounts.GetCloudMediaContext(channel.AMSAccountName);

                IChannel amsChannel = GetChannelByID(context, channel.AMSID);

                if (amsChannel != null)
                {
                    IProgram program = GetProgramByEvent(amsChannel, eventData);

                    if (program != null)
                    {
                        if (program.State == ProgramState.Running)
                        {
                            TraceOperation("Stop Program {0}", () => program.Stop(), program.Name);
                        }

                        program.FillAMSEvent(channel, retProgramInfo);

                        if (retProgramInfo.State == AMSEventState.NotStart)
                        {
                            retProgramInfo.State = AMSEventState.Completed;
                        }
                    }
                    else
                    {
                        retProgramInfo.State = AMSEventState.Completed;
                    }
                }
            }
        }
Exemplo n.º 9
0
        public void UpdateExistedUserView()
        {
            AMSEventSqlAdapter.Instance.ClearAll();
            AMSUserViewSqlAdapter.Instance.ClearAll();

            AMSChannel channel = DataHelper.PrepareChannelData();

            AMSEvent eventData = DataHelper.PrepareEventData(channel.ID);

            AMSEventSqlAdapter.Instance.Update(eventData);

            AMSUserView userView = DataHelper.PrepareUserView(eventData.ID);

            AMSUserViewSqlAdapter.Instance.UpdateUserView(userView);

            WhereSqlClauseBuilder builder = new WhereSqlClauseBuilder();

            builder.AppendItem("EventID", userView.EventID);
            builder.AppendItem("UserID", userView.UserID);

            AMSUserView userViewLoaded = AMSUserViewSqlAdapter.Instance.LoadByBuilder(builder).Single();

            AMSEvent eventLoaded = AMSEventSqlAdapter.Instance.LoadByID(eventData.ID);

            Assert.AreEqual(1, eventLoaded.Views);

            //再保存一下
            AMSUserViewSqlAdapter.Instance.UpdateUserView(userView);

            eventLoaded = AMSEventSqlAdapter.Instance.LoadByID(eventData.ID);

            //用户观看次数依然是1
            Assert.AreEqual(1, eventLoaded.Views);
        }
Exemplo n.º 10
0
 protected void InitNewEvent()
 {
     this.Data = new AMSEvent()
     {
         ID = UuidHelper.NewUuidString(),
         ChannelID = Res.Request.GetRequestQueryString("channelID", string.Empty)
     };
 }
Exemplo n.º 11
0
        protected void InitByEventID(string id)
        {
            AMSEvent eventData = AMSEventSqlAdapter.Instance.LoadByID(id);

            eventData.NullCheck(string.Format("不能找到ID为{0}的事件", id));

            this.Data = eventData;
        }
Exemplo n.º 12
0
        protected void InitByEventID(string id)
        {
            AMSEvent eventData = AMSEventSqlAdapter.Instance.LoadByID(id);

            eventData.NullCheck(string.Format("不能找到ID为{0}的事件", id));

            this.Data = eventData;
        }
Exemplo n.º 13
0
        public static bool IsLockAvailable(AMSEvent eventData)
        {
            AMSLock lockData = PrepareEventLock(eventData);

            AMSCheckLockResult lockResult = AMSLockSqlAdapter.Instance.AddLock(lockData);

            return(lockResult.Available);
        }
Exemplo n.º 14
0
        public static bool IsLockAvailable(AMSEvent eventData)
        {
            AMSLock lockData = PrepareEventLock(eventData);

            AMSCheckLockResult lockResult = AMSLockSqlAdapter.Instance.AddLock(lockData);

            return lockResult.Available;
        }
Exemplo n.º 15
0
        /// <summary>
        /// 准备事件相关的锁
        /// </summary>
        /// <returns></returns>
        public static AMSLock PrepareEventLock(AMSEvent eventData)
        {
            AMSLock lockData = new AMSLock();

            lockData.LockID      = eventData.ID;
            lockData.LockType    = AMSLockType.EventLock;
            lockData.Description = string.Format("Add lock for event(ID: {0}, Name: {1})", eventData.ID, eventData.Name);

            return(lockData);
        }
Exemplo n.º 16
0
 public SimpleEventData(AMSEvent eventData)
 {
     this.id              = eventData.ID;
     this.name            = eventData.Name;
     this.description     = eventData.Description;
     this.speakers        = eventData.Speakers;
     this.timeDescription = GetTimeDescription(eventData.StartTime, eventData.EndTime);
     this.logo            = eventData.LogoUrl.IsNotEmpty() ? eventData.LogoUrl : "/images/amsPoster1.png";
     this.state           = eventData.State.ToString();
 }
Exemplo n.º 17
0
        /// <summary>
        /// 准备事件相关的锁
        /// </summary>
        /// <returns></returns>
        public static AMSLock PrepareEventLock(AMSEvent eventData)
        {
            AMSLock lockData = new AMSLock();

            lockData.LockID = eventData.ID;
            lockData.LockType = AMSLockType.EventLock;
            lockData.Description = string.Format("Add lock for event(ID: {0}, Name: {1})", eventData.ID, eventData.Name);

            return lockData;
        }
Exemplo n.º 18
0
        private static void StartProgram(AMSEvent eventData, AMSChannel channel, AMSEventChannel ec, CancellationToken cancellationToken)
        {
            TraceHelper.AMSTaskTraceSource.TraceEvent(TraceEventType.Verbose, 60017, "Start Program:\n{0}", channel.ToTraceInfo());

            SimulateOrExecuteAction(() => LiveChannelManager.StartProgram(channel, eventData, ec), () => ec.State = AMSEventState.Running);

            AMSEventSqlAdapter.Instance.UpdateEventChannel(ec);

            TraceHelper.AMSTaskTraceSource.TraceEvent(TraceEventType.Verbose, 60017, "Program Started:\n{0}", channel.ToTraceInfo());
        }
Exemplo n.º 19
0
 public static void Unlock(AMSEvent eventData)
 {
     try
     {
         AMSLockSqlAdapter.Instance.DeleteLock(eventData.ID);
     }
     catch (System.Exception ex)
     {
         Trace.TraceError(ex.ToString());
     }
 }
Exemplo n.º 20
0
        public static void AreEqual(this AMSEvent expected, AMSEvent actual)
        {
            Assert.IsNotNull(expected);
            Assert.IsNotNull(actual);

            Assert.AreEqual(expected.ID, actual.ID);
            Assert.AreEqual(expected.ChannelID, actual.ChannelID);
            Assert.AreEqual(expected.Name, actual.Name);
            Assert.AreEqual(expected.Description, actual.Description);
            Assert.AreEqual(expected.State, actual.State);
        }
Exemplo n.º 21
0
        private static IProgram GetProgramByEvent(IChannel channel, AMSEvent eventData)
        {
            IProgram result = null;

            if (channel != null)
            {
                result = channel.Programs.Where(p => p.Name == GetProgramName(eventData)).FirstOrDefault();
            }

            return(result);
        }
Exemplo n.º 22
0
 public static void Unlock(AMSEvent eventData)
 {
     try
     {
         AMSLockSqlAdapter.Instance.DeleteLock(eventData.ID);
     }
     catch (System.Exception ex)
     {
         Trace.TraceError(ex.ToString());
     }
 }
Exemplo n.º 23
0
        protected void InitByEventID(string id, string channelID)
        {
            AMSEvent eventData = AMSEventSqlAdapter.Instance.Load(id, channelID);

            eventData.NullCheck(string.Format("不能找到ID为{0}的事件", id));

            if (eventData.PosterUrl.IsNullOrEmpty())
                eventData.PosterUrl = UriHelper.MakeAbsolute(new Uri(this.ResolveUrl("~/images/amsPoster1.png"), UriKind.RelativeOrAbsolute), this.Request.Url).ToString();

            this.Data = eventData;
        }
Exemplo n.º 24
0
        public static void AreEqual(this AMSEvent expected, AMSEvent actual)
        {
            Assert.IsNotNull(expected);
            Assert.IsNotNull(actual);

            Assert.AreEqual(expected.ID, actual.ID);
            Assert.AreEqual(expected.ChannelID, actual.ChannelID);
            Assert.AreEqual(expected.Name, actual.Name);
            Assert.AreEqual(expected.Description, actual.Description);
            Assert.AreEqual(expected.State, actual.State);
        }
Exemplo n.º 25
0
        protected void InitByEventID(string id, string channelID)
        {
            AMSEvent eventData = AMSEventSqlAdapter.Instance.Load(id, channelID);

            eventData.NullCheck(string.Format("不能找到ID为{0}的事件", id));

            if (eventData.PosterUrl.IsNullOrEmpty())
            {
                eventData.PosterUrl = UriHelper.MakeAbsolute(new Uri(this.ResolveUrl("~/images/amsPoster1.png"), UriKind.RelativeOrAbsolute), this.Request.Url).ToString();
            }

            this.Data = eventData;
        }
Exemplo n.º 26
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.HttpMethod.ToLower() == "post" && Request.Form["__VIEWSTATE"] == null)
            {
            }
            else
            {
                if (this.IsPostBack == false && this.IsCallback == false)
                    ControllerHelper.ExecuteMethodByRequest(this);

                this.bindingControl.Data = this.Data;
            }
        }
Exemplo n.º 27
0
        public static AMSEvent PrepareEventData(string channelID)
        {
            AMSEvent data = new AMSEvent();

            data.ID = UuidHelper.NewUuidString();
            data.Name = "Test Event";
            data.ChannelID = channelID;
            data.Description = "Test Event Description";
            data.State = AMSEventState.NotStart;
            data.StartTime = DateTime.Now.AddDays(1);
            data.EndTime = DateTime.Now.AddDays(2);

            return data;
        }
Exemplo n.º 28
0
        public void UpdateAMSEvent()
        {
            AMSEventSqlAdapter.Instance.ClearAll();

            AMSChannel channel = DataHelper.PrepareChannelData();

            AMSEvent eventData = DataHelper.PrepareEventData(channel.ID);

            AMSEventSqlAdapter.Instance.Update(eventData);
            AMSEvent eventLoaded = AMSEventSqlAdapter.Instance.LoadByChannelID(channel.ID).SingleOrDefault();

            Assert.IsNotNull(eventLoaded);
            eventData.AreEqual(eventLoaded);
        }
Exemplo n.º 29
0
        public static string ToTraceInfo(this AMSEvent eventData)
        {
            StringBuilder strB = new StringBuilder();

            StringWriter writer = new StringWriter(strB);

            writer.WriteLine("ID: {0}", eventData.ID);
            writer.WriteLine("Channel ID: {0}", eventData.ChannelID);
            writer.WriteLine("Name: {0}", eventData.Name);
            writer.WriteLine("AMS Program ID", eventData.AMSProgramID);
            writer.WriteLine("State: {0}", eventData.State);

            return(strB.ToString());
        }
Exemplo n.º 30
0
        public static AMSEvent PrepareEventData(string channelID)
        {
            AMSEvent data = new AMSEvent();

            data.ID          = UuidHelper.NewUuidString();
            data.Name        = "Test Event";
            data.ChannelID   = channelID;
            data.Description = "Test Event Description";
            data.State       = AMSEventState.NotStart;
            data.StartTime   = DateTime.Now.AddDays(1);
            data.EndTime     = DateTime.Now.AddDays(2);

            return(data);
        }
Exemplo n.º 31
0
        public static AMSEvent GetEventByID(string id, string channelID = "")
        {
            AMSEvent eventData = AMSEventSqlAdapter.Instance.Load(id, channelID);

            if (eventData != null)
            {
                HttpRequest request = HttpContext.Current.Request;

                if (eventData.PosterUrl.IsNullOrEmpty())
                {
                    eventData.PosterUrl = UriHelper.MakeAbsolute(new Uri("/images/amsPoster1.png", UriKind.RelativeOrAbsolute), request.Url).ToString();
                }
            }

            return(eventData);
        }
Exemplo n.º 32
0
        public void EventTimeValidationExecutor()
        {
            AMSEventSqlAdapter.Instance.ClearAll();

            AMSChannel channel = DataHelper.PrepareChannelData();

            AMSEvent eventData = DataHelper.PrepareEventData(channel.ID);

            eventData.StartTime = DateTime.Now;
            eventData.EndTime   = DateTime.Now.AddDays(-1);

            AMSEditEntityExecutor <AMSEvent> executor = new AMSEditEntityExecutor <AMSEvent>(eventData,
                                                                                             data => AMSEventSqlAdapter.Instance.Update(data), AMSOperationType.EditEvent);

            executor.Execute();
        }
Exemplo n.º 33
0
        /// <summary>
        /// 停止一个节目
        /// </summary>
        /// <param name="eventData"></param>
        /// <param name="ec"></param>
        /// <param name="cancellationToken"></param>
        private static void StopOneProgram(AMSEvent eventData, AMSEventChannel ec, CancellationToken cancellationToken)
        {
            try
            {
                if (ec.State == AMSEventState.Running)
                {
                    AMSEventSqlAdapter.Instance.UpdateEventChannelState(ec.EventID, ec.ChannelID, AMSEventState.Stopping);
                }

                StopProgram(eventData, ec, cancellationToken);
            }
            catch (System.Exception ex)
            {
                TraceHelper.AMSTaskTraceSource.TraceEvent(TraceEventType.Error, 60021, ex.ToString());
            }
        }
Exemplo n.º 34
0
        public void LoadNeedStartEventOutTimeFrame()
        {
            AMSEventSqlAdapter.Instance.ClearAll();

            AMSChannel channel = DataHelper.PrepareChannelData();

            AMSEvent eventData = DataHelper.PrepareEventData(channel.ID);

            eventData.StartTime = DateTime.Now.Add(TimeSpan.FromMinutes(10));

            AMSEventSqlAdapter.Instance.Update(eventData);

            AMSEventCollection eventsLoaded = AMSEventSqlAdapter.Instance.LoadNeedStartEvents(TimeSpan.FromMinutes(5));

            Assert.AreEqual(0, eventsLoaded.Count);
        }
Exemplo n.º 35
0
        public static void AddMooncakeEvent()
        {
            AMSEvent eventData = new AMSEvent();

            eventData.ID = UuidHelper.NewUuidString();

            eventData.Name = string.Format("新建节目{0:yyyy-MM-dd HH:mm:ss.fff}", DateTime.UtcNow);
            eventData.State = AMSEventState.NotStart;
            eventData.StartTime = DateTime.UtcNow.AddMinutes(5);
            eventData.EndTime = DateTime.UtcNow.AddMinutes(35);

            AMSChannel channel = AMSChannelSqlAdapter.Instance.Load(builder => builder.AppendItem("Name", TestChannelName)).SingleOrDefault();
            eventData.ChannelID = channel.ID;

            AMSEventSqlAdapter.Instance.Update(eventData);
        }
Exemplo n.º 36
0
        public void LoadNeedStopEventInTimeFrame()
        {
            AMSEventSqlAdapter.Instance.ClearAll();

            AMSChannel channel = DataHelper.PrepareChannelData();

            AMSEvent eventData = DataHelper.PrepareEventData(channel.ID);

            eventData.State   = AMSEventState.Running;
            eventData.EndTime = DateTime.UtcNow.Add(-TimeSpan.FromMinutes(10));

            AMSEventSqlAdapter.Instance.Update(eventData);

            AMSEventCollection eventsLoaded = AMSEventSqlAdapter.Instance.LoadNeedStopEvents();

            Assert.IsTrue(eventsLoaded.Count > 0);
        }
Exemplo n.º 37
0
        public static void AddMooncakeEvent()
        {
            AMSEvent eventData = new AMSEvent();

            eventData.ID = UuidHelper.NewUuidString();

            eventData.Name      = string.Format("新建节目{0:yyyy-MM-dd HH:mm:ss.fff}", DateTime.UtcNow);
            eventData.State     = AMSEventState.NotStart;
            eventData.StartTime = DateTime.UtcNow.AddMinutes(5);
            eventData.EndTime   = DateTime.UtcNow.AddMinutes(35);

            AMSChannel channel = AMSChannelSqlAdapter.Instance.Load(builder => builder.AppendItem("Name", TestChannelName)).SingleOrDefault();

            eventData.ChannelID = channel.ID;

            AMSEventSqlAdapter.Instance.Update(eventData);
        }
Exemplo n.º 38
0
        public void CheckNewIntersectEvent()
        {
            AMSEventSqlAdapter.Instance.ClearAll();
            AMSChannelSqlAdapter.Instance.ClearAll();

            AMSChannel originalChannel = DataHelper.PrepareChannelData();

            AMSChannelSqlAdapter.Instance.Update(originalChannel);

            AMSEvent originalEvent = DataHelper.PrepareEventData(originalChannel.ID);

            AMSEventSqlAdapter.Instance.Update(originalEvent);

            AMSEvent newEvent = DataHelper.PrepareEventData(originalChannel.ID);

            Assert.IsTrue(AMSEventSqlAdapter.Instance.HaveIntersectEvents(newEvent));
        }
Exemplo n.º 39
0
        protected void InitByEventID(string id, string channelID)
        {
            if (id.IsNotEmpty())
            {
                AMSEvent eventData = DataHelper.GetEventByID(id, channelID);

                if (eventData != null)
                {
                    this.Channel             = AMSChannelSqlAdapter.Instance.LoadByID(eventData.ChannelID);
                    this.pageEventData.Value = DataHelper.GetSingleEventJson(this.Channel, eventData, WebHelper.GetVideoAddressType());
                    this.videoTitle.Text     = HttpUtility.HtmlEncode(eventData.Name);

                    DataHelper.UpdateUserView(id);
                }

                this.Event = eventData;
            }
        }
Exemplo n.º 40
0
        public void UpdateEventExecutor()
        {
            AMSEventSqlAdapter.Instance.ClearAll();

            AMSChannel channel = DataHelper.PrepareChannelData();

            AMSEvent eventData = DataHelper.PrepareEventData(channel.ID);

            AMSEditEntityExecutor <AMSEvent> executor = new AMSEditEntityExecutor <AMSEvent>(eventData,
                                                                                             data => AMSEventSqlAdapter.Instance.Update(data), AMSOperationType.EditEvent);

            executor.Execute();

            AMSEvent eventLoaded = AMSEventSqlAdapter.Instance.LoadByChannelID(channel.ID).SingleOrDefault();

            Assert.IsNotNull(eventLoaded);
            eventData.AreEqual(eventLoaded);
        }
Exemplo n.º 41
0
        public static string GetSingleEventJson(AMSChannel channel, AMSEvent eventData, VideoAddressType addressType)
        {
            var simpleEventData = new
            {
                id          = eventData.ID,
                channelID   = eventData.ChannelID,
                name        = eventData.Name,
                description = eventData.Description,
                speakers    = eventData.Speakers,
                url         = ChangeVideoAddress(channel, eventData.CDNPlaybackUrl, addressType),
                poster      = eventData.PosterUrl,
                views       = string.Format("{0:#,##0}", eventData.Views),
                startTime   = string.Format("{0:yyyy-MM-dd HH:mm:ss}", eventData.StartTime),
                endTime     = string.Format("{0:yyyy-MM-dd HH:mm:ss}", eventData.EndTime)
            };

            return(JSONSerializerExecute.Serialize(simpleEventData));
        }
Exemplo n.º 42
0
        protected void InitByEventID(string id, string channelID)
        {
            if (id.IsNotEmpty())
            {
                AMSEvent eventData = DataHelper.GetEventByID(id, channelID);

                if (eventData != null)
                {
                    this.Channel = AMSChannelSqlAdapter.Instance.GetByID(eventData.ChannelID);
                    this.pageEventData.Value = DataHelper.GetSingleEventJson(this.Channel, eventData, WebHelper.GetVideoAddressType());
                    this.videoTitle.Text = HttpUtility.HtmlEncode(eventData.Name);

                    ExceptionHelper.DoSilentAction(() => DataHelper.UpdateUserView(id));
                }

                this.Event = eventData;
            }
        }
Exemplo n.º 43
0
 public SimpleEventData(AMSEvent eventData)
 {
     this.id = eventData.ID;
     this.name = eventData.Name;
     this.description = eventData.Description;
     this.speakers = eventData.Speakers;
     this.timeDescription = GetTimeDescription(eventData.StartTime, eventData.EndTime);
     this.logo = eventData.LogoUrl.IsNotEmpty() ? eventData.LogoUrl : "/images/amsPoster1.png";
     this.state = eventData.State.ToString();
 }
Exemplo n.º 44
0
        private static void InnerStartProgram(AMSEvent eventData, AMSChannel channel, AMSEventChannel ec, CancellationToken cancellationToken)
        {
            TraceHelper.AMSTaskTraceSource.TraceEvent(TraceEventType.Verbose, 60017, "Start Program:\n{0}", channel.ToTraceInfo());

            SimulateOrExecuteAction(() => LiveChannelManager.StartProgram(channel, eventData, ec), () => ec.State = AMSEventState.Running);

            AMSEventSqlAdapter.Instance.UpdateEventChannel(ec);

            TraceHelper.AMSTaskTraceSource.TraceEvent(TraceEventType.Verbose, 60017, "Program Started:\n{0}", channel.ToTraceInfo());
        }
Exemplo n.º 45
0
        private void InitAlternateCDNAddress(AMSChannel channel, AMSEvent eventData)
        {
            if (channel != null && eventData != null && channel.AlternateCDNEndpoint.IsNotEmpty())
            {
                VideoAddressType videoAddressType = WebHelper.GetVideoAddressType();
                VideoAddressType targetType = VideoAddressType.AlternateCDN;
                string buttonText = this.switchVideoAddressType.InnerText;

                switch (videoAddressType)
                {
                    case VideoAddressType.Default:
                        targetType = VideoAddressType.AlternateCDN;
                        buttonText = "切换到备用CDN";
                        break;
                    case VideoAddressType.AlternateCDN:
                        targetType = VideoAddressType.Default;
                        buttonText = "切换到默认地址";
                        break;
                }

                this.targetAddressType.Value = targetType.ToString();
                this.switchVideoAddressType.InnerText = buttonText;
                this.videoAddressType.Value = videoAddressType.ToString();
            }
            else
            {
                this.switchVideoAddressType.Attributes["class"] = "btn btn-default disabled";
            }
        }
Exemplo n.º 46
0
        private static void InnerStopProgram(AMSEvent eventData, AMSEventChannel ec, CancellationToken cancellationToken)
        {
            TraceHelper.AMSTaskTraceSource.TraceEvent(TraceEventType.Verbose, 60018, "Stop Program:\n{0}", eventData.ToTraceInfo());

            AMSChannel channel = AMSChannelSqlAdapter.Instance.LoadByID(ec.ChannelID);

            if (channel != null)
                SimulateOrExecuteAction(() => LiveChannelManager.StopProgram(channel, eventData, ec), () => ec.State = AMSEventState.Completed);
            else
                ec.State = AMSEventState.Completed;

            AMSEventSqlAdapter.Instance.UpdateEventChannel(ec);

            TraceHelper.AMSTaskTraceSource.TraceEvent(TraceEventType.Verbose, 60018, "Program Stopped:\n{0}", eventData.ToTraceInfo());
        }
Exemplo n.º 47
0
        /// <summary>
        /// 启动事件中的一个频道和节目
        /// </summary>
        /// <param name="eventData"></param>
        /// <param name="ec"></param>
        /// <param name="cancellationToken"></param>
        private static void StartOneChannelAndCreateProgram(AMSEvent eventData, AMSEventChannel ec, CancellationToken cancellationToken)
        {
            try
            {
                if (ec.State == AMSEventState.NotStart)
                    AMSEventSqlAdapter.Instance.UpdateEventChannelState(ec.EventID, ec.ChannelID, AMSEventState.Starting);

                AMSChannel channel = InnerStartChannel(ec.ChannelID, cancellationToken);

                if (cancellationToken.IsCancellationRequested == false)
                {
                    if (channel != null && channel.State == AMSChannelState.Running)
                    {
                        LockHelper.ExtendLockTime(eventData);

                        InnerCreateProgram(eventData, channel, ec, cancellationToken);
                    }
                }
            }
            catch (System.Exception ex)
            {
                TraceHelper.AMSTaskTraceSource.TraceEvent(TraceEventType.Error, 60020, ex.ToString());
            }
        }
Exemplo n.º 48
0
        /// <summary>
        /// 停止一个节目
        /// </summary>
        /// <param name="eventData"></param>
        /// <param name="ec"></param>
        /// <param name="cancellationToken"></param>
        private static void StopOneProgram(AMSEvent eventData, AMSEventChannel ec, CancellationToken cancellationToken)
        {
            try
            {
                if (ec.State == AMSEventState.Running)
                    AMSEventSqlAdapter.Instance.UpdateEventChannelState(ec.EventID, ec.ChannelID, AMSEventState.Stopping);

                InnerStopProgram(eventData, ec, cancellationToken);
            }
            catch (System.Exception ex)
            {
                TraceHelper.AMSTaskTraceSource.TraceEvent(TraceEventType.Error, 60021, ex.ToString());
            }
        }
Exemplo n.º 49
0
        public static string GetSingleEventJson(AMSChannel channel, AMSEvent eventData, VideoAddressType addressType)
        {
            var simpleEventData = new
            {
                id = eventData.ID,
                channelID = eventData.ChannelID,
                name = eventData.Name,
                description = eventData.Description,
                speakers = eventData.Speakers,
                url = ChangeVideoAddress(channel, eventData.CDNPlaybackUrl, addressType),
                poster = eventData.PosterUrl,
                views = string.Format("{0:#,##0}", eventData.Views),
                startTime = string.Format("{0:yyyy-MM-dd HH:mm:ss}", eventData.StartTime),
                endTime = string.Format("{0:yyyy-MM-dd HH:mm:ss}", eventData.EndTime)
            };

            return JSONSerializerExecute.Serialize(simpleEventData);
        }
Exemplo n.º 50
0
        public static AMSCheckLockResult ExtendLockTime(AMSEvent eventData)
        {
            AMSLock lockData = PrepareEventLock(eventData);

            return AMSLockSqlAdapter.Instance.ExtendLockTime(lockData);
        }