// Decompiled with JetBrains decompiler
// Type: SE0085.CTdB.clsDashBoard
// 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.CTdB.My;
using SE0085.dBc;
using SE0085.StCl;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;

namespace SE0085.CTdB
{
  public class clsDashBoard
  {
    private string _CTConnection;

    public string Revision
    {
      [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] get
      {
        return "Version; " + Conversions.ToString(MyProject.Application.Info.Version.Major) + "." + Conversions.ToString(MyProject.Application.Info.Version.Minor) + "." + Conversions.ToString((int) MyProject.Application.Info.Version.MajorRevision) + "." + Conversions.ToString((int) MyProject.Application.Info.Version.MinorRevision);
      }
    }

    public clsDashBoard()
    {
      this.GetdBConnString();
    }

    ~clsDashBoard()
    {
      // ISSUE: explicit finalizer call
      base.Finalize();
    }

    private void GetdBConnString()
    {
      clsDBC clsDbc = new clsDBC();
      clsDbc.GetServer((object) "SE0085CTEntities1");
      this._CTConnection = Conversions.ToString(clsDbc.ConnectionString);
    }

    public void UpdateProdDash(scLevels Plant, scLevels AssemblyLine, List<scRoutingCounts> RoutingList)
    {
      // ISSUE: object of a compiler-generated type is created
      // ISSUE: variable of a compiler-generated type
      clsDashBoard._Closure\u0024__92 closure92 = new clsDashBoard._Closure\u0024__92();
      // ISSUE: reference to a compiler-generated field
      closure92.\u0024VB\u0024Local_AssemblyLine = AssemblyLine;
      ProductionCount productionCount1 = (ProductionCount) null;
      using (SE0085CTEntities1 se0085CtEntities1 = new SE0085CTEntities1())
      {
        se0085CtEntities1.Database.Connection.ConnectionString = this._CTConnection;
        List<scRoutingCounts>.Enumerator enumerator1;
        try
        {
          enumerator1 = RoutingList.GetEnumerator();
          while (enumerator1.MoveNext())
          {
            scRoutingCounts current1 = enumerator1.Current;
            // ISSUE: reference to a compiler-generated field
            closure92.\u0024VB\u0024Local_ldWCDate = current1.RoutingStartDt;
            // ISSUE: reference to a compiler-generated field
            closure92.\u0024VB\u0024Local_ldWorkCenter = current1.RoutingWorkCenter;
            AssemblyLine assemblyLine1 = new AssemblyLine();
            if ((int) current1.RoutingCompletions > 0)
            {
              ParameterExpression parameterExpression1;
              // ISSUE: reference to a compiler-generated field
              IQueryable<AssemblyLine> source1 = (IQueryable<AssemblyLine>) Queryable.Select<AssemblyLine, AssemblyLine>(Queryable.Where<AssemblyLine>((IQueryable<M0>) se0085CtEntities1.AssemblyLines, (Expression<Func<M0, bool>>) Expression.Lambda<Func<AssemblyLine, bool>>((Expression) Expression.Equal(al.AssemLineId, closure92.\u0024VB\u0024Local_AssemblyLine.LevelId, true, (MethodInfo) null), new ParameterExpression[1]
              {
                parameterExpression1
              })), (Expression<Func<M0, M1>>) (al => al));
              if (source1 != null)
              {
                AssemblyLine assemblyLine2 = source1.First<AssemblyLine>();
                ParameterExpression parameterExpression2;
                // ISSUE: reference to a compiler-generated field
                // ISSUE: method reference
                // ISSUE: field reference
                // ISSUE: method reference
                // ISSUE: method reference
                // ISSUE: method reference
                // ISSUE: field reference
                IQueryable<ProductionCount> source2 = (IQueryable<ProductionCount>) Queryable.Select<ProductionCount, ProductionCount>(Queryable.Where<ProductionCount>((IQueryable<M0>) se0085CtEntities1.ProductionCounts, (Expression<Func<M0, bool>>) Expression.Lambda<Func<ProductionCount, bool>>((Expression) Expression.And((Expression) Expression.And((Expression) Expression.Equal(pd.AssemblyLine.AssemLineId, closure92.\u0024VB\u0024Local_AssemblyLine.LevelId, true, (MethodInfo) null), (Expression) Expression.Equal((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (ProductionCount.get_ProdCntDate))), (Expression) Expression.Field((Expression) Expression.Constant((object) closure92, typeof (clsDashBoard._Closure\u0024__92)), FieldInfo.GetFieldFromHandle(__fieldref (clsDashBoard._Closure\u0024__92.\u0024VB\u0024Local_ldWCDate))), true, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (DateTime.op_Equality)))), (Expression) Expression.Equal((Expression) Expression.Call((Expression) null, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Operators.CompareString)), (Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (ProductionCount.get_ProdCntWorkCenter))), (Expression) Expression.Field((Expression) Expression.Constant((object) closure92, typeof (clsDashBoard._Closure\u0024__92)), FieldInfo.GetFieldFromHandle(__fieldref (clsDashBoard._Closure\u0024__92.\u0024VB\u0024Local_ldWorkCenter))), (Expression) Expression.Constant((object) false, typeof (bool))), (Expression) Expression.Constant((object) 0, typeof (int)))), new ParameterExpression[1]
                {
                  parameterExpression2
                })), (Expression<Func<M0, M1>>) (pd => pd));
                int num;
                if (source2.Count<ProductionCount>() == 0)
                {
                  se0085CtEntities1.ProductionCounts.Add(new ProductionCount()
                  {
                    AssemblyLine = assemblyLine2,
                    ProdCntDate = current1.RoutingStartDt,
                    ProdCntWorkCenter = current1.RoutingWorkCenter,
                    ProdCntQty = (int) current1.RoutingCompletions,
                    ProdBklQty = (int) current1.RoutingBacklog,
                    ProdWIPQty = (int) current1.RoutingWIP
                  });
                  num = se0085CtEntities1.SaveChanges();
                }
                else if (source2.Count<ProductionCount>() == 1)
                {
                  IEnumerator<ProductionCount> enumerator2;
                  try
                  {
                    enumerator2 = source2.GetEnumerator();
                    while (enumerator2.MoveNext())
                    {
                      ProductionCount current2 = enumerator2.Current;
                      // ISSUE: reference to a compiler-generated field
                      if (!(current2.AssemblyLine.AssemLineId == closure92.\u0024VB\u0024Local_AssemblyLine.LevelId & DateTime.Compare(current2.ProdCntDate, current1.RoutingStartDt) == 0 & Operators.CompareString(current2.ProdCntWorkCenter, current1.RoutingWorkCenter, false) == 0 & current2.ProdCntQty == (int) current1.RoutingCompletions))
                      {
                        ProductionCount productionCount2 = current2;
                        productionCount2.ProdCntDate = current1.RoutingStartDt;
                        productionCount2.ProdCntWorkCenter = current1.RoutingWorkCenter;
                        productionCount2.ProdCntQty = (int) current1.RoutingCompletions;
                        productionCount2.ProdBklQty = (int) current1.RoutingBacklog;
                        productionCount2.ProdWIPQty = (int) current1.RoutingWIP;
                      }
                    }
                  }
                  finally
                  {
                    if (enumerator2 != null)
                      enumerator2.Dispose();
                  }
                  num = se0085CtEntities1.SaveChanges();
                }
              }
              else
                break;
            }
          }
        }
        finally
        {
          enumerator1.Dispose();
        }
        se0085CtEntities1.Database.Connection.Close();
      }
      productionCount1 = (ProductionCount) null;
    }

    public List<scRoutingCounts> rtnProdDashBoard(scLevels Plant, scLevels AssemblyLine, string WorkCenter, DateTime StartDate, DateTime EndDate)
    {
      // ISSUE: object of a compiler-generated type is created
      // ISSUE: variable of a compiler-generated type
      clsDashBoard._Closure\u0024__93 closure93 = new clsDashBoard._Closure\u0024__93();
      // ISSUE: reference to a compiler-generated field
      closure93.\u0024VB\u0024Local_AssemblyLine = AssemblyLine;
      // ISSUE: reference to a compiler-generated field
      closure93.\u0024VB\u0024Local_StartDate = StartDate;
      // ISSUE: reference to a compiler-generated field
      closure93.\u0024VB\u0024Local_EndDate = EndDate;
      // ISSUE: reference to a compiler-generated field
      closure93.\u0024VB\u0024Local_WorkCenter = WorkCenter;
      using (SE0085CTEntities1 se0085CtEntities1 = new SE0085CTEntities1())
      {
        se0085CtEntities1.Database.Connection.ConnectionString = this._CTConnection;
        ParameterExpression parameterExpression1;
        ParameterExpression parameterExpression2;
        // ISSUE: reference to a compiler-generated field
        // ISSUE: method reference
        // ISSUE: field reference
        // ISSUE: method reference
        // ISSUE: method reference
        // ISSUE: field reference
        // ISSUE: method reference
        // ISSUE: method reference
        // ISSUE: method reference
        // ISSUE: field reference
        // ISSUE: method reference
        // ISSUE: method reference
        // ISSUE: method reference
        // ISSUE: method reference
        // ISSUE: method reference
        // ISSUE: method reference
        // ISSUE: method reference
        // ISSUE: method reference
        // ISSUE: method reference
        // ISSUE: method reference
        // ISSUE: method reference
        // ISSUE: method reference
        IQueryable<scRoutingCounts> source = (IQueryable<scRoutingCounts>) Queryable.Select<ProductionCount, scRoutingCounts>((IQueryable<M0>) Queryable.OrderBy<ProductionCount, DateTime>(Queryable.Where<ProductionCount>((IQueryable<M0>) se0085CtEntities1.ProductionCounts, (Expression<Func<M0, bool>>) Expression.Lambda<Func<ProductionCount, bool>>((Expression) Expression.And((Expression) Expression.And((Expression) Expression.And((Expression) Expression.And((Expression) Expression.Equal(pd.AssemblyLine.AssemLineId, closure93.\u0024VB\u0024Local_AssemblyLine.LevelId, true, (MethodInfo) null), (Expression) Expression.GreaterThanOrEqual((Expression) Expression.Property((Expression) parameterExpression1, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (ProductionCount.get_ProdCntDate))), (Expression) Expression.Field((Expression) Expression.Constant((object) closure93, typeof (clsDashBoard._Closure\u0024__93)), FieldInfo.GetFieldFromHandle(__fieldref (clsDashBoard._Closure\u0024__93.\u0024VB\u0024Local_StartDate))), true, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (DateTime.op_GreaterThanOrEqual)))), (Expression) Expression.LessThanOrEqual((Expression) Expression.Property((Expression) parameterExpression1, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (ProductionCount.get_ProdCntDate))), (Expression) Expression.Field((Expression) Expression.Constant((object) closure93, typeof (clsDashBoard._Closure\u0024__93)), FieldInfo.GetFieldFromHandle(__fieldref (clsDashBoard._Closure\u0024__93.\u0024VB\u0024Local_EndDate))), true, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (DateTime.op_LessThanOrEqual)))), (Expression) Expression.Equal((Expression) Expression.Call((Expression) null, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Operators.CompareString)), (Expression) Expression.Property((Expression) parameterExpression1, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (ProductionCount.get_ProdCntWorkCenter))), (Expression) Expression.Field((Expression) Expression.Constant((object) closure93, typeof (clsDashBoard._Closure\u0024__93)), FieldInfo.GetFieldFromHandle(__fieldref (clsDashBoard._Closure\u0024__93.\u0024VB\u0024Local_WorkCenter))), (Expression) Expression.Constant((object) false, typeof (bool))), (Expression) Expression.Constant((object) 0, typeof (int)))), (Expression) Expression.GreaterThan((Expression) Expression.Property((Expression) parameterExpression1, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (ProductionCount.get_ProdCntQty))), (Expression) Expression.Constant((object) 0, typeof (int)), true, (MethodInfo) null)), new ParameterExpression[1]
        {
          parameterExpression1
        })), (Expression<Func<M0, M1>>) (pd => pd.ProdCntDate)), (Expression<Func<M0, M1>>) Expression.Lambda<Func<ProductionCount, scRoutingCounts>>((Expression) Expression.MemberInit(Expression.New((ConstructorInfo) MethodBase.GetMethodFromHandle(__methodref (scRoutingCounts.\u002Ector)), (Expression[]) null), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scRoutingCounts.set_RoutingWorkCenter)), (Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (ProductionCount.get_ProdCntWorkCenter)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scRoutingCounts.set_RoutingStartDt)), (Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (ProductionCount.get_ProdCntDate)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scRoutingCounts.set_RoutingCompletions)), (Expression) Expression.ConvertChecked((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (ProductionCount.get_ProdCntQty))), typeof (short))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scRoutingCounts.set_RoutingBacklog)), (Expression) Expression.ConvertChecked((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (ProductionCount.get_ProdBklQty))), typeof (short))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scRoutingCounts.set_RoutingWIP)), (Expression) Expression.ConvertChecked((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (ProductionCount.get_ProdWIPQty))), typeof (short)))), new ParameterExpression[1]
        {
          parameterExpression2
        }));
        if (source.Count<scRoutingCounts>() >= 1)
          return source.ToList<scRoutingCounts>();
        return (List<scRoutingCounts>) null;
      }
    }

    public List<scRoutingCounts> rtnProdDashBoardAllWC(scLevels Plant, scLevels AssemblyLine, DateTime StartDate, DateTime EndDate)
    {
      // ISSUE: object of a compiler-generated type is created
      // ISSUE: variable of a compiler-generated type
      clsDashBoard._Closure\u0024__94 closure94 = new clsDashBoard._Closure\u0024__94();
      // ISSUE: reference to a compiler-generated field
      closure94.\u0024VB\u0024Local_AssemblyLine = AssemblyLine;
      // ISSUE: reference to a compiler-generated field
      closure94.\u0024VB\u0024Local_StartDate = StartDate;
      // ISSUE: reference to a compiler-generated field
      closure94.\u0024VB\u0024Local_EndDate = EndDate;
      using (SE0085CTEntities1 se0085CtEntities1 = new SE0085CTEntities1())
      {
        se0085CtEntities1.Database.Connection.ConnectionString = this._CTConnection;
        ParameterExpression parameterExpression1;
        ParameterExpression parameterExpression2;
        // ISSUE: reference to a compiler-generated field
        // ISSUE: method reference
        // ISSUE: field reference
        // ISSUE: method reference
        // ISSUE: method reference
        // ISSUE: field reference
        // ISSUE: method reference
        // ISSUE: method reference
        // ISSUE: method reference
        // ISSUE: method reference
        // ISSUE: method reference
        // ISSUE: method reference
        // ISSUE: method reference
        // ISSUE: method reference
        // ISSUE: method reference
        // ISSUE: method reference
        // ISSUE: method reference
        // ISSUE: method reference
        // ISSUE: method reference
        IQueryable<scRoutingCounts> source = (IQueryable<scRoutingCounts>) Queryable.Select<ProductionCount, scRoutingCounts>((IQueryable<M0>) Queryable.OrderBy<ProductionCount, DateTime>(Queryable.Where<ProductionCount>((IQueryable<M0>) se0085CtEntities1.ProductionCounts, (Expression<Func<M0, bool>>) Expression.Lambda<Func<ProductionCount, bool>>((Expression) Expression.And((Expression) Expression.And((Expression) Expression.And((Expression) Expression.Equal(pd.AssemblyLine.AssemLineId, closure94.\u0024VB\u0024Local_AssemblyLine.LevelId, true, (MethodInfo) null), (Expression) Expression.GreaterThanOrEqual((Expression) Expression.Property((Expression) parameterExpression1, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (ProductionCount.get_ProdCntDate))), (Expression) Expression.Field((Expression) Expression.Constant((object) closure94, typeof (clsDashBoard._Closure\u0024__94)), FieldInfo.GetFieldFromHandle(__fieldref (clsDashBoard._Closure\u0024__94.\u0024VB\u0024Local_StartDate))), true, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (DateTime.op_GreaterThanOrEqual)))), (Expression) Expression.LessThanOrEqual((Expression) Expression.Property((Expression) parameterExpression1, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (ProductionCount.get_ProdCntDate))), (Expression) Expression.Field((Expression) Expression.Constant((object) closure94, typeof (clsDashBoard._Closure\u0024__94)), FieldInfo.GetFieldFromHandle(__fieldref (clsDashBoard._Closure\u0024__94.\u0024VB\u0024Local_EndDate))), true, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (DateTime.op_LessThanOrEqual)))), (Expression) Expression.GreaterThan((Expression) Expression.Property((Expression) parameterExpression1, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (ProductionCount.get_ProdCntQty))), (Expression) Expression.Constant((object) 0, typeof (int)), true, (MethodInfo) null)), new ParameterExpression[1]
        {
          parameterExpression1
        })), (Expression<Func<M0, M1>>) (pd => pd.ProdCntDate)), (Expression<Func<M0, M1>>) Expression.Lambda<Func<ProductionCount, scRoutingCounts>>((Expression) Expression.MemberInit(Expression.New((ConstructorInfo) MethodBase.GetMethodFromHandle(__methodref (scRoutingCounts.\u002Ector)), (Expression[]) null), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scRoutingCounts.set_RoutingWorkCenter)), (Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (ProductionCount.get_ProdCntWorkCenter)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scRoutingCounts.set_RoutingStartDt)), (Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (ProductionCount.get_ProdCntDate)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scRoutingCounts.set_RoutingCompletions)), (Expression) Expression.ConvertChecked((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (ProductionCount.get_ProdCntQty))), typeof (short))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scRoutingCounts.set_RoutingBacklog)), (Expression) Expression.ConvertChecked((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (ProductionCount.get_ProdBklQty))), typeof (short))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scRoutingCounts.set_RoutingWIP)), (Expression) Expression.ConvertChecked((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (ProductionCount.get_ProdWIPQty))), typeof (short)))), new ParameterExpression[1]
        {
          parameterExpression2
        }));
        if (source.Count<scRoutingCounts>() >= 1)
          return source.ToList<scRoutingCounts>();
        return (List<scRoutingCounts>) null;
      }
    }
  }
}
