Example #1
0
        public static Task<List<ControlSystemAlarmPriority>> GetControlSystemAlarmPriorities()
        {
            var task = new TaskCompletionSource<List<ControlSystemAlarmPriority>>();
            var cee = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);

            cee.GetControlSystemAlarmPrioritiesCompleted += (s, e) => task.SetResult(e.Result);
            cee.GetControlSystemAlarmPrioritiesAsync();
            return task.Task;
        }
        private void LoadAlarmPriorities(NodeView expandedNode)
        {
            var cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);

            EventHandler<GetControlSystemAlarmPrioritiesCompletedEventArgs> fetchCompleted = null;
            fetchCompleted = (s, eventArgs) =>
            {
                var alarmPriorities = eventArgs.Result;
                if (alarmPriorities != null)
                {
                    foreach (var priority in alarmPriorities)
                    {
                        var child = new NodeView(expandedNode)
                        {
                            Id = priority.Id,
                            Name = priority.Name,
                            Description = priority.Description,
                            Icon = "/CmsEquipmentDatabase;component/Images/Configuration.png",
                            Type = NodeType.AlarmPriorityNode,
                            HasChildren = false,
                            SortField = priority.Ordinal.ToString()
                        };
                        expandedNode.Children.Add(child);
                    }
                    Utils.HideSpinner(expandedNode);
                    expandedNode.Sort();
                }
            };
            cmsWebServiceClient.GetControlSystemAlarmPrioritiesCompleted += fetchCompleted;
            cmsWebServiceClient.GetControlSystemAlarmPrioritiesAsync();
        }