Overview
The Backup Case Organizer script creates a copy of the current CaseOrg folder as a method for backing up the Case Organizer and its tabs. The backup is complete copy of the CaseOrg folder, named by the current date and created in \Profiles\AllUsers\CaseOrgBkups.
Description
This script uses the Microsoft Windows FileSystem object (an object-based tool for working with files and folders) extensively. It uses the FileSystem object to check for the presence of an existing CaseOrgBkups folder within the case’s \Profiles\AllUsers directory. It also uses the FileSystem object to create the directory when absent as well as to copy the CaseOrg folder into the CaseOrgBkups folder.
Each backup folder is created by the script using the current date (sans backslashes) as the backup folder’s name. If a folder of the same name already exists the script applies a numeric (incrementing) suffix to the new folder’s name (e.g. if there already is a folder titled 021601 the backup will create one named 021601-1, if that exists then one named 021601-2 will be created, etc).
Collections / Objects / Methods / Properties
Code
sCaseOrgDir = CaseDir() & "profiles\all users\CaseOrg"
sCaseOrgBkupsDir = CaseDir() & "profiles\all users\CaseOrgBkUps"
sDate = Date
'Replaces the slashes in the date so that it
'can be used as a Folder Name
sDate = Replace(sDate, "/", "")
'Creates a new File System Object
Set fso = CreateObject("Scripting.filesystemobject")
FoldName = sDate
'If the CaseOrg folder exists for the case then it checks for the CaseOrgBkups folder
If fso.FolderExists(sCaseOrgDir) Then
'If the CaseOrgBkups exists, then it proceeds with the backing up
If fso.FolderExists(sCaseOrgBkupsDir) Then
Call CheckDup(FoldName)
Call fso.CopyFolder(sCaseOrgDir, sCaseOrgBkupsDir & "\" & NameCh, True)
'Verifies that the backup was created
If fso.FolderExists(sCaseOrgBkupsDir & "\" & NameCh) Then
msg "Case Organizer backed up."
Else
Alert "Case Organizer backup failed"
End If
'If that folder doesn't exist it is created
Else
fso.CreateFolder(sCaseOrgBkupsDir)
Call CheckDup(FoldName)
'Then the backup folder with today's date is copied into it.
Call fso.CopyFolder(sCaseOrgDir, sCaseOrgBkupsDir & "\" & NameCh, True)
'Verifies that the backup was created
If fso.FolderExists(sCaseOrgBkupsDir & "\" & NameCh) Then
msg "Case Organizer backed up."
Else
Alert "Case Organizer backup failed"
End If
End If
End If
'CheckDup is called during the above routine. It checks to see if a folder already exists
'with the backup name. If it does, then it adds a "-n" where n continues to increment
'until there is no longer a duplicate filename
Function CheckDup(FoldName)
i = 1
NameCh = FoldName
Do
DupFile = fso.FolderExists(sCaseOrgBkupsDir & "\" & NameCh)
If DupFile = True Then
i = i+1
NameCh = FoldName & "-" & i
End If
Loop While DupFile = True
End Function
Download File (zipped)
(right click on file and select 'Save Target As...')
NOTICE: This script is provided to you “As is” for use only with a valid CT Summation Enterprise or CT Summation LG family (iBlaze) license, pursuant to the terms of the license. Technical support is not provided for scripts under the CT Summation maintenance agreement or otherwise. The Limitation of Warranties and Liability provisions contained in the license accompanying the CT Summation program with which this script is run shall apply to use of this script with said program.
Overview
The Cleanup Case Organizer Backups script deletes the old backups created within the CaseOrgBkUps folder.
Description
This script uses the Microsoft Windows FileSystem object (an object-based tool for working with files and folders) extensively. It uses the FileSystem object to check for the presence of an existing CaseOrgBkups folder within the case’s \Profiles\AllUsers directory. It also uses the FileSystem object to delete the directories within the CaseOrgBkups folder created prior to a specific user specified date.
Collections / Objects / Methods / Properties
Code
CsOrgBkups = CaseDir() & "Profiles\All Users\CaseOrgBkUps"
Set fso = CreateObject("Scripting.FileSystemObject")
'If there are any backups for the Case organizer for this case, the prompt the user for a date
If fso.FolderExists(CsOrgBkups) Then
CleanDate = AskEntry("Please enter a cutoff date. All backups prior to this date will be"_
& "deleted", "Clean CaseOrgBkups Folder")
'If the user entered a date then call the CleanDirByDate function
If CleanDate<>"" And InStr(CleanDate, "/") Then
Call CleanDirByDate(CsOrgBkups, CleanDate)
Else
If CleanDate<>"" And Not InStr(CleanDate, "/") Then
msg "You must enter a valid date"
End If
End If
Else
msg "You don't have any backups of the Case Organizer to clean."
End If
Function CleanDirByDate(Dir, CleanDate)
'This function cleans out the specified Dir of subfolders that were created prior to the
'specified date
'Converts the user entered date string into a date type format
FormatDateTime(CleanDate)
Set fso = CreateObject("Scripting.FileSystemObject")
'Checks To make sure the specified Dir exists
If fso.FolderExists(Dir) Then
'If it does, create a file system object to work with the folder and its contents
Set fsoDir = fso.GetFolder(Dir)
Set Subs = fsoDir.Subfolders
'Cycle through each of the subfolder
For Each S1 in Subs
'Assign the subfoldername and the date created to variables
nm = S1.name
CheckDate = S1.DateCreated
'Assigns the date to a variable and sets the date format to be
'the same format as the user entered date string was converted to
CheckDate = FormatDateTime(CheckDate, 2)
'Gets the difference between the 2 dates,
'If the first date is more recent than the second it will assign a negative number
Diff = DateDiff("d", CleanDate, CheckDate)
'The current subfolder is not as recent as the CleanDate and is deleted
If Diff < 0 Then
fso.deletefolder(Dir & "\" & nm)
End If
Next
End If
End Function
Download File (zipped)
(right click on file and select 'Save Target As...')
NOTICE: This script is provided to you “As is” for use only with a valid CT Summation Enterprise or CT Summation LG family (iBlaze) license, pursuant to the terms of the license. Technical support is not provided for scripts under the CT Summation maintenance agreement or otherwise. The Limitation of Warranties and Liability provisions contained in the license accompanying the CT Summation program with which this script is run shall apply to use of this script with said program.
Overview
The ImageVerify script generates a report of the current case’s missing image files.
Description
This script uses Microsoft's ADO Data Control to read the current case’s Image Information table and Microsoft Windows FileSystem object (an object-based tool for working with files and folders) to detect if any listed image file is missing from the file system. The script includes extensive Image Information IMGFiles column parsing to convert CT Summation Image Information table syntax to Windows filepath. The script then uses the FileSystem object to write its findings to disk.
Collections / Objects / Methods / Properties
-
FileSystem object
- Microsoft ADO Data Control
- CT Summation’s CurrentCase object
-
CurrentCase.CoreDBPath
- CT Summation’s IMG object
-
IMG.CountPages
-
IMG.GetNthImgFile
Code
'This script verifies that the images in the Core database are actually physically
'present in the location that Summation is looking for them. If the images are not located
'on the path in the ImgInfo table, this script will create a file that contains the DocId number
'and the path to the image (including filename). The script will give the option to view the
'file/report at the end of the script. If the user chooses not to view the file right away, then
'a message box will appear telling them where the file can be found.
'The file is overwritten with each run of the script so there will not be a multitude of them
'to clean up periodically. The script can be modified to create multiple files so that each
'will not be overwritten by the last in much the same way that the Case Organizer backup
'script creates multiple backups.
'Creates an ADODB connection
Set cn = CreateObject("ADODB.Connection")
cn.ConnectionString = "Provider=SBP.1;Data Source=" & CurrentCase.CoreDBPath()
cn.Open
'Creates a recordset object to hold the recordset for the Imginfo table
Set rsImgInfo = CreateObject("ADODB.Recordset")
rsImgInfo.Open "Select * from imginfo", cn
'Creates a File system object to use for FileExists and to write to the text file
Set fso = CreateObject("Scripting.FileSystemObject")
'Sets some variables to cut down on typing and to make sure they
'don't have any existing values in them
Filename = "ImageVerify"
CheckField = "ImgFiles"
Failed = "ImgTag" & " " & "Image File" & vbCrLf
'Call the function to verify if the image files exist where Summation
'thinks they should
Call VerifyImages
'**************************************************************************************
'The main wrapper that checks to see if the image files referred to
'in the ImgInfo table actually exist in that location
Sub VerifyImages
'Sets ImgLoc to the Summation default image location to account
'for @I values in the DefDir field
imgLoc = img.ImgLoc
rsimginfo.movefirst
'Loops while the ImgInfo table has records in it
While Not rsimginfo.EOF
Dir = rsimginfo.Fields("DefDir").Value
Images = rsimginfo.Fields(CheckField).Value
'Replaces any @I values with the actual path
If InStr(Dir, "@I") Then
Dir = Replace(Dir, "@I", ImgLoc)
End If
'If the ImgFiles field contains a { or a Carriage return (chr(13)) then
'that means that there are probably multiple image files associated
'with that record
If InStr(Images, "{") > 0 Or InStr(Images, Chr(13)) Then
Call MultiVerify(Dir, Images)
'Otherwise it's a single image file and we can just check it
Else
ImgFile = Dir & Images
FileStatus = fso.FileExists(ImgFile)
'If the file doesn't exist then we add it to the failed string
If FileStatus = 0 Then
Failed = Failed + rsImgInfo.Fields("ImgTag") & " " & ImgFile & vbCrLf
End If
End If
rsimginfo.movenext
Wend
'Calls the function that writes out the failed string to a text file.
Call MakeLogFile
End Sub
Function MultiVerify(Dir, Images)
'Deals with the files that are not iterated, but just separated by carriage returns
'Replaces the carriage return (Chr(13) with a semi-colon which is what the
'Imaging object uses -this will allow us to use Summation functions like
'img.CountPages and img.GetNthImgFile. Then it replaces the line feed
'Chr(10), with nothing so that the line feed won't interfere with the file find.
If InStr(Images , Chr(13)) Then
images = Replace(Images , Chr(13), ";")
images = Replace(Images, Chr(10), "")
End If
'Cycles through the images associated with the current record
For i = 1 To img.CountPages(Images)
'Gets each individual page of the image and assigns it to ImgFile
ImgFile = img.GetNthImgFile(Dir, Images, i)
'Uses the File System Object to see if the file exists
FileTest = fso.FileExists(ImgFile)
'If the file can't be found where the imaging system will look for it
'then it gets written to a file.
If FileTest = 0 Then
Failed = Failed + rsImgInfo.Fields("ImgTag").Value & " " & ImgFile & vbCrLf
End If
Next
End Function
'The log file that is created will be saved to the case directory, but the previous one
'will always be overwritten by the most current one. This can be changed
'through the file system object, but in this case, it seemed best to
'allow it to be overwritten. This also prompt the user to see the file right away
'if they say no, it tells then where to find it later.
Function MakeLogFile
If Failed <> "" Then
Set f1 = fso.CreateTextFile(CurrentCase.CaseDir & Filename & ".txt", True)
f1.WriteLine(Failed)
f1.Close
SeeFile = AskYesNo("Would you like to see the list of images that couldn't be found?")
If SeeFile = -1 Then
addhtmlview "ImgLog", CurrentCase.CaseDir & "ImageVerify.txt"
Else
Msg "To look at this file in the future it will be in:" & vbCrLf _
& CurrentCase.CaseDir & "ImageVerify.txt"
End If
Else
Msg "All of your images were found."
End If
End Function
Download File (zipped)
(right click on file and select 'Save Target As...')
NOTICE: This script is provided to you “As is” for use only with a valid CT Summation Enterprise or CT Summation LG family (iBlaze) license, pursuant to the terms of the license. Technical support is not provided for scripts under the CT Summation maintenance agreement or otherwise. The Limitation of Warranties and Liability provisions contained in the license accompanying the CT Summation program with which this script is run shall apply to use of this script with said program.
Overview
The Cleanup Case Organizer Backups script deletes the old backups created within the CaseOrgBkUps folder.
Description
This script uses the Microsoft Windows FileSystem object (an object-based tool for working with files and folders) extensively. It uses the FileSystem object to check for the presence of an existing CaseOrgBkups folder within the case’s \Profiles\AllUsers directory. It also uses the FileSystem object to delete the directories within the CaseOrgBkups folder created prior to a specific user specified date.
Collections / Objects / Methods / Properties
Code
ct = 0
subpos = 0
subfound = 0
'Use as a flag to see if the Case Org has been restored
bRestored = "No"
sCaseOrgDir = CaseDir() & "profiles\all users\CaseOrg"
sCaseOrgBkupsDir = CaseDir() & "profiles\all users\CaseOrgBkUps"
'Create File System Objects and assign those objects to variables
Set fso = CreateObject("Scripting.FileSystemObject")
Set CsOrgBkps = fso.getfolder(CaseDir() & "profiles\all users\CaseOrgBkUps\")
Set Subs = CsOrgBkps.subfolders
Do
'Get the preferred Backup from the user
sDate = AskEntry("Type in the date from which you wish to restore the Case Organizer" _
& vbCrLf & "Use M/D/YY format","Restore Case Organizer")
'Will end the loop (and script) if the user has left the entry box blank or clicked Cancel
If sDate = "" Then
Exit Do
End If
'Checks to see if user input is a date or a foldername
If InStr(sDate, "/") Then
'If the users has entered a date, replace the slashes to make the folder name valid
sFolderDate = Replace(sDate, "/", "")
'Check to see if the folder exists
bExists = fso.FolderExists(sCaseOrgBkupsDir & "\" & sFolderDate)
If bExists Then
'If it exists, see If there are multiple folders For that Date.
If Subs.count > 1 Then
'Cycle through subfolders and see if the modified date string (no slashes) is
'present in the subfolder name
For Each SF in Subs
nm = SF.name
SubPos = InStr(nm, sFolderDate)
'If it is present SubPos will reflect the position found, if it is greater than 0 'then the string was found
If SubPos > 0 Then
'Add one to our variable to keep track of how many subfolders have that string
subfound = subfound + 1
End If
Next
' If there is more than one folder containing that string then ask what the
'user wants to backup
If subfound > 1 Then
bRest = AskYesNo("There is more than one backup for " & sDate & ", would"_
& "you like to restore the most recent?")
'If the users clicked yes, will restore the most recent backup based
'on the date created
If bRest = -1 Then
'Compares the files that contain the specified date string to find the most recent
sLatestFold = CompareFiles(sFolderDate)
'Copies the second folder over the first and names it the third argument
Call CopyOver(sCaseOrgDir, sCaseOrgBkupsDir & "\" & sLatestFold, "CaseOrg")
'Flags the CsOrg as restored
bRestored = ""
'Alerts the users that it has been restored from the specified date
msg "Case Organizer Restored from " & sDate
Else
'Instructs the user on what to do if they wish to restore by foldername
'And begins the Loop so they may enter a foldername
msg "Enter the folder name that you want to restore"
End If
'If there isn't more than one folder containing that date string, restore the one found
Else
'Copies the second folder over the first and names it the third argument
Call CopyOver(sCaseOrgDir, sCaseOrgBkupsDir & "\" & sFolderDate, "CaseOrg")
'Flags that the CaseOrg has been restored to break the loop
bRestored = ""
'Alerts the users that it has been restored from the specified date
msg "Case Organizer Restored from " & sDate
End If
End If
'If the folder cannot be found - gives the users information on how the date
'they provided might be off
Else
msg "There is no backup created on " & sDate & vbCrLf &"If this date is correct, "_
& "you may have entered the Date in MM/DD/YY format." & vbCrLf & "Do not" _
& " use zeros to round out the Month And day numbers"
End If
'The user didn't enter a date, entered a foldername
Else
'Checks to see if the folder the users entered exists
bExists = fso.FolderExists(sCaseOrgBkupsDir & "\" & sDate)
'If it does, we just take their word for it that that's the one they want and restore it
If bExists Then
Call CopyOver(sCaseOrgDir, sCaseOrgBkupsDir & "\" & sDate, "CaseOrg")
'Flags that the CaseOrg has been restored to break the loop
bRestored = ""
msg "Case Organizer Restored from " & sDate
Else
msg "That folder cannot be found"
End If
End If
'Loops to give the user opportunity to get the right date/folder name
Loop While bRestored = "No"
Function CompareFiles(ModDate)
'Compares the system date created attribute of the files containing the specified string and
'assigns the most recent filename to the variable Latest
Set fso = CreateObject("Scripting.FileSystemObject")
Set CsOrgBkps = fso.getfolder(CaseDir() & "profiles\all users\CaseOrgBkUps\")
Set Subs = CsOrgBkps.subfolders
iteration = 0 'Resets the variables to 0
Latest = 0
Current = 0
'Cycles through the subfolders
For Each S1 in Subs
'assigns the folder name to a variable
FoldNm = s1.name
'Looks for the user specified date string in the foldername
found = InStr(FoldNm, ModDate)
'If the date string is found,
If found > 0 Then
'Get the date created
Current = s1.datecreated
'Check to see which folder was more recently created
LatestDate = DateCheck(Current)
If LatestDate = Current Then
'If saves the folder name of the most recent folder
LatestName = s1.name
End If
Else
msg "There was a problem finding the requested folder, please try again"
End If
Next
'Returns the folder name to the main script
CompareFiles = LatestName
End Function
Function DateCheck(Current)
'Compares the dates created if date1 is more recent than date 2,
'DateDuff will return a negative number
Difference = DateDiff("s", Current, Latest)
If Difference < 0 Then
'Reassigns so that the most recent is assigned to the Latest variable
Latest = Current
End If
'Returns the date to the CompareFiles function
DateCheck = Latest
End Function
Function CopyOver(ToFolderPath, FromFolderPath, ExName)
'Copies the second folder over the first
'Gets the length of the path to be copied to
ToPathLen = Len(ToFolderPath)
'Gets the length of the path to be copied from
FromPathLen = Len(FromFolderPath)
'Gets the position of the last slash so that the foldername can be extracted
'from the string
ToLastSlash = InStrRev(ToFolderPath, "\")
FromLastSlash = InStrRev(FromFolderPath, "\")
'Strips the last folder from the path to be copied to so that the new folder
'will not end up inside the existing one
ToPath = Left(ToFolderPath, ToLastSlash - 1)
FromPath = Left(FromFolderPath, FromLastSlash - 1)
'Gets the folder name to be copied to
ToFolderName = Right(ToFolderPath, ToPathLen - ToLastSlash)
'Gets the folder name to be copied
FromFolderName = Right(FromFolderPath, FromPathLen - FromLastSlash)
'Creates a File System Object to handle the folder move and copy
Set fso = CreateObject("Scripting.FileSystemObject")
'Checks to see if the folder to be overwritten actally exists
If fso.FolderExists(ToFolderPath) Then
'If it does, it gets deleted
fso.DeleteFolder(ToFolderPath)
End If
'Copies the new folder into the old path (the True means it will overwrite any existing
'folder with that name
fso.CopyFolder FromFolderPath, ToPath & "\", True
'Sets the File System Object to the new placement of the new folder
Set fso = fso.GetFolder(ToPath & "\" & FromFolderName)
'Renames it to the specified name (The third argument passed in)
fso.Name = ExName
End Function
Download File (zipped)
(right click on file and select 'Save Target As...')
NOTICE: This script is provided to you “As is” for use only with a valid CT Summation Enterprise or CT Summation LG family (iBlaze) license, pursuant to the terms of the license. Technical support is not provided for scripts under the CT Summation maintenance agreement or otherwise. The Limitation of Warranties and Liability provisions contained in the license accompanying the CT Summation program with which this script is run shall apply to use of this script with said program.
Overview
The ScriptInHTML HTML page/script demonstrates accessing the CT Summation scripting object model from within an HTML page.
Description
The ScriptInHTML script calls the CT Summation object model while running within Internet Explorer (demonstrating how to run scripts from outside of CT Summation scripting). This script performs basic tasks, such as reading a few CT Summation scripting object property values and then creating basic HTML for displaying those values within the HTML view (one step above a “Hello World” application).
The sample HTML/script page can be run/seen within a CT Summation view by first copying the HTML file to the CT Summation application folder, then running the following script in the CT Summation scripting window:
AddHTMLTab "ScriptInHTML", AppDir & "ScriptInHTML.htm"
Collections / Objects / Methods / Properties
- HTML
- CT Summation CurrentCase object
- CurrentCase.CaseDir
- CurrentCase.FormName
- CurrentCase.ImageDir
- CurrentCase.NotePath
- CurrentCase.ProfileDir
- CurrentCase.SharedProfileDir
Code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE></TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<META content="MSHTML 5.50.4522.1800" name=GENERATOR>
<SCRIPT language=Javascript>
var objSW=window.external;
function procCaseInfo()
{
m_strInfo = "<B>Case Name:</B> " + objSW.CurrentCase.Name;
m_strInfo = m_strInfo + "<BR><B>Form Name:</B> ";
m_strInfo = m_strInfo + objSW.CurrentCase.FormName;
m_strInfo = m_strInfo + "<BR><B>Case Directory:</B> ";
m_strInfo = m_strInfo + objSW.CurrentCase.CaseDir;
m_strInfo = m_strInfo + "<BR><B>Image Directory:</B> ";
m_strInfo = m_strInfo + objSW.CurrentCase.ImageDir;
m_strInfo = m_strInfo + "<BR><B>Note Path:</B> ";
m_strInfo = m_strInfo + objSW.CurrentCase.NotePath;
m_strInfo = m_strInfo + "<BR><B>Profile Directory:</B> ";
m_strInfo = m_strInfo + objSW.CurrentCase.ProfileDir;
m_strInfo = m_strInfo + "<BR><B>Shared Profile Directory:</B> ";
m_strInfo = m_strInfo + objSW.CurrentCase.SharedProfileDir;
divCaseInfo.innerHTML = m_strInfo;
}
</SCRIPT>
</HEAD>
<BODY bgColor=#fff8dc>
<P><STRONG><FONT color=#a52a2a size=5>Case Information Sample
Script</FONT></STRONG></P>
<P><INPUT onclick=procCaseInfo() type=button value="Retrieve Case Info" name=btnCaseInfo _>
</P>
<P>
<DIV id=divCaseInfo></DIV>
<P></P></BODY></HTML>
Download File (html)
(right click on file and select 'Save Target As...')
NOTICE: This script is provided to you “As is” for use only with a valid CT Summation Enterprise or CT Summation LG family (iBlaze) license, pursuant to the terms of the license. Technical support is not provided for scripts under the CT Summation maintenance agreement or otherwise. The Limitation of Warranties and Liability provisions contained in the license accompanying the CT Summation program with which this script is run shall apply to use of this script with said program.