コード例 #1
0
ファイル: DatabaseLoader.cs プロジェクト: barrett2474/CMS2
 public static Task<List<ControlSystemComponentTypeTestingProperty>> GetControlSystemComponentTypeTestingProperties(int componentTypeId)
 {
     var task = new TaskCompletionSource<List<ControlSystemComponentTypeTestingProperty>>();
     var cee = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
     cee.GetControlSystemComponentTypeTestingPropertiesCompleted += (s, e) => task.SetResult(e.Result);
     cee.GetControlSystemComponentTypeTestingPropertiesAsync(componentTypeId);
     return task.Task;
 }
コード例 #2
0
        private void LoadComponentTypeTests(NodeView expandedNode)
        {
            var cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);

            EventHandler<GetControlSystemComponentTypeTestingPropertiesCompletedEventArgs> fetchCompleted = null;
            fetchCompleted = (s, eventArgs) =>
            {
                var componentTypeTestingProperties = eventArgs.Result;

                componentTypeTestingProperties = componentTypeTestingProperties.OrderBy(x => x.Ordinal).ThenBy(x => x.GroupOrdinal).ToList();

                foreach (var controlSystemEquipmentComponentProperty in componentTypeTestingProperties)
                {
                    if (controlSystemEquipmentComponentProperty.ComponentTypeGroupId.HasValue)
                    {
                        var childGroup = expandedNode.Children.FirstOrDefault(x => x.GroupId == controlSystemEquipmentComponentProperty.ComponentTypeGroupId.Value);

                        if (childGroup == null)
                        {
                            childGroup = new NodeView(expandedNode)
                            {
                                Id = controlSystemEquipmentComponentProperty.Id,
                                GroupId = controlSystemEquipmentComponentProperty.ComponentTypeGroupId.Value,
                                Name = controlSystemEquipmentComponentProperty.ComponentTypeGroup.Name,
                                Description = controlSystemEquipmentComponentProperty.ComponentTypeGroup.Description,
                                Icon = "/CmsEquipmentDatabase;component/Images/Configuration.png",
                                Type = NodeType.ComponentTypeGroup,
                                HasChildren = true,
                                SortField = controlSystemEquipmentComponentProperty.Ordinal.ToString()
                            };
                            expandedNode.Children.Add(childGroup);
                        }
                        else
                        {
                            Utils.HideSpinner(childGroup);
                        }

                        if (controlSystemEquipmentComponentProperty.TestPropertyId.HasValue)
                        {
                            var child = new NodeView(childGroup)
                            {
                                Id = controlSystemEquipmentComponentProperty.Id,
                                Name = controlSystemEquipmentComponentProperty.ControlSystemComponentTestingProperty.Name,
                                Description = controlSystemEquipmentComponentProperty.ControlSystemComponentTestingProperty.Description,
                                Icon = "/CmsEquipmentDatabase;component/Images/Configuration.png",
                                Type = NodeType.ComponentTypeTest,
                                HasChildren = false,
                                SortField = controlSystemEquipmentComponentProperty.GroupOrdinal.ToString()
                            };
                            childGroup.Children.Add(child);
                        }
                    }
                    else
                    {
                        var child = new NodeView(expandedNode)
                        {
                            Id = controlSystemEquipmentComponentProperty.Id,
                            Name = controlSystemEquipmentComponentProperty.ControlSystemComponentTestingProperty.Name,
                            Description = controlSystemEquipmentComponentProperty.ControlSystemComponentTestingProperty.Description,
                            Icon = "/CmsEquipmentDatabase;component/Images/Configuration.png",
                            Type = NodeType.ComponentTypeTest,
                            HasChildren = false,
                            SortField = controlSystemEquipmentComponentProperty.Ordinal.ToString()
                        };
                        expandedNode.Children.Add(child);
                    }
                }
                Utils.HideSpinner(expandedNode);

                cmsWebServiceClient.GetControlSystemComponentTypeTestingPropertiesCompleted -= fetchCompleted;
            };
            cmsWebServiceClient.GetControlSystemComponentTypeTestingPropertiesCompleted += fetchCompleted;
            cmsWebServiceClient.GetControlSystemComponentTypeTestingPropertiesAsync(expandedNode.Parent.Id);
        }