home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 53 / IOPROG_53.ISO / soft / c++ / xceedbkp.exe / Samples / Vb6 / frmSample.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-09-02  |  12.1 KB  |  289 lines

  1. VERSION 5.00
  2. Object = "{072C4DE1-ECF3-11D2-A5CD-00105A9C91C6}#1.0#0"; "XCEEDBKP.DLL"
  3. Begin VB.Form frmSample 
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Xceed Backup Library - VB Sample application"
  6.    ClientHeight    =   4095
  7.    ClientLeft      =   45
  8.    ClientTop       =   330
  9.    ClientWidth     =   5520
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   4095
  14.    ScaleWidth      =   5520
  15.    StartUpPosition =   2  'CenterScreen
  16.    Begin VB.Timer Timer1 
  17.       Interval        =   1000
  18.       Left            =   2640
  19.       Top             =   120
  20.    End
  21.    Begin VB.TextBox txtText 
  22.       Height          =   2295
  23.       Left            =   120
  24.       MultiLine       =   -1  'True
  25.       TabIndex        =   3
  26.       Text            =   "frmSample.frx":0000
  27.       Top             =   840
  28.       Width           =   5175
  29.    End
  30.    Begin VB.CommandButton cmdQuit 
  31.       Caption         =   "Quit"
  32.       Height          =   375
  33.       Left            =   4080
  34.       TabIndex        =   2
  35.       Top             =   3600
  36.       Width           =   1215
  37.    End
  38.    Begin VB.CommandButton cmdRollback 
  39.       Caption         =   "Rollback..."
  40.       Enabled         =   0   'False
  41.       Height          =   375
  42.       Left            =   2760
  43.       TabIndex        =   1
  44.       Top             =   3600
  45.       Width           =   1215
  46.    End
  47.    Begin VB.Label lblClock 
  48.       Height          =   255
  49.       Left            =   120
  50.       TabIndex        =   5
  51.       Top             =   3600
  52.       Width           =   2535
  53.    End
  54.    Begin VB.Label lblProgress 
  55.       Height          =   255
  56.       Left            =   120
  57.       TabIndex        =   4
  58.       Top             =   3240
  59.       Width           =   5175
  60.    End
  61.    Begin XceedBackupLibCtl.ScheduledJob xScheduled 
  62.       Left            =   2160
  63.       Top             =   120
  64.       DaysOfWeek      =   0
  65.       RecurrenceType  =   0
  66.       RecurrenceInterval=   0
  67.       Required        =   -1  'True
  68.       StartDate       =   2
  69.       Job             =   ""
  70.    End
  71.    Begin XceedBackupLibCtl.RestoreJob xRestoreJob 
  72.       Left            =   1680
  73.       Top             =   120
  74.       BackupSetName   =   ""
  75.       EncryptionPassword=   ""
  76.       PreservePaths   =   -1  'True
  77.       RedirectToFolder=   ""
  78.       RestoreCorruptedFiles=   0   'False
  79.       RestoreSecurity =   -1  'True
  80.       Selection       =   ""
  81.    End
  82.    Begin XceedBackupLibCtl.BackupJob xBackupJob 
  83.       Left            =   1200
  84.       Top             =   120
  85.       BackupFolder    =   ""
  86.       BackupSetName   =   ""
  87.       BackupType      =   1
  88.       CompressionLevel=   6
  89.       EncryptionPassword=   ""
  90.       RetentionPeriod =   -1
  91.       VerifyAfterBackup=   0   'False
  92.       Selection       =   ""
  93.    End
  94.    Begin XceedBackupLibCtl.FileSelection xFileSelection 
  95.       Left            =   720
  96.       Top             =   120
  97.       FilesToExclude  =   ""
  98.       FilesToProcess  =   ""
  99.       MaxDate         =   2958465
  100.       MinDate         =   2
  101.       RegKeysToInclude=   ""
  102.    End
  103.    Begin XceedBackupLibCtl.XceedBackup xMain 
  104.       Left            =   240
  105.       Top             =   120
  106.       CatalogFolder   =   ""
  107.       LogFolder       =   ""
  108.       BackgroundProcessing=   0   'False
  109.       LogDetailLevel  =   2
  110.       BeginProperty ScheduledJobs {FDF2F720-F80F-11D2-A5D2-00105A9C91C6} 
  111.          Count           =   0
  112.       EndProperty
  113.    End
  114.    Begin VB.Label Label1 
  115.       Caption         =   $"frmSample.frx":001C
  116.       Height          =   615
  117.       Left            =   120
  118.       TabIndex        =   0
  119.       Top             =   120
  120.       Width           =   5175
  121.    End
  122. Attribute VB_Name = "frmSample"
  123. Attribute VB_GlobalNameSpace = False
  124. Attribute VB_Creatable = False
  125. Attribute VB_PredeclaredId = True
  126. Attribute VB_Exposed = False
  127. Option Explicit
  128. Dim Dirty As Boolean ' Variable used to determine if text field has changed
  129. '------------------------------------------------------------------------------
  130. ' frmSample.frm:  Sample application that demonstrates backing up, restoring
  131. '                 and browsing backup catalog files. Whenever the sample's
  132. '                 text field is modified, the text is saved to a file. The
  133. '                 backup library backs up the text file every minute. The
  134. '                 user can restore any backed up version of the text.
  135. ' Part of the VB6 Sample application for the Xceed Backup Library
  136. ' Copyright (C)1999 Xceed Software Inc.
  137. '------------------------------------------------------------------------------
  138. Private Sub cmdQuit_Click()
  139.     Unload Me
  140. End Sub
  141. Private Sub cmdRollback_Click()
  142.     Dim nFileNumber As Integer
  143.     Dim sTemp As String
  144.         
  145. '   The rollback button opens the frmRollback form which
  146. '   allows the user to select which backed-up version of
  147. '   the text field to restore.
  148. '   While doing a rollback, let's interrupt the scheduling
  149. '   so that new backups aren't being performed while we
  150. '   are restoring.
  151.     Call xMain.StopScheduler(True)
  152. '   The FileSelection control on the form, named 'xFileSelection',
  153. '   is used by different portions of this sample. It is used by the
  154. '   the scheduler to know which file(s) to back up, it is used by our
  155. '   restore code (below) to specify which file to restore, and it is also
  156. '   used by the frmRollback form for browsing the catalogs, which is why
  157. '   we pass xFileSelection by parameter to the form.
  158.     If frmRollback.ShowModal(xMain, xFileSelection) = vbOK Then
  159.                   
  160.     '   Set the restore options.
  161.     '   We use the same backup set name that we use when we perform our backups
  162.         
  163.         xRestoreJob.BackupSetName = xBackupJob.BackupSetName
  164.         
  165.     '   Assign the FileSelection control to the restore job
  166.         xRestoreJob.Selection = xFileSelection
  167.     '   Run the restore job, and if it worked successfully,
  168.     '   load the text from the restored file. If an error occurs,
  169.     '   it will be displayed by ProcessCompleted event's handler
  170.         
  171.         If xMain.Restore(xRestoreJob) = berSuccess Then
  172.             txtText.Text = ""
  173.             nFileNumber = FreeFile
  174.             Open App.Path & "\TextField.txt" For Input As nFileNumber
  175.             While Not EOF(nFileNumber)
  176.                 If Len(txtText.Text) <> 0 Then
  177.                     txtText.Text = txtText.Text & Chr$(13) & Chr$(10)
  178.                 End If
  179.                 Line Input #nFileNumber, sTemp
  180.                 txtText.Text = txtText.Text & sTemp
  181.             Wend
  182.             Close nFileNumber
  183.         End If
  184.     '   After restoring, before restarting the scheduler, we must not forget to
  185.     '   reset the xFileSelection.MaxDate property which was possibly changed by the
  186.     '   frmRollback form, because the scheduler is using the same xFileSelection instance
  187.     '   for its backups
  188.         xFileSelection.MaxDate = DateSerial(9999, 12, 31)
  189.     End If
  190.     Unload frmRollback
  191.     Call xMain.StartScheduler
  192.             
  193. End Sub
  194. Private Sub Form_Load()
  195. '   Specify which files to backup. In this sample, the text edit field is
  196. '   saved in a file called TextField.txt, placed in the sample's current
  197. '   directory.
  198.     xFileSelection.FilesToProcess = App.Path & "\TextField.txt"
  199. '   How and where to backup the file(s) to
  200.       
  201.     xBackupJob.BackupFolder = App.Path & "\Backups"        ' Backup folder in our sample's directory
  202.     xBackupJob.BackupSetName = "VB Sample"
  203.     xBackupJob.BackupType = bbtIncremental                 ' Backup only if the text file has changed!
  204.     xBackupJob.RetentionPeriod = 1                         ' Delete backup files older than one hour
  205.     xBackupJob.Selection = xFileSelection                  ' Assign which FileSelection to use
  206.     xBackupJob.VerifyAfterBackup = True                    ' Take extra time to make sure the backup data is OK
  207. '   When to backup. This sample uses the library's scheduler to backup every 1 minute
  208.     xScheduled.Job = xBackupJob                              ' The backup job to schedule (defined above)
  209.     xScheduled.RecurrenceType = brtEveryNMinutes             ' Our backup recurrence time to be counted in minutes
  210.     xScheduled.RecurrenceInterval = 1                        ' The 'N' above! ...Backup every 1 minute
  211.     xScheduled.Required = True                               ' Don't skip this backup - see next comment
  212.     xMain.CatalogFolder = App.Path & "\Backups\Catalogs"
  213. '   We leave the default 1900/01/01 StartDate since we want to start the backups
  214. '   as soon as the scheduler is started (and every minute thereafter). Since
  215. '   we set the 'Required' property to true, a backup will be made immediately
  216. '   when the scheduler is started, because the backup due on 1900/01/01 has not
  217. '   yet been performed and cannot be skipped
  218. '   Next we assign the scheduled job to the backup library's list of
  219. '   scheduled jobs that it must monitor
  220.     Call xMain.ScheduledJobs.Add(xScheduled)
  221. '   For the first run, the text field contains the default text
  222. '   "This is the original text", which is saved to the text file
  223. '   (and therefore backed up). The "Dirty" variable lets us know
  224. '   if the text box contains new, changed text. If Dirty=True,
  225. '   then the text will be saved to the text file again, and since
  226. '   we have an incremental backup every minute, it will be backed up.
  227.     If Len(txtText.Text) <> 0 Then
  228.         Dirty = True
  229.     End If
  230. '   Finally, start the library's scheduler. Since we start it when the
  231. '   form is created, we'll be stopping the scheduler when the form is
  232. '   destroyed (in the Form_Unload event)
  233.     xMain.StartScheduler
  234. End Sub
  235. Private Sub Form_Unload(Cancel As Integer)
  236. '   Stop the Xceed Backup Scheduler
  237.     xMain.StopScheduler (True)
  238. '   We put True in order to allow the scheduler
  239. '   the chance to complete a potentially running backup job
  240. '   before stopping the scheduler and completing the above call.
  241. End Sub
  242. Private Sub Label2_Click()
  243. End Sub
  244. Private Sub Timer1_Timer()
  245. '   The timer is only used to update the "clock" on the form.
  246. '   (not to perform timing for backup jobs...)
  247.     lblClock = "Time: " + CStr(Now)
  248. End Sub
  249. Private Sub txtText_Change()
  250. '   When the text field has changed, we set Dirty=True, so that
  251. '   the text will be saved to the text file for backup purposes.
  252.     Dirty = True
  253. End Sub
  254. Private Sub txtText_KeyPress(KeyAscii As Integer)
  255.     lblProgress.Caption = ""
  256. End Sub
  257. Private Sub xMain_ProcessCompleted(ByVal lFilesTotal As Long, ByVal lFilesProcessed As Long, ByVal lFilesSkipped As Long, ByVal lBytesTotal As Long, ByVal lBytesProcessed As Long, ByVal lBytesSkipped As Long, ByVal xResult As XceedBackupLibCtl.bkpError)
  258.     Dim CompletionMessage As String
  259.     ' When a job comnpletes, we get this event, and we can display
  260.     ' the results to the user. We know which type of job has completed
  261.     ' by checking the CurrentOperation property.
  262.     cmdRollback.Enabled = True
  263.     Select Case xMain.CurrentOperation
  264.         Case bcoBrowseCatalogs
  265.             CompletionMessage = "Browse catalogs: "
  266.         Case bcoScheduledBackup
  267.             CompletionMessage = "Scheduled backup: "
  268.         Case bcoManualRestore
  269.             CompletionMessage = "Manual restore: "
  270.         Case Default
  271.             CompletionMessage = ""
  272.     End Select
  273.             
  274.     lblProgress.Caption = CompletionMessage + xMain.GetErrorDescription(bvtError, xResult)
  275. End Sub
  276. Private Sub xMain_StartingBackup(ByVal xBackupJob As XceedBackupLibCtl.IXceedBackupJob, ByVal dtBackupDate As Date, sMediaLabelPattern As String, bPreventLaunch As Boolean)
  277.     Dim nFileNumber As Integer
  278. '   Let's save the text field to file if necessary, before the backup starts
  279.     If Dirty Then
  280.         nFileNumber = FreeFile
  281.         Open App.Path & "\TextField.txt" For Output As nFileNumber
  282.         Print #nFileNumber, txtText.Text
  283.         Close nFileNumber
  284.         Dirty = False
  285.     End If
  286.     lblProgress.Caption = "Starting backup..."
  287.     cmdRollback.Enabled = False
  288. End Sub
  289.