Ejemplo n.º 1
0
		public static void Main()
		{
			LastLog ll = new LastLog();

			Password pw	= new Password();

			LastLogEntry llent;
			Console.WriteLine("Username         Port     From             Latest");
			while((llent = ll.GetLlEnt()) != null )
			{
				PasswordEntry pwent;
			
				if ((pwent = pw.GetPWUid((int)llent.Uid)) != null)
				{
					String dt;
					if ( llent.ll_time != 0 )
					{
						dt = llent.Time.ToString("F");
					}
					else
					{
						dt = "**Never logged in**";
					}
					Console.WriteLine("{0,-17}{1,-9}{2,-17}{3}", pwent.Name, llent.Line, llent.Host, dt);
				}
			}

		}
Ejemplo n.º 2
0
 public override void Act()
 {
     base.Act();
     _durations   = LastLog.GetProperty <IEnumerable <int> >(Property.Durations.Name, Property.DefaultChildName);
     _details     = LastLog.GetProperty <string>(Property.Details);
     _detailLines = _details.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
 }
Ejemplo n.º 3
0
        public static void Main()
        {
            LastLog ll = new LastLog();

            Password pw = new Password();

            LastLogEntry llent;

            Console.WriteLine("Username         Port     From             Latest");
            while ((llent = ll.GetLlEnt()) != null)
            {
                PasswordEntry pwent;

                if ((pwent = pw.GetPWUid((int)llent.Uid)) != null)
                {
                    String dt;
                    if (llent.ll_time != 0)
                    {
                        dt = llent.Time.ToString("F");
                    }
                    else
                    {
                        dt = "**Never logged in**";
                    }
                    Console.WriteLine("{0,-17}{1,-9}{2,-17}{3}", pwent.Name, llent.Line, llent.Host, dt);
                }
            }
        }
Ejemplo n.º 4
0
        public void then_total_is_greater_or_equal_to_durations()
        {
            var durations = LastLog.GetProperty <IEnumerable <int> >(Property.Durations.Name, Property.DefaultChildName);
            var total     = LastLog.GetProperty <int>(Property.Durations.Name, Property.Durations.Total);

            total.Should().BeGreaterOrEqualTo(durations.Sum());
        }
 /// <summary>
 ///		Añade un parámetro al log
 /// </summary>
 public void AddParameter(string name, object value)
 {
     if (LastLog != null)
     {
         LastLog.AddParameter(name, value);
     }
 }
 public void then_property_is_added_to_result()
 {
     LastLog.GetProperty <object>("parent")
     .Should().BeEquivalentTo(new Dictionary <string, object>
     {
         { "test property", "test value" }
     });
 }
Ejemplo n.º 7
0
 public void then_exception_is_logged()
 {
     LastLog.GetProperty <ExceptionSummary>(Property.Exceptions).Should().BeEquivalentTo(
         new ExceptionSummary
     {
         Types  = new HashSet <string>(new[] { "Exception" }),
         Values = new[] { "System.Exception: Test" }
     });
 }
 public void SetUp()
 {
     log = new LastLog()
     {
         Id        = 1,
         Role      = "Manager",
         Name      = "Test",
         Password  = "******",
         IsLogedIn = true
     };
 }
Ejemplo n.º 9
0
 public void then_exception_attribute_is_filled_correctly()
 {
     LastLog.GetProperty <ExceptionSummary>(Property.Exceptions).Should().BeEquivalentTo(
         new ExceptionSummary
     {
         Types  = new HashSet <string>(new[] { "Exception" }),
         Values = new[]
         {
             "System.Exception: first",
             $"System.Exception: last ---> System.Exception: inner{Environment.NewLine}   --- End of inner exception stack trace ---"
         }
     });
 }
        /// <summary>
        /// Update a single log in the database by Id.
        /// </summary>
        public string Update(LastLog log)
        {
            using (lastLogContext = new LastLogContext())
            {
                var item = lastLogContext.LastLog.Find(log.Id);
                if (item != null)
                {
                    lastLogContext.Entry(item).CurrentValues.SetValues(log);
                    lastLogContext.SaveChanges();
                }
            }

            return("The elemnt was updated");
        }
Ejemplo n.º 11
0
        public async Task <IActionResult> Get(string productKey, long date)
        {
            try
            {
                var dtUtc = date.FromUnixTime();
                var lic   = await _dB.Licenses
                            .Include(l => l.ProductKey)
                            .Where(l => l.ProductKey.Key == productKey && l.Active)
                            .FirstOrDefaultAsync();

                if (lic != null)
                {
                    if (lic.ActivationDateTimeUtc != dtUtc)
                    {
                        lic.ActivationDateTimeUtc = dtUtc;
                    }

                    //last log update
                    var ll = await _dB.LastLogs.Include(l => l.License).Where(l => l.License.Id == lic.Id).FirstOrDefaultAsync();

                    if (ll == null)
                    {
                        var l = new LastLog
                        {
                            Api         = Models.Api.UpdateDateTimeLicense,
                            License     = lic,
                            DateTimeUtc = DateTime.UtcNow.TruncateMillis()
                        };
                        await _dB.LastLogs.AddAsync(l);
                    }
                    else
                    {
                        ll.Api         = Models.Api.UpdateDateTimeLicense;
                        ll.DateTimeUtc = DateTime.UtcNow.TruncateMillis();
                    }
                    await _dB.SaveChangesAsync();

                    return(Ok());
                }
                return(NotFound());
            }
            catch { return(NotFound()); }
        }
Ejemplo n.º 12
0
 public void then_message_from_default_application_log_is_logged()
 {
     LastLog.GetProperty <string>(Property.Message).Should().Be(LogMessage);
 }
Ejemplo n.º 13
0
 public void then_no_log_message_created()
 {
     LastLog.Should().BeNull();
 }
Ejemplo n.º 14
0
 public void then_message_is_null()
 {
     LastLog.GetProperty <object>(Property.Message).Should().Be(null);
 }
Ejemplo n.º 15
0
 public void then_message_field_exists()
 {
     LastLog.PropertyExists(Property.Message).Should().BeTrue();
 }
Ejemplo n.º 16
0
 public void then_message_is_logged()
 {
     LastLog.Should().NotBeNull();
 }
Ejemplo n.º 17
0
 public void then_log_level_code_is_set()
 {
     LastLog.GetProperty <int>(Property.LogLevelCode).Should().Be((int)LogLevel.Warn);
 }
Ejemplo n.º 18
0
 public void then_log_level_is_set()
 {
     LastLog.GetProperty <string>(Property.LogLevel).Should().Be(LogLevel.Warn.ToString());
 }
Ejemplo n.º 19
0
 public void then_correlation_id_is_set()
 {
     LastLog.GetProperty <string>(Property.CorrelationId).Should().Be(CorrelationId);
 }
Ejemplo n.º 20
0
 public void then_exception_text_is_not_logged_but_placeholder_is_present()
 {
     LastLog.ToJson().Should().Contain($"\"{Property.Exceptions}\":null");
 }
Ejemplo n.º 21
0
 public void then_durations_are_populated()
 {
     LastLog.GetProperty <IEnumerable <int> >(Property.Durations.Name, Property.DefaultChildName)
     .Count().Should().Be(3);
 }
Ejemplo n.º 22
0
 public void then_higher_log_severity_is_picked_out_of_merge()
 {
     LastLog.GetProperty <string>(Property.LogLevel)
     .Should().Be("Error",
                  "Merge should have replaced accumulated value of the second log call with higher severity");
 }
Ejemplo n.º 23
0
        public async Task <IActionResult> Get(string productKey, string appCode, int appVersion, string hid)
        {
            try
            {
                if (string.IsNullOrEmpty(productKey) || string.IsNullOrEmpty(appCode) || appVersion == 0 || string.IsNullOrEmpty(hid))
                {
                    return(NotFound());
                }
                var version = IntToVersion(appVersion);
                if (version == null)
                {
                    return(NotFound());
                }
                string vstr = version.Major.ToString() + "." + version.Minor.ToString();
                var    lic  = await _dB.Licenses
                              .Include(p => p.ProductKey)
                              .Include(p => p.Hid)
                              .Include(p => p.Client)
                              .Include(p => p.ApplicationVersion)
                              .ThenInclude(v => v.Application)
                              .Where(l => l.ProductKey.Key == productKey && !l.Banned && l.ApplicationVersion.Application.Code == appCode && l.ApplicationVersion.Version == vstr)
                              .FirstOrDefaultAsync();

                if (lic == null)
                {
                    return(Ok(ActivationResult.InvalidData));
                }
                if (lic.Banned)
                {
                    return(Ok(ActivationResult.Banned));
                }
                if (lic.Active)
                {
                    return(Ok(ActivationResult.AlreadyActive));
                }
                hid = hid.Replace("_", "-");
                var cnfc = GetConfirmCode(lic.ProductKey.Key, hid);
                var h    = new HID
                {
                    Value = hid
                };
                lic.Hid                   = h;
                lic.ConfirmCode           = cnfc;
                lic.Active                = true;
                lic.ActivationDateTimeUtc = DateTime.UtcNow.TruncateMillis();

                //last log update
                var ll = await _dB.LastLogs.Include(l => l.License).Where(l => l.License.Id == lic.Id).FirstOrDefaultAsync();

                if (ll == null)
                {
                    var l = new LastLog
                    {
                        Api         = Models.Api.ActiveLicense,
                        License     = lic,
                        DateTimeUtc = DateTime.UtcNow.TruncateMillis()
                    };
                    await _dB.LastLogs.AddAsync(l);
                }
                else
                {
                    ll.Api         = Models.Api.ActiveLicense;
                    ll.DateTimeUtc = DateTime.UtcNow.TruncateMillis();
                }
                await _dB.SaveChangesAsync();

                return(Ok(ActivationResult.Activated));
            }
            catch { return(NotFound()); }
        }
Ejemplo n.º 24
0
 public void then_both_overrides_are_applied()
 {
     LastLog.GetProperty <object>(Property.Message).Should().BeEquivalentTo(new[] { "1", "2" });
 }
Ejemplo n.º 25
0
 public override void Act()
 {
     Logger.Warn(TestMessage);
     Complete();
     _generatedCorrelationId = LastLog.GetProperty <string>(Property.CorrelationId);
 }
Ejemplo n.º 26
0
 public void then_durations_total_is_populated()
 {
     LastLog
     .GetProperty <int>(Property.Durations.Name, Property.Durations.Total)
     .Should().BeGreaterOrEqualTo(0);
 }
Ejemplo n.º 27
0
 protected Dictionary <string, object> GetDurations()
 {
     return(LastLog.GetProperty <Dictionary <string, object> >(Property.Durations.Name));
 }
Ejemplo n.º 28
0
 public void then_details_are_concatenated_from_2_messages()
 {
     LastLog.GetProperty <string>(Property.Details).Should().NotBeNullOrEmpty();
 }
Ejemplo n.º 29
0
 public void then_logging_happenned_after_completion()
 {
     LastLog.GetProperty <string>(Property.Message).Should().Be(TestMessage);
 }
 public void then_log_is_not_written()
 {
     LastLog.Should().BeNull();
 }
Ejemplo n.º 31
0
 public void then_operation_is_set()
 {
     LastLog.GetProperty <string>(Property.OperationName).Should().Be(OperationName);
 }