// Decompiled with JetBrains decompiler
// Type: SE0085.CTdB.clsRegistryCntl
// Assembly: SE0085CTdB, Version=1.0.0.1, Culture=neutral, PublicKeyToken=null
// MVID: F67560B6-58CB-4471-AAC9-80007CA3AF52
// Assembly location: C:\Users\Abishek\Downloads\SchneiderCode_Breaker_09292016\Breaker Schedule-20160930T014118Z\Breaker Schedule\Solution for gathering Breaker Data\DMS\bin\Debug\SE0085CTdB.dll

using Microsoft.VisualBasic;
using Microsoft.VisualBasic.CompilerServices;
using Microsoft.Win32;
using SE0085.StCl;
using System;
using System.Collections.Generic;

namespace SE0085.CTdB
{
  public class clsRegistryCntl
  {
    private scPlants _Plant;
    private scAssemblyLine _AssemblyLine;
    private scVPoint _Verificationpoint;
    private List<scAssociateData> _QCAssociates;
    private string _dbServerIP;
    private string _dbCatalog;
    private bool _SearchAllQCAssoc;
    private bool _MailCopyToCurrentUser;

    public scPlants Plant
    {
      get
      {
        return this._Plant;
      }
      set
      {
        this._Plant = value;
      }
    }

    public scLevels PlantLevel
    {
      get
      {
        return this._Plant.PlantLevel;
      }
      set
      {
        this._Plant.PlantLevel = value;
      }
    }

    public scAssemblyLine AssemblyLine
    {
      get
      {
        return this._AssemblyLine;
      }
      set
      {
        this._AssemblyLine = value;
        this._dbCatalog = value.DataCatalog;
        this._dbServerIP = value.ServerIPAddress + "," + value.ServerPort;
      }
    }

    public scVPoint VerificationPoint
    {
      get
      {
        return this._Verificationpoint;
      }
      set
      {
        this._Verificationpoint = value;
      }
    }

    public List<scAssociateData> QCassociates
    {
      get
      {
        return this._QCAssociates;
      }
      set
      {
        this._QCAssociates = value;
      }
    }

    public string dbServerIP
    {
      get
      {
        return this._dbServerIP;
      }
      set
      {
        this._dbServerIP = value;
      }
    }

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

    public bool SearchAllQCAssoc
    {
      get
      {
        return this._SearchAllQCAssoc;
      }
      set
      {
        this._SearchAllQCAssoc = value;
      }
    }

    public bool MailCopyToCurrentUser
    {
      get
      {
        return this._MailCopyToCurrentUser;
      }
      set
      {
        this._MailCopyToCurrentUser = value;
      }
    }

    public clsRegistryCntl()
    {
      this._Verificationpoint = new scVPoint();
      this._QCAssociates = new List<scAssociateData>();
      this._Plant = new scPlants();
      this._Plant.PlantId = 1;
      this._AssemblyLine = new scAssemblyLine();
      this._AssemblyLine.LevelId = 2;
      this._Verificationpoint = new scVPoint();
      this._QCAssociates = new List<scAssociateData>();
      this._dbServerIP = "2ua14603mz";
      this._dbCatalog = "";
      this._SearchAllQCAssoc = true;
      this._MailCopyToCurrentUser = false;
    }

    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\\SE0085VMS", true);
      RegistryKey registryKey4 = Registry.CurrentUser.OpenSubKey("Software\\T2Designs", true);
      if (registryKey3 != null)
        return;
      registryKey4.CreateSubKey("SE0085VMS");
    }

    public void SaveConfiguration()
    {
      RegistryKey registryKey1 = Registry.CurrentUser.OpenSubKey("Software\\T2Designs\\SE0085VMS", true);
      RegistryKey registryKey2 = Registry.CurrentUser.OpenSubKey("Software", true);
      if (registryKey1 == null)
        this.InitRegistry();
      RegistryKey registryKey3 = Registry.CurrentUser.OpenSubKey("Software\\T2Designs\\SE0085VMS", true);
      registryKey2 = Registry.CurrentUser.OpenSubKey("Software\\T2Designs", true);
      if (registryKey3 == null)
        return;
      try
      {
        RegistryKey registryKey4 = Registry.CurrentUser.OpenSubKey("Software\\T2Designs\\SE0085VMS", true);
        if (Conversions.ToBoolean(Operators.NotObject(Operators.CompareObjectEqual(registryKey4.GetValue("Plant"), (object) this._Plant.PlantId, false))))
          registryKey4.SetValue("Plant", (object) this._Plant.PlantId);
      }
      catch (Exception ex)
      {
        ProjectData.SetProjectError(ex);
        ProjectData.ClearProjectError();
      }
      try
      {
        RegistryKey registryKey4 = Registry.CurrentUser.OpenSubKey("Software\\T2Designs\\SE0085VMS", true);
        if (Conversions.ToBoolean(Operators.NotObject(Operators.CompareObjectEqual(registryKey4.GetValue("AssemblyLine"), (object) this._AssemblyLine.LevelId, false))))
          registryKey4.SetValue("AssemblyLine", (object) this._AssemblyLine.LevelId);
      }
      catch (Exception ex)
      {
        ProjectData.SetProjectError(ex);
        ProjectData.ClearProjectError();
      }
      try
      {
        RegistryKey registryKey4 = Registry.CurrentUser.OpenSubKey("Software\\T2Designs\\SE0085VMS", true);
        if (Conversions.ToBoolean(Operators.NotObject(Operators.CompareObjectEqual(registryKey4.GetValue("VerificationPoint"), (object) this._Verificationpoint.VPointComposite, false))))
          registryKey4.SetValue("VerificationPoint", (object) this._Verificationpoint.VPointComposite);
      }
      catch (Exception ex)
      {
        ProjectData.SetProjectError(ex);
        ProjectData.ClearProjectError();
      }
      try
      {
        string[] array = (string[]) null;
        Array.Resize<string>(ref array, this._QCAssociates.Count);
        int num1 = 0;
        int num2 = checked (this._QCAssociates.Count - 1);
        int index = num1;
        while (index <= num2)
        {
          array[index] = Conversions.ToString(this._QCAssociates[index].AssocId);
          checked { ++index; }
        }
        Registry.CurrentUser.OpenSubKey("Software\\T2Designs\\SE0085VMS", true).SetValue("QCAssociates", (object) array);
      }
      catch (Exception ex)
      {
        ProjectData.SetProjectError(ex);
        ProjectData.ClearProjectError();
      }
      try
      {
        RegistryKey registryKey4 = Registry.CurrentUser.OpenSubKey("Software\\T2Designs\\SE0085VMS", true);
        if (Conversions.ToBoolean(Operators.NotObject(Operators.CompareObjectEqual(registryKey4.GetValue("dbServerIP"), (object) this._dbServerIP, false))))
          registryKey4.SetValue("dbServerIP", (object) this._dbServerIP);
      }
      catch (Exception ex)
      {
        ProjectData.SetProjectError(ex);
        ProjectData.ClearProjectError();
      }
      try
      {
        RegistryKey registryKey4 = Registry.CurrentUser.OpenSubKey("Software\\T2Designs\\SE0085VMS", true);
        if (Conversions.ToBoolean(Operators.NotObject(Operators.CompareObjectEqual(registryKey4.GetValue("dbCatalog"), (object) this._dbCatalog, false))))
          registryKey4.SetValue("dbCatalog", (object) this._dbCatalog);
      }
      catch (Exception ex)
      {
        ProjectData.SetProjectError(ex);
        ProjectData.ClearProjectError();
      }
      try
      {
        RegistryKey registryKey4 = Registry.CurrentUser.OpenSubKey("Software\\T2Designs\\SE0085VMS", true);
        if (Conversions.ToBoolean(Operators.NotObject(Operators.CompareObjectEqual(registryKey4.GetValue("SearchAllQCAssoc"), (object) this._SearchAllQCAssoc, false))))
          registryKey4.SetValue("SearchAllQCAssoc", (object) this._SearchAllQCAssoc);
      }
      catch (Exception ex)
      {
        ProjectData.SetProjectError(ex);
        ProjectData.ClearProjectError();
      }
      try
      {
        RegistryKey registryKey4 = Registry.CurrentUser.OpenSubKey("Software\\T2Designs\\SE0085VMS", true);
        if (Conversions.ToBoolean(Operators.NotObject(Operators.CompareObjectEqual(registryKey4.GetValue("MailCopyToCurrentUser"), (object) this._MailCopyToCurrentUser, false))))
          registryKey4.SetValue("MailCopyToCurrentUser", (object) this._MailCopyToCurrentUser);
      }
      catch (Exception ex)
      {
        ProjectData.SetProjectError(ex);
        ProjectData.ClearProjectError();
      }
    }

    public void LoadConfiguration()
    {
      RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("Software\\T2Designs\\SE0085VMS", true);
      if (registryKey == null)
      {
        this.InitRegistry();
        registryKey = Registry.CurrentUser.OpenSubKey("Software\\T2Designs\\SE0085VMS", true);
        if (registryKey == null)
        {
          int num = (int) Interaction.MsgBox((object) "Unable to Load Configuration", MsgBoxStyle.Information, (object) "Configuration Load Error - E0001");
          return;
        }
      }
      int integer1 = Conversions.ToInteger(registryKey.GetValue("Plant"));
      if (integer1 > 0)
        this._Plant.PlantId = integer1;
      int integer2 = Conversions.ToInteger(registryKey.GetValue("AssemblyLine"));
      if (integer2 > 0)
        this._AssemblyLine.LevelId = integer2;
      long num1 = Conversions.ToLong(registryKey.GetValue("VerificationPoint"));
      if (num1 > 0L)
        this._Verificationpoint.VPointComposite = num1;
      string[] strArray1 = (string[]) registryKey.GetValue("QCAssociates");
      if (strArray1 != null)
      {
        this._QCAssociates.Clear();
        string[] strArray2 = strArray1;
        int index = 0;
        while (index < strArray2.Length)
        {
          string str = strArray2[index];
          this._QCAssociates.Add(new scAssociateData()
          {
            AssocId = Conversions.ToInteger(str)
          });
          checked { ++index; }
        }
      }
      string str1 = Conversions.ToString(registryKey.GetValue("dbServerIP"));
      if (str1 != null && str1.Length > 0)
        this._dbServerIP = str1;
      string str2 = Conversions.ToString(registryKey.GetValue("dbCatalog"));
      if (str2 != null && str2.Length > 0)
        this._dbCatalog = str2;
      bool boolean1 = Conversions.ToBoolean(registryKey.GetValue("SearchAllQCAssoc"));
      try
      {
        this._SearchAllQCAssoc = boolean1;
      }
      catch (Exception ex)
      {
        ProjectData.SetProjectError(ex);
        this._SearchAllQCAssoc = true;
        ProjectData.ClearProjectError();
      }
      bool boolean2 = Conversions.ToBoolean(registryKey.GetValue("MailCopyToCurrentUser"));
      try
      {
        this._MailCopyToCurrentUser = boolean2;
      }
      catch (Exception ex)
      {
        ProjectData.SetProjectError(ex);
        this._MailCopyToCurrentUser = false;
        ProjectData.ClearProjectError();
      }
    }

    public bool ConfigExist()
    {
      bool flag = false;
      RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("Software\\T2Designs\\SE0085VMS", true);
      if (registryKey != null && Conversions.ToInteger(registryKey.GetValue("Plant")) > 0)
        flag = true;
      return flag;
    }
  }
}
