public async void ShowLog(object parm)
        {
            if (parm == null)
            {
                return;
            }
            string id = parm.ToString();

            DockerVoiceClient mClient = new DockerVoiceClient("tcp://dockerconhack.cloudapp.net:2376");


            CancellationToken token = new CancellationToken(false);

            Stream s = await mClient.ShowLogs(id, token);

            mParent.Logs.Clear();
            using (StreamReader sr = new StreamReader(s))
            {
                string log = "";
                while (!sr.EndOfStream)
                {
                    log = sr.ReadLine();
                    mParent.Logs.Add(new LogEntryViewModel {
                        Text = log
                    });
                }
            }
        }
Esempio n. 2
0
        public async void ShowLog(object parm)
        {
            if (parm == null)
            {
                return;
            }
            string            id    = parm.ToString();
            CancellationToken token = new CancellationToken(false);

            Stream s = await mClient.ShowLogs(id, token);

            this.Logs.Clear();
            using (StreamReader sr = new StreamReader(s))
            {
                string log = "";
                while (!sr.EndOfStream)
                {
                    log = sr.ReadLine();
                    this.Logs.Add(new LogEntryViewModel {
                        Text = log
                    });
                }
            }
        }
        private async void  mTimer_Tick(object sender, object e)
        {
            mTimer.Stop();

            //viewModel.ActiveContainer.Logs.Add(new LogEntryViewModel { Text = "line " + index.ToString() });
            //index++;
            //if (viewModel.ActiveContainer.Logs.Count > MAX_LOG_ENTRIES)
            //    viewModel.ActiveContainer.Logs.RemoveAt(0);
            if (!string.IsNullOrEmpty(parms))
            {
                string[] parts = parms.Split('|');
                if (parts.Length == 2)
                {
                    if (parts[0] == "runContainer")
                    {
                        await mClient.DockerRun(parts[1]);
                    }
                }
            }

            var containers = await mClient.DockerGetContainers();

            string newId = "";

            foreach (var container in containers)
            {
                if (!mCachedIds.Contains(container.Id))
                {
                    newId = container.Id;
                    viewModel.List.Insert(0, new ContainerViewModel(viewModel)
                    {
                        Name        = container.Names.First(),
                        Id          = container.Id,
                        ImageName   = container.Image,
                        Description = container.Status
                    });
                }
            }
            if (!string.IsNullOrEmpty(newId))
            {
                CancellationToken token = new CancellationToken(false);
                int linesRead           = 0;
                while (linesRead < 20)
                {
                    linesRead = 0;
                    Stream s = await mClient.ShowLogs(newId, token);

                    viewModel.Logs.Clear();
                    using (StreamReader sr = new StreamReader(s))
                    {
                        string log = "";
                        while (!sr.EndOfStream)
                        {
                            log = sr.ReadLine();
                            viewModel.Logs.Add(new LogEntryViewModel {
                                Text = log
                            });
                            linesRead++;
                        }
                    }
                }
            }
        }