-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Expand file tree
/
Copy pathManualValidationPipeline.cs
More file actions
5257 lines (4623 loc) · 236 KB
/
ManualValidationPipeline.cs
File metadata and controls
5257 lines (4623 loc) · 236 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//Copyright 2022-2025 Microsoft Corporation
//Author: Stephen Gillie
//Title: WinGet Approval Pipeline v3.-4.0
//Created: 1/19/2024
//Updated: 3/3/2025
//Notes: Tool to streamline evaluating winget-pkgs PRs.
/*Contents:
- Init vars
- Boilerplate
- UI top-of-box
- Menu
- Tabs
- Automation Tools
- PR Tools
- Network Tools
- Validation Starts Here
- Manifests Etc
- VM Image Management
- VM Pipeline Management
- VM Status
- VM Versioning
- VM Orchestration
- File Management
- Reporting
- Clipboard
- Et Cetera
- Utility functions
- Powershell equivalency
- VM Window management
- Event Handlers
- Inject into PRs
- Inject into files
- Misc data
Need work:
1. HourlyRun (pending)
- LabelAction (needs testing)
- DefenderFail (pending)
- PRStateFromComments (needs rewrite)
- ADOLog (needs testing)
2. PR Watcher bulk approvals & RandomIEDS (pending)
- Validation DataGridView needs a function to write to it.
- ListingDiff (pending)
- ManifestListing (pending)
3. ToWork Search & Full ToWork Run (need rewrite)
- PRStateFromComments (needs rewrite)
4. Every second / 5 seconds - Run Tracker
- VM Window arrangement (50% rewritten)
- VM Cycle (pending)
- GenerateVM (pending)
- DisgenerateVM (pending)
- RenameVM (pending)
- RedoCheckpoint (pending)
- CheckpointVM (pending)
- RemoveVMSnapshot (pending)
- ImportVM (pending)
- SetVMMemory (pending)
- RebuildStatus (pending)
- Automatic VM rotation (pending)
7. Update manifest tools
- SingleFileAutomation (pending)
- ManifestAutomation (pending)
- ManifestFile (pending)
8. AddValidationData - need a form to fill out. (and testing)
9. FullReport (needs testing)
10. AddPRToRecord (needs bugfix)
- Squash-merge and Closed stats should be higher, but some of the data is “evaporating” before it reaches the logs.
11. PRReportFromRecord (needs testing)
12. Import new image VM
- MoveVMStorage (pending)
- ImageVMMove (pending)
13. Win11 image VM
- ImageVMStart (pending)
- ImageVMStop (pending)
14. Update manifest
- In PR
- AddDependencyToPR (pending)
- UpdateHashInPR/2 (pending)
- UpdateArchInPR (pending)
- On Disk
- AddToValidationFile (pending)
- AddInstallerSwitch (pending)
15. Require admin/UAC (for VMs – might have non-admin mode that uses sandbox instead)
- OpenSandbox (pending)
16. Preferences (pending)
- Window arrangement
- Hourly Mode
- Warnings
- Add warnings
- Enable clipboard watching (manifests/)
- Enable approvals
- Enable Waivers?
- Comment-based moderator controls
- Use sandbox instead of VMs and don't require Admin/UAC
- Open VM folder
17. Status bar (pending)
18. PR counters on certain buttons - Approval-Ready, ToWork, Defender, IEDS
19. Buttons/controls foreach VM in VM display: Complete, open PR, open files on disk, Add dependency (Default VS2015 isf User Input is empty.),
- Faster/better to have in-VM controls or in-app controls, or both? Why?
- Double-click VM row to bring window to front.
20. Process for adding PackageIdentifier or PR# to VM display.
*/
//////////////////////////////////////////====================////////////////////////////////////////
//////////////////////====================--------------------====================////////////////////
//====================-------------------- Init vars --------------------====================
//////////////////////====================--------------------====================////////////////////
//////////////////////////////////////////====================////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Management;
using System.Net;
using System.Runtime.InteropServices;
using System.Security.Principal;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Forms;
using System.Web.Script.Serialization;
namespace WinGetApprovalNamespace {
public class WinGetApprovalPipeline : Form {
//vars
public int build = 931;//Get-RebuildPipeApp
public string appName = "WinGetApprovalPipeline";
public string appTitle = "WinGet Approval Pipeline - Build ";
public static string owner = "microsoft";
public static string repo = "winget-pkgs";
public static string remoteIP = Dns.GetHostEntry(Dns.GetHostName()).AddressList.Where(n => n.ToString().Contains("172.")).FirstOrDefault().ToString();
//PowerShell: $remoteIP = ([ipaddress](($ipconfig[($ipconfig | Select-String "vEthernet").LineNumber..$ipconfig.Length] | Select-String "IPv4 Address") -split ": ")[1]).IPAddressToString
//From VM perspective - for validation script builder.
public static string RemoteMainFolder = "//"+remoteIP+"/";
public string SharedFolder = RemoteMainFolder+"/write";
//Meanwhile, back on the host...
public static string MainFolder = "C:\\ManVal";
public string runPath = MainFolder+"\\vm\\"; //VM working folder;
public string vmCounter = MainFolder+"\\vmcounter.txt";
public string VMversion = MainFolder+"\\VMversion.txt";
public string LogFile = MainFolder+"\\misc\\ApprovedPRs.txt";
public string PeriodicRunLog = MainFolder+"\\misc\\PeriodicRunLog.txt";
public static string logsFolder = MainFolder+"\\logs"; //VM Logs folder;
public string timecardfile = logsFolder+"\\timecard.txt";
public string TrackerModeFile = logsFolder+"\\trackermode.txt";
public static string writeFolder = MainFolder+"\\write"; //Folder with write permissions;
public string SharedErrorFile = writeFolder+"\\err.txt";
public string StatusFile = writeFolder+"\\status.csv";
public static string ReposFolder = "C:\\repos\\"+repo;
public string DataFileName = ReposFolder+"\\Tools\\ManualValidationPipeline.csv";
public static string imagesFolder = MainFolder+"\\Images"; //VM Images folder;
public string Win10Folder = imagesFolder+"\\Win10-Created053025-Original";
public string Win11Folder = imagesFolder+"\\Win11-Created010424-Original";
public static string GitHubBaseUrl = "https://github.com/"+owner+"/"+repo;
public static string GitHubContentBaseUrl = "https://raw.githubusercontent.com/"+owner+"/"+repo;
public static string GitHubApiBaseUrl = "https://api.github.com/repos/"+owner+"/"+repo;
public string ADOMSBaseUrl = "https://dev.azure.com/shine-oss";
//ADOLogs - should be refactored to be in-memory.
public static string DestinationPath = MainFolder+"\\Installers";
public static string LogPath = DestinationPath+"\\InstallationVerificationLogs\\";
public static string ZipPath = DestinationPath+"\\InstallationVerificationLogs.zip";
public string CheckpointName = "Validation";
public string VMUserName = "user"; //Set to the internal username you're using in your VMs.;
public string gitHubUserName = "stephengillie";
//public string SystemRAM = (Get-CimInstance Win32_PhysicalMemory | Measure-Object -Property capacity -Sum).sum /1gb;
public int displayLine = 0;
public static string string_PRRegex = "[0-9]{5,6}";
public static string string_hashPRRegex = "[#]"+string_PRRegex;
public static string string_hashPRRegexEnd = string_hashPRRegex+"$";
public static string string_colonPRRegex = string_PRRegex+"[:]";
public Regex regex_PRRegex = new Regex(@string_PRRegex);
public Regex regex_hashPRRegex = new Regex(@string_hashPRRegex);
public Regex regex_hashPRRegexEnd = new Regex(@string_hashPRRegexEnd);
public Regex regex_colonPRRegex = new Regex(@string_colonPRRegex);
public string file_GitHubToken = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "\\Documents\\PowerShell\\ght.txt";
//public string file_GitHubToken = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "\\Documents\\PowerShell\\ght.txt";
public string GitHubToken;
public bool TokenLoaded = false;
public int GitHubRateLimitDelay = 333; // ms
public int HyperVRateLimitDelay = 3; // seconds
//JSON
JavaScriptSerializer serializer = new JavaScriptSerializer();
//WMI for local VMs
public ManagementScope scope = new ManagementScope(@"root\virtualization\v2");//, null);
/* Remote VMs
var connectionOptions = new ConnectionOptions(
@"en-US",
@"domain\user",
@"password",
null,
ImpersonationLevel.Impersonate,
AuthenticationLevel.Default,
false,
null,
TimeSpan.FromSeconds(5);
public ManagementScope scope = new ManagementScope(new ManagementPath { Server = "hostnameOrIpAddress", NamespacePath = @"root\virtualization\v2" }, connectionOptions);scope.Connect();
*/
//ui
public RichTextBox outBox_msg;
public System.Drawing.Bitmap myBitmap;//Depreciate
public System.Drawing.Graphics pageGraphics;//Depreciate?
public Panel pagePanel;
public ContextMenuStrip contextMenu1;//Menu?
public TextBox inputBox_PRNumber, inputBox_User, inputBox_VMRAM;
public Label label_VMRAM = new Label();
public Label label_User = new Label();
public Label label_PRNumber = new Label();
public DataGridView dataGridView_vm = new DataGridView();
public DataGridView dataGridView_val = new DataGridView();
public DataTable table_vm = new DataTable();
public DataTable table_val = new DataTable();
public Button btn0, btn1, btn2, btn3, btn4, btn5, btn6, btn7, btn8, btn9;
public Button btn10, btn11, btn12, btn13, btn14, btn15, btn16, btn17, btn18, btn19;
public Button btn20, btn21, btn22, btn23, btn24, btn25, btn26, btn27, btn28;
public ToolTip toolTip1, toolTip2, toolTip3, toolTip4;
public StatusStrip statusStrip1;
public ToolStripStatusLabel toolStripStatusLabel1;
int DarkMode = 1;//(int)Microsoft.Win32.Registry.GetValue("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", "AppsUseLightTheme", -1);
//0 : dark theme
//1 : light theme
//-1 : AppsUseLightTheme could not be found
public Color color_DefaultBack = Color.FromArgb(240,240,240);
public Color color_DefaultText = Color.FromArgb(0,0,0);
public Color color_InputBack = Color.FromArgb(255,255,255);
public Color color_ActiveBack = Color.FromArgb(200,240,240);
int table_vm_Row_Index = 0;
//PRWatch
public string oldclip = "";
public string PRTitle = "";
//Grid
public static int gridItemWidth = 70;
public static int gridItemHeight = 45;
public int lineHeight = 14;
public int WindowWidth = gridItemWidth*15+20;
public int WindowHeight = gridItemHeight*12+20;
//Fonts
string AppFont = "Calibri";
int AppFontSIze = 12;
int urlBoxFontSIze = 12;
string buttonFont = SystemFonts.MessageBoxFont.ToString();
int buttonFontSIze = 8;
//////////////////////////////////////////====================////////////////////////////////////////
//////////////////////====================--------------------====================////////////////////
//====================-------------------- Boilerplate --------------------====================
//////////////////////====================--------------------====================////////////////////
//////////////////////////////////////////====================////////////////////////////////////////
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new WinGetApprovalPipeline());
}// end Main
public WinGetApprovalPipeline() {
if (TokenLoaded == false) {
GitHubToken = GetContent(file_GitHubToken);
if (GitHubToken.Length > 0) {
TokenLoaded = true;
}
}
System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
timer.Interval = (1 * 1000); // 10 secs
timer.Tick += new EventHandler(timer_everysecond);
timer.Start();
this.Text = appTitle + build;
this.Size = new Size(WindowWidth,WindowHeight);
//this.StartPosition = FormStartPosition.CenterScreen;
//this.MaximizeBox = false;
//this.FormBorderStyle = FormBorderStyle.FixedSingle;
this.Resize += new System.EventHandler(this.OnResize);
this.AutoScroll = true;
Icon icon = Icon.ExtractAssociatedIcon("ManualValidationPipeline.ico");
this.Icon = icon;
if (DarkMode == 0) {
color_DefaultBack = Color.FromArgb(33,33,33);
color_DefaultText = Color.FromArgb(200,200,200);
color_ActiveBack = Color.FromArgb(15,55,105);
color_InputBack = Color.FromArgb(0,0,0);
}
this.BackColor = color_DefaultBack;
this.ForeColor = color_DefaultText;
drawMenuBar();
drawUrlBoxAndGoButton();
RefreshStatus();
} // end WinGetApprovalPipeline
//////////////////////////////////////////====================////////////////////////////////////////
//////////////////////====================--------------------====================////////////////////
//====================-------------------- UI top-of-box --------------------====================
//////////////////////====================--------------------====================////////////////////
//////////////////////////////////////////====================////////////////////////////////////////
public void drawButton(ref Button button, int pointX, int pointY, int sizeX, int sizeY,string buttonText, EventHandler buttonOnclick){
button = new Button();
button.Text = buttonText;
button.Location = new Point(pointX, pointY);
button.Size = new Size(sizeX, sizeY);
button.BackColor = color_DefaultBack;
button.ForeColor = color_DefaultText;
button.Click += new EventHandler(buttonOnclick);
button.Font = new Font(buttonFont, buttonFontSIze);
Controls.Add(button);
}// end drawButton
public void drawRichTextBox(ref RichTextBox richTextBox, int pointX,int pointY,int sizeX,int sizeY,string text, string name){
richTextBox = new RichTextBox();
richTextBox.Text = text;
richTextBox.Name = name;
richTextBox.Multiline = true;
richTextBox.AcceptsTab = true;
richTextBox.WordWrap = true;
richTextBox.ReadOnly = true;
richTextBox.DetectUrls = true;
richTextBox.BackColor = color_DefaultBack;
richTextBox.ForeColor = color_DefaultText;
richTextBox.Font = new Font(AppFont, AppFontSIze);
richTextBox.Location = new Point(pointX, pointY);
//richTextBox.LinkClicked += new LinkClickedEventHandler(Link_Click);
richTextBox.Width = sizeX;
richTextBox.Height = sizeY;
//richTextBox.Dock = DockStyle.Fill;
richTextBox.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None;
//richTextBox.BackColor = Color.Red;
//richTextBox.ForeColor = Color.Blue;
//richTextBox.RichTextBoxScrollBars = ScrollBars.Both;
//richTextBox.AcceptsReturn = true;
Controls.Add(richTextBox);
}// end drawRichTextBox
public void drawUrlBox(ref TextBox urlBox, int pointX, int pointY, int sizeX, int sizeY,string text){
urlBox = new TextBox();
urlBox.Text = text;
urlBox.Name = "urlBox";
urlBox.Font = new Font(AppFont, urlBoxFontSIze);
urlBox.Location = new Point(pointX, pointY);
urlBox.BackColor = color_InputBack;
urlBox.ForeColor = color_DefaultText;
urlBox.Width = sizeX;
urlBox.Height = sizeY;
Controls.Add(urlBox);
}
public void drawLabel(ref Label newLabel, int pointX, int pointY, int sizeX, int sizeY,string text){
newLabel = new Label();
newLabel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
//newLabel.ImageList = imageList1;
newLabel.ImageIndex = 1;
newLabel.ImageAlign = ContentAlignment.TopLeft;
newLabel.BackColor = color_DefaultBack;
newLabel.ForeColor = color_DefaultText;
newLabel.Name = "newLabel";
newLabel.Font = new Font(AppFont, AppFontSIze);
newLabel.Location = new Point(pointX, pointY);
newLabel.Width = sizeX;
newLabel.Height = sizeY;
//newLabel.KeyUp += newLabel_KeyUp;
newLabel.Text = text;
//newLabel.Size = new Size (label1.PreferredWidth, label1.PreferredHeight);
Controls.Add(newLabel);
}
public void drawDataGrid(ref DataGridView dataGridView, int startX, int startY, int sizeX, int sizeY){
dataGridView = new DataGridView();
dataGridView.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Raised;
dataGridView.CellBorderStyle = DataGridViewCellBorderStyle.Single;
dataGridView.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
dataGridView.ForeColor = color_DefaultText;//Selected cell text color
dataGridView.BackColor = color_DefaultBack;//Selected cell BG color
dataGridView.DefaultCellStyle.SelectionForeColor = color_DefaultText;//Unselected cell text color
dataGridView.DefaultCellStyle.SelectionBackColor = color_DefaultBack;//Unselected cell BG color
dataGridView.BackgroundColor = color_DefaultBack;//Space underneath/between cells
dataGridView.GridColor = SystemColors.ActiveBorder;//Gridline color
dataGridView.Name = "dataGridView";
dataGridView.Font = new Font(AppFont, AppFontSIze);
dataGridView.Location = new Point(startX, startY);
dataGridView.Size = new Size(sizeX, sizeY);
// dataGridView.KeyUp += dataGridView_KeyUp;
// dataGridView.Text = text;
Controls.Add(dataGridView);
dataGridView.EditMode = DataGridViewEditMode.EditProgrammatically;
dataGridView.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.RowHeadersVisible = false;
dataGridView.MultiSelect = false;
//dataGridView.Dock = DockStyle.Fill;
/*
dataGridView.CellFormatting += new DataGridViewCellFormattingEventHandler(dataGridView_CellFormatting);
dataGridView.CellParsing += new DataGridViewCellParsingEventHandler(dataGridView_CellParsing);
addNewRowButton.Click += new EventHandler(addNewRowButton_Click);
deleteRowButton.Click += new EventHandler(deleteRowButton_Click);
ledgerStyleButton.Click += new EventHandler(ledgerStyleButton_Click);
dataGridView.CellValidating += new DataGridViewCellValidatingEventHandler(dataGridView_CellValidating);
*/
}// end drawDataGrid
public void drawToolTip(ref ToolTip toolTip, ref Button button, string DisplayText, int AutoPopDelay = 5000, int InitialDelay = 1000, int ReshowDelay = 500){
toolTip = new ToolTip();
// Set up the delays for the ToolTip.
toolTip.AutoPopDelay = AutoPopDelay;
toolTip.InitialDelay = InitialDelay;
toolTip.ReshowDelay = ReshowDelay;
// Force the ToolTip text to be displayed whether or not the form is active.
toolTip.ShowAlways = true;
// Set up the ToolTip text for the Button and Checkbox.
toolTip.SetToolTip(button, DisplayText);
//toolTip.SetToolTip(this.checkBox1, "My checkBox1");
}
public void drawStatusStrip (StatusStrip statusStrip,ToolStripStatusLabel toolStripStatusLabel) {
statusStrip = new System.Windows.Forms.StatusStrip();
statusStrip.Dock = System.Windows.Forms.DockStyle.Bottom;
statusStrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Visible;
toolStripStatusLabel = new System.Windows.Forms.ToolStripStatusLabel();
toolStripStatusLabel.Name = "toolStripStatusLabel";
toolStripStatusLabel.Size = new System.Drawing.Size(109, 17);
toolStripStatusLabel.Text = "toolStripStatusLabel";
statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { toolStripStatusLabel });
statusStrip.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.HorizontalStackWithOverflow;
statusStrip.Location = new System.Drawing.Point(0, 0);
statusStrip.Name = "statusStrip";
statusStrip.ShowItemToolTips = true;
statusStrip.Size = new System.Drawing.Size(292, 22);
statusStrip.SizingGrip = false;
statusStrip.Stretch = false;
statusStrip.TabIndex = 0;
statusStrip.Text = "statusStrip";
Controls.Add(statusStrip);
}
public void drawMenuBar (){
this.Menu = new MainMenu();
MenuItem item = new MenuItem("File");
this.Menu.MenuItems.Add(item);
item.MenuItems.Add("(disabled) Specify key file location...", new EventHandler(Save_File_Action));
item.MenuItems.Add("(disabled) Generate daily report", new EventHandler(About_Click_Action));
item = new MenuItem("Selected VM");
this.Menu.MenuItems.Add(item);
item.MenuItems.Add("Complete VM", new EventHandler(Complete_VM_Image_Action));
item.MenuItems.Add("Relaunch window", new EventHandler(Launch_Window_Image_Action));
item.MenuItems.Add("Open VM folder", new EventHandler(Open_Folder_Image_Action));
MenuItem submenu = new MenuItem("WIn10 Image VM");
item.MenuItems.Add(submenu);
submenu.MenuItems.Add("Generate VM from image", new EventHandler(Generate_Win10_VM_Image_Action));
submenu.MenuItems.Add("Start", new EventHandler(Start_Win10_Image_Action));
submenu.MenuItems.Add("Relaunch window", new EventHandler(Launch_Win10_Window_Image_Action));
submenu.MenuItems.Add("Stop", new EventHandler(Stop_Win10_Image_Action));
submenu.MenuItems.Add("Turn off", new EventHandler(TurnOff_Win10_Image_Action));
submenu.MenuItems.Add("Attach new image VM", new EventHandler(Attach_Win10_Image_Action));
submenu = new MenuItem("Win11 Image VM");
item.MenuItems.Add(submenu);
submenu.MenuItems.Add("Generate VM from image", new EventHandler(Generate_Win11_VM_Image_Action));
submenu.MenuItems.Add("Start", new EventHandler(Start_Win11_Image_Action));
submenu.MenuItems.Add("Relaunch window", new EventHandler(Launch_Win11_Window_Image_Action));
submenu.MenuItems.Add("Stop", new EventHandler(Stop_Win11_Image_Action));
submenu.MenuItems.Add("Turn Off", new EventHandler(TurnOff_Win11_Image_Action));
submenu.MenuItems.Add("Attach new image VM", new EventHandler(Attach_Win11_Image_Action));
item.MenuItems.Add("Disgenerate VM", new EventHandler(Disgenerate_VM_Image_Action));
item = new MenuItem("Validate Manifest");
this.Menu.MenuItems.Add(item);
item.MenuItems.Add("Regular Validation", new EventHandler(Validate_Manifest_Action));
item.MenuItems.Add("DSC Configure", new EventHandler(Validate_By_Configure_Action));
item.MenuItems.Add("By PackageIdentifier (User Input)", new EventHandler(Validate_By_ID_Action));
item.MenuItems.Add("By Arch", new EventHandler(Validate_By_Arch_Action));
item.MenuItems.Add("By Scope", new EventHandler(Validate_By_Scope_Action));
item.MenuItems.Add("Both Arch and Scope", new EventHandler(Validate_By_Arch_And_Scope_Action));
submenu = new MenuItem("Generate manifest for selected VM");
item.MenuItems.Add(submenu);
submenu.MenuItems.Add("Manifest from clipboard", new EventHandler(Manifest_From_Clipboard));
submenu.MenuItems.Add("Installer.yaml and the rest from GH", new EventHandler(Single_File_Automation_Action));
submenu = new MenuItem("Update manifest");
item.MenuItems.Add(submenu);
submenu.MenuItems.Add("Add dependency (VS2015+)", new EventHandler(Add_Dependency_Disk_Action));
submenu.MenuItems.Add("Add installer switch (/S)", new EventHandler(Add_Installer_Switch_Action));
item = new MenuItem("Current PR");
this.Menu.MenuItems.Add(item);
submenu = new MenuItem("Approve PR");
item.MenuItems.Add(submenu);
submenu.MenuItems.Add("Approve PR", new EventHandler(Approved_Action));
submenu = new MenuItem("Update PR");
item.MenuItems.Add(submenu);
submenu.MenuItems.Add("@wingetbot run", new EventHandler(Retry_Action));
submenu.MenuItems.Add("Label Action", new EventHandler(Label_Action_Action));
submenu.MenuItems.Add("Check installer", new EventHandler(Check_Installer_Action));
submenu = new MenuItem("Update manifest");
item.MenuItems.Add(submenu);
submenu.MenuItems.Add("Add dependency (VS2015+)", new EventHandler(Add_Dependency_Repo_Action));
submenu.MenuItems.Add("Update hash 'Specified hash doesn't match.'", new EventHandler(Update_Hash_Action));
submenu.MenuItems.Add("Update hash 2 'SHA256 in manifest...'", new EventHandler(Update_Hash2_Action));
submenu.MenuItems.Add("Update architecture (x64)", new EventHandler(Update_Arch_Action));
submenu = new MenuItem("Complete PR");
item.MenuItems.Add(submenu);
submenu.MenuItems.Add("Installs Normally in VM", new EventHandler(Manually_Validated_Action));
submenu = new MenuItem("Wingetbot Close");
item.MenuItems.Add(submenu);
submenu.MenuItems.Add("Close: Merge Conflicts;", new EventHandler(Merge_Conflicts_Action));
submenu.MenuItems.Add("Close: Version Already Exists;", new EventHandler(Version_Already_Exiss_Action));
submenu.MenuItems.Add("Close: Regen with new hash;", new EventHandler(Regen_Hash_Action));
submenu = new MenuItem("Regular Close");
item.MenuItems.Add(submenu);
submenu.MenuItems.Add("Close: (User Input);", new EventHandler(Closed_Action));
submenu.MenuItems.Add("Close: Package still available;", new EventHandler(Package_Available_Action));
submenu.MenuItems.Add("Close: Duplicate of (User Input);", new EventHandler(Duplicate_Action));
// item.MenuItems.Add("Add Waiver", new EventHandler(Add_Waiver_Action));
// item.MenuItems.Add("(disabled) Needs Author Feedback (reason)", new EventHandler(Needs_Author_Feedback_Action));
// submenu = new MenuItem("Canned Replies");
// item.MenuItems.Add(submenu);
// submenu.MenuItems.Add("Automation block", new EventHandler(Automation_Block_Action));
// submenu.MenuItems.Add("Driver install", new EventHandler(Driver_Install_Action));
// submenu.MenuItems.Add("Installer missing", new EventHandler(Installer_Missing_Action));
// submenu.MenuItems.Add("Installer not silent", new EventHandler(Installer_Not_Silent_Action));
// submenu.MenuItems.Add("Needs PackageUrl", new EventHandler(Needs_PackageUrl_Action));
// submenu.MenuItems.Add("One manifest per PR", new EventHandler(One_Manifest_Per_PR_Action));
// item.MenuItems.Add("Record as Project File", new EventHandler(Project_File_Action));
// item.MenuItems.Add("Record as squash-merge", new EventHandler(Squash_Action));
item = new MenuItem("Open In Browser");
this.Menu.MenuItems.Add(item);
item.MenuItems.Add("Current PR", new EventHandler(Open_Current_PR_Action));
item.MenuItems.Add("PR for selected VM", new EventHandler(Open_PR_Selected_VM_Action));
submenu = new MenuItem("Open many tabs:");
item.MenuItems.Add(submenu);
submenu.MenuItems.Add("All PRs on clipboard", new EventHandler(Open_AllUrls_Action));
submenu.MenuItems.Add("Full Approval Run", new EventHandler(Approval_Run_Search_Action));
submenu.MenuItems.Add("Full ToWork Run", new EventHandler(ToWork_Run_Search_Action));
submenu.MenuItems.Add("All Start Of Day", new EventHandler(Start_Of_Day_Action));
submenu.MenuItems.Add("All Resources", new EventHandler(All_Resources_Action));
submenu = new MenuItem("Start Of Day:");
item.MenuItems.Add(submenu);
submenu.MenuItems.Add("WinGet-pkgs repo", new EventHandler(Open_PKGS_Repo_Action));
submenu.MenuItems.Add("WinGet-cli repo", new EventHandler(Open_CLI_Repo_Action)); submenu = new MenuItem("Resources:");
item.MenuItems.Add(submenu);
submenu.MenuItems.Add("Gitter chat", new EventHandler(Open_Gitter_Action));
submenu.MenuItems.Add("Pipeline status", new EventHandler(Open_Pipeline_Action));
submenu.MenuItems.Add("Dashboard", new EventHandler(Open_Dashboard_Action));
submenu.MenuItems.Add("Notifications mentions", new EventHandler(Open_Notifications_Action));
submenu.MenuItems.Add("Approval search", new EventHandler(Approval_Search_Action));
submenu.MenuItems.Add("Defender search", new EventHandler(Defender_Search_Action));
submenu.MenuItems.Add("ToWork search", new EventHandler(ToWork_Search_Action));
item.MenuItems.Add("Search GitHub for PRs (User Input)", new EventHandler(Pkgs_Search_Action));
item.MenuItems.Add("Approved PR selected below", new EventHandler(Open_SelectedApproved_Action));
item = new MenuItem("Help");
this.Menu.MenuItems.Add(item);
item.MenuItems.Add("About...", new EventHandler(About_Click_Action));
item.MenuItems.Add("VCRedist to dependency...", new EventHandler(VCDependency_Click_Action));
this.BackColor = color_DefaultBack;
this.ForeColor = color_DefaultText;
}// end drawMenuBar
public void drawUrlBoxAndGoButton(){
int inc = 0;
int row0 = gridItemHeight*inc;inc++;
int row1 = gridItemHeight*inc;inc++;
int row2 = gridItemHeight*inc;inc++;
int row3 = gridItemHeight*inc;inc++;
int row4 = gridItemHeight*inc;inc++;
int row5 = gridItemHeight*inc;inc++;
int row6 = gridItemHeight*inc;inc++;
int row7 = gridItemHeight*inc;inc++;
int row8 = gridItemHeight*inc;inc++;
int row9 = gridItemHeight*inc;inc++;
int row10 = gridItemHeight*inc;inc++;
inc = 0;
int col0 = gridItemWidth*inc;inc++;
int col1 = gridItemWidth*inc;inc++;
int col2 = gridItemWidth*inc;inc++;
int col3 = gridItemWidth*inc;inc++;
int col4 = gridItemWidth*inc;inc++;
int col5 = gridItemWidth*inc;inc++;
int col6 = gridItemWidth*inc;inc++;
int col7 = gridItemWidth*inc;inc++;
int col8 = gridItemWidth*inc;inc++;
int col9 = gridItemWidth*inc;inc++;
int col10 = gridItemWidth*inc;inc++;
//drawStatusStrip(statusStrip1, toolStripStatusLabel1);
table_vm.Columns.Add("vm", typeof(string));
table_vm.Columns.Add("status", typeof(string));
table_vm.Columns.Add("version", typeof(int));
table_vm.Columns.Add("OS", typeof(string));
table_vm.Columns.Add("Package", typeof(string));
table_vm.Columns.Add("PR", typeof(int));
table_vm.Columns.Add("Mode", typeof(string));
table_vm.Columns.Add("RAM", typeof(double));
table_val.Columns.Add("Timestamp", typeof(string));
table_val.Columns.Add("PR", typeof(int));
table_val.Columns.Add("PackageIdentifier", typeof(string));
table_val.Columns.Add("prVersion", typeof(string));
table_val.Columns.Add("A", typeof(string));
table_val.Columns.Add("M", typeof(int));
table_val.Columns.Add("R", typeof(string));
table_val.Columns.Add("G", typeof(string));
table_val.Columns.Add("W", typeof(string));
table_val.Columns.Add("F", typeof(string));
table_val.Columns.Add("I", typeof(string));
table_val.Columns.Add("D", typeof(string));
table_val.Columns.Add("V", typeof(string));
table_val.Columns.Add("ManifestVer", typeof(string));
table_val.Columns.Add("OK", typeof(string));
foreach (DataGridViewColumn column in dataGridView_vm.Columns){
column.SortMode = DataGridViewColumnSortMode.NotSortable;
}
drawDataGrid(ref dataGridView_vm, col0, row0, gridItemWidth*7, gridItemHeight*5);
drawLabel(ref label_PRNumber, col6, row0, gridItemWidth, gridItemHeight,"Current PR:");
drawUrlBox(ref inputBox_PRNumber, col7, row0, gridItemWidth*2,gridItemHeight,"#000000");
drawLabel(ref label_User, col6, row1, gridItemWidth, gridItemHeight,"User Input:");
drawUrlBox(ref inputBox_User,col7, row1, gridItemWidth*2,gridItemHeight,"");//UserInput field
drawLabel(ref label_VMRAM, col6, row2, gridItemWidth, gridItemHeight,"VM RAM:");
drawUrlBox(ref inputBox_VMRAM,col7, row2, gridItemWidth*2,gridItemHeight,"");//VM RAM display
drawDataGrid(ref dataGridView_val, col0, row5, gridItemWidth*8, gridItemHeight*5);
//dataGridView_val.Anchor = AnchorStyles.Top | AnchorStyles.Bottom;
drawRichTextBox(ref outBox_msg, col0, row10, this.ClientRectangle.Width,gridItemHeight, "", "outBox_msg");
drawButton(ref btn10, col6, row3, gridItemWidth, gridItemHeight, "Bulk Approving", Approving_Action);
drawToolTip(ref toolTip1, ref btn10, "Automatically approve PRs. (Caution - easy to accidentally approve, use with care.)");
drawButton(ref btn18, col7, row3, gridItemWidth, gridItemHeight, "Individual Validations", Validating_Action);
drawToolTip(ref toolTip2, ref btn18, "Automatically start manifest in VM.");
drawButton(ref btn11, col6, row4, gridItemWidth, gridItemHeight, "Validate Rand IEDS", IEDS_Action);
drawToolTip(ref toolTip3, ref btn11, "Automatically start manifest for random IEDS in VM.");
drawButton(ref btn19, col7, row4, gridItemWidth, gridItemHeight, "Idle Mode", Idle_Action);
drawToolTip(ref toolTip4, ref btn19, "It does nothing.");
drawButton(ref btn20, col8, row3, gridItemWidth, gridItemHeight, "Testing button", Testing_Action);
drawButton(ref btn21, col8, row4, gridItemWidth, gridItemHeight, "Testing button 2", Testing2_Action);
}// end drawGoButton
public void OnResize(object sender, System.EventArgs e) {
//Width - VM and Validation windows adjust with window.
dataGridView_vm.Width = ClientRectangle.Width - gridItemWidth*3;// - gridItemWidth*2;
dataGridView_val.Width = ClientRectangle.Width;// - gridItemWidth*2;
outBox_msg.Width = ClientRectangle.Width;
inputBox_PRNumber.Left = ClientRectangle.Width - gridItemWidth*2;//col8
inputBox_User.Left = ClientRectangle.Width - gridItemWidth*2;//col8
inputBox_VMRAM.Left = ClientRectangle.Width - gridItemWidth*2;//col8
label_PRNumber.Left = ClientRectangle.Width - gridItemWidth*3;//col7
label_User.Left = ClientRectangle.Width - gridItemWidth*3;//col7
label_VMRAM.Left = ClientRectangle.Width - gridItemWidth*3;//col7
//Height -Validation and mode buttons adjusts with window.
btn10.Left = ClientRectangle.Width - gridItemWidth*3;//col7
btn11.Left = ClientRectangle.Width - gridItemWidth*3;//col7
btn18.Left = ClientRectangle.Width - gridItemWidth*2;//col8
btn19.Left = ClientRectangle.Width - gridItemWidth*2;//col8
btn20.Left = ClientRectangle.Width - gridItemWidth*1;//col9
btn21.Left = ClientRectangle.Width - gridItemWidth*1;//col9
}
//Refresh display and buttons
private void timer_everysecond(object sender, EventArgs e) {
UpdateTableVM();
RefreshStatus();
dataGridView_vm.AutoResizeColumns();
dataGridView_vm.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
dataGridView_val.AutoResizeColumns();
dataGridView_val.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
//Hourly Run functionality
bool HourLatch = false;
if (Int32.Parse(DateTime.Now.ToString("mm")) == 20
&& Int32.Parse(DateTime.Now.ToString("mm")) > 00
&& Int32.Parse(DateTime.Now.ToString("mm")) < 02) {
HourLatch = true;
}
if (HourLatch) {
HourLatch = false;
HourlyRun();
// if (Int32.Parse(DateTime.Now.ToString("mm")) == 20) {
// string seconds = DateTime.Now.ToString("ss");
// Thread.Sleep((60-Int32.Parse(seconds))*1000);//If it's still :20 after, sleep out the minute.
// }
}
//Update PR display
string clip = Clipboard.GetText();
Regex regex = new Regex("^[0-9]{6}$");
string[] clipSplit = clip.Replace("\r\n","\n").Replace("\n"," ").Replace("/"," ").Replace("#"," ").Replace(";"," ").Split(' ');
string c = clipSplit.Where(n => regex.IsMatch(n)).FirstOrDefault();
if (null != c) {
if (regex.IsMatch(c)) {
inputBox_PRNumber.Text = "#"+c;
}
}
string Mode = GetMode();
//Automatic clipboard actions
regex = new Regex(@"^manifests/");
if (clip.Contains("Skip to content")) {
if (Mode == "Validating") {
//ValidateManifest;
// Mode | clip
} else if (Mode == "Approving") {
PRWatch(false, "Default", "C:\\ManVal\\misc\\ApprovedPRs.txt", "C:\\repos\\winget-pkgs\\Tools\\Review.csv");
}
} else if (regex.IsMatch(clip)) {
Clipboard.SetText("open manifest");
string ManifestUrl = GitHubBaseUrl+"/tree/master/"+clip;
System.Diagnostics.Process.Start(ManifestUrl);
}
//Random IEDS mode
// if ($Mode == "IEDS") {
// if ((Get-ArraySum (GetStatus()).RAM) < ($SystemRAM*.42)) {
// RandomIEDS();
// }
// }
//Automatic RAM adjustment
// (Get-VM) | foreach-Object {
// if(($_.MemoryDemand / $_.MemoryMaximum) -ge 0.9){
// set-vm -VMName $_.name -MemoryMaximumBytes "$(($_.MemoryMaximum / 1073741824)+2)GB"
// }
// }
//CycleVMs();
//WindowArrange();
//RotateVMs();
}
public void HourlyRun() {
Console.Beep(500,250);Console.Beep(500,250);Console.Beep(500,250); //Beep 3x to alert the PC user.
foreach (string Preset in HourlyRun_PresetList) {
dynamic Results = SearchGitHub(Preset,1);
if (Results != null) {
//foreach (int Result in Results) {
// LabelAction(Result);
//}
}
}
}
public void RefreshStatus() {
string Mode = "";
if (TestPath(TrackerModeFile) == "File") {
Mode = GetMode();
}
if (Mode == "Approving") {
btn10.BackColor = color_ActiveBack;//Bulk Approving
btn18.BackColor = color_DefaultBack;//Individual Validations
btn11.BackColor = color_DefaultBack;//IEDS
btn19.BackColor = color_DefaultBack;//Idle
} else if (Mode == "Validating") {
btn10.BackColor = color_DefaultBack;//Bulk Approving
btn18.BackColor = color_ActiveBack;//Individual Validations
btn11.BackColor = color_DefaultBack;//IEDS
btn19.BackColor = color_DefaultBack;//Idle
} else if (Mode == "IEDS") {
btn10.BackColor = color_DefaultBack;//Bulk Approving
btn18.BackColor = color_DefaultBack;//Individual Validations
btn11.BackColor = color_ActiveBack;//IEDS
btn19.BackColor = color_DefaultBack;//Idle
} else if (Mode == "Idle") {
btn10.BackColor = color_DefaultBack;//Bulk Approving
btn18.BackColor = color_DefaultBack;//Individual Validations
btn11.BackColor = color_DefaultBack;//IEDS
btn19.BackColor = color_ActiveBack;//Idle
} else if (Mode == "Config") {
btn10.BackColor = color_DefaultBack;//Bulk Approving
btn18.BackColor = color_DefaultBack;//Individual Validations
btn11.BackColor = color_DefaultBack;//IEDS
btn19.BackColor = color_DefaultBack;//Idle
}
if (TestPath(StatusFile) == "File") {
double VMRAM = 0;
try {
Dictionary<string,object>[] GetStatus = FromCsv(GetContent(StatusFile));
//Update RAM column and write
for (int VM = 0; VM < GetStatus.Length -1; VM++) {
//$_.RAM = Math.Round((Get-VM -Name ("vm"+$_.vm)).MemoryAssigned/1024/1024/1024,2)}
try {
VMRAM += Convert.ToDouble(GetStatus[VM]["RAM"]);
} catch (Exception e) {
inputBox_VMRAM.Text = "VM"+VM+": "+e.ToString();
}//end try
}//end for VM
} catch {}
inputBox_VMRAM.Text = VMRAM.ToString();
}//end if TestPath
}//end function
public void UpdateTableVM() {
try {
if (TestPath(StatusFile) == "File") {
if (dataGridView_vm.SelectedCells.Count > 0) {//Record the selected row.
table_vm_Row_Index = dataGridView_vm.SelectedCells[0].RowIndex;
} else {
table_vm_Row_Index = 0;
}
table_vm.Clear();//Clear the table
dynamic Status = FromCsv(GetContent(StatusFile, true));
if (Status != null) {
for (int r = 1; r < Status.Length -1; r++){
var rowData = Status[r];//Reload the table
table_vm.Rows.Add(rowData["vm"], rowData["status"], rowData["version"], rowData["OS"], rowData["Package"], rowData["PR"], rowData["Mode"], rowData["RAM"]);
}//end for r
}//end if Status
dataGridView_vm.DataSource=table_vm;
dataGridView_vm.Rows[table_vm_Row_Index].Selected = true;//Reselect the row.
dataGridView_vm.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;//vm
dataGridView_vm.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;//status
dataGridView_vm.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;//version
dataGridView_vm.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;//OS
dataGridView_vm.Columns[4].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;//Package
dataGridView_vm.Columns[5].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;//PR
dataGridView_vm.Columns[6].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;//RAM
dataGridView_val.DataSource=table_val;
dataGridView_val.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCellsExceptHeader;//Timestamp
dataGridView_val.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;//PR
dataGridView_val.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;//PackageIdentifier
dataGridView_val.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCellsExceptHeader;//prVersion
dataGridView_val.Columns[4].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;//A
dataGridView_val.Columns[5].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;//R
dataGridView_val.Columns[6].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;//G
dataGridView_val.Columns[7].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;//W
dataGridView_val.Columns[8].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;//F
dataGridView_val.Columns[9].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;//I
dataGridView_val.Columns[10].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;//D
dataGridView_val.Columns[11].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;//V
dataGridView_val.Columns[12].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCellsExceptHeader;//ManifestVer
dataGridView_val.Columns[13].AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader;//OK
}//end if TestPath
} catch (Exception e){
outBox_msg.AppendText(Environment.NewLine + "e: " + e );
}//end try
}//end function
//////////////////////////////////////////====================////////////////////////////////////////
//////////////////////====================--------------------====================////////////////////
//====================-------------------- Tabs --------------------====================
//////////////////////====================--------------------====================////////////////////
//////////////////////////////////////////====================////////////////////////////////////////
public void PRWatch(bool noNew, string Chromatic = "Default", string LogFile = ".\\PR.txt", string ReviewFile = ".\\Review.csv"){
//$Host.UI.RawUI.WindowTitle = "PR Watcher"//I'm a PR Watcher, watchin PRs go by.
string clip = Clipboard.GetText();
string[] split_clip = clip.Replace("\r\n","\n").Split('\n');
string replace_clip = clip.Replace("'","").Replace("\"","");
PRTitle = split_clip.Where(n => regex_hashPRRegexEnd.IsMatch(n)).FirstOrDefault();
int PR = GetCurrentPR();
if (PRTitle != "") {
if (PRTitle != oldclip) {
//(GetStatus() .Where(n => n["status"] == "ValidationCompleted"} | format-Table);//Drops completed VMs in the middle of the PR approval display.
//Chromatic was here.
string[] title = PRTitle.Split(':');
if (title.Length > 1) {
title = title[1].Split(' ');
} else {
title = title[0].Split(' ');
}
string Submitter = "";
try {
Submitter = split_clip.Where(n => n.Contains("wants to merge")).FirstOrDefault().Split(' ')[0];
} catch {}
string InstallerType = YamlValue("InstallerType",clip);
//Split the title by spaces. Try extracting the version location as the next item after the word "version", and if that fails, use the 2nd to the last item, then 3rd to last, and 4th to last. for some reason almost everyone puts the version number as the last item, and GitHub appends the PR number.
int prVerLoc = 0;
for (int i = 0; i < title.Length; i++) {
if (title[i].Contains("version")) {
prVerLoc = i;
}
}
string PRVersion = YamlValue("PackageVersion",replace_clip);
//Get the PackageIdentifier and alert if it matches the auth list.
string PackageIdentifier = "";
try {
PackageIdentifier = YamlValue("PackageIdentifier",replace_clip);
} catch {
PackageIdentifier = replace_clip;
}
// string matchColor = validColor;
string Timestamp = DateTime.Now.ToString("H:mm:ss");
//Write-Host -nonewline -f $matchColor "| $(Get-Date -format T) | $PR | $(Get-PadRight "PackageIdentifier") | "
DataRow row = table_val.NewRow();
row[0] = Timestamp; //Timestamp
row[1] = PR; //PR (int)
row[2] = PackageIdentifier; //PackageIdentifier
row[3] = ""; //prVersion
row[4] = ""; //A - Auth
row[5] = 0; //M (int) - Major version difference
row[6] = ""; //R - Review file
row[7] = ""; //G - aGreements
row[8] = ""; //W - Word filter
row[9] = ""; //F - apps and Features changed
row[10] = ""; //I - InstallerUrl contains PackageVersion
row[11] = ""; //D - PR has fewer files than manifest
row[12] = ""; //V - Versions remaining
row[13] = ""; //ManifestVer
row[14] = ""; //OK
table_val.Rows.InsertAt(row,0);
int LastRow = 0;//table_val.Rows.Count -1;
table_val.Rows[LastRow].SetField("PRVersion", PRVersion);
string ManifestVersion = FindWinGetVersion(PackageIdentifier);
int PRMajorVersion = Convert.ToInt32(PRVersion.Split('.')[0]);