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; } } } }