Last Good Quote: Son's are the seasoning on our lives. - Someone on Facebook

Showing posts with label Logi. Show all posts
Showing posts with label Logi. Show all posts

Saturday, April 26

LogiAnalytics - 5 Steps to Masking Your Connection String

Hi All,

I was recently asked if there was a way to mask your connection string in Logi Studio. I thought I'd jot down some notes.


My thinking was why not put the connection string in a DLL. That will make it a bit harder for folks to find. Not exactly 128 bit encryption but each step helps. So that means I need a plugin that populates the connection string element in the Settings.xml file BEFORE the Logi report is processed.

This should be pretty straight forward.

First: There is an excellent plugin example already available on Dev-Net. But it reads from a text file which is still not masked. (Take a look)

Step 1: Fire up Visual Studio and create a new Class Library project

Step 2: Add a reference to Logi's DLL.

  • Project Properties
  • References
  • Add
  • Browse
  • In your web root folder is a "bin" folder, in there is a file called rdPlugin.dll, add that
  • Click the just added reference and in the Properties of it, set Copy Local to false. (This makes sure we don't overwrite the existing dll file when we deploy, this is imporant, do not skip)
I then used this code, it's fairly straight forward, if that doesn't makes sense to you, you probably shouldn't be going this route.

BTW: Do both of us a favor and check that your connection string is correct by putting it in a normal connection element in the Settings file.
Imports System.Xml
Imports System.Web
Imports System.IO
Public Class LogiPlugin
    Public Sub setConnectionString(ByRef rdObjects As rdPlugin.rdServerObjects)
        Dim sConnID As String = rdObjects.PluginParameters("ConnID")
        Dim xmlSettings As New XmlDocument()
        xmlSettings.LoadXml(rdObjects.CurrentDefinition)
        'locate your connection element from it's ID (this is passed in from the variable)
        Dim eleConn As XmlElement = xmlSettings.SelectSingleNode("//*[@ID='" & sConnID & "']")
        Dim sConnection As String = "Server=OneWickedMachine;Database=NorthWind;User Id=sa;Password=ucannothave;"
        eleConn.SetAttribute("ConnectionString", sConnection)
        rdObjects.CurrentDefinition = xmlSettings.OuterXml
    End Sub

End Class

Step 3: Deploy to the file

There are multiple ways to do this, the most stright forward...but not so formal approach

  • Build your project.
  • Browse to the Debug/Bin folder of your VS project
  • Copy the SetConnection.dll to the wwwroot/YourSite/bin folder

Step 4: Call Plugin in Studio

Open up Logi Studio and alter the Settings file

Add a Connection Element, but place "NA" in all the required attributes.

Add a Plugin element

  • Assembly Name: ..\bin\SetConnection.dll (referencial path, so you can deploy on Dev, QA and Prod
  • Class Type Name: SetConnection.LogiPlugin.LogiPlugin
  • Event: Load Definition
  • Method: setConnectionString
Add a Plugin Parameter call and ConnID = NorthWind (or your database)

Step 5: Test it!

You should be good to go from this point.

Suggestion: If you have multiple environments (Dev/QA/Prod), I would add an additional parameter for which connection string to use. This can be done within the vb file and should be pretty straight forward.

Monday, September 16

Logi Analytics - jQuery Auto-complete


This would be the third time I've been asked to incorporate some type of auto-complete function using jQuery and Logi elements.

Here is my cheat sheet:

1. First create a report that returns the results you want in your auto-complete drop down:
  • @Request.q~ will have what the user typed
  • Keep it simple and quick as this will impact response times
  • A single data layer and data table is typically enough
2. Include the jquery script files, I've not had a lot of issues with versioning, so anything over 9 should be fine.
  • http://code.jquery.com/jquery-1.9.1.js
  • http://code.jquery.com/ui/1.10.3/jquery-ui.js

3. Add a user input element with an ID of inptSearchText

4. Add the following script in a script tag, typically at the bottom of the page:


$(document).ready(function(){

  $("#iptAutoComplete").autocomplete({
minLength: 2,                       
delimiter: /(,|;)\s*/, // regex or character 
source:  function(request, response) 
{
                                    var matches = null;
var data = null;
                                    if(data != null )
{
                                          matches = $.map(data, function(tag) {                                         
                                                if ( tag.value.match(new RegExp("^" +request.term, "i"))){
                                                return tag;
                                                }
                                    });   
                                          response(matches);
                                    }

if (matches == null || matches.length == 0){
                                          $.ajax({
                                                      url: 'rdPage.aspx',
                                                      data: {rdReport:"jQuery.search",rdReportFormat:"DataLayerXml", q:request.term },
                                                      dataType: 'xml',
                                                      success: function( xmlResponse ) {
                                                            data = $( "dtSearchResults", xmlResponse ).map(
                                                                        function() {
                                                                              return {
                                                                                    value: $(this).attr("FORMATTED_NAME"),
                                                                                    id: $(this).attr("EMP_ID")
                                                                              };
                                                                        });
                                                                  response(data.slice(0, 10));   
                                                            }
                                          })
                                    }
                              },
select: function(event, ui)
{ 
alert("you have selected " + ui.item.value + " (" + ui.item.id + ")");
        }
});

});


5. Modify the following:




  • "jQuery.search" - replace with the name of the report from step 1
  • FORMATTED_NAME needs to be your displayed value from prior table
  • EMP_ID needs to be the id you want triggered with the specific data set
  • minLength:2 - Set this to the number of characters the user types before triggering the AJAX call
  • alert(....) - Call your own javascript function or re-direction after selection. Typically you would store the ID in some hidden variable for future usage.


Followers