I am writing a Windows service for doing Parental Control (Visual C++).
I am having trouble with the following:
how to count the time a Windows user has been logged on today (time measured in hours)
how to trigger log-off from the user Windows account, when time per day exceeds a specified value, say 5 hours.
Any help is appreciated.
Regards!
To do that I think there may me several ways.
I think the simplest one is to use a timer that could be launched when the service start (or when your application start if placed in the startup menu).
For that you can use the SetTimer method associated to a WM_TIMER message :
http://msdn.microsoft.com/en-us/library/ms644906(v=vs.85).aspx
You should get the time before the launching of the timer using a CTime function for example :
CTime t;
t.GetCurrentTime ();
timeAtLaunched=t.GetSecond(); //or GetHour()
After that you can put a similar CTime call inside your timer function to have a currentTime value and calculate a difference between the currentTime value and the timeAtLaunched value
To keep the connected time during a day if an user connect and disconnect several times, you should keep the difference value inside a file or inside the registry.
To force logoff, you can use :
ExitWindowsEx (EWX_SHUTDOWN | EWX_FORCE, SHTDN_REASON_MAJOR_OPERATINGSYSTEM |
SHTDN_REASON_MINOR_UPGRADE | SHTDN_REASON_FLAG_PLANNED)
Related
I found out that you can manually trigger Time Trigger Azure function link and in step number 7 there is a way to pass dictionary, but there is no example on how to read this information. If that is not possible I tried to read how to make fire and forget http request just to trigger my calculations, but that also is not that resalable to do, so in the end I left with durable functions this could be okay, but in this case it would be a bit overkill.
Use case:
Some date is processed daily during a night (Time trigger) and takes default value "Today", but for example data provider was down, but in few days it is up and running, I need a way to reprocess for previous days. Http call will timeout because it takes for example 1 hour and so on.
Maybe someone have any suggestions.
For process previous day data you can use fromdays(-1) for previous days data process.
DateTime previous_day= context.CurrentUtcDateTime.Add(TimeSpan.FromDays(-1));
await context.CreateTimer(previous_day, CancellationToken.None);
await context.CallActivityAsync("Function1_ProcessPreviousDays");
[FunctionName("Function1_ProcessPreviousDays")]
public static string processdata([ActivityTrigger] string name, ILogger log)
{
// apply logic here
return $"Process Previous Days Data!";
}
When I try to reset the assignments of a course, front-end wise all data get deleted. I tested this with a single file upload by myself in a test assignment. But when checking disk usage with
du moodledata/filedir
the same usage remains. I ensured execution of the cron task which printed
...
Cron script completed correctly
Cron completed at 17:40:03. Memory used 32.8MB.
Execution took 0.810698 seconds
The files also are not in moodledata/trashdir probably reason why the cron task does not clean it.
Removing file with
moosh file-hash-delete <hash>
seemed to work. I identified the hash with pre/after executing disk usage and checking hash in the folder that used up the size of the file I uploaded.
The hash was not in the mdl_files table in MySQL, but the draft of it was. This one I found out via
moosh file-check
and I also checked it with phpMyAdmin, which outputted the file(draft) alongside other files.
Logs for resetting the course show the following:
Core System, course reset finished, The reset of the course with id '4' has ended.
Core System, deadline updated, The user with id '2' updated the event 'test ist zur Bewertung fällig.' with id '4'.
Core System, deadline updated, The user with id '2' updated the event 'test ist fällig.' with id '3'.
Core System, course reset begin, The user with id '2' started the reset of the course with id '4'.
(note that I translated some of the messages, because my setup is in German).
Unfortunately I'm having to run this Moodle instance on a hoster with extremely low disk storage (hence backup/deletion requirement).
Some background infos:
Moodle - version 3.8.2+ stable, dbtype set to mariadb
MariaDB - version 10.3.19
Machine: CentOS Linux 7
UPDATE: It seems that after some days (I checked today, ~4 days later) the files have been deleted. I don't know why this happened after so many days even though I manually triggered the cron job (seems that it doesn't delete the files). It would be nice to check where the timer is set and which script finally deletes the files.
On the course reset page, if you scroll down, there is a drop down for Assignments
Did you check the box for Delete all submissions ?
In the code, $data->reset_assign_submissions will delete the files:
public function reset_userdata($data) {
global $CFG, $DB;
$componentstr = get_string('modulenameplural', 'assign');
$status = array();
$fs = get_file_storage();
if (!empty($data->reset_assign_submissions)) {
I'm trying to use ETW for logging with several custom EventSource classes in Azure SDK 2.6.
When testing locally with the compute/storage emulator, three of my custom WADMyEventXYZ tables show up; however, the final expected table "WADMyDataSets" never seems to be created. How should I determine what is causing this problem? I see no errors from the compute emulator when the debugger is attached and stepping through the code in the debugger shows that WriteEntry on the EventSource is definitely called. The other tables show up in SchemasTable in the developer storage account, but there is no entry there for WADMyDataSets.
I exported WADDiagnosticInfrastrureLogsTable into CSV and examined it in Excel and see the following messages that reference "MyDataSets":
Validating table MyDataSets; DiskMB:451; RequiredQuota:451 RetentionSeconds:7776000 Pri:2 MinQuotaMB:0 RunningTotal:3757
Table does not exist
table C:\Users\Caleb\AppData\Local\dftmp\Resources\b316f531-f673-4db3-ac1c-e4649e289871\WAD0104\Tables\MyDataSets does not exist, CreationDisposition = 4
Table MyDataSets does not exist, will create a new one
Delaying the creation of table MyDataSets until the schema is known
Later on:
Converted EventSource provider name "MyDataSets" to {74a2b9c9-0bd8-547f-6cad-453da47055be}
Matched task with query id MyDataSetsQuery and regex ^MyDataSets$ to source table MyDataSets
Registering query MyDataSetsQuery_MyDataSets_XTableWadAccount:
Adding standard PkRk (MA) fields to 'MyDataSetsQuery_MyDataSets'
Successfully compiled the query 'MyDataSetsQuery_MyDataSets'
Added task MyDataSetsQuery_MyDataSets_WADMyDataSets_PT1M_XTableWadAccount from MyDataSets - Partitions:-1 Pri:normal TSPolicy:start StoreType:Central Repeat:2147483647 Timeout:3600s Deadline:300s DelayRange:0.00
Later on:
No checkpoint found for task MyDataSetsQuery_MyDataSets_WADMyDataSets_PT1M_XTableWadAccount after time 2015-05-13T00:44:21.000Z; retry time out is 3600 seconds
First scheduled task for MyDataSetsQuery_MyDataSets_WADMyDataSets_PT1M_XTableWadAccount is at 2015-05-13T01:44:00.000Z (plus a delay of 20s)
Later on:
Increasing query delay of task MyDataSetsQuery_MyDataSets_WADMyDataSets_PT1M_XTableWadAccount from 20 to 40 seconds to introduce randomness to the upload schedule
Later on:
Starting scheduled task MyDataSetsQuery_MyDataSets_WADMyDataSets_PT1M_XTableWadAccount from 2015-05-13T01:43:00.000Z to 2015-05-13T01:44:00.000Z; query delay 40 seconds
Table C:\Users\Caleb\AppData\Local\dftmp\Resources\b316f531-f673-4db3-ac1c-e4649e289871\WAD0104\Tables\MyDataSets does not exist
Ending scheduled task MyDataSetsQuery_MyDataSets_WADMyDataSets_PT1M_XTableWadAccount from 2015-05-13T01:43:00.000Z to 2015-05-13T01:44:00.000Z in 1ms
Update
The EventSource in question had one event on it:
[Event(1)]
public void DataSetLoaded(string traceActivityId, string userId, string reportCode, long timeToLoadMs)
Removing the fourth parameter "timeToLoadMs" resulted in the WAD event table showing up as expected. I tried changing the last parameter to a string, and it failed to show up again. Is there a documented limit on the number of parameters for an event method? I'm pretty sure I've seen samples that have four parameters.
I upgraded my web project to .NET 4.5.1 and now the WAD table shows up as expected (I had been running on just .NET 4.5 before this).
It would seem that there might be a bug with having 4 parameters on an EventSource event when using .NET 4.5.0.
As a side note, with 4.5.1, I now have the System.Diagnostics.Tracing.EventSource.SetCurrentThreadActivityId method which will let me get rid of manually including the CorrelationManager.ActivityId in my event output.
https://channel9.msdn.com/Series/ConnectOn-Demand/240 video released today says full support for Azure table logging for ETW eventsources.
We are getting an error when we try to set it to a specific time every 7 days at a specific time. The doc says it is possible by using the optional [d] argument. We want to recycle every 7 days at 3 am.
http://technet.microsoft.com/en-us/library/cc754494(v=ws.10).aspx
Command :
C:\Windows\System32\inetsrv>appcmd set apppool /apppool.name: TempPool /+recycli
ng.periodicRestart.schedule.[value='7.03:00:00']
Error Message:
Application Pools
There was an error while performing this operation.
Details:
Timespan value must be between 00:00:00 and 23:59:59 seconds inclusive, with a granularity of 60 seconds
Although this question is a bit expired, but i faced it yesterday when i was writing some c# codes to manipulate an application pool programmly.
I found the sample for schedules at doc in following link which reads "adding an application pool... then set the application pool to daily recycle at 3:00 A.M.", which means we could not specify a fixed time span for recycling by add a schedule.
http://www.iis.net/configreference/system.applicationhost/applicationpools/add/recycling/periodicrestart/schedule/add#006
That's why it throws the exception to ask a time span under 23:59:59.
When you want specify a fixed time span for recycling, you should use time property from periodicRestart level.
See this doc for samples for various ways to target your requirement.
http://www.iis.net/configreference/system.applicationhost/applicationpools/add/recycling/periodicrestart#005
// add schedule to recycle at 3 am every day
appPool.Recycling.PeriodicRestart.Schedule.Clear();
appPool.Recycling.PeriodicRestart.Schedule.Add(new TimeSpan(3, 0, 0));
// set to recycle every 3 hours
appPool.Recycling.PeriodicRestart.Time = new TimeSpan(3, 0, 0);
Have been working on a two-player turn based game that uses a custom UI for match management. Considering restricting the app to iOS 6+ in order to use player timeouts. I would like to show the user the remaining amount of time to move, but the participant.timeoutDate is always null? Per the WWDC 2012 video (that says the timeout won't apply to the last participant in nextParticipants), I pass an array with two entries (opponent at index 0 and local player at index 1) when calling endTurnWithNextParticipants:turnTimeout:matchData:completionHandler: to take a turn. I've tried both GKTurnTimeoutDefault and various integer literals ... no luck ... always seems to be null. The player's last turn date works fine.
On the subject of player timeouts ... after I get them working, how is this delivered? I see GKTurnBasedMatchOutcomeTimeExpired ... does this come in a turn event?
From Apple's developer forum
Elian Gidoni -
+1
The doc should be:
timeoutDate
The date and time when the participant’s turn timed out. (read-only)