2 ################################################################################
4 # File: CheckCodePage.pl
5 # Description: With Clearquest 2003.06.15 there is more support for
6 # internationalization. This means that Clearquest now
7 # implements a Code Page which essentially defines the
8 # valid character set for data. If it encounters invalid
9 # characters the user must correct them.
11 # This script will check a Clearquest database to see if
12 # there are any invalid ASCII characters in string oriented
14 # Author: Andrew@DeFaria.com
15 # Created: Fri Sep 23 17:27:58 PDT 2005
18 # (c) Copyright 2005, Andrew@DeFaria.com, all rights reserved
20 ################################################################################
26 our ($me, $SEPARATOR);
28 my ($abs_path, $lib_path);
31 # Extract relative path and basename from script name.
32 $0 =~ /(.*)[\/\\](.*)/;
34 $abs_path = (!defined $1) ? "." : File::Spec->rel2abs ($1);
35 $me = (!defined $2) ? $0 : $2;
38 # Remove .pl for Perl scripts that have that extension
41 # Define the path separator
42 $SEPARATOR = ($^O =~ /MSWin/) ? "\\" : "/";
45 $lib_path = "$abs_path" . $SEPARATOR . ".." . $SEPARATOR . "lib";
47 # Add the appropriate path to our modules to @INC array.
48 unshift (@INC, "$abs_path");
49 unshift (@INC, "$lib_path");
57 my $from_db_connection_name = "Controller";
62 display "ERROR: $msg\n" if defined $msg;
64 display "Usage: $me\t[-u] [-v] [-d] [-from <connection name>]
69 -v: Turn on verbose mode
70 -d: Turn on debug mode
71 -from <connection name>: Specify the from connection name
72 (Default: $from_db_connection_name)";
77 if ($ARGV [0] eq "-v") {
80 } elsif ($ARGV [0] eq "-d") {
82 } elsif ($ARGV [0] eq "-from") {
85 Usage "Must specify <connection name> after -from";
87 $from_db_connection_name = $ARGV [0];
89 } elsif ($ARGV [0] eq "-u") {
92 Usage "Unknown argument found: " . $ARGV [0];
98 my $log = Logger->new (path => ".");
100 my $process_start_time = time;
103 $log->msg ("Starting Cont session");
104 my $session = StartSession ("Cont", $from_db_connection_name);
108 #$log->msg ("Checking customer record...");
109 #CheckRecord $log, $session, "dbid", "customer", undef, @customer_fields;
111 #$log->msg ("Checking project record...");
112 #CheckRecord $log, $session, "dbid", "project", undef, @project_fields;
114 $log->msg ("Checking defect record...");
115 #CheckRecord $log, $session, "id", "defect", undef, @new_Cont_defect_fields;
116 CheckRecord $log, $session, "id", "defect", "Cont00022003", @new_Cont_defect_fields;
118 $log->msg ("Ending Cont session...");
121 display_duration $start_time, $log;
124 $log->msg ("\nInvalid character analysis\n");
128 foreach (sort (keys (%bad_chars))) {
129 $log->msg (++$i . "\t$_\t$bad_chars{$_}\n");
132 display_duration $process_start_time, $log;