private void Disable(DisabledReason p_reason) { enabled = false; disabledReason = p_reason; src = null; undoManager = null; }
private void Update() { Text = TheSR.NameWithoutHost; Image = Images.GetImage16For(TheSR.GetIcon); Host affinity = TheVM.Connection.Resolve<Host>(TheVM.affinity); Host activeHost = TheVM.Connection.Resolve<Host>(TheVM.resident_on); if (TheSR.content_type != SR.Content_Type_ISO && !((affinity != null && !TheSR.CanBeSeenFrom(affinity)) || (activeHost != null && TheVM.power_state == vm_power_state.Running && !TheSR.CanBeSeenFrom(activeHost)) || TheSR.IsBroken(false) || TheSR.PBDs.Count < 1)) { Description = ""; Enabled = true; Show = true; Reason = DisabledReason.None; } else if (((affinity != null && !TheSR.CanBeSeenFrom(affinity)) || (activeHost != null && TheVM.power_state == vm_power_state.Running && !TheSR.CanBeSeenFrom(activeHost))) && !TheSR.IsBroken(false) && TheSR.PBDs.Count < 1) { Description = string.Format(Messages.SR_CANNOT_BE_SEEN, Helpers.GetName(affinity)); Enabled = false; Show = true; Reason = DisabledReason.NotSeen; } else if (TheSR.IsBroken(false) && TheSR.PBDs.Count >= 1) { Description = Messages.SR_IS_BROKEN; Enabled = false; Show = true; Reason = DisabledReason.Broken; } else { Show = false; } }
public void DisableClan(Platform platform, long clanId, DisabledReason disabledReason) { Log.DebugFormat("Desabilitando clã {0}.{1} no BD por motivo {2}...", clanId, platform, disabledReason); var sw = Stopwatch.StartNew(); Execute(t => EnableDisableClan(platform, clanId, false, disabledReason, t)); Log.DebugFormat("Desabilitado clã {0}.{1} no BD em {2}.", clanId, platform, sw.Elapsed); }
/// <summary>Frees up the Idle CPU and Energy from the ships systems.</summary> /// <returns> /// A <c>ModuleResult</c> to indicate the result of disabling the module. /// <list type="bullet"> /// <item> /// <description><c>AlreadyDisabled</c> if the module is already disabled.</description> /// </item> /// <item> /// <description><c>InvalidSystem</c> if the system reference is null already.</description> /// </item> /// </list> /// </returns> public virtual ModuleResult DisableModule(DisabledReason reason = DisabledReason.User) { if (!_isEnabled) { // Override any other disabled by reason if the user manually disabled the module, // so it won't auto re-enable. if (reason == DisabledReason.User) { _disabledBy = reason; } return(ModuleResult.AlreadyDisabled); } _isEnabled = false; _disabledBy = reason; if (_core != null) { // Make sure to disable any ActivatorComponents or ModifierComponents if (activator != null) { activator.Deactivate(this); } if (modifier != null) { modifier.Remove(); } // Reset the targeter if we have one if (targeter != null) { targeter.ResetToDefault(); } // Unload any loaded ammo if (ammoStore != null) { ammoStore.UnloadToInventory(); } // Deallocate the idle resources _core.computer.DeallocateCpu(idleComputerResources); _core.power.Free(idleEnergyDrain); _core = null; return(ModuleResult.Success); } else { return(ModuleResult.InvalidSystem); } }
/// <summary>Allocates the idle CPU and reserves the idle energy required.</summary> /// <returns> /// A <c>ModuleResult</c> to indicate the result of disabling the module. /// <list type="bullet"> /// <item> /// <description><c>AlreadyEnabled</c> if the module is already enabled.</description> /// </item> /// <item> /// <description><c>InvalidSystem</c> if the system reference is null.</description> /// </item> /// <item> /// <description><c>InsufficientPower</c> if there is not enough power to enable the module.</description> /// </item> /// <item> /// <description><c>InsufficientCpu</c> if there is not enough CPU to enable the module.</description> /// </item> /// </list> /// </returns> public virtual ModuleResult EnableModule() { if (_isEnabled) { return(ModuleResult.AlreadyEnabled); } if (_core == null) { _core = gameObject.GetComponentInParent <MechaCoreComponent>(); if (_core == null) { return(ModuleResult.InvalidSystem); } } if (_core.computer.AllocateCpu(idleComputerResources)) { if (_core.power.Reserve(idleEnergyDrain)) { _isEnabled = true; _disabledBy = DisabledReason.NotDisabled; // If we have an ammoStore component, then do an initial ammo load. if (ammoStore != null) { ammoStore.LoadFromInventory(); } return(ModuleResult.Success); } else // Not enough power to enable module. { _core.computer.DeallocateCpu(idleComputerResources); _core = null; return(ModuleResult.InsufficientPower); } } else // Not enough CPU to enable module. { _core = null; return(ModuleResult.InsufficientCpu); } }
private static void EnableDisableClan(Platform platform, long clanId, bool enable, DisabledReason disabledReason, SqlTransaction t) { const string sql = "update Main.Clan set [Enabled] = @enableDisable, DisabledReason = @disabledReason where (ClanId = @clanId) and (PlataformId = @plataformId);"; using (var cmd = new SqlCommand(sql, t.Connection, t)) { cmd.CommandType = CommandType.Text; cmd.CommandTimeout = 5 * 60; cmd.Parameters.AddWithValue("@clanId", clanId); cmd.Parameters.AddWithValue("@plataformId", (int)platform); cmd.Parameters.AddWithValue("@enableDisable", enable); cmd.Parameters.AddWithValue("@disabledReason", (int)disabledReason); cmd.ExecuteNonQuery(); } }
/// <summary> /// Constructor. /// </summary> /// <param name="dr">Reason the test is being disabled</param> public DisabledAttribute(DisabledReason dr) : this(dr, null) { }
/// <summary> /// Standard constructor. /// </summary> /// <param name="dr">Reason the test is being disabled</param> /// <param name="description">Additional info</param> public DisabledAttribute(DisabledReason dr, string description) { _disabledReason = dr; _description = description; }
/// <summary> /// Converts the <see cref="sourceValue" /> parameter to the <see cref="destinationType" /> parameter using <see cref="formatProvider" /// /> and <see cref="ignoreCase" /> /// </summary> /// <param name="sourceValue">the <see cref="System.Object"/> to convert from</param> /// <param name="destinationType">the <see cref="System.Type" /> to convert to</param> /// <param name="formatProvider">not used by this TypeConverter.</param> /// <param name="ignoreCase">when set to <c>true</c>, will ignore the case when converting.</param> /// <returns> /// an instance of <see cref="DisabledReason" />, or <c>null</c> if there is no suitable conversion. /// </returns> public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => DisabledReason.CreateFrom(sourceValue);