public AddEditExistingControlSystemComponentAlarmPropertyViewModel(ControlSystemComponentType controlSystemEquipmentComponentType)
        {
            //new
            mControlSystemComponentTypeAlarmProperty = new ControlSystemComponentTypeAlarmProperty { ComponentTypeId = controlSystemEquipmentComponentType.Id };

            OkButtonCommand = new DelegateCommand<object>(OkButtonHander, CanModify);
            CancelButtonCommand = new DelegateCommand<object>(CancelButtonHander, x => true);

            CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
            Properties = new List<ControlSystemAlarmProperty>();

            //Load Component types
            EventHandler<GetAllControlSystemAlarmPropertiesCompletedEventArgs> getAllControlSystemAlarmPropertiesCompleted = (s, allEventArgs) =>
                                              {
                                                  cmsWebServiceClient.GetControlSystemComponentTypeAlarmPropertiesCompleted +=
                                                      (s1, e1)
                                                      =>
                                                      {
                                                          List<int> listOfAssignedPropertyIds = new List<int>();
                                                          e1.Result.ForEach(x => listOfAssignedPropertyIds.Add(x.AlarmPropertyId));

                                                          foreach (var componentProperty in allEventArgs.Result)
                                                          {
                                                              if (!listOfAssignedPropertyIds.Contains(componentProperty.Id))
                                                              {
                                                                  Properties.Add(componentProperty);
                                                              }
                                                          }

                                                          if (Properties.Count > 0)
                                                          {
                                                              mControlSystemComponentTypeAlarmProperty.AlarmPropertyId = Properties[0].Id;
                                                              mControlSystemComponentTypeAlarmProperty.ControlSystemAlarmProperty = Properties[0];
                                                          }
                                                          Loaded();
                                                      };

                                                  cmsWebServiceClient.GetControlSystemComponentTypeAlarmPropertiesAsync(controlSystemEquipmentComponentType.Id);
                                              };
            cmsWebServiceClient.GetAllControlSystemAlarmPropertiesCompleted += getAllControlSystemAlarmPropertiesCompleted;
            cmsWebServiceClient.GetAllControlSystemAlarmPropertiesAsync();
        }
        public AddEditExistingControlSystemComponentAlarmPropertyViewModel(int componentTypePropertyId)
        {
            //edit

            OkButtonCommand = new DelegateCommand<object>(OkButtonHander, CanModify);
            CancelButtonCommand = new DelegateCommand<object>(CancelButtonHander, x => true);

            CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
            Properties = new List<ControlSystemAlarmProperty>();

            //Load ControlSystem Properties types
            EventHandler<GetAllControlSystemAlarmPropertiesCompletedEventArgs>
                fetchCompleted = (s, e) =>
                                     {
                                         Properties = e.Result;
                                         cmsWebServiceClient.GetControlSystemComponentTypeAlarmPropertyCompleted +=
                                             (s2, e2) =>
                                             {
                                                 if (Properties.Count > 0)
                                                 {
                                                     SelectedProperty = (from x in Properties
                                                                         where x.Id == e2.Result.ComponentTypeId
                                                                         select x).FirstOrDefault();
                                                 }

                                                 mControlSystemComponentTypeAlarmProperty = e2.Result;
                                                 Loaded();
                                             };
                                         cmsWebServiceClient.GetControlSystemComponentTypeAlarmPropertyAsync(componentTypePropertyId);
                                     };

            cmsWebServiceClient.GetAllControlSystemAlarmPropertiesCompleted += fetchCompleted;
            cmsWebServiceClient.GetAllControlSystemAlarmPropertiesAsync();
        }
예제 #3
0
        public static Task<List<ControlSystemAlarmProperty>> GetAllControlSystemAlarmProperties()
        {
            var task = new TaskCompletionSource<List<ControlSystemAlarmProperty>>();
            var cee = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);

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

            EventHandler<GetAllControlSystemAlarmPropertiesCompletedEventArgs> fetchCompleted = null;
            fetchCompleted = (s, eventArgs) =>
            {
                var properties = eventArgs.Result;
                if (properties != null)
                {
                    foreach (var property in properties)
                    {
                        var child = new NodeView(expandedNode)
                        {
                            Id = property.Id,
                            Name = property.Name,
                            Description = property.Description,
                            Icon = "/CmsEquipmentDatabase;component/Images/Configuration.png",
                            Type = NodeType.AlarmCentum,
                            HasChildren = false,
                            SortField = property.Name
                        };
                        expandedNode.Children.Add(child);
                    }
                    Utils.HideSpinner(expandedNode);
                    cmsWebServiceClient.GetAllControlSystemAlarmPropertiesCompleted -= fetchCompleted;
                    expandedNode.Sort();
                }
            };
            cmsWebServiceClient.GetAllControlSystemAlarmPropertiesCompleted += fetchCompleted;
            cmsWebServiceClient.GetAllControlSystemAlarmPropertiesAsync();
        }