Esempio n. 1
0
        public void DoChannelMonitor(IChannel channel, OperationType operationtype)
        {
            Task.Run(() =>
            {
                if (operationtype == OperationType.Delete)
                {
                    bool timeout = false;
                    bool Error   = false;
                    List <StatusInfo> LSI;
                    DateTime starttime = DateTime.Now;

                    while (_context.Channels.Where(o => o.Id == channel.Id).FirstOrDefault() != null)
                    {
                        RefreshChannel(channel);
                        System.Threading.Thread.Sleep(1000);
                        if (DateTime.Now > starttime.AddMinutes(10))
                        {
                            timeout = true;
                            break;
                        }
                        LSI = ListStatus.Where(l => l.EntityName == channel.Name).ToList();
                        if (LSI.Count > 0)
                        {
                            Error = true;
                            MessageBox.Show(LSI.FirstOrDefault().ErrorMessage);
                            break;
                        }
                    }
                    RefreshChannels();
                }

                else
                {
                    ChannelState StateToReach;

                    switch (operationtype)
                    {
                    case OperationType.Create:
                        StateToReach = ChannelState.Stopped;
                        break;

                    case OperationType.Start:
                        StateToReach = ChannelState.Running;
                        break;

                    case OperationType.Stop:
                        StateToReach = ChannelState.Stopped;
                        break;

                    case OperationType.Reset:
                        StateToReach = ChannelState.Running;
                        break;


                    default:
                        StateToReach = ChannelState.Stopped;
                        break;
                    }


                    bool timeout = false;
                    bool Error   = false;
                    List <StatusInfo> LSI;
                    DateTime starttime = DateTime.Now;

                    while (channel.State != StateToReach)
                    {
                        RefreshChannel(channel);
                        System.Threading.Thread.Sleep(500);
                        if (DateTime.Now > starttime.AddMinutes(10))
                        {
                            timeout = true;
                            break;
                        }
                        LSI = ListStatus.Where(l => l.EntityName == channel.Name).ToList();
                        if (LSI.Count > 0)
                        {
                            Error = true;
                            //MessageBox.Show(LSI.FirstOrDefault().ErrorMessage);
                            break;
                        }
                    }
                    RefreshChannel(channel);
                }
            });
        }
Esempio n. 2
0
        public void DoStreamingEndpointMonitor(IStreamingEndpoint origin, OperationType operationtype)
        {
            Task.Run(() =>
            {
                if (operationtype == OperationType.Scale)
                {
                    List <StatusInfo> LSI;
                    DateTime starttime = DateTime.Now;
                    System.Threading.Thread.Sleep(1000); // it take some time for the origin to switch to scaling mode

                    while (origin.State == StreamingEndpointState.Scaling)
                    {
                        RefreshStreamingEndpoint(origin);
                        System.Threading.Thread.Sleep(500);
                        if (DateTime.Now > starttime.AddMinutes(10))
                        {
                            break;
                        }
                        LSI = ListStatus.Where(l => l.EntityName == origin.Name).ToList();
                        if (LSI.Count > 0)
                        {
                            MessageBox.Show(LSI.FirstOrDefault().ErrorMessage);
                            break;
                        }
                    }
                    RefreshStreamingEndpoint(origin);
                }
                else if (operationtype == OperationType.Delete)
                {
                    string originid = origin.Id;
                    List <StatusInfo> LSI;
                    DateTime starttime = DateTime.Now;
                    while (_context.StreamingEndpoints.Where(o => o.Id == originid).FirstOrDefault() != null)
                    {
                        RefreshStreamingEndpoint(origin);
                        System.Threading.Thread.Sleep(1000);
                        if (DateTime.Now > starttime.AddMinutes(10))
                        {
                            break;
                        }
                        LSI = ListStatus.Where(l => l.EntityName == origin.Name).ToList();
                        if (LSI.Count > 0)
                        {
                            MessageBox.Show(LSI.FirstOrDefault().ErrorMessage);
                            break;
                        }
                    }
                    RefreshStreamingEndpoints();
                }
                else
                {
                    StreamingEndpointState StateToReach;

                    switch (operationtype)
                    {
                    case OperationType.Create:
                        StateToReach = StreamingEndpointState.Stopped;
                        break;

                    case OperationType.Start:
                        StateToReach = StreamingEndpointState.Running;
                        break;

                    case OperationType.Stop:
                        StateToReach = StreamingEndpointState.Stopped;
                        break;

                    default:
                        StateToReach = StreamingEndpointState.Stopped;
                        break;
                    }

                    List <StatusInfo> LSI;
                    DateTime starttime = DateTime.Now;

                    while (origin.State != StateToReach)
                    {
                        RefreshStreamingEndpoint(origin);
                        System.Threading.Thread.Sleep(500);
                        if (DateTime.Now > starttime.AddMinutes(10))
                        {
                            break;
                        }
                        LSI = ListStatus.Where(l => l.EntityName == origin.Name).ToList();
                        if (LSI.Count > 0)
                        {
                            MessageBox.Show(LSI.FirstOrDefault().ErrorMessage);
                            break;
                        }
                    }
                    RefreshStreamingEndpoint(origin);
                }
            });
        }
Esempio n. 3
0
        public void DoProgramMonitor(IProgram program, OperationType operationtype)
        {
            Task.Run(() =>
            {
                if (operationtype == OperationType.Delete)
                {
                    List <StatusInfo> LSI;
                    DateTime starttime = DateTime.Now;
                    while (_context.Programs.Where(p => p.Id == program.Id).FirstOrDefault() != null)
                    {
                        RefreshProgram(program);
                        System.Threading.Thread.Sleep(1000);
                        if (DateTime.Now > starttime.AddMinutes(10))
                        {
                            break;
                        }
                        LSI = ListStatus.Where(l => l.EntityName == program.Name).ToList();
                        if (LSI.Count > 0)
                        {
                            MessageBox.Show(LSI.FirstOrDefault().ErrorMessage);
                            break;
                        }
                    }
                    RefreshPrograms();
                }


                else
                {
                    ProgramState StateToReach;

                    switch (operationtype)
                    {
                    case OperationType.Create:
                        StateToReach = ProgramState.Stopped;
                        break;

                    case OperationType.Start:
                        StateToReach = ProgramState.Running;
                        break;

                    case OperationType.Stop:
                        StateToReach = ProgramState.Stopped;
                        break;

                    case OperationType.Reset:
                        StateToReach = ProgramState.Stopped;
                        break;


                    default:
                        StateToReach = ProgramState.Stopped;
                        break;
                    }

                    List <StatusInfo> LSI;
                    DateTime starttime = DateTime.Now;

                    while (program.State != StateToReach)
                    {
                        RefreshProgram(program);
                        System.Threading.Thread.Sleep(500);
                        if (DateTime.Now > starttime.AddMinutes(10))
                        {
                            break;
                        }
                        LSI = ListStatus.Where(l => l.EntityName == program.Name).ToList();
                        if (LSI.Count > 0)
                        {
                            MessageBox.Show(LSI.FirstOrDefault().ErrorMessage);
                            break;
                        }
                    }
                    RefreshProgram(program);
                }
            });
        }