owenG
home learn tableau about
divider
legalific swsom swsom diagram swapps ahk ue








swsom wrapper
[Overview] Application - CurrentNote DB - Notes ocrBase - OpenTranscripts Permission - Views
 
Download :: Diagram
swsom wrapper

Application

The most notable aspect of the Application object is that it has been moved from being the parent object and is now presented as being a sibling to the other major objects. This was done primarily so that the Intellisense didn't look crowded at the root level. The result is that instead of using sw.AppDir in order to get the application directory, the code would be:

C#
    string appDir = sw.Application.AppDir;


The .HtmlDialog in Application is an example of an intrinsic that needed to be re-written with overloaded variants. If this method were called in VBScript, without the Optional params

VBScript
    Call HtmlDialog("www.yahoo.com")

the resulting window will have 'CT Summation Blaze LG' or something appropriately similar as the caption. In the .Net wrapper the method was originally (v1.0) written as

VB   swsom v1.0
    Public Shared Function HtmlDialog(ByVal pszUrl As String, 
            Optional ByVal pszCaption As String = "", Optional ByVal pszFloatPos As String = "", 
            Optional ByVal pszFloatSize As String = "") As Object
        Return sw.swObj.HtmlDialog(pszUrl, pszCaption, pszFloatPos, pszFloatSize)
    End Function

where the Optional parameters are required to have a default value in VB. Therefore the method could be called in VB using same syntax as in VBScript

VB
    Application.HtmlDialog("www.yahoo.com")

but there would be no caption on the resulting window, since it would have been set to the default empty string value. On the other hand, C# (.Net v3.5 and earlier) doesn't allow for optional parameters, so each param would need to be populated by the programmer:

C#
    sw.Application.HtmlDialog("www.yahoo.com", "CT Summation", "100, 100", "500, 500");

thereby disallowing access to the default caption. Not a big deal for this particular intrinsic but there would be others for which this use of the Optional keyword could cause problems. With the method overloading present in v1.1, there is now one .HtmlDialog that requires only the url and in turn passes only that param to Summation. Then a second .HtmlDialog takes a url param + caption param, and only pass those on to Summation. Likewise, a 3rd and 4th variation cover the last two Optional parameters.

VB   swsom v1.1
    Public Shared Function HtmlDialog(ByVal pszUrl As String) As Object
        Return sw.swObj.HtmlDialog(pszUrl)
    End Function

    Public Shared Function HtmlDialog(ByVal pszUrl As String, ByVal pszCaption As String)
            As Object
        Return sw.swObj.HtmlDialog(pszUrl, pszCaption)
    End Function

    Public Shared Function HtmlDialog(ByVal pszUrl As String, ByVal pszCaption As String, 
            ByVal pszFloatPos As String) As Object
        Return sw.swObj.HtmlDialog(pszUrl, pszCaption, pszFloatPos)
    End Function

    Public Shared Function HtmlDialog(ByVal pszUrl As String, ByVal pszCaption As String, 
            ByVal pszFloatPos As String, ByVal pszFloatSize As String) As Object
        Return sw.swObj.HtmlDialog(pszUrl, pszCaption, pszFloatPos, pszFloatSize)
    End Function

CaseOrg

The CaseOrg implementation is fairly straightforward but the below illustrates how a parameterized Property is supported in VB but is prepended by the _get and _set accessors in C#. In this example, the first tab in the CaseOrganizer is set as the active tab, followed by the first line (.Text) being retrieved and appended to. Then .Text is set to the new value and a message box shows the before and after:

VB
    Dim origCaseOrgText, currCaseOrgText As String
    sw.CaseOrg.Tab = "1"
    origCaseOrgText = sw.CaseOrg.Text(1)
    sw.CaseOrg.Text(1) = origCaseOrgText & " Modified"
    sw.CaseOrg.Save()
    currCaseOrgText = sw.CaseOrg.Text(1)
    MessageBox.Show(vbTab & "original .Text:" & vbCrLf & origCaseOrgText & vbCrLf & vbTab & 
        "new .Text:" & vbCrLf & currCaseOrgText)

in C#, with .get_Text and .set_Text accessor methods:

C#
    sw.CaseOrg.Tab = "1";
    string origCaseOrgText = sw.CaseOrg.get_Text(1);
    sw.CaseOrg.set_Text(1, origCaseOrgText + " Modified");
    sw.CaseOrg.Save();
    string  currCaseOrgText = sw.CaseOrg.get_Text(1);
    MessageBox.Show(String.Format("\toriginal .Text:\r\n{0}\r\n\tnew .Text:\r\n{1}", 
        origCaseOrgText, currCaseOrgText));

CurrentCase

Some cleanup on the auto-generated methods, .Customize was in sumscript.xml but appears to have been replaced by .ShowCustomizeDlg and .SetSearchString listed in orig. documentation should really be .SetSearch. All of the properties in the base CurrentCase object are ReadOnly, below will display some of the case details for the currently open case:

C#
    string caseName = sw.CurrentCase.Name;
    string caseDir = sw.CurrentCase.CaseDir;
    string tranDir = sw.CurrentCase.TranscriptDir;
    string noteFileName = sw.CurrentCase.NotePath;
    string dbName = sw.CurrentCase.CoreDBPath;
    MessageBox.Show(String.Format("CASE DETAILS\r\nCase Name: {0}\r\nCase Directory: {1}\r\n
        Transcript Dir: {2}\r\nNote File Name: {3}\r\nDatabase Name: {4}", caseName, caseDir, 
        tranDir, noteFileName, dbName));   

CurrentCase.Explorer

Most properties are read-only, though a few like .GetScriptFolder took parameters and were instead re-written as functions - since they weren't settable, might as well avoid the get_ & set_ in C#. In fact it looks like most of these should be implemented as functions in the future. The below looks for an existing Scripts folder item in the Shared section of the Case Explorer and if necessary, creates one under ocrBase. Then the AutoFillEnddoc script is added as a separate item under the Scripts folder:

VB
    Dim isShared As Boolean = True
    Dim sharedScriptIndex, wantedSharedScriptIndex, scriptFileIndex As Integer
    sharedScriptIndex = sw.CurrentCase.Explorer.GetScriptFolder(isShared)
    If (sharedScriptIndex = -1) Then
        wantedSharedScriptIndex = sw.CurrentCase.Explorer.Find("ocrBase") + 1
        sharedScriptIndex = sw.CurrentCase.Explorer.AddScriptFolder(wantedSharedScriptIndex)
    End If
    If (sharedScriptIndex > 0) Then
        scriptFileIndex = sw.CurrentCase.Explorer.AddScript(sharedScriptIndex + 1, "AutoFillEnddoc", 
            sw.Application.AppSharedProfile & "Script\AutoFillEnddoc.vs")
        If (scriptFileIndex = 0) Then
            MessageBox.Show("Error adding script item")
        End If
    Else
        MessageBox.Show("Error adding Scripts folder")
    End If

CurrentCase.Items*
* containing class renamed from orig 'Item' to plural Items so that parent Explorer could contain Default Property for Item while still supporting the nested class structure

Items is present as an Instance class, with Item the Default Property of the Explorer class. The .Check method has been re-written as a parameterless Sub because it does not appear to support a boolean param as indicated in the API documentation (.CheckChildren does work as-described). Example shows two different ways of working with Item(s), where the first expands the Transcripts node while the second collapses it:

C#
    sw.CurrentCase.Explorer itmTran = new sw.CurrentCase.Explorer(); 
    string id = itmTran["Transcripts"].Name; 
    bool includingChildren = true; 
    int childCount = itmTran["Transcripts"].ChildCount(includingChildren); 
    bool isExpanded = true; 
    itmTran["Transcripts"].Expand(isExpanded);
or
C#
    long tranIndex = sw.CurrentCase.Explorer.Find("Transcripts"); 
    //or could have simply passed "Transcripts" string directly intead of the tranIndex.ToString()
    sw.CurrentCase.Explorer.Items itemTran = new sw.CurrentCase.Explorer.Items(tranIndex.ToString());  
    string desc = itemTran.Descrip; 
    isExpanded = false; 
    itemTran.Expand(isExpanded);

CurrentNote

Most of the properties here had two forms of syntax in VBScript, where something like .Docid could be accessed by either 'Docid(docidString) as Empty' or 'Docid() as String' syntax. The latter form was favored (and the former ignored) in the wrapper, allowing all to be written as true Properties. Also, looks like .BOF and .EOF aren't working in the native VBScript, maybe I'm missing something - it only takes one or two endless loops to discourage further testing. Example moves to first Note in Note recordset, gets the current values in Issues and then appends a new value/issue at the end. Then it goes back and displays the final issue, which should be the newly added one:

VB
    Dim issues, lastIssue As String 
    sw.CurrentNote.MoveFirst() 
    issues = sw.CurrentNote.Issues 
    sw.CurrentNote.Issues = issues & Chr(254) & "my new issue" 
    sw.CurrentNote.Update() 
    lastIssue = sw.CurrentNote.GetNthIssue(sw.CurrentNote.IssueCount) 
    MessageBox.Show(lastIssue)