<?xml version="1.0" encoding="utf-8"?><finScript version="1.00" exportedUtcDate="2012-08-29T22:06:34.0000000"><CreatedUtcDate>2012-08-16T00:45:41.0000000</CreatedUtcDate><CreatedUserId>Admin</CreatedUserId><UpdatedUtcDate>2012-08-16T01:48:59.0000000</UpdatedUtcDate><UpdatedUserId>Admin</UpdatedUserId><ScriptId>DOCMANFOLD</ScriptId><Description>Create Document Manager Folders from finPOWER 5</Description><ScriptType>GeneralUserInterface</ScriptType><Active>true</Active><AllowUI>false</AllowUI><Category /><Code>Option Explicit On

' #################################################################
' Convert finPOWER 5 Document Manager Folders to finPOWER Connect
' structure (copies files and folders, does not move them).
'
' Version: 1.00 (16/08/2012)
'
' Usage: Location that this Script is used
' #################################################################

Public Function Main(ByVal userInterface As ISUserInterfaceBL, ByVal reports As ISfinReports, ByVal parameters As ISKeyValueList) As Boolean

  Dim DestinationFolder As String
  Dim FolderFin5 As String
  Dim FolderFinC As String
  Dim FolderName As String
  Dim FolderType As String
  Dim FolderCode As String
  Dim Include As Boolean
  Dim List As ISList
  Dim n As Integer
  Dim s As String
  Dim strTemp As String
  Dim Warnings As ISList

  ' Assume Success
  Main = True

  ' Initialise
  FolderFin5 = parameters.GetString("FolderFin5")
  FolderFinC = parameters.GetString("FolderFinC")
  If Right(FolderFin5, 1) = "\" Then FolderFin5 = Left(FolderFin5, Len(FolderFin5) - 1)
  If Right(FolderFinC, 1) = "\" Then FolderFinC = Left(FolderFinC, Len(FolderFinC) - 1)
  Warnings = New ISList()

  ' Validate
  If Not finBL.Runtime.FileUtilities.FolderExists(FolderFin5) Then
    Main = False
    finBL.Error.ErrorBegin(String.Format("finPOWER 5 Document Manager folder '{0}' not found.", FolderFin5))
  End If

  ' Create finPOWER Connect Document Manager Folder
  If Main AndAlso Not finBL.Runtime.FileUtilities.FolderExists(FolderFinC) Then
    Select Case userInterface.MsgBox(String.Format("Create finPOWER Connect Document Manager folder '{0}'?", FolderFinC), MsgBoxStyle.Question Or MsgBoxStyle.YesNo)
      Case MsgBoxResult.Yes
        Main = finBL.Runtime.FileUtilities.CreateFolder(FolderFinC)
      Case Else
        Main = False
        finBL.Error.ErrorBegin("Cannot continue without creating finPOWER Connect Document Manager folder.")
    End Select
  End If

  If Main Then
    ' Get List of finPOWER 5 Folders
    Main = finBL.Runtime.FileUtilities.GetFolderList(FolderFin5, List)
  End If

  ' Copy Folders and Files
  If Main Then
    For Each s In List
      ' Get Folder Name
      n = InstrRev(s, "\")
      If n = 0 Then
        FolderName = ""
      Else
        FolderName = Mid(s, n + 1)
      End If
    
      ' Include?
      If FolderName.StartsWith("Deposit_") Then
        Include = True
        FolderType = "Accounts"
        FolderCode = Mid(FolderName, 9)
      ElseIf FolderName.StartsWith("Loan_") Then
        Include = True
        FolderType = "Accounts"
        FolderCode = Mid(FolderName, 6)
      ElseIf FolderName.StartsWith("Client_") Then
        Include = True
        FolderType = "Clients"
        FolderCode = Mid(FolderName, 8)
      Else
        Include = False
      End If
    
      ' Create Destination Folder
      If Include Then
        DestinationFolder = FolderFinC &amp; "\" &amp; FolderType &amp; "\" &amp; FolderCode
        If Not finBL.Runtime.FileUtilities.CreateFolder(DestinationFolder) Then
          Main = False
          Exit For
        End If
      End If
    
      ' Copy
      If Include Then
        If finBL.Runtime.FileUtilities.CopyFiles(s, DestinationFolder, True, True) Then
          
        Else
          Warnings.Add(String.Format("Copy failed for folder '{0}'. The following error was returned: ", s, finBL.Error.Message(True, True)))
        End If
      Else
        Warnings.Add(String.Format("Folder not copied. Unrecogised folder type '{0}'.", s))
      End If
    Next
  End If

  ' Warn if files in root folder
  If Main Then
    If finBL.Runtime.FileUtilities.GetFileList(FolderFin5, List, "", False) Then
      If List.Count &lt;&gt; 0 Then
        Warnings.Add(String.Format("{0} files exist in the root folder and were not copied.", List.Count))
      End If
    End If
  End If

  ' Notify
  If Main Then
    strTemp = String.Format("{0} folders and their contents were copied from '{1}' to '{2}'.", list.Count, FolderFin5, FolderFinC)
    If Warnings.Count &lt;&gt; 0 Then strTemp &amp;= vbNewLine &amp; vbNewLine &amp; String.Format("WARNING: {0} warnings were generated. These will be displayed upon clicking 'OK'. Please review carefully.", Warnings.Count)
    userInterface.MsgBox(strTemp, MsgBoxStyle.Information)
  End If

  ' Show Warnings
  If Main Then
    strTemp = "&lt;html&gt;&lt;body&gt;"
    strTemp &amp;= "&lt;ul&gt;"
    For Each s In Warnings
      strTemp &amp;= String.Format("&lt;li&gt;{0}&lt;/li&gt;", finBL.HtmlEncode(s, True, True))
    Next
    strTemp &amp;= "&lt;/ul&gt;"
    strTemp &amp;= "&lt;/body&gt;&lt;/html&gt;"
    
    userInterface.CommonForms.ShowHtmlViewer(strTemp, "Document Manager Copy Warnings")
  End If

End Function</Code><Language>VisualBasic</Language><Notes /><PermissionKeyExecute /><RunWithoutPrompts>false</RunWithoutPrompts><TimeoutSeconds>60</TimeoutSeconds><RunAsAdministrator>false</RunAsAdministrator><ShowInMenu>Process</ShowInMenu><ParametersType>Custom</ParametersType><Parameters><ISParameterDefs version="1.00"><Parameters><Parameter name="" type="SectionStart"><Caption>Specify the root folder for the finPOWER 5 Document Manager.</Caption><StandaloneOnly>false</StandaloneOnly><TooltipText /><SectionColumns>1</SectionColumns></Parameter><Parameter name="FolderFin5" type="Text"><Caption>Folder</Caption><StandaloneOnly>false</StandaloneOnly><TooltipText /><DefaultValueExpression /><Enabled>true</Enabled><HideDescription>false</HideDescription><IndentLevel>0</IndentLevel><Mandatory>true</Mandatory><NonPersistable>false</NonPersistable><ReadOnly>false</ReadOnly><ReadOnly2>false</ReadOnly2><Value /><Visible>true</Visible><MaxLength>0</MaxLength><Rows>1</Rows></Parameter><Parameter name="" type="SectionStart"><Caption>Specify the root folder for the finPOWER Connect Document Manager.</Caption><StandaloneOnly>false</StandaloneOnly><TooltipText /><SectionColumns>1</SectionColumns></Parameter><Parameter name="FolderFinC" type="Text"><Caption>Folder</Caption><StandaloneOnly>false</StandaloneOnly><TooltipText /><DefaultValueExpression /><Enabled>true</Enabled><HideDescription>false</HideDescription><IndentLevel>0</IndentLevel><Mandatory>true</Mandatory><NonPersistable>false</NonPersistable><ReadOnly>false</ReadOnly><ReadOnly2>false</ReadOnly2><Value /><Visible>true</Visible><MaxLength>0</MaxLength><Rows>1</Rows></Parameter></Parameters></ISParameterDefs></Parameters></finScript>