Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Decompiled with JetBrains decompiler
- // Type: Avaya.IPOffice.Manager.CommandLine
- // Assembly: Manager, Version=11.0.300.0, Culture=neutral, PublicKeyToken=null
- // MVID: B4130B18-EDBD-4114-BC90-017467B86D8D
- // Assembly location: X:\files\decompile\Manager.exe
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Net;
- namespace Avaya.IPOffice.Manager
- {
- public class CommandLine
- {
- private bool _primary = true;
- private string _commonFileArea = "manager_files";
- private string _username = "";
- private string _password = "";
- private string _decryptedPassword = "";
- private Dictionary<string, string> _args = new Dictionary<string, string>();
- private const int _minumumArgLength = 3;
- private bool _isValid;
- public static CommandLine Parse(string[] args)
- {
- CommandLine commandLine = new CommandLine();
- for (int index = 1; index < args.Length; ++index)
- {
- if (args[index] != null)
- {
- if (args[index].Length >= 3 && (int) args[index][0] == (int) char.Parse("/") && args[index].IndexOf(":") > -1)
- {
- int num1 = 0;
- int num2 = args[index].IndexOf(":");
- string str1 = args[index].Substring(num1 + 1, num2 - 1);
- string str2 = args[index].Substring(num2 + 1, args[index].Length - num2 - 1);
- if (string.Compare(str1, "ip") == 0 && MainForm.Instance != null)
- MainForm.Instance.IsCommandLineAndContainsIP = true;
- if (string.Compare(str1, "input") == 0 && !str2.Contains("\\"))
- {
- if (MainForm._appData != null && !string.IsNullOrEmpty(MainForm._appData.WorkingDirectory))
- {
- string str3 = MainForm._appData.WorkingDirectory;
- if (str3.EndsWith("\\") || str3.EndsWith(";"))
- str3 = str3.Substring(0, str3.Length - 1);
- str2 = str3 + "\\" + str2;
- }
- }
- if (!commandLine._args.ContainsKey(str1))
- {
- if (str1.ToUpper() == "SYSTEMTYPE" && str2.ToUpper() == "IP OFFICE")
- commandLine._args.Add(str1, "ABG B5800");
- else
- commandLine._args.Add(str1, str2);
- }
- }
- else
- {
- if (args.Length != 2 || (int) args[index][0] == (int) char.Parse("/"))
- return commandLine;
- commandLine._args.Add("input", args[1]);
- }
- }
- }
- if (!string.IsNullOrEmpty(commandLine.Launch) && EnumLaunchDef.GetLaunchType(commandLine.Launch) == LaunchType.CONFIG_ONLINE)
- {
- IPAddress address = (IPAddress) null;
- if (IPAddress.TryParse(commandLine.IP, out address) && !string.IsNullOrEmpty(commandLine.UserName) && !string.IsNullOrEmpty(commandLine.Password))
- {
- commandLine._isValid = true;
- }
- else
- {
- commandLine._isValid = false;
- return commandLine;
- }
- }
- else
- {
- foreach (string key in commandLine._args.Keys)
- {
- 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")))
- {
- commandLine._isValid = true;
- }
- else
- {
- commandLine._isValid = false;
- return commandLine;
- }
- }
- if (commandLine.Launch == LaunchType.TEMPLATE.ToString() && !commandLine._args.ContainsKey("type"))
- {
- commandLine._isValid = false;
- return commandLine;
- }
- if (commandLine._args.ContainsKey("type"))
- {
- if (Convert.ToInt32((object) EnumTemplateTypeDefinitions.GetTemplateType(commandLine._args["type"])) != Convert.ToInt32((object) TemplateType.None))
- {
- commandLine._isValid = true;
- }
- else
- {
- commandLine._isValid = false;
- return commandLine;
- }
- }
- if (commandLine._args.ContainsKey("input") && commandLine._args["input"].Trim().Length == 0)
- {
- commandLine._isValid = false;
- return commandLine;
- }
- commandLine._isValid = true;
- }
- return commandLine;
- }
- public bool IsValid
- {
- get
- {
- return this._isValid;
- }
- }
- public string InputFile
- {
- get
- {
- return this.GetValue("input");
- }
- }
- public string OutputFile
- {
- get
- {
- return this.GetValue("output");
- }
- }
- public string Launch
- {
- get
- {
- return this.GetValue("launch");
- }
- }
- public string Type
- {
- get
- {
- return this.GetValue("type");
- }
- }
- public string Name
- {
- get
- {
- return this.GetValue("name");
- }
- }
- public string Action
- {
- get
- {
- if (this.GetValue("action") == "upgrade")
- return "edit";
- return this.GetValue("action");
- }
- set
- {
- this.SetValue("action", value);
- }
- }
- public string WavList
- {
- get
- {
- return this.GetValue("wavlist");
- }
- }
- public string IP
- {
- get
- {
- return this.GetValue("ip");
- }
- }
- public string UserName
- {
- get
- {
- if (!string.IsNullOrEmpty(this.GetValue("user")))
- return this.GetValue("user");
- return this._username;
- }
- set
- {
- this._username = value;
- }
- }
- public string Password
- {
- get
- {
- if (string.IsNullOrEmpty(this.GetValue("password")))
- return this._password;
- if (!this.EncryptCredential || MainForm.Instance == null)
- return this.GetValue("password");
- if (string.IsNullOrEmpty(this._decryptedPassword))
- this._decryptedPassword = MainForm.Instance.DecryptCommandLineParameter(this.GetValue("password"));
- return this._decryptedPassword;
- }
- set
- {
- this._password = value;
- }
- }
- public string Caption
- {
- get
- {
- return this.GetValue("caption");
- }
- }
- public string Locale
- {
- get
- {
- return this.GetValue("locale");
- }
- }
- public string SystemType
- {
- get
- {
- return this.GetValue("systemtype");
- }
- }
- public double DeviceVersion
- {
- get
- {
- string str = this.GetValue("version");
- try
- {
- return Convert.ToDouble(str);
- }
- catch (Exception ex)
- {
- return 9.0;
- }
- }
- }
- public double TargetVersion
- {
- get
- {
- string str = this.GetValue("targetversion");
- try
- {
- if (string.IsNullOrEmpty(str))
- return 0.0;
- return Convert.ToDouble(str);
- }
- catch (Exception ex)
- {
- return 9.0;
- }
- }
- }
- public string ExtnType
- {
- get
- {
- return this.GetValue("extntype");
- }
- }
- public string VMLocales2Add
- {
- get
- {
- return this.GetValue("addvmlocales");
- }
- }
- public string CentralDirectory
- {
- get
- {
- if (!string.IsNullOrEmpty(this.GetValue("dir")))
- return this.GetValue("dir");
- return this._commonFileArea;
- }
- }
- public void SetPrimary(bool value)
- {
- this._primary = value;
- }
- public bool IsPrimary
- {
- get
- {
- if (!string.IsNullOrEmpty(this.GetValue("primary")))
- {
- try
- {
- return Convert.ToBoolean(this.GetValue("primary"), (IFormatProvider) CultureInfo.InvariantCulture);
- }
- catch (Exception ex)
- {
- }
- }
- return this._primary;
- }
- }
- public bool IsRemote
- {
- get
- {
- if (!string.IsNullOrEmpty(this.GetValue("remote")))
- {
- try
- {
- return Convert.ToBoolean(this.GetValue("remote"), (IFormatProvider) CultureInfo.InvariantCulture);
- }
- catch (Exception ex)
- {
- }
- }
- return false;
- }
- }
- public int BasePort
- {
- get
- {
- if (!string.IsNullOrEmpty(this.GetValue("baseport")))
- {
- try
- {
- return Convert.ToInt32(this.GetValue("baseport"), (IFormatProvider) CultureInfo.InvariantCulture);
- }
- catch (Exception ex)
- {
- }
- }
- return 0;
- }
- }
- public bool EncryptCredential
- {
- get
- {
- if (!string.IsNullOrEmpty(this.GetValue("encryptcredential")))
- {
- try
- {
- return Convert.ToBoolean(this.GetValue("encryptcredential"), (IFormatProvider) CultureInfo.InvariantCulture);
- }
- catch (Exception ex)
- {
- }
- }
- return false;
- }
- }
- public bool HasValue(string key)
- {
- return this._args.ContainsKey(key);
- }
- private string GetValue(string key)
- {
- if (this._args.ContainsKey(key))
- return this._args[key];
- return string.Empty;
- }
- private void SetValue(string key, string value)
- {
- if (!this._args.ContainsKey(key))
- return;
- this._args[key] = value;
- }
- public void ClearAll()
- {
- this._args.Clear();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement