Advertisement
Guest User

Untitled

a guest
May 21st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.08 KB | None | 0 0
  1. // Decompiled with JetBrains decompiler
  2. // Type: Avaya.IPOffice.Manager.CommandLine
  3. // Assembly: Manager, Version=11.0.300.0, Culture=neutral, PublicKeyToken=null
  4. // MVID: B4130B18-EDBD-4114-BC90-017467B86D8D
  5. // Assembly location: X:\files\decompile\Manager.exe
  6.  
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Globalization;
  10. using System.Net;
  11.  
  12. namespace Avaya.IPOffice.Manager
  13. {
  14. public class CommandLine
  15. {
  16. private bool _primary = true;
  17. private string _commonFileArea = "manager_files";
  18. private string _username = "";
  19. private string _password = "";
  20. private string _decryptedPassword = "";
  21. private Dictionary<string, string> _args = new Dictionary<string, string>();
  22. private const int _minumumArgLength = 3;
  23. private bool _isValid;
  24.  
  25. public static CommandLine Parse(string[] args)
  26. {
  27. CommandLine commandLine = new CommandLine();
  28. for (int index = 1; index < args.Length; ++index)
  29. {
  30. if (args[index] != null)
  31. {
  32. if (args[index].Length >= 3 && (int) args[index][0] == (int) char.Parse("/") && args[index].IndexOf(":") > -1)
  33. {
  34. int num1 = 0;
  35. int num2 = args[index].IndexOf(":");
  36. string str1 = args[index].Substring(num1 + 1, num2 - 1);
  37. string str2 = args[index].Substring(num2 + 1, args[index].Length - num2 - 1);
  38. if (string.Compare(str1, "ip") == 0 && MainForm.Instance != null)
  39. MainForm.Instance.IsCommandLineAndContainsIP = true;
  40. if (string.Compare(str1, "input") == 0 && !str2.Contains("\\"))
  41. {
  42. if (MainForm._appData != null && !string.IsNullOrEmpty(MainForm._appData.WorkingDirectory))
  43. {
  44. string str3 = MainForm._appData.WorkingDirectory;
  45. if (str3.EndsWith("\\") || str3.EndsWith(";"))
  46. str3 = str3.Substring(0, str3.Length - 1);
  47. str2 = str3 + "\\" + str2;
  48. }
  49. }
  50. if (!commandLine._args.ContainsKey(str1))
  51. {
  52. if (str1.ToUpper() == "SYSTEMTYPE" && str2.ToUpper() == "IP OFFICE")
  53. commandLine._args.Add(str1, "ABG B5800");
  54. else
  55. commandLine._args.Add(str1, str2);
  56. }
  57. }
  58. else
  59. {
  60. if (args.Length != 2 || (int) args[index][0] == (int) char.Parse("/"))
  61. return commandLine;
  62. commandLine._args.Add("input", args[1]);
  63. }
  64. }
  65. }
  66. if (!string.IsNullOrEmpty(commandLine.Launch) && EnumLaunchDef.GetLaunchType(commandLine.Launch) == LaunchType.CONFIG_ONLINE)
  67. {
  68. IPAddress address = (IPAddress) null;
  69. if (IPAddress.TryParse(commandLine.IP, out address) && !string.IsNullOrEmpty(commandLine.UserName) && !string.IsNullOrEmpty(commandLine.Password))
  70. {
  71. commandLine._isValid = true;
  72. }
  73. else
  74. {
  75. commandLine._isValid = false;
  76. return commandLine;
  77. }
  78. }
  79. else
  80. {
  81. foreach (string key in commandLine._args.Keys)
  82. {
  83. if (key == "input" || key == "output" || (key == "launch" || key == "action") || (key == "type" || key == "name" || (key == "wavlist" || key == "ip")) || (key == "user" || key == "password" || (key == "caption" || key == "locale") || (key == "systemtype" || key == "extntype" || (key == "addvmlocales" || key == "primary"))) || (key == "dir" || key == "remote" || (key == "baseport" || key == "encryptcredential") || (key == "version" || key == "targetversion")))
  84. {
  85. commandLine._isValid = true;
  86. }
  87. else
  88. {
  89. commandLine._isValid = false;
  90. return commandLine;
  91. }
  92. }
  93. if (commandLine.Launch == LaunchType.TEMPLATE.ToString() && !commandLine._args.ContainsKey("type"))
  94. {
  95. commandLine._isValid = false;
  96. return commandLine;
  97. }
  98. if (commandLine._args.ContainsKey("type"))
  99. {
  100. if (Convert.ToInt32((object) EnumTemplateTypeDefinitions.GetTemplateType(commandLine._args["type"])) != Convert.ToInt32((object) TemplateType.None))
  101. {
  102. commandLine._isValid = true;
  103. }
  104. else
  105. {
  106. commandLine._isValid = false;
  107. return commandLine;
  108. }
  109. }
  110. if (commandLine._args.ContainsKey("input") && commandLine._args["input"].Trim().Length == 0)
  111. {
  112. commandLine._isValid = false;
  113. return commandLine;
  114. }
  115. commandLine._isValid = true;
  116. }
  117. return commandLine;
  118. }
  119.  
  120. public bool IsValid
  121. {
  122. get
  123. {
  124. return this._isValid;
  125. }
  126. }
  127.  
  128. public string InputFile
  129. {
  130. get
  131. {
  132. return this.GetValue("input");
  133. }
  134. }
  135.  
  136. public string OutputFile
  137. {
  138. get
  139. {
  140. return this.GetValue("output");
  141. }
  142. }
  143.  
  144. public string Launch
  145. {
  146. get
  147. {
  148. return this.GetValue("launch");
  149. }
  150. }
  151.  
  152. public string Type
  153. {
  154. get
  155. {
  156. return this.GetValue("type");
  157. }
  158. }
  159.  
  160. public string Name
  161. {
  162. get
  163. {
  164. return this.GetValue("name");
  165. }
  166. }
  167.  
  168. public string Action
  169. {
  170. get
  171. {
  172. if (this.GetValue("action") == "upgrade")
  173. return "edit";
  174. return this.GetValue("action");
  175. }
  176. set
  177. {
  178. this.SetValue("action", value);
  179. }
  180. }
  181.  
  182. public string WavList
  183. {
  184. get
  185. {
  186. return this.GetValue("wavlist");
  187. }
  188. }
  189.  
  190. public string IP
  191. {
  192. get
  193. {
  194. return this.GetValue("ip");
  195. }
  196. }
  197.  
  198. public string UserName
  199. {
  200. get
  201. {
  202. if (!string.IsNullOrEmpty(this.GetValue("user")))
  203. return this.GetValue("user");
  204. return this._username;
  205. }
  206. set
  207. {
  208. this._username = value;
  209. }
  210. }
  211.  
  212. public string Password
  213. {
  214. get
  215. {
  216. if (string.IsNullOrEmpty(this.GetValue("password")))
  217. return this._password;
  218. if (!this.EncryptCredential || MainForm.Instance == null)
  219. return this.GetValue("password");
  220. if (string.IsNullOrEmpty(this._decryptedPassword))
  221. this._decryptedPassword = MainForm.Instance.DecryptCommandLineParameter(this.GetValue("password"));
  222. return this._decryptedPassword;
  223. }
  224. set
  225. {
  226. this._password = value;
  227. }
  228. }
  229.  
  230. public string Caption
  231. {
  232. get
  233. {
  234. return this.GetValue("caption");
  235. }
  236. }
  237.  
  238. public string Locale
  239. {
  240. get
  241. {
  242. return this.GetValue("locale");
  243. }
  244. }
  245.  
  246. public string SystemType
  247. {
  248. get
  249. {
  250. return this.GetValue("systemtype");
  251. }
  252. }
  253.  
  254. public double DeviceVersion
  255. {
  256. get
  257. {
  258. string str = this.GetValue("version");
  259. try
  260. {
  261. return Convert.ToDouble(str);
  262. }
  263. catch (Exception ex)
  264. {
  265. return 9.0;
  266. }
  267. }
  268. }
  269.  
  270. public double TargetVersion
  271. {
  272. get
  273. {
  274. string str = this.GetValue("targetversion");
  275. try
  276. {
  277. if (string.IsNullOrEmpty(str))
  278. return 0.0;
  279. return Convert.ToDouble(str);
  280. }
  281. catch (Exception ex)
  282. {
  283. return 9.0;
  284. }
  285. }
  286. }
  287.  
  288. public string ExtnType
  289. {
  290. get
  291. {
  292. return this.GetValue("extntype");
  293. }
  294. }
  295.  
  296. public string VMLocales2Add
  297. {
  298. get
  299. {
  300. return this.GetValue("addvmlocales");
  301. }
  302. }
  303.  
  304. public string CentralDirectory
  305. {
  306. get
  307. {
  308. if (!string.IsNullOrEmpty(this.GetValue("dir")))
  309. return this.GetValue("dir");
  310. return this._commonFileArea;
  311. }
  312. }
  313.  
  314. public void SetPrimary(bool value)
  315. {
  316. this._primary = value;
  317. }
  318.  
  319. public bool IsPrimary
  320. {
  321. get
  322. {
  323. if (!string.IsNullOrEmpty(this.GetValue("primary")))
  324. {
  325. try
  326. {
  327. return Convert.ToBoolean(this.GetValue("primary"), (IFormatProvider) CultureInfo.InvariantCulture);
  328. }
  329. catch (Exception ex)
  330. {
  331. }
  332. }
  333. return this._primary;
  334. }
  335. }
  336.  
  337. public bool IsRemote
  338. {
  339. get
  340. {
  341. if (!string.IsNullOrEmpty(this.GetValue("remote")))
  342. {
  343. try
  344. {
  345. return Convert.ToBoolean(this.GetValue("remote"), (IFormatProvider) CultureInfo.InvariantCulture);
  346. }
  347. catch (Exception ex)
  348. {
  349. }
  350. }
  351. return false;
  352. }
  353. }
  354.  
  355. public int BasePort
  356. {
  357. get
  358. {
  359. if (!string.IsNullOrEmpty(this.GetValue("baseport")))
  360. {
  361. try
  362. {
  363. return Convert.ToInt32(this.GetValue("baseport"), (IFormatProvider) CultureInfo.InvariantCulture);
  364. }
  365. catch (Exception ex)
  366. {
  367. }
  368. }
  369. return 0;
  370. }
  371. }
  372.  
  373. public bool EncryptCredential
  374. {
  375. get
  376. {
  377. if (!string.IsNullOrEmpty(this.GetValue("encryptcredential")))
  378. {
  379. try
  380. {
  381. return Convert.ToBoolean(this.GetValue("encryptcredential"), (IFormatProvider) CultureInfo.InvariantCulture);
  382. }
  383. catch (Exception ex)
  384. {
  385. }
  386. }
  387. return false;
  388. }
  389. }
  390.  
  391. public bool HasValue(string key)
  392. {
  393. return this._args.ContainsKey(key);
  394. }
  395.  
  396. private string GetValue(string key)
  397. {
  398. if (this._args.ContainsKey(key))
  399. return this._args[key];
  400. return string.Empty;
  401. }
  402.  
  403. private void SetValue(string key, string value)
  404. {
  405. if (!this._args.ContainsKey(key))
  406. return;
  407. this._args[key] = value;
  408. }
  409.  
  410. public void ClearAll()
  411. {
  412. this._args.Clear();
  413. }
  414. }
  415. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement