9 my ($abs_path, $lib_path);
12 # Extract relative path and basename from script name.
13 $0 =~ /(.*)[\/\\](.*)/;
15 $abs_path = (!defined $1) ? "." : File::Spec->rel2abs ($1);
16 $me = (!defined $2) ? $0 : $2;
19 # Define the path SEPARATOR
20 $SEPARATOR = ($^O =~ /MSWin/) ? "\\" : "/";
23 $lib_path = "$abs_path" . $SEPARATOR . ".." . $SEPARATOR . "lib";
25 # Add the appropriate path to our modules to @INC array.
26 unshift (@INC, "$abs_path");
27 unshift (@INC, "$lib_path");
38 my $attachments_size = 0;
40 my $from_attachment_fields = $from->GetAttachmentFields;
42 for (my $i = 0; $i < $from_attachment_fields->Count; $i++) {
43 my $from_attachment_field = $from_attachment_fields->Item ($i);
44 my $field_name = $from_attachment_field->GetFieldName;
46 # Process attachments in this attachment field
47 my $from_attachments = $from_attachment_field->GetAttachments;
49 for (my $j = 0; $j < $from_attachments->Count; $j++) {
50 my $from_attachment = $from_attachments->Item ($j);
51 my $description = $from_attachment->GetDescription;
52 my $filename = $from_attachment->GetFileName;
53 my $size = $from_attachment->GetFileSize;
55 next if $filename eq "history.txt";
56 $log->msg ("$id,$filename,$size");
57 $attachments_size += $size;
61 $log->msg ("$id,Total attachment size,$attachments_size") if $attachments_size ne 0;
63 return $attachments_size;
66 my $log = Logger->new (path => ".");
69 my $record_name = "defect";
71 my $connection = "2005.02.00";
72 my $cont = StartSession "Cont", $connection;
74 $connection = "2003.06.00";
75 my $teton = StartSession "TO", $connection;
76 my $prod = StartSession "Prod", $connection;
78 my $result = GetAllDefectRecords $log, $cont, $record_name;
80 my $grand_total_old = 0;
81 my $grand_total_new = 0;
83 while ($result->MoveNext == $CQPerlExt::CQ_SUCCESS) {
84 # GetEntity by using $id
85 my $id = $result->GetColumnValue (1);
86 my $from = $cont->GetEntity ($record_name, $id);
88 my $new_size = TotalAttachment $log, $id, $from;
90 my $old_id = $from->GetFieldValue ("old_id")->GetValue;
94 if ($old_id =~ /^TO/) {
95 $to = $teton->GetEntity ($record_name, $old_id);
96 } elsif ($old_id =~ /^Prod/) {
97 $to = $prod->GetEntity ($record_name, $old_id);
99 error "Old_id is not set! $old_id";
102 my $old_size = TotalAttachment $log, $id, $to;
104 $grand_total_old += $old_size;
105 $grand_total_new += $new_size;
107 if ($new_size gt $old_size) {
108 display "$id:$new_size > $old_id:$old_size";
109 } elsif ($new_size lt $old_size) {
110 display "$id:$new_size < $old_id:$old_size";
112 # display "$id:$new_size = $old_id:$old_size";
117 display "Grand total (old): $grand_total_old";
118 display "Grand total (new): $grand_total_new";