Пример #1
0
        private void TestGetSummaryHardware(object sender, RoutedEventArgs e)
        {
            if (login == null || String.IsNullOrEmpty(login.SessionID))
            {
                AddMessage("Not logged in.");
                return;
            }
            try {
                SiteHardwareList.Items.Clear();
                foreach (CheckBox cb in SiteList.Items)
                {
                    if (cb.IsChecked == null || cb.IsChecked == false)
                    {
                        continue;
                    }

                    hardwares = api.GetSummaryHardware(login.SessionID, Convert.ToInt32(cb.Tag.ToString()));
                    if (hardwares.ResultCode() == AEResultCodes.OK)
                    {
                        foreach (HardwareComplete h in hardwares.HardwareList)
                        {
                            CheckBox hwCheckBox = new CheckBox();
                            hwCheckBox.Tag = h.HardwareID;

                            string archiveFields = "[";
                            if (h.FieldList == null || h.FieldList.Count() == 0)
                            {
                                archiveFields += "no archive fields" + "  ";
                            }
                            else
                            {
                                foreach (FieldInfo field in h.FieldList)
                                {
                                    archiveFields += field.Name + ", ";
                                }
                            }
                            archiveFields      = archiveFields.Remove(archiveFields.Length - 2, 2);
                            archiveFields     += "]";
                            hwCheckBox.Tag     = h;
                            hwCheckBox.Content = string.Format("{0} - {1}: {2}, {3}: {4}, {5}", cb.Tag.ToString(), h.HardwareID, h.DeviceCode, h.Name, archiveFields, h.SerialNum);
                            hwCheckBox.Click  += new RoutedEventHandler(hwCheckBox_Click);
                            SiteHardwareList.Items.Add(hwCheckBox);
                        }
                    }
                    else
                    {
                        AddMessage(string.Format("*** GetSummaryHardware returned {0}", hardwares.ResultCodeString()));
                    }
                }
            } catch {
                AddMessage("GetSummaryHardware failed. Please check your connection.");
            }
        }