Example #1
0
 /// <summary>
 /// Remove self from DB.
 /// </summary>
 public void DeleteFromPersistence()
 {
     lock (this)
     {
         PersistenceHelper.Delete <PlatformComponent>(new MatchExpression("PlatformId", this.Id));
         PersistenceHelper.Delete <Platform>(new MatchExpression("Name", this.Name));
     }
 }
Example #2
0
 public bool RemovePersistedComponentById(long componentId)
 {
     if (PersistenceHelper.Delete <PlatformComponent>(new MatchExpression("Id", componentId)) != 1)
     {
         SystemMonitor.Error("Failed to remove persisted component [" + componentId + "].");
         return(false);
     }
     return(true);
 }
Example #3
0
        /// <summary>
        /// Called when a component is removed permanently from the platfrom.
        /// </summary>
        /// <param name="component"></param>
        /// <returns></returns>
        public bool UnRegisterComponent(PlatformComponent component)
        {
            if (component == null)
            {
                return(false);
            }

            TracerHelper.Trace(component.Name);

            lock (this)
            {
                if (_components.ContainsValue(component) == false)
                {
                    SystemMonitor.OperationWarning("Component not registered.");
                    return(true);
                }
            }

            component.OperationalStateChangedEvent -= new OperationalStateChangedDelegate(component_OperationalStatusChangedEvent);

            UnInitializeComponent(component);

            component.Dispose();

            lock (this)
            {
                _components.Remove(component.SubscriptionClientID.Id);
            }

            if (component.IsPersistableToDB &&
                PersistenceHelper.Delete <PlatformComponent>(component) == false)
            {
                SystemMonitor.Error("Failed to remove component [" + component.Name + "] from DB.");
            }

            if (ActiveComponentRemovedEvent != null)
            {
                ActiveComponentRemovedEvent(component, false);
            }

            return(true);
        }