Subpage Listing |
QBO 3 Blog
AWS and TinyProxy
AWS EC2 instances can be used as proxy servers. To start a proxy server:
From the EC2 Security Groups panel:
From the EC2 Instances panel:
Configuration of the TinyProxy image was based on the following references.
Issues:
|
SQL Constraints CHECK, NOCHECK, WITH CHECK, WITH NOCHECK
From a 2015 email... I was researching disabling constraints and came across the posts below, which lead me to an OH MY moment. http://geekswithblogs.net/dturner/archive/2011/01/31/sql-constraints-check-and-nocheck.aspx http://sqlblog.com/blogs/hugo_kornelis/archive/2007/03/29/can-you-trust-your-constraints.aspx http://sqlwithmanoj.com/2012/03/14/nocheck-vs-with-nocheck-while-creating-disabled-foreign-key-fk-constraint/ https://msdn.microsoft.com/en-us/library/ms190273(v=sql.105).aspx To summarize, constraint parameters "NOCHECK" and "WITH NOCHECK" are two different things, as are their brethren "CHECK" and "WITH CHECK" "WITH CHECK" and "WITH NOCHECK" determine if the constraint will be enforced on existing rows at the time of constraint is created or modified. "CHECK" and "NOCHECK" determine if the constraint is enabled or disabled. Microsoft should have just named these parameters ENABLE and DISABLED You can't create a disabled constraint with "NOCHECK", but it can be disabled after creation by using "NOCHECK" So what is the problem? When a constraint is modified or created using "WITH NOCHECK" the SQL optimizer ignores the constraint which can result in table scans. From the MS library... The query optimizer does not consider constraints that are defined WITH NOCHECK. Such constraints are ignored until they are re-enabled by using ALTER TABLE <table> WITH CHECK CHECK CONSTRAINT ALL. Ouch !! The queries below will list un-trusted constraints where "WITH NOCHECK" should probably be removed SELECT * from sys.check_constraints WHERE is_not_trusted = 1 SELECT * from sys.foreign_keys WHERE is_not_trusted = 1 If the number of un-trusted foreign keys is extremely high then the performance impact has to be considered. The command below will do an alter table on all tables and constraints to issue a WITH CHECK CHECK. It will enable the constraint and force a check of all rows. exec sp_MSforeachtable 'ALTER TABLE ? WITH CHECK CHECK CONSTRAINT ALL' This would be fine to run on an empty DB, but a little scary to run on a large DB. It would be better to check the constraints first via executing the output of the below - again be aware that on large DBs this may take a while exec sp_MSforeachtable @command1="PRINT '?'; DBCC CHECKCONSTRAINTS ([?]) |
Publishing Data-Tier Components
Quandis uses a Microsoft Visual Studio SQL Project (.sqlproj) file to manage data tier components. |
Attachment/UploadChunk on a server farm
The Attachment/UploadChunk method supports efficient upload of files using HTML5 features. In a load-balanced server farm without sticky sessions, this method must ensure that chunks of a file received by different servers are appended to the same physical file. To ensure this, the UploadChunk method must leverage a FileObject that implements an Append method. As of the time of this post, the only standard FileObject that supports Append is UNCFile .UploadChunk will work as follows:
Once all the chunks have been appended to the scratchpad file, the application will call Attachment/Queue/MoveFile to move the file from the scratchpad to a 'final' repository (typically S3). Note that we queue this move, instead of executing it, so the user does not need to wait for a large files to be moved between repositories. A very large file move may result in an HTTP timeout. If the file is accessed before the move happens, it is simply read from the scratchpad file object, as opposed to the 'final' repository. |
Migrating State Transitions from Roles to Permissions
Early version of the ObjectState table included RoleRequired, enabling a power user to determine which role was required to effect a state transition. This has been deprecated in favor of PermissionRequired, enabling a power use to grant a permissions to a specific transition to multiple roles. To migrate from one to the other, run the query below. It will:
DECLARE @T TABLE (ID int, RoleRequired nvarchar(50), Permission nvarchar(50)) INSERT INTO @T SELECT ObjectStateID, RoleRequired, REPLACE( REPLACE( REPLACE(LEFT(ImportFormTEmplate, 50-LEN(ISNULL(LEFT(StatusFrom,15), 'None'))-LEN(ISNULL(LEFT(StatusTo,15), 'None'))) + ISNULL(LEFT(StatusFrom, 15), 'None') + 'To' + ISNULL(LEFT(StatusTo,15), 'None'), ' ', ''), '/', '' ), '-', '' ) FROM ObjectState INNER JOIN ImportFormTemplate ON ImportFormTemplateID = ObjectState.TemplateID WHERE RoleREquired IS NOT NULL AND PermissionRequired IS NULL SELECT * FROM @T INSERT INTO SystemFunction (SystemFunction) SELECT Permission FROM @T AS T WHERE NOT EXISTS ( SELECT 1 FROM SystemFunction WHERE SystemFunction = Permission ) -- -- INSERT INTO SystemPermission (SystemRoleID, SystemFunctionID, UpdatedPersonID, UpdatedDate) SELECT SystemRole.SystemRoleID, SystemFunction.SystemFunctionID, 1, GETDATE() FROM @T AS T INNER JOIN SystemRole ON SystemRole.SystemRole = T.RoleREquired LEFT OUTER JOIN SystemFunction ON SystemFunction.SystemFunction = T.Permission WHERE NOT EXISTS ( SELECT 1 FROM SystemPermission WHERE SystemRoleID = SystemRole.SystemRoleID AND SystemFunctionID = SystemFunction.SystemFunctionID ) UPDATE ObjectState SET PermissionRequired = Permission FROM @T AS T INNER JOIN OBjectState ON ObjectSTateID= T.ID |
AWS Load Balancer and SSL Updates
Over the past year, a flurry of SSL vulnerabilities have been announced. Fortunately, the AWS team does a good job keeping up with these on our behalf. To update an AWS load balancer to meeting up-to-date SSL requirements: 1. Navigate to the load balancer, and select the Listeners tab: |
QBO3: Publishing Configuration Between Sites
If you have multiple environments (DEV, UAT, PROD, etc.) You can publish configuration data between the different sites. One time setup for the target system:
One time setup for the source system:
Publishing from the source system:
|
RESTHooks
This blog post is intended to be a working draft to discuss the implementation of RESTHooks in QBO3. Sample use cases include:
Provide RESTHook callback parameters:
RESTHook actions:
RESTHook payload:
What a RESTHook is NOT:
Sample Use Case: Matrix/AsyncLookupMatrix/AsyncLookup is used to bulk-process matrix calls. The body of the post is an XML document containing Matrix inputs; we probably don't want to force a third party developer to mix their RESTHook into that. Thus, we could do the following on the request: RESTHook on the query string: GET http://localhost/Application/Matrix.ashx/AsyncLookup?Matrix=ABC 123&RESTHook=smtp:someone@example.com HTTP/1.1 Host: localhost Connection: keep-alive Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 ... RESTHook in an HTTP Header: GET http://localhost/Application/Matrix.ashx/AsyncLookup?Matrix=ABC 123 HTTP/1.1 Host: localhost Connection: keep-alive Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 X-REST-Hook: smtp:someone@example.com ... In either case, en email would go out to someone@example.com with some sort of body. We might extend the queuing infrastructure to handle RESTHooks by considering them a callback. Roughly:
|
QBO3 Database Deployments
BackgroundA Visual Studio Database project 'qbo.Db' has been created in Source\qbo.3\qbo.Db. This project contains all database components required for a 'fresh' QBO 3 installation, and can be used to upgrade QBO 2 and QBO 3 systems to a current data structure. PublicationTo create a 'fresh' database:
To update an existing database, follow the instructions above, but choose an existing database instead of enter a new database name. NotesThe Visual Studio database projects are very powerful; they allow definition of file groups, extended properties, and installation of CLR modules. When publishing a database, the project will generate a schema from source code, and if you are updating an existing database, it will also generate a schema from the target database. Publication to an existing database is done by comparing the schemes, generating a change script, and running the change script against the target db. If you prefer, when you publish, you can just generate the change script and inspect that prior to running it. Creating the 'Standard' DB on TAURUS2UAT over the VPN took a little more than 7 minutes (7:12). SnapshotsProject "snapshots" create .dacpac files that can be deployed to create new or updated existing databases. A .datpac is the database equivalent to a web publication package (.zip file with all the web components). When deploying a .datpac, a tool called SqlPackage.exe will compare the .datpac schema to the target database schema, build an upgrade script, and deploy. To deploy a .dacpac directly, open a CMD or Powershell window in a folder containing SqlPackage.exe: PS C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\120> .\sqlpackage.exe /sourcefile:E:\Source\qbo.3\qbo.Db\Standard\Snapshots\Standard_20140727_15-00-49.dacpac /targetServerName:minbar /targetdatabaseName:testdb.quandis.net /variables:FileDataPath=e:\data\ /variables:FileBackupPath=e:\data\ /variables:FileBlobPath=e:\data\ /variables:FileHistoryPath=e:\data\ /variables:FileLogPath=e:\data\ /variables:FileIndexPath=e:\data\ To view prospective changes and their impact, use action:deployReport and specify an outputPath: PS C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\120> .\sqlpackage.exe /action:deployReport /outputPath:.\qboTest.Deploy.log /sourcefile:E:\Source\qbo.3\qbo.Db\Standard\Snapshots\Standard_20140727_15-00-49.dacpac /targetServerName:minbar /targetdatabaseName:testdb.quandis.net /variables:FileDataPath=e:\data\ /variables:FileBackupPath=e:\data\ /variables:FileBlobPath=e:\data\ /variables:FileHistoryPath=e:\data\ /variables:FileLogPath=e:\data\ /variables:FileIndexPath=e:\data\ Items to note:
|
Behavior: OperationSignature
Parameters from methods, services, and statements can be rendered for the user to choose from.
<i class="icon-list" data-behavior="OperationSignature" data-operationsignature-options="{{
'basemoduleid': 'MethodObject', 'baseoperationid': 'MethodOperation', 'baseparameterid': 'MethodParameters' 'moduleid': 'Object', 'operationid': 'Operation', 'parameterid': 'Parameters' 'appliesto': '{AppliesTo}' }}"/> The options passed to the behavior comprise:
Use case:
|
1-10 of 58