void LoadAllInfo() { ProcessService.ServiceSoapClient client = new ProcessService.ServiceSoapClient(); client.getHostInfosCompleted += new EventHandler<ProcessService.getHostInfosCompletedEventArgs>(client_getHostInfosCompleted); client.getHostInfosAsync(); }
void client_getHostInfosCompleted(object sender, ProcessService.getHostInfosCompletedEventArgs e) { hostinfos = e.Result; foreach (SLProcessController.ProcessService.HostInfo hi in e.Result) { ProcessService.ServiceSoapClient client = new ProcessService.ServiceSoapClient(); AccordionHeader header=new AccordionHeader(){ DataContext=hi }; header.OnChangeHostAllState += new OnHostChangeAllStateHandler(header_OnChangeHostAllState); AccordionItem item = new AccordionItem() { Header = header, Content = new ListBox() { Width = this.ActualWidth } }; item.Tag = hi; accordion.Items.Add(item); client.GetProcessInfoCompleted += (o, a) => { loadHostCnt++; if (e.Error != null) { // MessageBox.Show(e.Error.Message); return; } if (a.Result != null) foreach (ProcessService.ProcessInfo info in a.Result) { ProcessInfoCtl ctl = new ProcessInfoCtl(); ctl.Tag=info; ctl.Name = info.ProcessName; dict.Add(info.ProcessName, ctl); if (info.ProcessName.ToUpper() == "HOST") { ctl.SetProgressMaxValue(10000); ctl.ProgressBar.SetBinding(ProgressBar.ValueProperty, new System.Windows.Data.Binding() { Path =new PropertyPath( "DataQueueCnt"), Converter = new HostQueueCntProgressConverter() }); // ctl.ProgressBar.GetBindingExpression(ProgressBar.ValueProperty).ParentBinding.Converter = new HostQueueCntProgressConverter(); } else ctl.ProgressBar.SetBinding(ProgressBar.ValueProperty, new System.Windows.Data.Binding() { Path = new PropertyPath("DataQueueCnt"), Converter = new MFCCQueueCntProcessConverter() }); // ctl.ProgressBar.GetBindingExpression(ProgressBar.ValueProperty).ParentBinding.Converter = new MFCCQueueCntProcessConverter(); } if (loadHostCnt == hostinfos.Count) { for (int i = 0; i < dict.Count; i++) { ProcessInfoCtl ctl; ctl= dict.Values.ToArray<ProcessInfoCtl>()[i]; ProcessInfo info = ctl.Tag as ProcessInfo; foreach (AccordionItem aitem in accordion.Items) { //if(aitem.Content==null) // aitem.Content = new ListBox() { Width = this.ActualWidth }; if ((aitem.Tag as HostInfo).IP == info.HostIP) { (aitem.Content as ListBox).Items.Add(ctl); ctl.OnChangeState += new OnChangeStateHandler(ctl_OnChangeState); ctl.setDataContext(info); break; } } } tmr30sec.Start(); } // item.IsEnabled = true; // lock(client) // System.Threading.Monitor.PulseAll(client); }; client.GetProcessInfoAsync(hi.IP); this.accordion.SelectedIndex = 1; } }
void FetchPorcessInfo() { if (loadHostCnt == 0 || hostinfos.Count == 0 || loadHostCnt != hostinfos.Count) return; if (this.accordion.SelectedItem == null) return; foreach (HostInfo hinfo in hostinfos) { //if ((this.accordion.SelectedItem as AccordionItem).Tag != hinfo) // continue; ProcessService.ServiceSoapClient client = new ProcessService.ServiceSoapClient(); client.GetProcessInfoCompleted += (s, a) => { try { if (a.Result == null || a.Error!=null ) return; foreach (ProcessService.ProcessInfo info in a.Result) { (dict[info.ProcessName].DataContext as ProcessInfo).Mermory = info.Mermory; (dict[info.ProcessName].DataContext as ProcessInfo).State = info.State; (dict[info.ProcessName].DataContext as ProcessInfo).IsAlive = info.IsAlive; dict[info.ProcessName].RefreshState(); } } catch (Exception ex) { // MessageBox.Show(ex.Message); } }; client.GetProcessInfoAsync(hinfo.IP); } }