-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
136 lines (131 loc) · 5.48 KB
/
Program.cs
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
using SevenZipExtractor;
using System;
using System.IO;
using System.Xml;
namespace FILETransfer
{
class Program
{
static int Main(string[] args)
{
string fileName = string.Empty ;
string target = string.Empty;
string source = string.Empty ;
int selectedValue = SelectDeployment(ref fileName,ref source);
if (fileName != null && fileName != "" && source != null && source != "")
{
target = GetTargetPath(selectedValue);
string source1 = Path.Combine(source, fileName);
if (target != null && target != string.Empty)
{
string target1 = Path.Combine(target, fileName);
if (File.Exists(source1))
{
DeleteFiles(target);
System.IO.File.Copy(source1, target1, true);
if (File.Exists(target1))
{
System.Console.WriteLine("Copy deployment Initiated...............................");
using (ArchiveFile file = new ArchiveFile(target1))
{
file.Extract(target, true);
}
}
else
System.Console.WriteLine("File Not Found in Directory");
}
else
System.Console.WriteLine("File Not Found in Network");
System.Console.Read();
}
}
else
Console.WriteLine("File.Source Not Found");
return 0;
}
private static string GetTargetPath(int selectedValue)
{
XmlDocument xmlDoc = new XmlDocument();
try
{
string path = selectedValue == 1 ? "/Check/Himanshu[@build = '999.999']" : selectedValue == 2 ? "/Check/Himanshu[@build = '823.999']" : selectedValue == 3 ? "/Check/Himanshu[@build = '822.999']" : selectedValue == 4 ? "/Check/Himanshu[@build = 'NG999.999']" : selectedValue == 5 ? "/Check/Himanshu[@build = 'NG823.999']" : string.Empty ;
xmlDoc.Load(@"XMLFile1.xml");
if (path != null && path != "")
{
XmlNode node = xmlDoc.SelectSingleNode(path);
if (node != null)
return node.Attributes?[0]?.InnerText;
}
}
catch(Exception ex)
{
return string.Empty;
}
return string.Empty;
}
private static int SelectDeployment (ref string fileName ,ref string source)
{
Console.WriteLine("Please Select Deployment...........................");
Console.WriteLine("1.999.999");
Console.WriteLine("2.823.999");
Console.WriteLine("3.822.999");
Console.WriteLine("4.NG 999.999");
Console.WriteLine("5.NG 823.999");
int selectedDeply = int.Parse(Console.ReadLine());
switch (selectedDeply)
{
case 1:
{
fileName = "iMedClient_999.999.7z";
source = @"\\CSPUDEP01\Client\Install\ITBMED.ins\iMed_999.999";
break;
}
case 2:
{
fileName = "iMedClient_823.999.7z";
source = @"\\CSPUDEP01\Client\Install\ITBMED.ins\iMed_823.999";
break;
}
case 3:
{
fileName = "iMedClient_822.999.7z";
source = @"\\CSPUDEP01\Client\Install\ITBMED.ins\iMed_822.999";
break;
}
case 4:
{
fileName = "iM1Web_999.999.7z";
source = @"\\CSPUDEP01\Client\Install\ITBMED.ins\iMed_999.999";
break;
}
case 5:
{
fileName = "iM1Web_823.999.7z";
source = @"\\CSPUDEP01\Client\Install\ITBMED.ins\iMed_823.999";
break;
}
}
return selectedDeply;
}
private static void DeleteFiles(string target)
{
DirectoryInfo dir = new DirectoryInfo(target);
FileInfo[] info = dir.GetFiles();
DirectoryInfo[] dirInfo = dir.GetDirectories();
if (info != null && info.Length > 0)
{
foreach (FileInfo item in info)
{
System.Console.WriteLine(item.FullName);
if (item.Name != "iMed.Config" && item.Name != "LabFindingsSimulator.exe.config" && item.Name != "LabFindingsSimulator" && item.Name != "LabFindingsSimulator.exe" && item.Name != "Web.config")
item.Delete();
}
if (dirInfo != null && dirInfo.Length > 0)
{
foreach (DirectoryInfo item in dirInfo)
item.Delete(true);
}
}
}
}
}