// Decompiled with JetBrains decompiler
// Type: SE0085.CTdB.scEngrRelStats
// 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.CompilerServices;
using SE0085.StCl;
using System;
using System.Collections.Generic;

namespace SE0085.CTdB
{
  public class scEngrRelStats
  {
    private short _ICSSchRel;
    private short _ICSRelOTOS;
    private List<scOrderImportInfo> _ICSLateOrders;
    private scOrderAuditStats _ICSMechAuditStats;
    private scOrderAuditStats _ICSElectAuditStats;
    private short _DCSSchRel;
    private short _DCSRelOTOS;
    private List<scOrderImportInfo> _DCSLateOrders;
    private scOrderAuditStats _DCSMechAuditStats;
    private scOrderAuditStats _DCSElectAuditStats;
    private short _WWTSchRel;
    private short _WWTRelOTOS;
    private List<scOrderImportInfo> _WWTLateOrders;
    private scOrderAuditStats _WWTMechAuditStats;
    private scOrderAuditStats _WWTElectAuditStats;

    public short ICSSchRel
    {
      get
      {
        return this._ICSSchRel;
      }
      set
      {
        this._ICSSchRel = value;
      }
    }

    public object ICSRelOTOS
    {
      get
      {
        return (object) this._ICSRelOTOS;
      }
      set
      {
        this._ICSRelOTOS = Conversions.ToShort(value);
      }
    }

    public List<scOrderImportInfo> ICSLateOrders
    {
      get
      {
        return this._ICSLateOrders;
      }
      set
      {
        this._ICSLateOrders = value;
      }
    }

    public scOrderAuditStats ICSMechAuditStats
    {
      get
      {
        return this._ICSMechAuditStats;
      }
      set
      {
        this._ICSMechAuditStats = value;
      }
    }

    public scOrderAuditStats ICSElectAuditStats
    {
      get
      {
        return this._ICSElectAuditStats;
      }
      set
      {
        this._ICSElectAuditStats = value;
      }
    }

    public short DCSSchRel
    {
      get
      {
        return this._DCSSchRel;
      }
      set
      {
        this._DCSSchRel = value;
      }
    }

    public object DCSRelOTOS
    {
      get
      {
        return (object) this._DCSRelOTOS;
      }
      set
      {
        this._DCSRelOTOS = Conversions.ToShort(value);
      }
    }

    public List<scOrderImportInfo> DCSLateOrders
    {
      get
      {
        return this._DCSLateOrders;
      }
      set
      {
        this._DCSLateOrders = value;
      }
    }

    public scOrderAuditStats DCSMechAuditStats
    {
      get
      {
        return this._DCSMechAuditStats;
      }
      set
      {
        this._DCSMechAuditStats = value;
      }
    }

    public scOrderAuditStats DCSElectAuditStats
    {
      get
      {
        return this._DCSElectAuditStats;
      }
      set
      {
        this._DCSElectAuditStats = value;
      }
    }

    public short WWTSchRel
    {
      get
      {
        return this._WWTSchRel;
      }
      set
      {
        this._WWTSchRel = value;
      }
    }

    public object WWTRelOTOS
    {
      get
      {
        return (object) this._WWTRelOTOS;
      }
      set
      {
        this._WWTRelOTOS = Conversions.ToShort(value);
      }
    }

    public List<scOrderImportInfo> WWTLateOrders
    {
      get
      {
        return this._WWTLateOrders;
      }
      set
      {
        this._WWTLateOrders = value;
      }
    }

    public scOrderAuditStats WWTMechAuditStats
    {
      get
      {
        return this._WWTMechAuditStats;
      }
      set
      {
        this._WWTMechAuditStats = value;
      }
    }

    public scOrderAuditStats WWTElectAuditStats
    {
      get
      {
        return this._WWTElectAuditStats;
      }
      set
      {
        this._WWTElectAuditStats = value;
      }
    }

    public Decimal ICSPctOTOS
    {
      get
      {
        if ((int) this._ICSSchRel > 0)
          return new Decimal((double) this._ICSRelOTOS / (double) this._ICSSchRel * 100.0);
        return Decimal.Zero;
      }
    }

    public Decimal DCSPctOTOS
    {
      get
      {
        if ((int) this._DCSSchRel > 0)
          return new Decimal((double) this._DCSRelOTOS / (double) this._DCSSchRel * 100.0);
        return Decimal.Zero;
      }
    }

    public Decimal WWTPctOTOS
    {
      get
      {
        if ((int) this._WWTSchRel > 0)
          return new Decimal((double) this._WWTRelOTOS / (double) this._WWTSchRel * 100.0);
        return Decimal.Zero;
      }
    }

    public Decimal AveOTOS
    {
      get
      {
        if ((int) checked ((short) unchecked ((int) checked ((short) unchecked ((int) this._ICSSchRel + (int) this._DCSSchRel)) + (int) this._WWTSchRel)) > 0)
          return new Decimal((double) checked ((short) unchecked ((int) checked ((short) unchecked ((int) this._ICSRelOTOS + (int) this._DCSRelOTOS)) + (int) this._WWTRelOTOS)) / (double) checked ((short) unchecked ((int) checked ((short) unchecked ((int) this._ICSSchRel + (int) this._DCSSchRel)) + (int) this._WWTSchRel)) * 100.0);
        return Decimal.Zero;
      }
    }

    public Decimal AveMechAuditPct
    {
      get
      {
        if ((int) checked ((short) unchecked ((int) checked ((short) unchecked ((int) this._ICSMechAuditStats.SectCnt + (int) this._DCSMechAuditStats.SectCnt)) + (int) this._WWTMechAuditStats.SectCnt)) > 0)
          return new Decimal((double) checked ((short) unchecked ((int) checked ((short) unchecked ((int) this._ICSMechAuditStats.Audited + (int) this._DCSMechAuditStats.Audited)) + (int) this._WWTMechAuditStats.Audited)) / (double) checked ((short) unchecked ((int) checked ((short) unchecked ((int) this._ICSMechAuditStats.SectCnt + (int) this._DCSMechAuditStats.SectCnt)) + (int) this._WWTMechAuditStats.SectCnt)) * 100.0);
        return Decimal.Zero;
      }
    }

    public Decimal AveMechFPYPct
    {
      get
      {
        if ((int) checked ((short) unchecked ((int) checked ((short) unchecked ((int) this._ICSMechAuditStats.Audited + (int) this._DCSMechAuditStats.Audited)) + (int) this._WWTMechAuditStats.Audited)) > 0)
          return new Decimal((double) checked ((short) unchecked ((int) checked ((short) unchecked ((int) this._ICSMechAuditStats.AuditNPF + (int) this._DCSMechAuditStats.AuditNPF)) + (int) this._WWTMechAuditStats.AuditNPF)) / (double) checked ((short) unchecked ((int) checked ((short) unchecked ((int) this._ICSMechAuditStats.Audited + (int) this._DCSMechAuditStats.Audited)) + (int) this._WWTMechAuditStats.Audited)) * 100.0);
        return Decimal.Zero;
      }
    }

    public Decimal AveMechDPU
    {
      get
      {
        if ((int) checked ((short) unchecked ((int) checked ((short) unchecked ((int) this._ICSMechAuditStats.Audited + (int) this._DCSMechAuditStats.Audited)) + (int) this._WWTMechAuditStats.Audited)) > 0)
          return new Decimal((double) checked ((short) unchecked ((int) checked ((short) unchecked ((int) this._ICSMechAuditStats.AuditDefects + (int) this._DCSMechAuditStats.AuditDefects)) + (int) this._WWTMechAuditStats.AuditDefects)) / (double) checked ((short) unchecked ((int) checked ((short) unchecked ((int) this._ICSMechAuditStats.Audited + (int) this._DCSMechAuditStats.Audited)) + (int) this._WWTMechAuditStats.Audited)));
        return Decimal.Zero;
      }
    }

    public Decimal AveElectAuditPct
    {
      get
      {
        if ((int) checked ((short) unchecked ((int) checked ((short) unchecked ((int) this._ICSElectAuditStats.SectCnt + (int) this._DCSElectAuditStats.SectCnt)) + (int) this._WWTElectAuditStats.SectCnt)) > 0)
          return new Decimal((double) checked ((short) unchecked ((int) checked ((short) unchecked ((int) this._ICSElectAuditStats.Audited + (int) this._DCSElectAuditStats.Audited)) + (int) this._WWTElectAuditStats.Audited)) / (double) checked ((short) unchecked ((int) checked ((short) unchecked ((int) this._ICSElectAuditStats.SectCnt + (int) this._DCSElectAuditStats.SectCnt)) + (int) this._WWTElectAuditStats.SectCnt)) * 100.0);
        return Decimal.Zero;
      }
    }

    public Decimal AveElectFPYPct
    {
      get
      {
        if ((int) checked ((short) unchecked ((int) checked ((short) unchecked ((int) this._ICSElectAuditStats.Audited + (int) this._DCSElectAuditStats.Audited)) + (int) this._WWTElectAuditStats.Audited)) > 0)
          return new Decimal((double) checked ((short) unchecked ((int) checked ((short) unchecked ((int) this._ICSElectAuditStats.AuditNPF + (int) this._DCSElectAuditStats.AuditNPF)) + (int) this._WWTElectAuditStats.AuditNPF)) / (double) checked ((short) unchecked ((int) checked ((short) unchecked ((int) this._ICSElectAuditStats.Audited + (int) this._DCSElectAuditStats.Audited)) + (int) this._WWTElectAuditStats.Audited)) * 100.0);
        return Decimal.Zero;
      }
    }

    public Decimal AveElectDPU
    {
      get
      {
        if ((int) checked ((short) unchecked ((int) checked ((short) unchecked ((int) this._ICSElectAuditStats.Audited + (int) this._DCSElectAuditStats.Audited)) + (int) this._WWTElectAuditStats.Audited)) > 0)
          return new Decimal((double) checked ((short) unchecked ((int) checked ((short) unchecked ((int) this._ICSElectAuditStats.AuditDefects + (int) this._DCSElectAuditStats.AuditDefects)) + (int) this._WWTElectAuditStats.AuditDefects)) / (double) checked ((short) unchecked ((int) checked ((short) unchecked ((int) this._ICSElectAuditStats.Audited + (int) this._DCSElectAuditStats.Audited)) + (int) this._WWTElectAuditStats.Audited)));
        return Decimal.Zero;
      }
    }

    public int TotSections
    {
      get
      {
        return (int) checked ((short) unchecked ((int) checked ((short) unchecked ((int) this._ICSElectAuditStats.SectCnt + (int) this._DCSElectAuditStats.SectCnt)) + (int) this._WWTElectAuditStats.SectCnt));
      }
    }

    public scEngrRelStats()
    {
      this.InitClass();
    }

    public scEngrRelStats(string AssemblyLine, DateTime ReleaseDtStart, DateTime ReleaseDtEnd)
    {
      this.InitClass();
      this.CalStats(AssemblyLine, ReleaseDtStart, ReleaseDtEnd);
    }

    private void InitClass()
    {
      this._ICSSchRel = (short) 0;
      this._ICSRelOTOS = (short) 0;
      this._ICSLateOrders = new List<scOrderImportInfo>();
      this._ICSMechAuditStats = new scOrderAuditStats();
      this._ICSElectAuditStats = new scOrderAuditStats();
      this._DCSSchRel = (short) 0;
      this._DCSRelOTOS = (short) 0;
      this._DCSLateOrders = new List<scOrderImportInfo>();
      this._DCSMechAuditStats = new scOrderAuditStats();
      this._DCSElectAuditStats = new scOrderAuditStats();
      this._WWTSchRel = (short) 0;
      this._WWTRelOTOS = (short) 0;
      this._WWTLateOrders = new List<scOrderImportInfo>();
      this._WWTMechAuditStats = new scOrderAuditStats();
      this._WWTElectAuditStats = new scOrderAuditStats();
    }

    public void CalStats(string AssemblyLine, DateTime ReleaseDtStart, DateTime ReleaseDtEnd)
    {
      this.InitClass();
      string Left = AssemblyLine;
      int VPointId1;
      int VPointId2;
      if (Operators.CompareString(Left, "SWBD", false) == 0)
      {
        VPointId1 = 28;
        VPointId2 = 29;
      }
      else if (Operators.CompareString(Left, "LVDO", false) == 0)
      {
        VPointId1 = 36;
        VPointId2 = 37;
      }
      clsEngineCTdB clsEngineCtdB = new clsEngineCTdB();
      List<scOrderImportInfo> scOrderImportInfoList1 = new List<scOrderImportInfo>();
      List<scOrderImportInfo> scOrderImportInfoList2 = clsEngineCtdB.rtnEngrOrderStatus(AssemblyLine, ReleaseDtStart, ReleaseDtEnd);
      List<scOrderImportInfo>.Enumerator enumerator;
      try
      {
        enumerator = scOrderImportInfoList2.GetEnumerator();
        while (enumerator.MoveNext())
        {
          scOrderImportInfo current = enumerator.Current;
          if (Operators.CompareString(current.OrderLineEngrGrp, "ICS", false) == 0)
          {
            this._ICSSchRel = checked ((short) ((int) this._ICSSchRel + 1));
            if (DateTime.Compare(current.OrderLineCurEngrRelDt, current.OrderLineActEngrRelDt) >= 0)
              this._ICSRelOTOS = checked ((short) ((int) this._ICSRelOTOS + 1));
            else
              this._ICSLateOrders.Add(current);
            scOrderAuditStats scOrderAuditStats1 = new scOrderAuditStats();
            scOrderAuditStats scOrderAuditStats2 = clsEngineCtdB.rtnOrderAuditDataByLineId(current.OrderLineId, VPointId1, current.OrderLineActEngrRelDt);
            scOrderAuditStats icsMechAuditStats1 = this._ICSMechAuditStats;
            icsMechAuditStats1.SectCnt = checked ((short) unchecked ((int) icsMechAuditStats1.SectCnt + (int) scOrderAuditStats2.SectCnt));
            scOrderAuditStats icsMechAuditStats2 = this._ICSMechAuditStats;
            icsMechAuditStats2.Audited = checked ((short) unchecked ((int) icsMechAuditStats2.Audited + (int) scOrderAuditStats2.Audited));
            scOrderAuditStats icsMechAuditStats3 = this._ICSMechAuditStats;
            icsMechAuditStats3.AuditNPF = checked ((short) unchecked ((int) icsMechAuditStats3.AuditNPF + (int) scOrderAuditStats2.AuditNPF));
            scOrderAuditStats icsMechAuditStats4 = this._ICSMechAuditStats;
            icsMechAuditStats4.AuditDefects = checked ((short) unchecked ((int) icsMechAuditStats4.AuditDefects + (int) scOrderAuditStats2.AuditDefects));
            scOrderAuditStats icsMechAuditStats5 = this._ICSMechAuditStats;
            icsMechAuditStats5.AuditPreRM = checked ((short) unchecked ((int) icsMechAuditStats5.AuditPreRM + (int) scOrderAuditStats2.AuditPreRM));
            scOrderAuditStats scOrderAuditStats3 = clsEngineCtdB.rtnOrderAuditDataByLineId(current.OrderLineId, VPointId2, current.OrderLineActEngrRelDt);
            scOrderAuditStats icsElectAuditStats1 = this._ICSElectAuditStats;
            icsElectAuditStats1.SectCnt = checked ((short) unchecked ((int) icsElectAuditStats1.SectCnt + (int) scOrderAuditStats3.SectCnt));
            scOrderAuditStats icsElectAuditStats2 = this._ICSElectAuditStats;
            icsElectAuditStats2.Audited = checked ((short) unchecked ((int) icsElectAuditStats2.Audited + (int) scOrderAuditStats3.Audited));
            scOrderAuditStats icsElectAuditStats3 = this._ICSElectAuditStats;
            icsElectAuditStats3.AuditNPF = checked ((short) unchecked ((int) icsElectAuditStats3.AuditNPF + (int) scOrderAuditStats3.AuditNPF));
            scOrderAuditStats icsElectAuditStats4 = this._ICSElectAuditStats;
            icsElectAuditStats4.AuditDefects = checked ((short) unchecked ((int) icsElectAuditStats4.AuditDefects + (int) scOrderAuditStats3.AuditDefects));
            scOrderAuditStats icsElectAuditStats5 = this._ICSElectAuditStats;
            icsElectAuditStats5.AuditPreRM = checked ((short) unchecked ((int) icsElectAuditStats5.AuditPreRM + (int) scOrderAuditStats3.AuditPreRM));
          }
          else if (Operators.CompareString(current.OrderLineEngrGrp, "DCS", false) == 0)
          {
            this._DCSSchRel = checked ((short) ((int) this._DCSSchRel + 1));
            if (DateTime.Compare(current.OrderLineCurEngrRelDt, current.OrderLineActEngrRelDt) >= 0)
              this._DCSRelOTOS = checked ((short) ((int) this._DCSRelOTOS + 1));
            else
              this._DCSLateOrders.Add(current);
            scOrderAuditStats scOrderAuditStats1 = new scOrderAuditStats();
            scOrderAuditStats scOrderAuditStats2 = clsEngineCtdB.rtnOrderAuditDataByLineId(current.OrderLineId, VPointId1, current.OrderLineActEngrRelDt);
            scOrderAuditStats dcsMechAuditStats1 = this._DCSMechAuditStats;
            dcsMechAuditStats1.SectCnt = checked ((short) unchecked ((int) dcsMechAuditStats1.SectCnt + (int) scOrderAuditStats2.SectCnt));
            scOrderAuditStats dcsMechAuditStats2 = this._DCSMechAuditStats;
            dcsMechAuditStats2.Audited = checked ((short) unchecked ((int) dcsMechAuditStats2.Audited + (int) scOrderAuditStats2.Audited));
            scOrderAuditStats dcsMechAuditStats3 = this._DCSMechAuditStats;
            dcsMechAuditStats3.AuditNPF = checked ((short) unchecked ((int) dcsMechAuditStats3.AuditNPF + (int) scOrderAuditStats2.AuditNPF));
            scOrderAuditStats dcsMechAuditStats4 = this._DCSMechAuditStats;
            dcsMechAuditStats4.AuditDefects = checked ((short) unchecked ((int) dcsMechAuditStats4.AuditDefects + (int) scOrderAuditStats2.AuditDefects));
            scOrderAuditStats dcsMechAuditStats5 = this._DCSMechAuditStats;
            dcsMechAuditStats5.AuditPreRM = checked ((short) unchecked ((int) dcsMechAuditStats5.AuditPreRM + (int) scOrderAuditStats2.AuditPreRM));
            scOrderAuditStats scOrderAuditStats3 = clsEngineCtdB.rtnOrderAuditDataByLineId(current.OrderLineId, VPointId2, current.OrderLineActEngrRelDt);
            scOrderAuditStats dcsElectAuditStats1 = this._DCSElectAuditStats;
            dcsElectAuditStats1.SectCnt = checked ((short) unchecked ((int) dcsElectAuditStats1.SectCnt + (int) scOrderAuditStats3.SectCnt));
            scOrderAuditStats dcsElectAuditStats2 = this._DCSElectAuditStats;
            dcsElectAuditStats2.Audited = checked ((short) unchecked ((int) dcsElectAuditStats2.Audited + (int) scOrderAuditStats3.Audited));
            scOrderAuditStats dcsElectAuditStats3 = this._DCSElectAuditStats;
            dcsElectAuditStats3.AuditNPF = checked ((short) unchecked ((int) dcsElectAuditStats3.AuditNPF + (int) scOrderAuditStats3.AuditNPF));
            scOrderAuditStats dcsElectAuditStats4 = this._DCSElectAuditStats;
            dcsElectAuditStats4.AuditDefects = checked ((short) unchecked ((int) dcsElectAuditStats4.AuditDefects + (int) scOrderAuditStats3.AuditDefects));
            scOrderAuditStats dcsElectAuditStats5 = this._DCSElectAuditStats;
            dcsElectAuditStats5.AuditPreRM = checked ((short) unchecked ((int) dcsElectAuditStats5.AuditPreRM + (int) scOrderAuditStats3.AuditPreRM));
          }
          else if (Operators.CompareString(current.OrderLineEngrGrp, "WWT", false) == 0)
          {
            this._WWTSchRel = checked ((short) ((int) this._WWTSchRel + 1));
            if (DateTime.Compare(current.OrderLineCurEngrRelDt, current.OrderLineActEngrRelDt) >= 0)
              this._WWTRelOTOS = checked ((short) ((int) this._WWTRelOTOS + 1));
            else
              this._WWTLateOrders.Add(current);
            scOrderAuditStats scOrderAuditStats1 = new scOrderAuditStats();
            scOrderAuditStats scOrderAuditStats2 = clsEngineCtdB.rtnOrderAuditDataByLineId(current.OrderLineId, VPointId1, current.OrderLineActEngrRelDt);
            scOrderAuditStats wwtMechAuditStats1 = this._WWTMechAuditStats;
            wwtMechAuditStats1.SectCnt = checked ((short) unchecked ((int) wwtMechAuditStats1.SectCnt + (int) scOrderAuditStats2.SectCnt));
            scOrderAuditStats wwtMechAuditStats2 = this._WWTMechAuditStats;
            wwtMechAuditStats2.Audited = checked ((short) unchecked ((int) wwtMechAuditStats2.Audited + (int) scOrderAuditStats2.Audited));
            scOrderAuditStats wwtMechAuditStats3 = this._WWTMechAuditStats;
            wwtMechAuditStats3.AuditNPF = checked ((short) unchecked ((int) wwtMechAuditStats3.AuditNPF + (int) scOrderAuditStats2.AuditNPF));
            scOrderAuditStats wwtMechAuditStats4 = this._WWTMechAuditStats;
            wwtMechAuditStats4.AuditDefects = checked ((short) unchecked ((int) wwtMechAuditStats4.AuditDefects + (int) scOrderAuditStats2.AuditDefects));
            scOrderAuditStats wwtMechAuditStats5 = this._WWTMechAuditStats;
            wwtMechAuditStats5.AuditPreRM = checked ((short) unchecked ((int) wwtMechAuditStats5.AuditPreRM + (int) scOrderAuditStats2.AuditPreRM));
            scOrderAuditStats scOrderAuditStats3 = clsEngineCtdB.rtnOrderAuditDataByLineId(current.OrderLineId, VPointId2, current.OrderLineActEngrRelDt);
            scOrderAuditStats wwtElectAuditStats1 = this._WWTElectAuditStats;
            wwtElectAuditStats1.SectCnt = checked ((short) unchecked ((int) wwtElectAuditStats1.SectCnt + (int) scOrderAuditStats3.SectCnt));
            scOrderAuditStats wwtElectAuditStats2 = this._WWTElectAuditStats;
            wwtElectAuditStats2.Audited = checked ((short) unchecked ((int) wwtElectAuditStats2.Audited + (int) scOrderAuditStats3.Audited));
            scOrderAuditStats wwtElectAuditStats3 = this._WWTElectAuditStats;
            wwtElectAuditStats3.AuditNPF = checked ((short) unchecked ((int) wwtElectAuditStats3.AuditNPF + (int) scOrderAuditStats3.AuditNPF));
            scOrderAuditStats wwtElectAuditStats4 = this._WWTElectAuditStats;
            wwtElectAuditStats4.AuditDefects = checked ((short) unchecked ((int) wwtElectAuditStats4.AuditDefects + (int) scOrderAuditStats3.AuditDefects));
            scOrderAuditStats wwtElectAuditStats5 = this._WWTElectAuditStats;
            wwtElectAuditStats5.AuditPreRM = checked ((short) unchecked ((int) wwtElectAuditStats5.AuditPreRM + (int) scOrderAuditStats3.AuditPreRM));
          }
        }
      }
      finally
      {
        enumerator.Dispose();
      }
    }
  }
}
