// Decompiled with JetBrains decompiler
// Type: SE0085.dBc.lcRegistryCntldB01
// Assembly: SE0085dBc, Version=1.0.0.1, Culture=neutral, PublicKeyToken=null
// MVID: 1D280293-B91C-46EA-A3BF-F18C4E33A97F
// Assembly location: C:\Users\Abishek\Downloads\SchneiderCode_Breaker_09292016\Breaker Schedule-20160930T014118Z\Breaker Schedule\Solution for gathering Breaker Data\DMS\bin\Debug\SE0085dBc.dll

using Microsoft.VisualBasic;
using Microsoft.VisualBasic.CompilerServices;
using Microsoft.Win32;

namespace SE0085.dBc
{
  public class lcRegistryCntldB01
  {
    private string _Plant;
    private string _dbComputerName;
    private string _dbServer;
    private string _dbCatalog;

    public string SQLServer
    {
      get
      {
        return this._dbComputerName + "\\" + this._dbServer;
      }
    }

    public string dbComputerName
    {
      get
      {
        return this._dbComputerName;
      }
      set
      {
        this._dbComputerName = value;
      }
    }

    public string dbServer
    {
      get
      {
        return this._dbServer;
      }
      set
      {
        this._dbServer = value;
      }
    }

    public string dbCatalog
    {
      get
      {
        return this._dbCatalog;
      }
      set
      {
        this._dbCatalog = value;
      }
    }

    public lcRegistryCntldB01(string SEPlant)
    {
      this._Plant = SEPlant != null ? (SEPlant.Length != 0 ? SEPlant : "0085") : "0085";
      this._dbComputerName = "2ua14603mz.m087.us.schneider-electric.com";
      this._dbServer = "SESQLSVR";
      this._dbCatalog = "SE0085CT";
    }

    public void InitRegistry()
    {
      RegistryKey registryKey1 = Registry.CurrentUser.OpenSubKey("Software\\T2Designs", true);
      RegistryKey registryKey2 = Registry.CurrentUser.OpenSubKey("Software", true);
      if (registryKey1 == null)
        registryKey2.CreateSubKey("T2Designs");
      RegistryKey registryKey3 = Registry.CurrentUser.OpenSubKey("Software\\T2Designs\\" + this._Plant, true);
      RegistryKey registryKey4 = Registry.CurrentUser.OpenSubKey("Software\\T2Designs", true);
      if (registryKey3 != null)
        return;
      registryKey4.CreateSubKey("" + this._Plant);
    }

    public void SaveConfiguration()
    {
      RegistryKey registryKey1 = Registry.CurrentUser.OpenSubKey("Software\\T2Designs\\" + this._Plant, true);
      RegistryKey registryKey2 = Registry.CurrentUser.OpenSubKey("Software", true);
      if (registryKey1 == null)
        this.InitRegistry();
      RegistryKey registryKey3 = Registry.CurrentUser.OpenSubKey("Software\\T2Designs\\" + this._Plant, true);
      registryKey2 = Registry.CurrentUser.OpenSubKey("Software\\T2Designs", true);
      if (registryKey3 == null)
        return;
      RegistryKey registryKey4 = Registry.CurrentUser.OpenSubKey("Software\\T2Designs\\" + this._Plant, true);
      if (Conversions.ToBoolean(Operators.NotObject(Operators.CompareObjectEqual(registryKey4.GetValue("dbServerIP"), (object) this._dbComputerName, false))))
        registryKey4.SetValue("dbServerIP", (object) this._dbComputerName);
      RegistryKey registryKey5 = Registry.CurrentUser.OpenSubKey("Software\\T2Designs\\" + this._Plant, true);
      if (Conversions.ToBoolean(Operators.NotObject(Operators.CompareObjectEqual(registryKey5.GetValue("dbServerInst"), (object) this._dbServer, false))))
        registryKey5.SetValue("dbServerInst", (object) this._dbServer);
      RegistryKey registryKey6 = Registry.CurrentUser.OpenSubKey("Software\\T2Designs\\" + this._Plant, true);
      if (Conversions.ToBoolean(Operators.NotObject(Operators.CompareObjectEqual(registryKey6.GetValue("dbCatalog"), (object) this._dbCatalog, false))))
        registryKey6.SetValue("dbCatalog", (object) this._dbCatalog);
    }

    public void LoadConfiguration()
    {
      RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("Software\\T2Designs\\" + this._Plant, true);
      if (registryKey == null)
      {
        this.InitRegistry();
        registryKey = Registry.CurrentUser.OpenSubKey("Software\\T2Designs\\" + this._Plant, true);
        if (registryKey == null)
        {
          int num = (int) Interaction.MsgBox((object) "Unable to Load Configuration", MsgBoxStyle.Information, (object) "Configuration Load Error - E0001");
          return;
        }
      }
      string str1 = Conversions.ToString(registryKey.GetValue("dbServerIP"));
      if (str1 != null && str1.Length > 0)
        this._dbComputerName = str1;
      string str2 = Conversions.ToString(registryKey.GetValue("dbServerInst"));
      if (str2 != null && str1.Length > 0)
        this._dbServer = str2;
      string str3 = Conversions.ToString(registryKey.GetValue("dbCatalog"));
      if (str3 != null && str3.Length > 0)
        this._dbCatalog = str3;
    }

    public bool ConfigExist()
    {
      bool flag = false;
      RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("Software\\T2Designs\\" + this._Plant, true);
      if (registryKey != null)
      {
        string str = Conversions.ToString(registryKey.GetValue("dbServerIP"));
        if (str != null && str.Length > 0)
          flag = true;
      }
      return flag;
    }
  }
}
