예제 #1
0
        protected override void OnActivate()
        {
            base.OnActivate();

            Machines.Clear();
            Machines.AddRange(_networkOperations.GetMachines());
            IsAddressValid = true;
        }
예제 #2
0
        public void ReadMachines()
        {
            if (SelectedPrintShop != null)
            {
                using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(DatabaseHelper.dbFile))
                {
                    var machines = conn.Table <Machine>().Where(m => m.PrintShopId == SelectedPrintShop.Id).ToList();

                    Machines.Clear();
                    foreach (var machine in machines)
                    {
                        Machines.Add(machine);
                    }
                }
            }
        }
예제 #3
0
        public async Task Refresh()
        {
            Status = "Searching...";
            var vms = await Task.Run(() => Check());

            foreach (var item in Machines)
            {
                item.Dispose();
            }

            Machines.Clear();
            foreach (var item in vms)
            {
                item.RunPuTTY   += () => StartPuTTY(item);
                item.RunWinSCP  += () => StartWinSCP(item);
                item.RunBrowser += () => StartBrowser(item);
                Machines.Add(item);
            }

            Status = $"{Machines.Count} devices found.";
        }
        private void LoadMachineFromFile(string fileName)
        {
            var serializer = new System.Xml.Serialization.XmlSerializer(typeof(MM.MachineElement));

            using (var reader = new System.IO.StreamReader(fileName))
            {
                var m = (MM.MachineElement)serializer.Deserialize(reader);

                if (m != null)
                {
                    var vm = m.ToMachineData(true);

                    if (vm is MD.RootElement re)
                    {
                        re.AssemblyName = Path.GetFileNameWithoutExtension(fileName);
                        re.RootType     = MDE.RootType.CX220;
                    }

                    Machines.Clear();
                    Machines.Add(vm);
                }
            }
        }
 private void FileClearCommandImplementation()
 {
     SelectedItem = null;
     Machines.Clear();
 }
        private async void DbLoadCommandImplementation()
        {
            Machines.Clear();
            SelectedItem = null;

            using (var client = new HttpClient())
            {
                var response = await client.GetAsync("https://localhost:44306/api/Machine");

                if (response.IsSuccessStatusCode)
                {
                    var content = await response.Content.ReadAsAsync <IEnumerable <MachineInfo> >();

                    foreach (var item in content)
                    {
                        var rr = await client.GetAsync($"https://localhost:44306/api/Machine/{item.MachineElementID}");

                        if (rr.IsSuccessStatusCode)
                        {
                            var cc = await rr.Content.ReadAsAsync <MD.MachineElement>(new[]
                            {
                                new JsonMediaTypeFormatter()
                                {
                                    SerializerSettings = new JsonSerializerSettings()
                                    {
                                        Converters = new List <JsonConverter>()
                                        {
                                            new LinkJsonConverter(),
                                            new MachineElementJsonConverter()
                                        },
                                        NullValueHandling = NullValueHandling.Ignore,
                                    }
                                }
                            });

                            Machines.Add(cc);
                        }
                    }

                    //var tasks = new List<Task<MD.MachineElement>>();

                    //foreach (var item in content)
                    //{
                    //    var rr = await client.GetAsync($"https://localhost:44306/api/Machine/{item.MachineElementID}");

                    //    if (rr.IsSuccessStatusCode)
                    //    {
                    //        tasks.Add(rr.Content.ReadAsAsync<MD.MachineElement>(new[]
                    //        {
                    //            new JsonMediaTypeFormatter()
                    //            {
                    //                SerializerSettings = new JsonSerializerSettings()
                    //                {
                    //                    Converters = new List<JsonConverter>()
                    //                    {
                    //                        new LinkJsonConverter(),
                    //                        new MachineElementJsonConverter()
                    //                    },
                    //                    NullValueHandling = NullValueHandling.Ignore,
                    //                }
                    //            }
                    //        }));

                    //        //Machines.Add(cc);
                    //    }
                    //}

                    //var elements = await Task.WhenAll<MD.MachineElement>(tasks.ToArray());

                    //foreach (var item in elements) Machines.Add(item);
                }
            }
        }