coldfusion query in session problems - coldfusion

Using Coldfusion 8, Coldbox 2.6.3.
Storing query object in session. Session is set asynchronously and attempted to be read from 'instantly' in a popup window to generate excel sheet/csv. Initial error of garbage data in the generated file fixed with 'cflock' on setting/reading session code chunks(session scope). Same session var is set in multiple places to different queries. New error is that the session var is just set to the previous query it was set to and not the one it should be set to. After waiting a few seconds and doing a refresh, session var has correct query.
A Coldfusion exception is generated in CF debugging that a certain query column is not defined - the column names being hardcoded to read from the query in session - which just means that the session var has the wrong query which I confirmed to be the previous query using cfdump.
I wonder why cflock would fix the garbage data problem but not this problem.
Thanks.

Related

Coldfusion session variables usage

I have few doubts on coldfusion session scope variables usage.
I am using Jquery calendar to show the daily/scheduled events per monthly basis. The event detail rows(json records) are saved in cfm array variable, when user click on next/previous month it is going to make an ajax call and will be getting a new cfm array variable with required event records. Initially I tried to store the previous search events array in browser localstorage but unable to do it properly as the size of array exceeds 8MB and the browser limit should be below 5MB(in chrome, it varies based on browsers), even though using compress technique also having issues in IE browser, finally I want to save the last 6 cfm arrays(earlier search events data) in session scope and at the time of saving 7th array I deleted the first events array. Please suggest whether we can proceed this or is there any other scope like client rather than session scope. I am working in coldfusion 9 environment.

How to use real database in Power BI and make it refresh dynamicaly?

I'm new to Power BI (Free Version) and I have been asked to develop a report system which generates report from an excel sheet, the reports work good for only the data I have collected.
but my question is how to connect to the data immediately from SQL server without the need to convert it to excel and then import it in power BI, I also want the data to be refreshed dynamically.
One of the solutions I tried is to add new dataset but I get the following message:
Refresh can't be scheduled because the data set doesn't contain any
data model connections, or is a worksheet or linked table. To schedule
refresh, the data must be loaded into the data model.
I have looked for many solutions but none has worked.
am I missing a concept? thank you
If this data is stored in a SQL SERVER table it is a pretty straight forward process.
When you create a new power bi report (.Pbix) you should see a prompt asking you if you want to "Get Data". You would select the 'SQL Server Database' option - See the image below:
Then, you will be asked to enter the Server and Database name, and to specify either 'Import' or 'Direct Query' mode. If you choose 'Import' the data will be refreshed every time you access the report or upon 'Refresh' within a report session. If you choose the latter, the connection will always be live i.e. any changes to the data in your database will be reflected in the report.
Once you get passed this window, you will be asked to either specify credentials or use a windows authentication to access the database and server. After that you can either specify a query to pull in some data or you can select from a list of tables.
I hope this helps!!

Microsoft Sync Framework and Aggregate Functions

I'm currently trying to implement Microsoft Sync Framework for field agents that will be working mostly disconnected from the server.
Currently I have a SQL Express database the application points to for offline mode and when they are back online, They can hit a sync button to push the changes up and down.
I have no problems creating the filtered scope, But our schema uses a "VersionID" column to handle historical data.
No data is deleted from the databases, so when a row is "updated" a new row is inserted with max(VersionID) + 1 as its new versionID.
Since I can't use aggregate functions in a filtered scope, I can't figure out how to retrieve the max version only for each unique row.
I only need to retrieve the max(versionID) record because of the 10GB limit for the database, I can't possibly download all records without going over the limit with all the support tables the application requires.
Any ideas?
the scope filter is simply appended to the _selectchanges SP's WHERE clause. If you can put your condition in a simple query, you should be able to set the same as the scope filter.

Is there a "ThisVisit" timestamp in ColdFusion?

Coldfusion has a system created client variable called lastvisit.
Is there a way to get the value of that variable during the request that it is actually set (i.e. client.thisvisit)?
The idea would be that I can store the "ThisVisit" timestamp in session and then compare it to lastvisit when the next request is made. This would tell me if another request was made in the session.
The purpose is that we have a page that we use an ajax record lock on which refreshes the lock every minute. After sixty minutes the ajax lock code will automatically log the user out of the website (due to inactivity). The issue arises where the user is executing tasks in other windows/tabs (indication of activity).
Sense all requests update LastVisit, I would like to have the ajax lock code save the save a "thisvisit" value so that the next time it runs it can compare it to the LastVisit client variable.
A couple requirements:
Set up to use a DB rather than registry for your client vars (trust
me).
Client vars have to have "global variables" enabled
Your cfapplication or application.cfc has to have client management enabled.
If you have those three things you can select a query like the following:
<cfquery name="getLvisit" datasource="myClientVarsDB">
SELECT lvist
FROM cglobal
WHERE cfid =
<cfqueryparam type="CF_SQL_CHAR" value="#urltoken#"/>
</cfquery>
urltoken might be wrong... it may need the jsessionID or CFID but my memory tells me cftoken. I'd have to hunt down a site using Client DBs to give you a definitive answer.
So that would give you the current value of the lvisit variable. you would store this in the session and then compare it against the value from the table on subsequent queries before you overwrite it again (if that makes sense).
Note - this value is updated on each request - so your query get's the current value (before it has been updated). I previously thought this it was updated first but according to Tom it's actually updated last.

Keep value state in apex page

Does anyone know to keep the state in an apex page when I go to another page and return?. It doesn't keep the values entered in the fields, it appears all empty. I appreciate anyone can help. Thanks
What is your ApEx version ?
By default, when you submit a page, item values are automatically set in session state, so you should find them again when you go back to the page.
Be aware that Firefox retain form element values on page refresh, so displayed values may not correspond to values that are really in session state... A solution is to set the «Form Auto Complete» attribute to "Off" in your page security attributes, or use $('#wwvFlowForm').attr('autocomplete','off'); on page load.
If you want to set a value into session state manually without submitting the page :
from PL/SQL, you can use APEX_UTIL.SET_SESSION_STATE (see documentation)
from JavaScript, you have to call a dummy application process, like :
setItemInSessionState: function(p_item, p_value) {
var l_get = new htmldb_Get(null,$('#pFlowId').val(),'APPLICATION_PROCESS=dummy',0);
l_get.add(p_item, p_value);
l_get.get();
}
Finally you can choose to maintain session state per session, or for a user across sessions, by changing «Maintain session state» attribute in the source tab of your item. And if your data is sensitive, you can set «Session State Protection» attribute to "Yes" for your item.
There are a lot of other solutions to keep item values between pages : passing values in the URL into hidden items, apex collections, basic database storage, cookies, etc.
If this does not answer your question, you might give more details.
Maybe you should use session in order to save the inputs and then when the client returns to that page, you will just put the data you have stored in the sessions.