Ejemplo n.º 1
0
 /// <summary> Creates a ShutdownParams object with given parameters.
 /// <param name="customReason"/> and <param name="initiatedBy"/> may be null. </summary>
 public ShutdownParams(ShutdownReason reason, TimeSpan delay,
                       bool restart, [CanBeNull] string customReason,
                       [CanBeNull] Player initiatedBy)
     : this(reason, delay, restart) {
     customReasonString = customReason;
     InitiatedBy = initiatedBy;
 }
Ejemplo n.º 2
0
		public static void Shutdown(ShutdownReason reasonFlag)
		{
			int			Result;
			bool		BooleanResult;
			TokenPrivileges	tp	= new TokenPrivileges ();
			long			LocallyUniqueIdentifier;

			IntPtr hproc	= (IntPtr)ApiNativeMethods.GetCurrentProcess();
			int		htok	= 0;

			BooleanResult	= ApiNativeMethods.OpenProcessToken( (int)hproc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref htok );
			if( BooleanResult == false)
				throw new NolmeGenericException (string.Format (CultureInfo.InvariantCulture, "OpenProcessToken Failed"));

			tp.Count					= 1;
			tp.LocallyUniqueIdentifier	= 0;
			tp.Attributes				= SE_PRIVILEGE_ENABLED;
			LocallyUniqueIdentifier		= 0;
			BooleanResult				= ApiNativeMethods.LookupPrivilegeValue( null, SE_SHUTDOWN_NAME, ref LocallyUniqueIdentifier);
			if( BooleanResult == false)
				throw new NolmeGenericException (string.Format (CultureInfo.InvariantCulture, "LookupPrivilegeValue Failed"));

			tp.LocallyUniqueIdentifier	= LocallyUniqueIdentifier;
			BooleanResult	= ApiNativeMethods.AdjustTokenPrivileges( htok, false, ref tp, 0, 0, 0);
			if( BooleanResult == false)
				throw new NolmeGenericException (string.Format (CultureInfo.InvariantCulture, "AdjustTokenPrivileges Failed"));

			Result = User32ApiNativeMethods.ExitWindowsEx(ExitWindows.PowerOff | ExitWindows.Shutdown, reasonFlag);
			if( Result == 0)
				throw new NolmeGenericException (string.Format (CultureInfo.InvariantCulture, "Shutdown Failed"));
		}
Ejemplo n.º 3
0
 public static bool ExitWindows(ExitWindows exitWindows, ShutdownReason reason, bool ajustToken)
 {
     if (ajustToken && !TokenAdjuster.EnablePrivilege("SeShutdownPrivilege", true)) {
         return false;
     }
     return ExitWindowsEx(exitWindows, reason) != 0;
 }
Ejemplo n.º 4
0
 void Shutdown( ShutdownReason reason, bool quit ) {
     if( shutdownPending ) return;
     shutdownPending = true;
     uriDisplay.Enabled = false;
     console.Enabled = false;
     console.Text = "Shutting down...";
     Server.Shutdown( new ShutdownParams( reason, TimeSpan.Zero, quit, false ), false );
 }
Ejemplo n.º 5
0
		public static void LogOff(ShutdownReason reasonFlag) 
		{
			int Result;
			Result = User32ApiNativeMethods.ExitWindowsEx(ExitWindows.LogOff, reasonFlag);
			if( Result == 0)
			{
				throw new NolmeGenericException (string.Format (CultureInfo.InvariantCulture, "LogOff Failed"));
			}
		}
Ejemplo n.º 6
0
 static void ReportFailure( ShutdownReason reason ) {
     Console.Title = String.Format( "fCraft {0} {1}", Updater.CurrentRelease.VersionString, reason );
     if( useColor ) Console.ForegroundColor = ConsoleColor.Red;
     Console.Error.WriteLine( "** {0} **", reason );
     if( useColor ) Console.ResetColor();
     Server.Shutdown( new ShutdownParams( reason, TimeSpan.Zero, false, false ), true );
     if( !Server.HasArg( ArgKey.ExitOnCrash ) ) {
         Console.ReadLine();
     }
 }
Ejemplo n.º 7
0
        void Shutdown( ShutdownReason reason, bool quit ) {
            if( shutdownPending ) return;

            //Log( "Shutting down...", LogType.ConsoleOutput ); // write to console only

            shutdownPending = true;
            urlDisplay.Enabled = false;
            console.Enabled = false;
            Server.Shutdown( new ShutdownParams( reason, 0, quit, false ), false );
        }
Ejemplo n.º 8
0
 void Shutdown(ShutdownReason reason, bool quit)
 {
     if (shutdownPending)
     {
         return;
     }
     shutdownPending    = true;
     console.Enabled    = false;
     console.Text       = "Shutting down...";
     Text               = "fCraft " + Updater.CurrentRelease.VersionString + " - shutting down...";
     uriDisplay.Enabled = false;
     if (!startupComplete)
     {
         startupThread.Join();
     }
     Server.Shutdown(new ShutdownParams(reason, TimeSpan.Zero, quit, false), false);
 }
Ejemplo n.º 9
0
 static void ReportFailure(ShutdownReason reason)
 {
     Console.Title = String.Format("fCraft {0} {1}", Updater.CurrentRelease.VersionString, reason);
     if (useColor)
     {
         Console.ForegroundColor = ConsoleColor.Red;
     }
     Console.Error.WriteLine("** {0} **", reason);
     if (useColor)
     {
         Console.ResetColor();
     }
     Server.Shutdown(new ShutdownParams(reason, TimeSpan.Zero, false, false), true);
     if (!Server.HasArg(ArgKey.ExitOnCrash))
     {
         Console.ReadLine();
     }
 }
Ejemplo n.º 10
0
        private void LockedShutdown(ShutdownReason reason)
        {
            if (!_remoteShutdownRequested)
            {
                ChannelDisconnecting?.Invoke(this, reason);
            }

            if (reason == ShutdownReason.Requested)
            {
                var letter = new Letter.Letter(LetterOptions.Ack)
                {
                    Type = LetterType.Shutdown
                };
                InternalEnqueue(letter);

                if (_options.ShutdownGrace.TotalMilliseconds > 0)
                {
                    Thread.Sleep((int)_options.ShutdownGrace.TotalMilliseconds);
                }
                else
                {
                    Thread.Sleep(10);
                }
            }

            bool wasConnected = IsConnected;

            _initalizationCount = 0;
            IsConnected         = false;

            _transmitter?.Stop();
            _receiver?.Stop();

            DisconnectSocket();
            WaitForTranseiviersToShutDown();

            FailQueuedLetters();
            FailedReceivedLetters();

            if (wasConnected)
            {
                ChannelDisconnected?.Invoke(this, _remoteShutdownRequested ? ShutdownReason.Remote : reason);
            }
        }
Ejemplo n.º 11
0
        private void ChannelDisconnected(IChannel channel, ShutdownReason reason)
        {
            Binding binding = channel.Binding;

            _routeChannels.Remove(channel.RemoteNodeId);

            if (channel.Direction == Direction.Inbound || reason == ShutdownReason.Requested)
            {
                _channels.Remove(binding);
                UnhookChannel(channel);
            }

            Action <IHyperSocket, IDisconnectedEventArgs> evnt = Disconnected;

            if (evnt != null)
            {
                evnt(this, new DisconnectedEventArgs {
                    Binding = binding, Reason = reason, Socket = this, RemoteNodeId = channel.RemoteNodeId
                });
            }
        }
Ejemplo n.º 12
0
        public static void Shutdown(ShutdownReason reasonFlag)
        {
            int             Result;
            bool            BooleanResult;
            TokenPrivileges tp = new TokenPrivileges();
            long            LocallyUniqueIdentifier;

            IntPtr hproc = (IntPtr)ApiNativeMethods.GetCurrentProcess();
            int    htok  = 0;

            BooleanResult = ApiNativeMethods.OpenProcessToken((int)hproc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref htok);
            if (BooleanResult == false)
            {
                throw new NolmeGenericException(string.Format(CultureInfo.InvariantCulture, "OpenProcessToken Failed"));
            }

            tp.Count = 1;
            tp.LocallyUniqueIdentifier = 0;
            tp.Attributes           = SE_PRIVILEGE_ENABLED;
            LocallyUniqueIdentifier = 0;
            BooleanResult           = ApiNativeMethods.LookupPrivilegeValue(null, SE_SHUTDOWN_NAME, ref LocallyUniqueIdentifier);
            if (BooleanResult == false)
            {
                throw new NolmeGenericException(string.Format(CultureInfo.InvariantCulture, "LookupPrivilegeValue Failed"));
            }

            tp.LocallyUniqueIdentifier = LocallyUniqueIdentifier;
            BooleanResult = ApiNativeMethods.AdjustTokenPrivileges(htok, false, ref tp, 0, 0, 0);
            if (BooleanResult == false)
            {
                throw new NolmeGenericException(string.Format(CultureInfo.InvariantCulture, "AdjustTokenPrivileges Failed"));
            }

            Result = User32ApiNativeMethods.ExitWindowsEx(ExitWindows.PowerOff | ExitWindows.Shutdown, reasonFlag);
            if (Result == 0)
            {
                throw new NolmeGenericException(string.Format(CultureInfo.InvariantCulture, "Shutdown Failed"));
            }
        }
Ejemplo n.º 13
0
 private static extern int NTSetSystemPowerState(NTSetPowerState_PowerActionFlags powerActionFlags,
                                                 NTSetPowerState_SystemPowerStateFlags systemPowerStateFlags,
                                                 ShutdownReason reason);
 public ShutdownEventArgs(Exception exception)
 {
     Reason    = ShutdownReason.Exception;
     Exception = exception;
 }
 public DefaultShutdownInput(ShutdownReason reason, Checkpointer checkpointer)
 {
     _reason       = reason;
     _checkpointer = checkpointer;
 }
 public NestResult Shutdown(ShutdownReason reason)
 {
     shutdownLatch.Set();
     parameters?.Host.Shutdown();
     return(NestResult.Success);
 }
 public DefaultShutdownInput(ShutdownReason reason, Checkpointer checkpointer)
 {
     _reason = reason;
     _checkpointer = checkpointer;
 }
Ejemplo n.º 18
0
 public static extern bool ExitWindowsEx(ShutdownFlags flags, ShutdownReason reason);
Ejemplo n.º 19
0
 void Shutdown( ShutdownReason reason, bool quit )
 {
     if( shutdownPending ) return;
     shutdownPending = true;
     SetURIDisplayEnabled(false);
     SetConsoleEnabled(false);
     SetConsoleText("Shutting down...");
     Server.Shutdown( new ShutdownParams( reason, TimeSpan.Zero, quit, false ), false );
 }
Ejemplo n.º 20
0
 public DisconnectedEventArgs(ShutdownReason shutdownReason)
 {
     ShutdownReason = shutdownReason;
 }
Ejemplo n.º 21
0
 public static extern Boolean ExitWindowsEx(ExitWindows uFlags, ShutdownReason dwReason);
 public NestResult Shutdown(ShutdownReason reason)
 {
     ryu.Get <DaemonService>().Shutdown();
     return(NestResult.Success);
 }
Ejemplo n.º 23
0
        private void ChannelDisconnected(IChannel channel, ShutdownReason reason)
        {
            Binding binding = channel.Binding;

            _routeChannels.Remove(channel.RemoteNodeId);

            if(channel.Direction == Direction.Inbound || reason == ShutdownReason.Requested) {
                _channels.Remove(binding);
                UnhookChannel(channel);
            }

            Action<IHyperSocket, IDisconnectedEventArgs> evnt = Disconnected;
            if(evnt != null) evnt(this, new DisconnectedEventArgs {Binding = binding, Reason = reason, Socket = this, RemoteNodeId = channel.RemoteNodeId});
        }
Ejemplo n.º 24
0
 public static extern bool ExitWindowsEx(ExitWindowsFlags uFlags, ShutdownReason dwReason);
Ejemplo n.º 25
0
 private void ChannelOnDisconnected(IChannel channel, ShutdownReason reason)
 {
     ChangeTimerState(false);
     _sentBatch = false;
     FailedQueuedLetters();
     ChannelDisconnected(this, reason);
 }
Ejemplo n.º 26
0
 public NestResult Shutdown(ShutdownReason reason)
 {
     // host shutdown is called by UI thread.
     application.Dispatcher.Invoke(() => { application.Shutdown(); });
     return(NestResult.Success);
 }
Ejemplo n.º 27
0
 public NestResult Shutdown(ShutdownReason reason)
 {
     // host shutdown is called by UI thread.
      application.Dispatcher.Invoke(() => { application.Shutdown(); });
      return NestResult.Success;
 }
Ejemplo n.º 28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ShutdownNotification" /> class.
 /// </summary>
 /// <param name="AdditionalInfo">AdditionalInfo.</param>
 /// <param name="Countdown">Countdown.</param>
 /// <param name="Reason">Reason.</param>
 public ShutdownNotification(string AdditionalInfo = default(string), float?Countdown = default(float?), ShutdownReason Reason = default(ShutdownReason))
 {
     this.AdditionalInfo = AdditionalInfo;
     this.Countdown      = Countdown;
     this.Reason         = Reason;
 }
Ejemplo n.º 29
0
 internal static extern bool ExitWindowsEx(ExitWindows flg, ShutdownReason rea);
Ejemplo n.º 30
0
 public ShutdownParams(ShutdownReason reason, TimeSpan delay, bool restart)
 {
     Reason  = reason;
     Delay   = delay;
     Restart = restart;
 }
        private void DispatchAction(Action a)
        {
            var initAction = a as InitializeAction;
            if (initAction != null)
            {
                ShardId = initAction.ShardId;
                _stateMachine.Fire(Trigger.BeginInitialize);
                return;
            }

            var processRecordAction = a as ProcessRecordsAction;
            if (processRecordAction != null)
            {
                Records = processRecordAction.Records;
                _stateMachine.Fire(Trigger.BeginProcessRecords);
                return;
            }

            var shutdownAction = a as ShutdownAction;
            if (shutdownAction != null)
            {
                ShutdownReason = (ShutdownReason)Enum.Parse(typeof(ShutdownReason), shutdownAction.Reason);
                _stateMachine.Fire(Trigger.BeginShutdown);
                return;
            }

            var checkpointAction = a as CheckpointAction;
            if (checkpointAction != null)
            {
                CheckpointError = checkpointAction.Error;
                CheckpointSeqNo = checkpointAction.SequenceNumber;
                _stateMachine.Fire(Trigger.FinishCheckpoint);
                return;
            }

            throw new MalformedActionException("Received an action which couldn't be understood: " + a.Type);
        }
Ejemplo n.º 32
0
 static void ReportFailure(ShutdownReason reason)
 {
     Console.ForegroundColor = ConsoleColor.Red;
     Console.Error.WriteLine("** {0} **", reason);
     Console.Title = String.Format("800Craft {0} {1}", Updater.CurrentRelease.VersionString, reason);
     Console.ResetColor();
     if (!Server.HasArg(ArgKey.ExitOnCrash))
     {
         Console.ReadLine();
     }
 }
Ejemplo n.º 33
0
        /// <summary>
        ///   Handles the event of the dispatcher closing (and disposing)
        ///   because of a disconnect or a user request.
        /// </summary>
        /// <param name="reason"> The reason why the dispatcher closed. </param>
        internal void HandleDispatcherClosed(ShutdownReason reason)
        {
            this.ShutdownReason = reason;
            this.dispatcher = null;

#if DEBUG
            this.runningLock.Set();
#endif

            this.OnDisconnected(new DisconnectedEventArgs(reason));
        }
Ejemplo n.º 34
0
 private void ChannelDisconnecting(IChannel channel, ShutdownReason shutdownReason)
 {
     _letterDispatcher.DequeueChannel(channel);
     Action<IHyperSocket, IDisconnectingEventArgs> evnt = Disconnecting;
     if(evnt != null)
         evnt(this, new DisconnectingEventArgs {Binding = channel.Binding, Reason = shutdownReason, RemoteNodeId = channel.RemoteNodeId, Socket = this});
 }
 public NestResult Shutdown(ShutdownReason reason)
 {
     return(NestResult.Success);
 }
Ejemplo n.º 36
0
 private static extern int InitiateSystemShutdownEx(string lpMachineName, string lpMessage,
                                                    uint dwTimeout, bool bForceAppsClosed,
                                                    bool bRebootAfterShutdown, ShutdownReason dwReason);
Ejemplo n.º 37
0
 static extern bool ExitWindowsEx(ExitWindows uFlags, ShutdownReason dwReason);
Ejemplo n.º 38
0
 public static int ExitWindows(ExitWindows exitWindows, ShutdownReason reason)
 {
     return(ExitWindowsEx(exitWindows, reason));
 }
Ejemplo n.º 39
0
 private void HandleSocketError(ShutdownReason reason)
 {
     Receiving = false;
     if(SocketError != null) SocketError(reason);
 }
Ejemplo n.º 40
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="message">The message to record</param>
 /// <param name="timeout">How long to show the shutdown dialog box, in seconds. If zero, there is no prompt and it cannot be aborted easily</param>
 /// <param name="force">Forcibly close all applications, even if they have unsaved changes</param>
 /// <param name="reboot">Restart the machine immediately after shutdown</param>
 /// <param name="reason"></param>
 /// <returns></returns>
 public static int InitiateSystemShutdown(string message, uint timeout, bool force, bool reboot, ShutdownReason reason)
 {
     return(InitiateSystemShutdownEx(null, message, timeout, force, reboot, reason));
 }
 public ShutdownEventArgs(ShutdownReason reason)
 {
     Reason    = reason;
     Exception = null;
 }
Ejemplo n.º 42
0
 public NestResult Shutdown(ShutdownReason reason)
 {
     trinketDtpServer.Dispose();
      host.Shutdown();
      return NestResult.Success;
 }
Ejemplo n.º 43
0
 public void ShutdownAgent(ShutdownReason reason)
 {
     ArgUtil.NotNull(reason, nameof(reason));
     AgentShutdownReason = reason;
     _agentShutdownTokenSource.Cancel();
 }
Ejemplo n.º 44
0
 private static extern bool ExitWindowsEx(EXIT_WINDOWS uFlags, ShutdownReason dwReason);
Ejemplo n.º 45
0
 private static extern int ExitWindowsEx(ExitWindowsFlags uFlags, ShutdownReason dwReason);
Ejemplo n.º 46
0
 static bool Kernel32_ProcessShuttingDown(ShutdownReason sig) {
     ShutdownEventArgs args = new ShutdownEventArgs(sig);
     RaiseShutdownEvent(args);
     return false;
 }
Ejemplo n.º 47
0
 public ShutdownParams( ShutdownReason reason, TimeSpan delay, bool killProcess, bool restart )
 {
     Reason = reason;
     Delay = delay;
     KillProcess = killProcess;
     Restart = restart;
 }
Ejemplo n.º 48
0
 public ShutdownEventArgs(Exception exception) {
     Reason = ShutdownReason.Exception;
     Exception = exception;
 }
Ejemplo n.º 49
0
 private static extern bool ExitWindowsEx(ExitWindows uFlags,
                                          ShutdownReason dwReason);
Ejemplo n.º 50
0
 private static void ShutDown(ShutdownReason downReason)
 {
     GemsCraft.fSystem.Server.Shutdown(new ShutdownParams(downReason, TimeSpan.Zero, true, false), true);
 }
Ejemplo n.º 51
0
 public void ShutdownRunner(ShutdownReason reason)
 {
     ArgUtil.NotNull(reason, nameof(reason));
     RunnerShutdownReason = reason;
     _runnerShutdownTokenSource.Cancel();
 }
Ejemplo n.º 52
0
 public static extern int ExitWindowsEx(ExitWindows uFlags, ShutdownReason dwReason);
Ejemplo n.º 53
0
 void Shutdown(ShutdownReason reason, bool quit)
 {
     if (shutdownPending) return;
     shutdownPending = true;
     console.Enabled = false;
     console.Text = "Shutting down...";
     Text = "800Craft " + Updater.CurrentRelease.VersionString + " - shutting down...";
     uriDisplay.Enabled = false;
     if (!startupComplete)
     {
         startupThread.Join();
     }
     Server.Shutdown(new ShutdownParams(reason, TimeSpan.Zero, quit, false), false);
 }
Ejemplo n.º 54
0
		internal static extern int		ExitWindowsEx			(ExitWindows exitFlags, ShutdownReason shutDownReason);
Ejemplo n.º 55
0
 public ShutdownEventArgs(ShutdownReason reason) {
     Reason = reason;
     Exception = null;
 }
Ejemplo n.º 56
0
 protected virtual void AfterDisconnectHook(ShutdownReason reason)
 {
 }
Ejemplo n.º 57
0
 public static extern bool InitiateSystemShutdownEx(
     string lpMachineName,
     string lpMessage,
     uint dwTimeout,
     bool bForceAppsClosed,
     bool bRebootAfterShutdown,
     ShutdownReason dwReason);
Ejemplo n.º 58
0
 private static extern bool ExitWindowsEx(EXIT_WINDOWS uFlags, ShutdownReason dwReason);
Ejemplo n.º 59
0
 /// <summary> Creates a ShutdownParams object with given reason/delay/restart flag. </summary>
 public ShutdownParams(ShutdownReason reason, TimeSpan delay, bool restart) {
     Reason = reason;
     Delay = delay;
     Restart = restart;
 }
Ejemplo n.º 60
0
 public NestResult Shutdown(ShutdownReason reason)
 {
     trinketDtpServer.Dispose();
     host.Shutdown();
     return(NestResult.Success);
 }