Пример #1
0
        public static Task<List<ControlSystemAlarmPurpose>> GetControlSystemAlarmPurposes()
        {
            var task = new TaskCompletionSource<List<ControlSystemAlarmPurpose>>();
            var cee = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);

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

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