Exemplo n.º 1
0
        private void Update(EvaluationContext context)
        {
            var now = DateTime.Now;

            try
            {
                var targetTime = DateTime.Today;
                var launchTime = LaunchTime.GetValue(context);
                if (DateTime.TryParse(launchTime, out var d))
                {
                    targetTime = d;
                    //Log.Debug("date:" + d);
                }
                else
                {
                    Log.Warning($"invalid format for lauchTime '{launchTime}'");
                }
                //var v = Duration.GetValue(context);
                var duration = DateTime.Now - targetTime;


                var format    = Format.GetValue(context);
                var outString = duration.ToString(format, CultureInfo.InvariantCulture);
                Output.Value = outString;
            }
            catch (System.FormatException)
            {
                //Log.Warning("Failed to format CountDown time: " + e.Message, SymbolChildId);
                Output.Value = "Invalid Format";
                return;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Tracks information about the app's launch.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        /// <param name="xamlRoot">The XamlRoot object from your visual tree.</param>
        public void TrackAppUse(IActivatedEventArgs args, XamlRoot xamlRoot = null)
        {
            if (args.PreviousExecutionState == ApplicationExecutionState.ClosedByUser ||
                args.PreviousExecutionState == ApplicationExecutionState.NotRunning)
            {
                LaunchCount      = _localObjectStorageHelper.Read <long>(nameof(LaunchCount)) + 1;
                TotalLaunchCount = _localObjectStorageHelper.Read <long>(nameof(TotalLaunchCount)) + 1;

                // In case we upgraded the properties, make TotalLaunchCount is correct
                if (TotalLaunchCount < LaunchCount)
                {
                    TotalLaunchCount = LaunchCount;
                }

                _localObjectStorageHelper.Save(nameof(LaunchCount), LaunchCount);
                _localObjectStorageHelper.Save(nameof(TotalLaunchCount), TotalLaunchCount);

                LaunchTime = DateTime.UtcNow;

                var lastLaunch = _localObjectStorageHelper.Read <long>(nameof(LastLaunchTime));
                LastLaunchTime = lastLaunch != default(long)
                    ? DateTime.FromFileTimeUtc(lastLaunch)
                    : LaunchTime;

                _localObjectStorageHelper.Save(nameof(LastLaunchTime), LaunchTime.ToFileTimeUtc());
                _localObjectStorageHelper.Save(nameof(AppUptime), 0L);

                var lastResetTime = _localObjectStorageHelper.Read <long>(nameof(LastResetTime));
                LastResetTime = lastResetTime != default(long)
                    ? DateTime.FromFileTimeUtc(lastResetTime)
                    : DateTime.MinValue;
            }

            if (xamlRoot != null)
            {
                void XamlRoot_Changed(XamlRoot sender, XamlRootChangedEventArgs e)
                {
                    UpdateVisibility(sender.IsHostVisible);
                }

                xamlRoot.Changed -= XamlRoot_Changed;
                xamlRoot.Changed += XamlRoot_Changed;
            }
            else
            {
                void App_VisibilityChanged(Windows.UI.Core.CoreWindow sender, Windows.UI.Core.VisibilityChangedEventArgs e)
                {
                    UpdateVisibility(e.Visible);
                }

                Windows.UI.Core.CoreWindow.GetForCurrentThread().VisibilityChanged -= App_VisibilityChanged;
                Windows.UI.Core.CoreWindow.GetForCurrentThread().VisibilityChanged += App_VisibilityChanged;
            }
        }
        /// <summary>
        /// Tracks information about the app's launch.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        public static void TrackAppUse(LaunchActivatedEventArgs args)
        {
            if (args.PreviousExecutionState == ApplicationExecutionState.ClosedByUser ||
                args.PreviousExecutionState == ApplicationExecutionState.NotRunning)
            {
                LaunchCount      = _localObjectStorageHelper.Read <long>(nameof(LaunchCount)) + 1;
                TotalLaunchCount = _localObjectStorageHelper.Read <long>(nameof(TotalLaunchCount)) + 1;

                // In case we upgraded the properties, make TotalLaunchCount is correct
                if (TotalLaunchCount < LaunchCount)
                {
                    TotalLaunchCount = LaunchCount;
                }

                _localObjectStorageHelper.Save(nameof(LaunchCount), LaunchCount);
                _localObjectStorageHelper.Save(nameof(TotalLaunchCount), TotalLaunchCount);

                LaunchTime = DateTime.UtcNow;

                var lastLaunch = _localObjectStorageHelper.Read <long>(nameof(LastLaunchTime));
                LastLaunchTime = lastLaunch != default(long)
                    ? DateTime.FromFileTimeUtc(lastLaunch)
                    : LaunchTime;

                _localObjectStorageHelper.Save(nameof(LastLaunchTime), LaunchTime.ToFileTimeUtc());
                _localObjectStorageHelper.Save(nameof(AppUptime), 0L);

                var lastResetTime = _localObjectStorageHelper.Read <long>(nameof(LastResetTime));
                LastResetTime = lastResetTime != default(long)
                    ? DateTime.FromFileTimeUtc(lastResetTime)
                    : DateTime.MinValue;
            }

            void App_VisibilityChanged(Windows.UI.Core.CoreWindow sender, Windows.UI.Core.VisibilityChangedEventArgs e)
            {
                if (e.Visible)
                {
                    _sessionStart = DateTime.UtcNow;
                }
                else
                {
                    var subsessionLength = DateTime.UtcNow.Subtract(_sessionStart).Ticks;

                    var uptimeSoFar = _localObjectStorageHelper.Read <long>(nameof(AppUptime));

                    _localObjectStorageHelper.Save(nameof(AppUptime), uptimeSoFar + subsessionLength);
                }
            }

            Windows.UI.Core.CoreWindow.GetForCurrentThread().VisibilityChanged -= App_VisibilityChanged;
            Windows.UI.Core.CoreWindow.GetForCurrentThread().VisibilityChanged += App_VisibilityChanged;
        }
Exemplo n.º 4
0
        public override string ToString()
        {
            string line = "";

            line += " " + StringUtil.FillSpace(SatelliteCode, 4);
            line += " " + StringUtil.FillSpace(PRN, 2);
            line += " " + StringUtil.FillSpace(CosparId, 9);
            line += " " + StringUtil.FillSpace(ObservationCode, 1);
            line += " " + LaunchTime.ToYdsString();
            line += " " + DecommissionTime.ToYdsString();
            line += " " + StringUtil.FillSpace(AntennaType, 20);

            return(line);
        }
Exemplo n.º 5
0
        public async Task <bool> Add(LaunchTime launchTime)
        {
            if (launchTime.IdDeveloper == null)
            {
                Notify("Não informado um desenvolvedor válido");
                return(false);
            }

            if (launchTime.IdProject == null)
            {
                Notify("Não informado um projeto valido");
                return(false);
            }

            await _launchTimeRepository.Add(launchTime);

            return(true);
        }
Exemplo n.º 6
0
        public static string GetStatus(bool bSilent = false)
        {
            StringBuilder toReturn          = new StringBuilder();
            Process       currentProcess    = Process.GetCurrentProcess();
            TimeSpan      Uptime            = DateTime.Now - LaunchTime;
            TimeSpan      TrueProcessorTime = TimeSpan.FromTicks(currentProcess.TotalProcessorTime.Ticks / Environment.ProcessorCount);

            toReturn.Append("Server status at " + DateTime.Now.ToString("r") + "\r\n");
            toReturn.Append("     Server Started: " + LaunchTime.ToString("r") + "\r\n");
            toReturn.Append("             Uptime: " + Uptime + "\r\n");
            toReturn.Append("     Total CPU Time: " + TrueProcessorTime + " on " + Environment.ProcessorCount + " cores\r\n");
            toReturn.Append("  Average CPU Usage: " + (100 * ((TrueProcessorTime.TotalMilliseconds * Environment.ProcessorCount) / Uptime.TotalMilliseconds)) + "%\r\n");
            toReturn.Append("    Total RAM Usage: " + (currentProcess.WorkingSet64 / 1024 / 1024) + "MB\r\n");
            toReturn.Append("   Thread Pool Info:\r\n");
            toReturn.Append("                    " + BismuthThreadPool.GetActiveThreadCount() + " active threads\r\n");
            toReturn.Append("                    " + BismuthThreadPool.GetTotalPossibleThreads() + " free threads\r\n");
            toReturn.Append("                    " + BismuthThreadPool.GetPendingTaskCount() + " tasks waiting\r\n");
            return(toReturn.ToString());
        }
Exemplo n.º 7
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = (Id != null ? Id.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Subject != null ? Subject.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Location != null ? Location.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (LocationProposition != null ? LocationProposition.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (AdditionalInformation != null ? AdditionalInformation.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ StartTime.GetHashCode();
         hashCode = (hashCode * 397) ^ LaunchTime.GetHashCode();
         hashCode = (hashCode * 397) ^ EndTime.GetHashCode();
         hashCode = (hashCode * 397) ^ Status;
         hashCode = (hashCode * 397) ^ (AlarmStation != null ? AlarmStation.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ AlarmLevel;
         hashCode = (hashCode * 397) ^ (CallerName != null ? CallerName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (CallerTelephoneNumber != null ? CallerTelephoneNumber.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (SirenProgram != null ? SirenProgram.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ FireBrigades.GetHashCode();
         return(hashCode);
     }
 }
Exemplo n.º 8
0
        /// <summary>
        /// Track app launch information
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        public static void TrackAppUse(LaunchActivatedEventArgs args)
        {
            if (args.PreviousExecutionState == ApplicationExecutionState.ClosedByUser ||
                args.PreviousExecutionState == ApplicationExecutionState.NotRunning)
            {
                if (ApplicationData.Current.LocalSettings.Values.TryGetValue(nameof(LaunchCount), out object launchCount))
                {
                    LaunchCount = (long)launchCount + 1;
                }
                else
                {
                    LaunchCount = 1;
                }

                ApplicationData.Current.LocalSettings.Values[nameof(LaunchCount)] = LaunchCount;

                LaunchTime = DateTime.UtcNow;

                if (ApplicationData.Current.LocalSettings.Values.TryGetValue(nameof(LastLaunchTime), out object lastLaunch))
                {
                    LastLaunchTime = DateTime.FromFileTimeUtc((long)lastLaunch);
                }

                ApplicationData.Current.LocalSettings.Values[nameof(LastLaunchTime)] = LaunchTime.ToFileTimeUtc();

                ApplicationData.Current.LocalSettings.Values[nameof(AppUptime)] = 0L;
            }

            void App_VisibilityChanged(Windows.UI.Core.CoreWindow sender, Windows.UI.Core.VisibilityChangedEventArgs e)
            {
                if (e.Visible)
                {
                    _sessionStart = DateTime.UtcNow;
                }
                else
                {
                    var subsessionLength = DateTime.UtcNow.Subtract(_sessionStart).Ticks;

                    ApplicationData.Current.LocalSettings.Values.TryGetValue(nameof(AppUptime), out object uptimeSoFar);

                    ApplicationData.Current.LocalSettings.Values[nameof(AppUptime)] = (long)uptimeSoFar + subsessionLength;
                }
            }

            Windows.UI.Core.CoreWindow.GetForCurrentThread().VisibilityChanged -= App_VisibilityChanged;
            Windows.UI.Core.CoreWindow.GetForCurrentThread().VisibilityChanged += App_VisibilityChanged;
        }
Exemplo n.º 9
0
        private static void Main(string[] args)
        {
            var devices = CaptureDeviceList.Instance;

            if (devices.Count < 1)
            {
                Console.WriteLine("No device found on this machine");
                return;
            }

            Console.WriteLine("The following devices are available on this machine:");
            Console.WriteLine("----------------------------------------------------");
            Console.WriteLine();

            var i = 0;

            foreach (var dev in devices)
            {
                Console.WriteLine("{0}) {1} {2}", i, dev.Name, dev.Description);
                i++;
            }

            Console.WriteLine();
            Console.Write("-- Please choose a device to capture: ");
            i = int.Parse(Console.ReadLine());

            var device = devices[i];

            device.OnPacketArrival +=
                device_OnPacketArrival;

            var readTimeoutMilliseconds = 1000;

            device.Open(DeviceMode.Promiscuous, readTimeoutMilliseconds);

            var filter = "ip and tcp";

            device.Filter = filter;

            Console.WriteLine();
            Console.WriteLine("-- The following tcpdump filter will be applied: \"{0}\"", filter);

            if (LoginServerIP == null)
            {
                Console.Write("-- Please input target LoginServer IP: ");
                LoginServerIP = IPAddress.Parse(Console.ReadLine());
                Console.WriteLine();
            }

            if (LoginServerPort == 0)
            {
                Console.Write("-- Please input target LoginServer Port: ");
                LoginServerPort = int.Parse(Console.ReadLine());
                Console.WriteLine();
            }

            BreakIpAddresses.Add(LoginServerIP);
            ServerPorts.Add(LoginServerPort);

            Console.WriteLine
                ("-- Listening on {0}, hit 'Ctrl-C' to exit...",
                device.Description);
            var filePath = Path.Combine(LaunchTime.ToString("s").Replace(':', '_'), "PacketFlow.txt");
            var flowFile = new FileInfo(filePath);

            flowFile.Directory?.Create();
            using var fs = new FileStream(filePath, FileMode.Create, FileAccess.Write);
            using (packerFlowStream = new StreamWriter(fs))
            {
                packerFlowStream.AutoFlush = true;
                device.Capture();
                device.Close();
                packerFlowStream.Flush();
                fs.Flush(true);
            }
        }
Exemplo n.º 10
0
        public async Task <bool> Update(LaunchTime launchTime)
        {
            await _launchTimeRepository.Update(launchTime);

            return(true);
        }