Friday, 28 August 2015

Delay between submitting and receiving data from Siebel

I am having a problem with a history table not displaying new data being submitted. The data appears in the table ~10 minutes after submission. Using Siebel for data management.

At first I thought there was a caching issue on my end; either not refreshing the cache after submitting new data, or refreshing faster than it was taking for the system to register there was new data.

Upon further testing (get history data, submit new request data, get history data again) and logs, identified that the cache was indeed being refreshed, however the data being returned from Siebel was not up to date with the new entry.

Options:
  1. Disable caching entirely on the history calls (bad performance)
  2. Set a static cache refresh for an amount of time that they expect the new request to be included in history (still need the user to refresh the page after that amount of time)
Neither options are good. Either the whole process is slowed on purpose by X seconds, or stays fast but without the newly submitted data.

I decided to test how long it is between submitting the data and retrieving the history with the new data using sleep(). I incrementally tested times, staring from 2000ms (2 seconds) to 300000ms (5 minutes). After 5 minutes Siebel was still returning the history list without the newly submitted data.

That means there is not much point disabling caching since it won't make a difference over that extended amount of time, where our caching refresh is 10 minutes.

Not sure why Siebel has such a long delay between receiving data and having it available, it's something I will have to look in to.

***

Upon further investigation it appears the newly created submission actually does appear in the history list. Apparently Siebel is only returning the most recent 25 entries, however I was calculating whether the data had been submitted based on count (assuming the max number would increase with a new entry). Because the full history list isn't returned, it is necessary to look for the specific entry instead of relying on count.

Therefore it looks to be a caching issue after all. Looking into the controller to see if a databind refresh is possible after submission of the new entry.

***

Solution:

Implemented cache expiry functionality to invalidate all previous search results after submitting a new entry.

Tuesday, 25 August 2015

AngularJS ng-cloak flickering

I was having a problem when using ng-cloak/ng-show, where there were unwanted elements flickering on the page and then disappearing.

Example:

The error message was flickering briefly before disappearing when it shouldn't have been appearing at all. It is occurring between when the view is first loaded and before Angular has initialized.

Adding a rule to CSS can stop the flickering:

Monday, 24 August 2015

Restoring databases

To keep up to date on the project I am working on, I am required to manually update my local database to new versions.

Steps I take restore the database:
  1. Copy new .bak file to accessible location
  2. Open Microsoft SQL Server Management Studio
  3. Connect
  4. Right click "Databases"
  5. Click "Restore Database..."
  6. Select "Device"
  7. Click "..."
  8. Select "Add" in the pop up box
  9. Locate and select new .bak file, click "OK"
  10. Make sure new backup is selected and click "OK"

    If this error occurs:
  11. Open IIS (Internet Information Services Manager)
  12. Under Actions->Manage Server click "Stop"
  13. Reselect new database backup in SQL and click "OK"
  14. Press "Start" in IIS to restart server

    And then because I am using Sitecore, the updated master has to be published to web for me to be able to see the changes:
  15. Open Sitecore instance
  16. Click "Publish" tab
  17. Click "Publish" drop down arrow
  18. Select "Publish Item"
  19. "Smart publish" and then "Publish >"

AngularJS $scope

I am learning AngularJS as part of the project I am working on.

One problem I was having was not binding my values to $scope, which is necessary otherwise Angular doesn't retain the information. Without the correct binding, my console logs were printing the correct value but the wrong data was being displayed on my .ascx.

Example:

This does not set the IsAuthorised bool such that it will retain the value. The correct way is:

Automated GulpJS file sync

Currently, to deploy front end files to the local website either Sublime has to be used to file sync, or manual Ctrl-A|Ctrl-C from Source to Website is another option.

Gulp can be used to automate file synchronisation. It monitors all front-end files (css, js, aspx, ascx, html) in the DEV directory, and synchronises the file into the (IIS) Websites directory on save of the file.

This means that upon editing these files in Visual Studio and saving (Ctrl-S), the file will automatically deploy to the local website.

Instructions:

  1. Create gulpfile.js to do the syncing in the project root directory
  2. Create install_gulp.bat in <root directory>/tools to install Gulp and all its dependencies
  3. Install Node.js (https://nodejs.org/)
  4. In an elevated command prompt, cd into the <project root>\tools directory
  5. Run install_gulp.bat
  6. cd.. to the root directory
  7. Enter gulp into the cmd prompt to run it

Gulp will need to be running (repeat step 7) to continue to monitor and sync files, This can be done by either creating a script or adding a task to the task scheduler.