Ejemplo n.º 1
0
        private void btnRefresh_Click(object sender, EventArgs e)
        {
            SafeInvoke(() =>
            {
                TopicInformation[] topicSet = EventControlClient.GetTopics();
                DisplayTopicSet(topicSet);

                //AreaInfo[] areas = PACSClient.GetAreaInfo(null);
                List <AreaInfo> areas = GetList <AreaInfo>(PACSClient.GetAreaInfoList);
                _areaTokenSelector.Input.DataSource    = areas;
                _areaTokenSelector.Input.DisplayMember = "token";

                //AccessPointInfo[] points = PACSClient.GetAccessPointInfo(null);
                List <AccessPointInfo> points = GetList <AccessPointInfo>(PACSClient.GetAccessPointInfoList);
                _accessPointTokenSelector.Input.DataSource    = points;
                _accessPointTokenSelector.Input.DisplayMember = "token";

                //AccessProfileInfo[] accessProfiles = ConfigurationServiceClient.GetAccessProfileInfo();
                List <AccessProfileInfo> accessProfiles         = GetList <AccessProfileInfo>(AccessRulesClient.GetAccessProfileInfoList);
                _accessProfileTokenSelector.Input.DataSource    = accessProfiles;
                _accessProfileTokenSelector.Input.DisplayMember = "token";

                //CredentialInfo[] credentials = ConfigurationServiceClient.GetCredentialInfo();
                List <CredentialInfo> credentials             = GetList <CredentialInfo>(CredentialClient.GetCredentialInfoList);
                _credentialsTokenSelector.Input.DataSource    = credentials;
                _credentialsTokenSelector.Input.DisplayMember = "token";

                //DoorInfo[] doors = DoorControlClient.GetDoorInfo(null);
                List <DoorInfo> doors = GetList <DoorInfo>(DoorControlClient.GetDoorInfoList);
                _doorTokenSelector.Input.DataSource    = doors;
                _doorTokenSelector.Input.DisplayMember = "token";

                //ScheduleInfo[] schedules = SchedulePortControlClient.GetScheduleInfo(null);
                List <ScheduleInfo> schedules              = GetList <ScheduleInfo>(SchedulePortControlClient.GetScheduleInfoList);
                _scheduleTokenSelector.Input.DataSource    = schedules;
                _scheduleTokenSelector.Input.DisplayMember = "token";

                //SpecialDayGroupInfo[] specialDayGroups = SchedulePortControlClient.GetSpecialDayGroupInfo(null);
                List <SpecialDayGroupInfo> specialDayGroups       = GetList <SpecialDayGroupInfo>(SchedulePortControlClient.GetSpecialDayGroupInfoList);
                _specialDayGroupTokenSelector.Input.DataSource    = specialDayGroups;
                _specialDayGroupTokenSelector.Input.DisplayMember = "token";
            });
        }
Ejemplo n.º 2
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            if (tvTopics.SelectedNode != null)
            {
                TopicInformation topic = tvTopics.SelectedNode.Tag as TopicInformation;
                if (topic != null)
                {
                    List <SimpleItem> sourceItems       = new List <SimpleItem>();
                    List <SimpleItem> dataItems         = new List <SimpleItem>();
                    DateTime          messageTime       = DateTime.MinValue;
                    string            propertyOperation = null;

                    if (tcMessageConstricting.SelectedTab == tpRawMessage)
                    {
                        XmlDocument doc = new XmlDocument();
                        try
                        {
                            doc.LoadXml(tbMessage.Text);

                            XmlElement messageElement = doc.DocumentElement;
                            if (messageElement.HasAttribute("PropertyOperation"))
                            {
                                propertyOperation = messageElement.Attributes["PropertyOperation"].Value;
                            }
                            XmlNodeList sourceSimpleItems = messageElement.SelectNodes("Source/SimpleItem");
                            foreach (XmlNode node in sourceSimpleItems)
                            {
                                XmlElement element = node as XmlElement;
                                if (element != null)
                                {
                                    sourceItems.Add(new SimpleItem()
                                    {
                                        Name  = element.Attributes["Name"].Value,
                                        Value = element.Attributes["Value"].Value
                                    });
                                }
                            }
                            XmlNodeList dataSimpleItems = messageElement.SelectNodes("Data/SimpleItem");
                            foreach (XmlNode node in dataSimpleItems)
                            {
                                XmlElement element = node as XmlElement;
                                if (element != null)
                                {
                                    dataItems.Add(new SimpleItem()
                                    {
                                        Name  = element.Attributes["Name"].Value,
                                        Value = element.Attributes["Value"].Value
                                    });
                                }
                            }

                            string dateTimeValue = messageElement.Attributes["UtcTime"].Value;
                            if (dateTimeValue != "%NOW%")
                            {
                                messageTime = DateTime.Parse(dateTimeValue);
                            }
                        }
                        catch (Exception exc)
                        {
                            MessageBox.Show("Message format is not correct");
                            return;
                        }
                    }
                    else
                    {
                        foreach (SimpleItemDescription item in topic.SourceItems)
                        {
                            SimpleItem messageItem = new SimpleItem();
                            messageItem.Name  = item.Name;
                            messageItem.Value = _inputs[item.Name].GetText();
                            sourceItems.Add(messageItem);
                        }
                        foreach (SimpleItemDescription item in topic.DataItems)
                        {
                            SimpleItem messageItem = new SimpleItem();
                            messageItem.Name  = item.Name;
                            messageItem.Value = _inputs[item.Name].GetText();
                            dataItems.Add(messageItem);
                        }
                    }
                    try
                    {
                        EventControlClient.FireEvent(topic, messageTime, propertyOperation, sourceItems.ToArray(), dataItems.ToArray());
                    }
                    catch (Exception exc)
                    {
                        ShowError(exc);
                    }
                }
            }
        }