File: SaveToFile.cs

package info (click to toggle)
sysinfo 0.7-8
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 1,832 kB
  • ctags: 1,140
  • sloc: cs: 2,933; sh: 701; makefile: 115; xml: 98
file content (226 lines) | stat: -rw-r--r-- 9,447 bytes parent folder | download | duplicates (2)
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
// Filename: SaveToFile.cs
// Contains functions to save all the information to plain text file

using System;
using System.IO;
using Gtk;

namespace Sysinfo {
	
	public class SaveToFile {
		

		public void Save(String filename, SystemInfo system_info, CpuInfo cpu_info, MemoryInfo memory_info, StorageInfo storage_info,
		HardwareInfo hardware_info, NvidiaInfo nvidia_info) {
			
			system_info.Release();
			system_info.Gnome();
			system_info.Kernel();
			system_info.Ostype();
			system_info.Gccv();
			system_info.Xorg();
			system_info.Hostname();
			system_info.Uptime();
			
			cpu_info.CpuStaticInfo();
			cpu_info.CpuDynamicInfo();
			
			memory_info.MemoryStaticInfo();
			
			storage_info.IdeInfo();
			storage_info.ScsiInfo();
			
			hardware_info.StaticInfo();
			
			nvidia_info.MainInfo();
			nvidia_info.Version();
			nvidia_info.AditionaInfo();
			
			using (TextWriter textwrite = File.CreateText(filename)) {
			
				textwrite.WriteLine("System information report, generated by Sysinfo: " + DateTime.Now);
				textwrite.WriteLine("http://sourceforge.net/projects/gsysinfo\n");
				                        
				//system
				textwrite.WriteLine("SYSTEM INFORMATION");
				textwrite.WriteLine("\tRunning " + system_info.distro + " " + system_info.system_ostype +  ", the "+ system_info.system_release + " release.");
				textwrite.WriteLine("\tGNOME: " + system_info.system_gnomev + " (" + system_info.system_gnomeo + ")");
				textwrite.WriteLine("\tKernel version: " + system_info.system_kernelv + " (" + system_info.system_kernelb + ")");
				textwrite.WriteLine("\tGCC: " + system_info.system_gcc);
				textwrite.WriteLine("\tXorg: " + system_info.system_xorg);
				textwrite.WriteLine("\tHostname: " + system_info.system_hostname);
				textwrite.WriteLine("\tUptime: " + system_info.system_uptime);
				
				//cpu
				textwrite.WriteLine("\nCPU INFORMATION");
				textwrite.WriteLine("\t" + cpu_info.cpu_vendor + ", " + cpu_info.cpu_name);
				textwrite.WriteLine("\tNumber of CPUs: " + cpu_info.cpu_cpus);
				textwrite.WriteLine("\tCPU clock currently at " + cpu_info.cpu_frequency + " with " + cpu_info.cpu_cache + " cache");
				textwrite.WriteLine("\tNumbering: " + cpu_info.cpu_numbering);
				textwrite.WriteLine("\tBogomips: " + cpu_info.cpu_bogomips);
				textwrite.WriteLine("\tFlags: " + cpu_info.cpu_flags);
				
				//memory
				textwrite.WriteLine("\nMEMORY INFORMATION");
				textwrite.WriteLine("\tTotal memory: " + memory_info.memory_total + " MB");
				textwrite.WriteLine("\tTotal swap: " + memory_info.memory_swaptotal + " MB");
				
				//storage
				textwrite.WriteLine("\nSTORAGE INFORMATION");
				if (storage_info.ide_hda[1] != null ) {
		    		
		    		textwrite.WriteLine("\tPrimary Master /dev/hda - " + storage_info.ide_hda[0]);
					textwrite.WriteLine("\t\tModel: " + storage_info.ide_hda[1]);
					if (storage_info.ide_hda[2] != null)
		    			textwrite.WriteLine("\t\tCapacity: " + storage_info.ide_hda[2]);
		    		if (storage_info.ide_hda[3] != null)
			   			textwrite.WriteLine("\t\tCache: " + storage_info.ide_hda[3]);
				}
				if (storage_info.ide_hdb[1] != null ) {
		    		
		    		textwrite.WriteLine("\tPrimary Master /dev/hdb - " + storage_info.ide_hdb[0]);
					textwrite.WriteLine("\t\tModel: " + storage_info.ide_hdb[1]);
					if (storage_info.ide_hdb[2] != null)
		    		textwrite.WriteLine("\t\tCapacity: " + storage_info.ide_hdb[2]);
		    		if (storage_info.ide_hdb[3] != null)
			   			textwrite.WriteLine("\t\tCache: " + storage_info.ide_hdb[3]);
				}
				if (storage_info.ide_hdc[1] != null ) {
		    		
		    		textwrite.WriteLine("\tPrimary Master /dev/hdc - " + storage_info.ide_hdc[0]);
					textwrite.WriteLine("\t\tModel: " + storage_info.ide_hdc[1]);
					if (storage_info.ide_hdc[2] != null)
		    			textwrite.WriteLine("\t\tCapacity: " + storage_info.ide_hdc[2]);
		    		if (storage_info.ide_hdc[3] != null)
			   			textwrite.WriteLine("\t\tCache: " + storage_info.ide_hdc[3]);
				}
				if (storage_info.ide_hdd[1] != null ) {
		    		
		    		textwrite.WriteLine("\tPrimary Master /dev/hdd - " + storage_info.ide_hdd[0]);
					textwrite.WriteLine("\t\tModel: " + storage_info.ide_hdd[1]);
					if (storage_info.ide_hdd[2] != null)
		    			textwrite.WriteLine("\t\tCapacity: " + storage_info.ide_hdd[2]);
		    		if (storage_info.ide_hdd[3] != null)
			   			textwrite.WriteLine("\t\tCache: " + storage_info.ide_hdd[3]);
				}
				if (storage_info.scsi_1[0] != null) {
		    		
		    		textwrite.WriteLine("\tSCSI device - " + storage_info.scsi_1[0]);;
		    		textwrite.WriteLine("\t\tVendor: " + storage_info.scsi_1[1]);
			   		textwrite.WriteLine("\t\tModel: " + storage_info.scsi_1[2]);
				}
				if (storage_info.scsi_2[0] != null) {
		    		
		    		textwrite.WriteLine("\tSCSI device - " + storage_info.scsi_2[0]);;
		    		textwrite.WriteLine("\t\tVendor: " + storage_info.scsi_2[1]);
			   		textwrite.WriteLine("\t\tModel: " + storage_info.scsi_2[2]);
				}
				if (storage_info.scsi_3[0] != null) {
		    		
		    		textwrite.WriteLine("\tSCSI device - " + storage_info.scsi_3[0]);;
		    		textwrite.WriteLine("\t\tVendor: " + storage_info.scsi_3[1]);
			   		textwrite.WriteLine("\t\tModel: " + storage_info.scsi_3[2]);
				}
				if (storage_info.scsi_4[0] != null) {
		    		
		    		textwrite.WriteLine("\tSCSI device - " + storage_info.scsi_4[0]);;
		    		textwrite.WriteLine("\t\tVendor: " + storage_info.scsi_4[1]);
			   		textwrite.WriteLine("\t\tModel: " + storage_info.scsi_4[2]);
		    	}
		    	
		    	//hardware
		    	textwrite.WriteLine("\nHARDWARE INFORMATION");
				textwrite.WriteLine("MOTHERBOARD");
		    	if ( hardware_info.host_bridge[0] != null ) {
			    		
			    	textwrite.WriteLine("\tHost bridge");
		    		textwrite.WriteLine("\t\t" + hardware_info.host_bridge[0]);
			    	if ( hardware_info.host_bridge[1] != null )
			    		textwrite.WriteLine("\t\tSubsystem: " + hardware_info.host_bridge[1]);
		    	}
		    	if ( hardware_info.pci_bridge.Count > 0 ) {
		    		
		    		textwrite.WriteLine("\tPCI bridge(s)");
		    		foreach (object pci_brdg in hardware_info.pci_bridge) {
			    			textwrite.WriteLine("\t\t" + pci_brdg);
					}
		    	}
		    	if ( hardware_info.usb_controller.Count > 0 ) {
		    		textwrite.WriteLine("\tUSB controller(s)");
		    		foreach (object usb_ctrlr in hardware_info.usb_controller) {
			    			textwrite.WriteLine("\t\t" + usb_ctrlr);
					}
		    	}
		    	if ( hardware_info.isa_bridge[0] != null ) {
			    		
			    	textwrite.WriteLine("\tISA bridge");
		    		textwrite.WriteLine("\t\t" + hardware_info.isa_bridge[0]);
			    	if ( hardware_info.isa_bridge[1] != null )
			    		textwrite.WriteLine("\t\tSubsystem: " + hardware_info.isa_bridge[1]);
		    	}
		    	if ( hardware_info.ide_interface[0] != null ) {
			    		
			    	textwrite.WriteLine("\tIDE interface");
		    		textwrite.WriteLine("\t\t" + hardware_info.ide_interface[0]);
			    	if ( hardware_info.ide_interface[1] != null )
			    		textwrite.WriteLine("\t\tSubsystem: " + hardware_info.ide_interface[1]);
		    	}
		    	textwrite.WriteLine("\nGRAPHIC CARD");
				if ( hardware_info.vga_controller[0] != null ) {
			    		
			    	textwrite.WriteLine("\tVGA controller");
		    		textwrite.WriteLine("\t\t" + hardware_info.vga_controller[0]);
			    	if ( hardware_info.vga_controller[1] != null )
			    		textwrite.WriteLine("\t\tSubsystem: " + hardware_info.vga_controller[1]);
				}
				textwrite.WriteLine("\nSOUND CARD");
				if ( hardware_info.multimedia_controller[0] != null ) {
			    		
			    	textwrite.WriteLine("\tMultimedia controller");
		    		textwrite.WriteLine("\t\t" + hardware_info.multimedia_controller[0]);
			    	if ( hardware_info.multimedia_controller[1] != null )
			    		textwrite.WriteLine("\t\tSubsystem: " + hardware_info.multimedia_controller[1]);
				}
				textwrite.WriteLine("\nNETWORK");
				if ( hardware_info.network_controller[0] != null ) {
			    		
			    	textwrite.WriteLine("\tNetwork controller");
		    		textwrite.WriteLine("\t\t" + hardware_info.network_controller[0]);
			    	if ( hardware_info.network_controller[1] != null )
			    		textwrite.WriteLine("\t\tSubsystem: " + hardware_info.network_controller[1]);
				}
				if ( hardware_info.ethernet_controller[0] != null ) {
			    		
			    	textwrite.WriteLine("\tEthernet controller");
		    		textwrite.WriteLine("\t\t" + hardware_info.ethernet_controller[0]);
			    	if ( hardware_info.ethernet_controller[1] != null )
			    		textwrite.WriteLine("\t\tSubsystem: " + hardware_info.ethernet_controller[1]);
				}
				if ( hardware_info.modem[0] != null ) {
			    		
			    	textwrite.WriteLine("\tModem");
		    		textwrite.WriteLine("\t\t" + hardware_info.modem[0]);
			    	if ( hardware_info.modem[1] != null )
			    		textwrite.WriteLine("\t\tSubsystem: " + hardware_info.modem[1]);
		    	}
		    	
		    	if ( nvidia_info.nvidiaB ) {
		    		
		    		textwrite.WriteLine("\nNVIDIA GRAPHIC CARD INFORMATION");

			    	textwrite.WriteLine("\tModel name: " + nvidia_info.nvidia_model);
		    		textwrite.WriteLine("\tCard Type: " + nvidia_info.nvidia_ctype + " " + nvidia_info.nvidia_busrate);
		    		textwrite.WriteLine("\tVideo RAM: " + nvidia_info.nvidia_videoram);
		    		textwrite.WriteLine("\tGPU Frequency: " + nvidia_info.nvidia_gpu);
		    		textwrite.WriteLine("\tDriver version: " + nvidia_info.nvidia_version);
		    	}
		    	
			}
		}
		
		
		
	}
}

//ghaefb