>>Message imported from previous forum - Category:Scripts and Tips<< User: mchartrand, originally posted: 2018-10-25 18:38:43 Id:268 This is a re-posting from the obsoleted (October 2018) "Schneider Electric Telemetry & SCADA" forum.
**_NIWTelemetry: Hello Everyone, Looking for a bit of help if possible. I am looking for a method to record and log the frequency of end users accessing a given mimic configured on our ClearSCADA database. This would be something like a 'hit rate' on a website - only I need to record which user accessed the mimic. Grateful for any assistance._**
geoffpatton: You could user a vbscript and the Mimic_Load function to to get the current user name and time then write to a Data table or data grid.
I have used scripts to write to data grids but it has been a while and I forget exactly what I did.
**_NIWTelemetry: Hi Thank you very much. I thought about VB script - Just wondering if anybody has done this or something similar I could perhaps try?_**
bevanweiss: As Geoff said, there's no native inbuilt way to do this.
But, you could code something up with scripting. You'd want to have something in the back end that the mimic script could write to (like a DataGrid / DataTable), and then on the Mimic_Load function get the username, the mimic fullname and the datetime and write it into the DataTable.
You could then query for this information elsewhere.
I doubt that anyone will have ready to go code for this however, since it wouldn't be commonly requested. It shouldn't be complicated to code up however.
**_NIWTelemetry: Hi Yes indeed I have thought about this as a solution. My only problem is I'm not great with VB and would like a bit of a pointer with some code examples I could play about with to extract the current user / date time during the mimic on load event and populate a datagrid or table. I assume that I firstly need to create a path to the data grid / table in the script , declare variables for the user and datetime then execute a method to write data then close the scrip. I am more confident with ST and FBD Logic - but am a newbie to VB as I never really had a reason to use it. Just wondering if anybody can help get me started. Thanks in advance._**
bevanweiss: The help is quite good with the various properties and methods available for scripting, and it's the VBScript engine, so google is helpful for the syntax and programming concepts.
What you probably want is..
_Mimic.FullName Server.UserName VBScript to get DateTime_
and then a proper combination of this stuff in the Mimic_Load/Mimic_Navigate method for each mimic you want to track.
You will definitely want to check the help for the Mimic_Load/Navigate, since there are limitations on both which make this script non-ideal.
Can I ask why you want to track user accesses to mimics?
**_NIWTelemetry: Hi I created a table and used the following code to dump values into._**
_Dim SqlResult Dim User Dim SQL Dim CurrentDTString User = Server.UserName CurrentDTString = CStr(DatePart("yyyy",Date)) + "-" + Right("0" & DatePart("m",Date), 2) + "-" + Right("0" & DatePart("d",Date), 2) + " " + CStr(Time) SQL = "INSERT INTO MimicTable VALUES ('" + User + "', " + "timestamp'" + CurrentDTString + "')" Msgbox SQL, vbOKOnly, "Query" Set SqlResult = Server.Query(SQL) If SqlResult.Error Then Msgbox SqlResult.ErrorMessage, vbCritical + vbOKOnly, "Error in SQL Command" End If_
**_Working ok now!_**
**_NIWTelemetry: We want to track user access to key dashboard mimics as it involves a great deal of effort by us to endure the dashboard is kept up to date. We want to have a metric of user hits to see if it is worthwile._**
bevanweiss: What format do the dashboards have that takes such effort?
Highly graphical items have been shown (by studies) to have limited benefit in presenting data. It would also go against ASM guidelines if there is too much detail in the dashboards.
Things like site deviations is what we normally present, and this is generally just a big animated table (from a Data Set, and Data Set Rows in each instance to aggregate the data). If the data is good, then black text on white background, if it's bad (like a significant pump run / starts deviation), then make things a different colour (like a red shading on the background).
Good work on your script 🙂 The only change that I'd make is to just use the SQL CURRENT_TIMESTAMP instead of using the VBscript to get the date and time. You also don't appear to be logging the Mimic itself, do you only have one mimic that you're wanting to log records for?
du5tin: I have a client who is asking similar questions. We built a set of easy to use ViewX graphics but we do not believe operators are making use of the functionality. They want to track ClearSCADA use in order to drive further improvements, kind of like web site stats.
It occurs to me as I write I could just try it, but if you put the mimic_load subroutine into a script library will it be called from a mimic that references the library?