/// <summary> /// Method that does the tracking of app usage on the system. /// </summary> protected void TrackAppUsage() { if (!this.IsUserIdle(IdleTimeout)) { Process activeProcess = this.GetActiveProcess(); if (activeProcess == null) { return; } AppUsage appUsageToUpdate = this.AppUsages.Find(x => x.Name.Equals(activeProcess.ProcessName)); if (appUsageToUpdate != null) { appUsageToUpdate.TimeUsed += Interval; } else { AppUsage appUsage = new AppUsage { Name = activeProcess.ProcessName, TimeUsed = Interval, Environment = this.UserEnvironment, }; this.AppUsages.Add(appUsage); } } Thread.Sleep(Interval * 1000); this.TimeSinceLastSent += Interval; this.CheckAndSendToHost(); }
internal SKSAuthorizationDialog(int key_handle, PassphraseFormat format, Grouping grouping, AppUsage app_usage, int zero_or_retriesleft) { this.key_handle = key_handle; this.retry_warning = zero_or_retriesleft != 0; this.retriesleft = zero_or_retriesleft; this.pin_format = format; if (app_usage == AppUsage.SIGNATURE && (grouping == Grouping.UNIQUE || grouping == Grouping.SIGNATURE_PLUS_STANDARD)) { show_picture = true; add_on_dialog_header = " - SIGNATURE"; picture_resource = "sks.signsymb.gif"; picture_tooltip_text = "Signature operation requiring a specific PIN"; } if (app_usage == AppUsage.AUTHENTICATION && grouping == Grouping.UNIQUE) { show_picture = true; add_on_dialog_header = " - AUTHENTICATION"; picture_resource = "sks.idcard.gif"; picture_tooltip_text = "Authentication operation requiring a specific PIN"; } if (app_usage == AppUsage.ENCRYPTION && grouping == Grouping.UNIQUE) { show_picture = true; add_on_dialog_header = " - ENCRYPTION"; picture_resource = "sks.encrypt.gif"; picture_tooltip_text = "Encryption operation requiring a specific PIN"; } pin_format = format; InitializeComponent(); }
protected void GetAppDetails(AppUsage a) { KillRunningThreads(); AppDetailsViewSource.Source = null; ProgressRing2.Visibility = Visibility.Visible; Task.Run(() => { threads.Add(Thread.CurrentThread); List <AppDetail> details; using (var db = new ArgonDB()) { details = db.NetworkTraffic .Where(x => x.Time.Between(DateFrom.Ticks, DateTo.Ticks) && x.FilePath == a.Path && x.ApplicationName == a.Name) .Select(x => new AppDetail { SourceIP = x.SourceAddr, SourcePort = x.SourcePort, DestinationIP = x.DestAddr, DestinationPort = x.DestPort }).Distinct().ToList(); } Dispatcher.BeginInvoke(new Action(() => { ProgressRing2.Visibility = Visibility.Collapsed; AppDetailsViewSource.Source = details; })); threads.Clear(); }); }
public void TestPostAppUsageNew_SunnyDay() { // Arrange string userId = "TestUser"; string appName = "TestApp"; int timeUsed = 15; AppEnvironment environment = AppEnvironment.Windows; List <AppUsage> testAppUsages = new List <AppUsage>(); AppUsage testAppUsage = CreateAppUsage(appName, timeUsed, userId, environment); testAppUsages.Add(testAppUsage); var appUsageAdministratorMock = new Mock <IAppUsageAdministrator>(); appUsageAdministratorMock.Setup(admin => admin.SaveAppUsage(testAppUsage)); var appUsageProviderMock = new Mock <IAppUsageProvider>(); AppUsage nullAppUsage = null; appUsageProviderMock.Setup(provider => provider.FindByUserAndName(userId, appName)).Returns(nullAppUsage); AppUsageController appUsageController = new AppUsageController(appUsageProviderMock.Object, appUsageAdministratorMock.Object); // Act List <AppUsage> actualAppUsageResults = appUsageController.Post(testAppUsages); // Assert AppUsage actualAppUsage = actualAppUsageResults.Find(x => x.Name.Equals(appName)); }
public void TestGetByUser_SunnyDay() { // Arrange string appName = "TestApp"; string userId = "TestUser"; int timeUsed = 15; AppEnvironment environment = AppEnvironment.Windows; var appUsageProviderMock = new Mock <AppUsageProvider>(); List <AppUsage> expectedAppUsages = new List <AppUsage>(); AppUsage expectedAppUsage = CreateAppUsage(appName, timeUsed, userId, environment); expectedAppUsages.Add(expectedAppUsage); appUsageProviderMock.Setup(provider => provider.FindByUser(userId)).Returns(expectedAppUsages); // Act AppUsageController appUsageController = new AppUsageController(appUsageProviderMock.Object, null); List <AppUsage> appUsages = appUsageController.Get(userId); AppUsage actualAppUsage = appUsages.Find(x => x.Name.Equals(appName)); // Assert Assert.AreEqual(expectedAppUsage, actualAppUsage); }
public AppUsageViewModel(AppUsage au) : base(au) { App = new AppViewModel(au.App); EndTimestamp = au.EndTimestamp; StartTimestamp = au.StartTimestamp; UsageStartReason = au.UsageStartReason; UsageEndReason = au.UsageEndReason; UsageType = au.UsageType; }
private static void LogAppSwitch(AppUsage prevAppUsage, App newApp) { Log.Information("[{start} - {end} ({duration})] {{{startReason}, {endReason}}} {prev} -> {new}", prevAppUsage.StartTimestamp.ToString("HH:mm:ss.fff tt"), prevAppUsage.EndTimestamp.ToString("HH:mm:ss.fff tt"), prevAppUsage.EndTimestamp - prevAppUsage.StartTimestamp, prevAppUsage.UsageStartReason, prevAppUsage.UsageEndReason, prevAppUsage.App.Path, newApp?.Path); }
/// <inheritdoc/> public AppUsage FindByUserAndName(string userId, string appName) { AppUsage appUsage = new AppUsage { Name = "MockApp", TimeUsed = 37, UserId = "MockUser", Environment = AppEnvironment.Windows, }; return(appUsage); }
public static AvayaResult MakeCall(string sourceExt, string dest) { AvayaResult result = new AvayaResult { Extension = sourceExt, Destination = dest }; if (String.IsNullOrEmpty(sourceExt) || String.IsNullOrEmpty(dest)) { result.Error = new Exception("Invalid or Missing Parameters"); return(result); } Int32 e = 0; if (!Int32.TryParse(sourceExt, out e)) { return(MakeCallByUser(sourceExt, dest)); } // take the incoming number and add any prefixes to it for out-dial dest = PrefixDestination(sourceExt, dest); AppUsage.Log("Avaya", DEFAULT_COMPANY, sourceExt, "MakeCall", dest); //Establish Service AvayaTSWS.TelephonyServiceService svc = new AvayaTSWS.TelephonyServiceService(); svc.Url = (string)Cache.MemoryCacher.GetValue(AVAYA_URL) ?? CommonLookup.GetLookups("BHCCRM", AVAYA_URL, true)[0].CodeDesc; // "http://192.168.101.26/axis/services/TelephonyService"; Cache.MemoryCacher.Add(AVAYA_URL, svc.Url); //endpoints AvayaTSWS.endpoints ep = new AvayaTSWS.endpoints(); ep.originatingExtension = sourceExt; // System.Configuration.ConfigurationManager.AppSettings.Get("ext").ToString(); ep.destinationNumber = dest; try { //do work System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return(true); }; string sess = null; svc.attach(sess); svc.makeCall(ep); } catch (Exception ex) { result.Error = ex; } return(result); }
/// <inheritdoc/> public List <AppUsage> FindByUser(string userId) { List <AppUsage> appUsages = new List <AppUsage>(); AppUsage appUsage = new AppUsage { Name = "MockApp", TimeUsed = 37, UserId = "MockUser", Environment = AppEnvironment.Windows, }; appUsages.Add(appUsage); return(appUsages); }
public void AddAppUsage(AppUsage appUsage) { appUsage.Id = Insert("insert into AppUsage(" + "Id, " + "AppId, " + "UsageType, " + "StartTimestamp, " + "EndTimestamp, " + "UsageStartReason, " + "UsageEndReason) " + "values (?,?,?,?,?,?,?)", null, appUsage.App.Id, (int)appUsage.UsageType, appUsage.StartTimestamp.Ticks, appUsage.EndTimestamp.Ticks, (int)appUsage.UsageStartReason, (int)appUsage.UsageEndReason); }
public static void Save(this AppUsage usage, IDataService provider) { // get database instance using (var database = ((DataProvider)provider).Database) { var usageR = database.All <AppUsageRealm>().FirstOrDefault(); if (usageR == null) { usageR = ObjectMapper.MapData <AppUsage, AppUsageRealm>(usage); database.Write(() => database.Add(usageR, true)); } else { database.Write(() => { usageR.LastActivity = usage.LastActivity; }); } } }
public async Task <IActionResult> CreateAppUsage(AppUsage AppUsage) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } else { var result = await _masterRepository.CreateAppUsage(AppUsage); return(Ok(result)); } } catch (Exception ex) { ErrorLog.WriteToFile("Master/CreateAppUsage", ex); return(BadRequest(ex.Message)); } }
public void TestPostAppUsageUpdate_SunnyDay() { // Arrange string userId = "TestUser"; string appName = "TestApp"; int timeUsed = 15; AppEnvironment environment = AppEnvironment.Windows; int expectedTimeUsed = 30; AppUsage appUsage = CreateAppUsage(appName, timeUsed, userId, environment); List <AppUsage> appUsages = new List <AppUsage> { appUsage }; AppUsage expectedAppUsage = CreateAppUsage(appName, expectedTimeUsed, userId, environment); List <AppUsage> expectedAppUsages = new List <AppUsage> { expectedAppUsage }; var appUsageProviderMock = new Mock <IAppUsageProvider>(); appUsageProviderMock.Setup(provider => provider.FindByUserAndName(userId, appName)).Returns(appUsage); var appUsageAdministratorMock = new Mock <IAppUsageAdministrator>(); appUsageAdministratorMock.Setup(admin => admin.SaveAppUsage(new AppUsage())); AppUsageController appUsageController = new AppUsageController(appUsageProviderMock.Object, appUsageAdministratorMock.Object); // Act List <AppUsage> actualAppUsages = appUsageController.Post(appUsages); AppUsage actualAppUsage = actualAppUsages.Find(x => x.Name.Equals(appName)); // Assert Assert.AreEqual(expectedAppUsage, actualAppUsage); }
public ForegroundAppSwitchEventArgs(AppUsage prev, App newApp) { PreviousAppUsage = prev; NewApp = newApp; }
public AppSwitchMessage(AppUsage prev, App newApp) { PreviousAppUsage = prev; NewApp = newApp; }
/// <inheritdoc/> public virtual void SaveAppUsage(AppUsage appUsage) { appUsage.Save(); }