Guest User

Untitled

a guest
Jun 1st, 2018
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.99 KB | None | 0 0
  1. use strict;
  2. use warnings;
  3. use DBI;
  4. my @projects = (
  5. [ 'NL0241', 'Axios Improvements' ],
  6. [ 'NL0230', 'U-Next' ],
  7. [ 'NL0232', 'Resource Data Management' ],
  8. [ 'NL0234', 'Improved Baseline Documentation' ]
  9. [ 'NL0185', 'Slotnota' ],
  10. [ 'NL0236', 'More Fun on KPN' ],
  11. [ 'NL0235', 'Broadband Impact 1 IVR_Manual Solution' ],
  12. [ 'NL0237', 'Unique Extension to KPN WS-MX Stream' ],
  13. [ 'NL0243', 'SMS Gateway' ],
  14. [ 'NL0245', 'Baby Box' ],
  15. [ 'NL0240', 'Re-engineering Test Environments' ],
  16. [ 'NL0248', 'CIOT Migration' ],
  17. [ 'NL0200', 'Service Assurance Study' ],
  18. [ 'NL0252', 'VoIP on Starter - Parrot' ],
  19. [ 'NL0253', 'Multiple Year Contract' ],
  20. [ 'NL0254', 'Infranet Improvements' ],
  21. [ 'NL0255', 'Service At Home' ],
  22. [ 'NL0209', 'One CRM' ],
  23. [ 'NL0212', 'UMA-One Voice' ],
  24. [ 'NL0215', 'KPN Wholesale' ],
  25. [ 'NL0218', 'SMC' ],
  26. [ 'NL0221', 'Split up retention' ],
  27. [ 'NL0223', 'Multi Line' ],
  28. [ 'NL0225', 'Desktop Security Suite' ],
  29. [ 'NL0229', 'SIP Migration' ],
  30. [ 'NL0231', 'E-Shop' ],
  31. [ 'NL0233', 'Speedtest Tool' ],
  32. [ 'NL0217', 'Voice platform in NL' ],
  33. [ 'NL0239', 'O2O' ],
  34. [ 'NL0242', 'Upgrade D-Layer' ],
  35. [ 'NL0238', 'Fixed number for Unique (Flying Fish)' ],
  36. [ 'NL0191', 'Directory Services Wanadoo Telephony' ],
  37. [ 'NL0244', 'Hyperion Migration' ],
  38. [ 'NL0246', 'News Outsourcing' ],
  39. [ 'NL0247', 'KMS ph2' ],
  40. [ 'NL0249', 'Slotnota (Ph2)' ],
  41. [ 'NL0201', 'One KMS' ],
  42. [ 'NL0203', 'More FUN' ],
  43. [ 'NL0207', 'PRP-Pre Registration' ],
  44. [ 'NL0250', 'Fox (Unique on ADSL Starter)' ],
  45. [ 'NL0210', 'Voice Low End' ],
  46. [ 'NL0256', 'KPN Wholesale Ethernet' ],
  47. [ 'NL0213', 'CPE Management Tooling' ],
  48. [ 'NL0216', 'Citynet Pilot' ],
  49. [ 'NL0219', 'Converged Ordering' ],
  50. [ 'NL0222', 'Replacement of Enertel solution for VOIP and Dial-in' ],
  51. [ 'NL0224', 'Unique Ordering' ],
  52. [ 'NL0226', 'Unified Messaging' ],
  53. [ 'NL0228', 'PPD-Test Automation' ]
  54. );
  55.  
  56. my @teams = (
  57. [ 'PPD.PM', '' ],
  58. [ 'PPD.FDA', '' ],
  59. [ 'PPD.BPA', '' ],
  60. [ 'PPD.DEV.BILLING', 'Billing development' ],
  61. [ 'PPD.DEV.FE', 'Front end development'],
  62. [ 'PPD.DEV.MW', 'Middle ware development' ],
  63. [ 'PPD.DEV.AXIOSS', 'Axioss development' ],
  64. [ 'PPD.DART', '' ],
  65. [ 'ITO OM', '' ],
  66. [ 'ITO BS', '' ],
  67. [ 'ITO SD', '' ],
  68. [ 'NETWORK', '' ]
  69. );
  70.  
  71. my @gates = ("T-1", "T0", "T1", "T2", "T3", "T4");
  72.  
  73. main();
  74.  
  75. sub main {
  76. my $dbh = DBI->connect('dbi:Oracle:xe', 'QUOTES', 'quotes', { RaiseError => 1, AutoCommit => 0 }) || die "Database connection not made: $DBI::errstr";
  77.  
  78.  
  79. # my $dbh = DBI->connect('dbi:Oracle:xe', 'JOURNIX', 'journix', { RaiseError => 1, AutoCommit => 0 }) || die "Database connection not made: $DBI::errstr";
  80. # truncateTables($dbh);
  81. addTeamsOLD($dbh);
  82. # addProjects($dbh);
  83. # addQuotes($dbh);
  84. # addDates($dbh);
  85. # addApproved($dbh);
  86. # addFinal($dbh);
  87. # addEstimate($dbh);
  88.  
  89. $dbh->disconnect;
  90. }
  91.  
  92. sub truncateTables {
  93. my ($dbh) = @_;
  94.  
  95. $dbh->prepare("TRUNCATE TABLE $_")->execute for ('approved', 'dates', 'final', 'estimate', 'projects')
  96. }
  97.  
  98. sub truncateTablesOLD {
  99. my ($dbh) = @_;
  100.  
  101. $dbh->prepare("TRUNCATE TABLE $_")->execute for ('projects', 'teams', 'final', 'estimate', 'quotes')
  102. }
  103. sub addTeamsOLD {
  104. my ($dbh) = @_;
  105. my $sth = $dbh->prepare('INSERT INTO teams("ID","NAME") VALUES (?,?)');
  106.  
  107. $sth->execute($_->[0], $_->[1]) || die $sth->errstr foreach @teams;
  108. }
  109.  
  110. sub addTeams {
  111. my ($dbh) = @_;
  112. my $sth = $dbh->prepare('INSERT INTO teams("ID") VALUES (?)');
  113.  
  114. $sth->execute($_->[0]) || die $sth->errstr foreach @teams;
  115. }
  116.  
  117. sub addProjects {
  118. my ($dbh) = @_;
  119. my $sth = $dbh->prepare('INSERT INTO projects("ID","NAME") VALUES (?,?)');
  120.  
  121. $sth->execute($_->[0], $_->[1]) || die $sth->errstr foreach @projects;
  122. }
  123.  
  124. sub addQuotes {
  125. my ($dbh) = @_;
  126. my $sth = $dbh->prepare('INSERT INTO quotes("PROJECT","T-1", "T0", "T1", "T2", "T3", "T4", "FINAL", "ESTIMATE") VALUES (?,?,?,?,?,?,?,?,?)');
  127.  
  128. $sth->execute($_->[0], randomGateDates(), 0, 0) || die $sth->errstr foreach @projects;
  129. }
  130.  
  131. sub addDates {
  132. my ($dbh) = @_;
  133. my $sth = $dbh->prepare('INSERT INTO dates("PROJECT","GATE", "DATE") VALUES (?,?,?)');
  134.  
  135. foreach my $project (map { $_->[0] } @projects) {
  136. my $datevalue = time;
  137. foreach my $gate (@gates) {
  138. my $datestring;
  139.  
  140. ($datevalue, $datestring) = randomGateDate($datevalue);
  141.  
  142. $sth->execute($project, $gate, $datestring);
  143. }
  144. }
  145. }
  146.  
  147. sub addApproved {
  148. my ($dbh) = @_;
  149. my $sth = $dbh->prepare('INSERT INTO approved("PROJECT", "FINAL", "ESTIMATE") VALUES (?,?,?)');
  150.  
  151. $sth->execute($_->[0], 0, 0) || die $sth->errstr foreach @projects;
  152. }
  153.  
  154. sub randomGateDate {
  155. my ($date) = @_;
  156.  
  157. $date += (3 + int(rand(10))) * 60 * 60 * 24;
  158. my ($seconds, $minutes, $hours, $day_of_month, $month, $year, $wday, $yday, $isdst) = localtime($date);
  159.  
  160. return ($date, sprintf("%02d-%02d-%02d", $day_of_month, $month + 1, $year - 100) )
  161. }
  162.  
  163. sub randomGateDates {
  164. my $last = time;
  165. my @dates = map {
  166. $last += (3 + int(rand(10))) * 60 * 60 * 24;
  167. my ($seconds, $minutes, $hours, $day_of_month, $month, $year, $wday, $yday, $isdst) = localtime($last);
  168.  
  169. sprintf("%02d-%02d-%02d", $day_of_month, $month + 1, $year - 100);
  170. } (0 .. 5);
  171.  
  172. print join(" / ", @dates) . "\n";
  173. return @dates;
  174. }
  175.  
  176. sub addFinal {
  177. addQuotedata(@_, 'final');
  178. }
  179.  
  180. sub addEstimate {
  181. addQuotedata(@_, 'estimate');
  182. }
  183.  
  184. sub addQuotedataOLD {
  185. my ($dbh, $table) = @_;
  186. my $sth = $dbh->prepare('INSERT INTO ' . $table . '("PROJECT", "TEAM", "T-1", "T0", "T1", "T2", "T3", "T4" ) VALUES (?,?,?,?,?,?,?,?)');
  187.  
  188. foreach my $project (map { $_->[0] } @projects) {
  189. foreach my $team (map { $_->[0] } @teams) {
  190. $sth->execute($project, $team, map { 1 + int(rand(10)) } ( 0 .. 5));
  191. }
  192. }
  193. }
  194.  
  195. sub addQuotedata {
  196. my ($dbh, $table) = @_;
  197. my $sth = $dbh->prepare('INSERT INTO ' . $table . '("PROJECT", "TEAM", "GATE", "HOURS" ) VALUES (?,?,?,?)');
  198.  
  199. foreach my $project (map { $_->[0] } @projects) {
  200. foreach my $team (map { $_->[0] } @teams) {
  201. foreach my $gate (@gates) {
  202. $sth->execute($project, $team, $gate, 1 + int(rand(10)));
  203. }
  204. }
  205. }
  206. }
Add Comment
Please, Sign In to add comment