// Decompiled with JetBrains decompiler
// Type: SE0085.CTdB.clsShipments
// 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 SE0085.dBc;
using SE0085.Q2CdB;
using SE0085.StCl;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Threading;

namespace SE0085.CTdB
{
  public class clsShipments
  {
    private static List<WeakReference> __ENCList = new List<WeakReference>();
    private string _CTConnection;
    private scLevels _Plant;
    private scLevels _AssemblyLine;
    private clsT2Q2CdB lcQ2C;

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

    public scLevels AssemblyLine
    {
      get
      {
        return this._AssemblyLine;
      }
      set
      {
        this._AssemblyLine = value;
      }
    }

    public event clsShipments.ueUpdateProgressEventHandler ueUpdateProgress;

    [DebuggerNonUserCode]
    static clsShipments()
    {
    }

    public clsShipments(scLevels Plant, scLevels AssemblyLine)
    {
      clsShipments.__ENCAddToList((object) this);
      this.lcQ2C = new clsT2Q2CdB();
      this._Plant = Plant;
      this._AssemblyLine = AssemblyLine;
      this.lcQ2C = new clsT2Q2CdB();
      this.GetdBConnString();
    }

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

    [DebuggerNonUserCode]
    private static void __ENCAddToList(object value)
    {
      List<WeakReference> encList = clsShipments.__ENCList;
      bool flag = false;
      try
      {
        Monitor.Enter((object) encList, ref flag);
        if (clsShipments.__ENCList.Count == clsShipments.__ENCList.Capacity)
        {
          int index1 = 0;
          int num1 = 0;
          int num2 = checked (clsShipments.__ENCList.Count - 1);
          int index2 = num1;
          while (index2 <= num2)
          {
            if (clsShipments.__ENCList[index2].IsAlive)
            {
              if (index2 != index1)
                clsShipments.__ENCList[index1] = clsShipments.__ENCList[index2];
              checked { ++index1; }
            }
            checked { ++index2; }
          }
          clsShipments.__ENCList.RemoveRange(index1, checked (clsShipments.__ENCList.Count - index1));
          clsShipments.__ENCList.Capacity = clsShipments.__ENCList.Count;
        }
        clsShipments.__ENCList.Add(new WeakReference(RuntimeHelpers.GetObjectValue(value)));
      }
      finally
      {
        if (flag)
          Monitor.Exit((object) encList);
      }
    }

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

    public ArrayList ImportShipments(string ImportFile, scPlants SEPlant, scLevels[] AssemblyLines)
    {
      StreamReader streamReader;
      ArrayList arrayList1;
      try
      {
        streamReader = File.OpenText(ImportFile);
      }
      catch (Exception ex)
      {
        ProjectData.SetProjectError(ex);
        arrayList1 = (ArrayList) null;
        ProjectData.ClearProjectError();
        goto label_26;
      }
      short[] numArray1 = new short[126];
      short[] numArray2 = new short[126];
      numArray1[0] = (short) 1;
      numArray2[0] = (short) 3;
      numArray1[1] = (short) 5;
      numArray2[1] = (short) 8;
      numArray1[2] = (short) 14;
      numArray2[2] = (short) 3;
      numArray1[3] = (short) 18;
      numArray2[3] = (short) 2;
      numArray1[4] = (short) 21;
      numArray2[4] = (short) 2;
      numArray1[5] = (short) 24;
      numArray2[5] = (short) 35;
      numArray1[6] = (short) 60;
      numArray2[6] = (short) 7;
      numArray1[7] = (short) 68;
      numArray2[7] = (short) 46;
      numArray1[8] = (short) 115;
      numArray2[8] = (short) 10;
      numArray1[9] = (short) 126;
      numArray2[9] = (short) 10;
      numArray1[10] = (short) 137;
      numArray2[10] = (short) 10;
      numArray1[11] = (short) 148;
      numArray2[11] = (short) 11;
      numArray1[12] = (short) 160;
      numArray2[12] = (short) 11;
      numArray1[13] = (short) 172;
      numArray2[13] = (short) 1;
      numArray1[14] = (short) 174;
      numArray2[14] = (short) 4;
      numArray1[15] = (short) 179;
      numArray2[15] = (short) 1;
      numArray1[16] = (short) 181;
      numArray2[16] = (short) 2;
      numArray1[17] = (short) 184;
      numArray2[17] = (short) 2;
      numArray1[18] = (short) 187;
      numArray2[18] = (short) 2;
      numArray1[19] = (short) 190;
      numArray2[19] = (short) 10;
      numArray1[20] = (short) 201;
      numArray2[20] = (short) 10;
      numArray1[21] = (short) 212;
      numArray2[21] = (short) 10;
      numArray1[22] = (short) 223;
      numArray2[22] = (short) 10;
      numArray1[23] = (short) 234;
      numArray2[23] = (short) 8;
      numArray1[24] = (short) 243;
      numArray2[24] = (short) 3;
      numArray1[25] = (short) 247;
      numArray2[25] = (short) 4;
      numArray1[26] = (short) 252;
      numArray2[26] = (short) 4;
      numArray1[27] = (short) 257;
      numArray2[27] = (short) 5;
      numArray1[28] = (short) 263;
      numArray2[28] = (short) 30;
      numArray1[29] = (short) 294;
      numArray2[29] = (short) 20;
      numArray1[30] = (short) 315;
      numArray2[30] = (short) 10;
      numArray1[31] = (short) 326;
      numArray2[31] = (short) 10;
      numArray1[32] = (short) 337;
      numArray2[32] = (short) 10;
      numArray1[33] = (short) 348;
      numArray2[33] = (short) 10;
      numArray1[34] = (short) 359;
      numArray2[34] = (short) 10;
      numArray1[35] = (short) 370;
      numArray2[35] = (short) 10;
      numArray1[36] = (short) 381;
      numArray2[36] = (short) 10;
      numArray1[37] = (short) 392;
      numArray2[37] = (short) 10;
      numArray1[38] = (short) 403;
      numArray2[38] = (short) 10;
      numArray1[39] = (short) 414;
      numArray2[39] = (short) 10;
      numArray1[40] = (short) 425;
      numArray2[40] = (short) 10;
      numArray1[41] = (short) 436;
      numArray2[41] = (short) 10;
      numArray1[42] = (short) 447;
      numArray2[42] = (short) 10;
      numArray1[43] = (short) 458;
      numArray2[43] = (short) 10;
      numArray1[44] = (short) 469;
      numArray2[44] = (short) 10;
      numArray1[45] = (short) 480;
      numArray2[45] = (short) 10;
      numArray1[46] = (short) 491;
      numArray2[46] = (short) 10;
      numArray1[47] = (short) 502;
      numArray2[47] = (short) 10;
      numArray1[48] = (short) 513;
      numArray2[48] = (short) 10;
      numArray1[49] = (short) 524;
      numArray2[49] = (short) 10;
      numArray1[50] = (short) 535;
      numArray2[50] = (short) 10;
      numArray1[51] = (short) 546;
      numArray2[51] = (short) 10;
      numArray1[52] = (short) 557;
      numArray2[52] = (short) 10;
      numArray1[53] = (short) 568;
      numArray2[53] = (short) 10;
      numArray1[54] = (short) 579;
      numArray2[54] = (short) 10;
      numArray1[55] = (short) 590;
      numArray2[55] = (short) 10;
      numArray1[56] = (short) 601;
      numArray2[56] = (short) 10;
      numArray1[57] = (short) 612;
      numArray2[57] = (short) 10;
      numArray1[58] = (short) 623;
      numArray2[58] = (short) 10;
      numArray1[59] = (short) 634;
      numArray2[59] = (short) 10;
      numArray1[60] = (short) 645;
      numArray2[60] = (short) 10;
      numArray1[61] = (short) 656;
      numArray2[61] = (short) 10;
      numArray1[62] = (short) 667;
      numArray2[62] = (short) 10;
      numArray1[63] = (short) 678;
      numArray2[63] = (short) 10;
      numArray1[64] = (short) 689;
      numArray2[64] = (short) 10;
      numArray1[65] = (short) 700;
      numArray2[65] = (short) 10;
      numArray1[66] = (short) 711;
      numArray2[66] = (short) 10;
      numArray1[67] = (short) 722;
      numArray2[67] = (short) 10;
      numArray1[68] = (short) 733;
      numArray2[68] = (short) 10;
      numArray1[69] = (short) 744;
      numArray2[69] = (short) 10;
      numArray1[70] = (short) 755;
      numArray2[70] = (short) 1;
      numArray1[71] = (short) 757;
      numArray2[71] = (short) 3;
      numArray1[72] = (short) 761;
      numArray2[72] = (short) 3;
      numArray1[73] = (short) 765;
      numArray2[73] = (short) 3;
      numArray1[74] = (short) 769;
      numArray2[74] = (short) 3;
      numArray1[75] = (short) 773;
      numArray2[75] = (short) 15;
      numArray1[76] = (short) 789;
      numArray2[76] = (short) 2;
      numArray1[77] = (short) 792;
      numArray2[77] = (short) 1;
      numArray1[78] = (short) 794;
      numArray2[78] = (short) 18;
      numArray1[79] = (short) 813;
      numArray2[79] = (short) 1;
      numArray1[80] = (short) 815;
      numArray2[80] = (short) 1;
      numArray1[81] = (short) 817;
      numArray2[81] = (short) 3;
      numArray1[82] = (short) 821;
      numArray2[82] = (short) 15;
      numArray1[83] = (short) 837;
      numArray2[83] = (short) 35;
      numArray1[84] = (short) 873;
      numArray2[84] = (short) 5;
      numArray1[85] = (short) 879;
      numArray2[85] = (short) 10;
      numArray1[86] = (short) 890;
      numArray2[86] = (short) 1;
      numArray1[87] = (short) 892;
      numArray2[87] = (short) 1;
      numArray1[88] = (short) 894;
      numArray2[88] = (short) 1;
      numArray1[89] = (short) 896;
      numArray2[89] = (short) 10;
      numArray1[90] = (short) 907;
      numArray2[90] = (short) 10;
      numArray1[91] = (short) 918;
      numArray2[91] = (short) 1;
      numArray1[92] = (short) 920;
      numArray2[92] = (short) 2;
      numArray1[93] = (short) 923;
      numArray2[93] = (short) 4;
      numArray1[94] = (short) 928;
      numArray2[94] = (short) 10;
      numArray1[95] = (short) 939;
      numArray2[95] = (short) 10;
      numArray1[96] = (short) 950;
      numArray2[96] = (short) 10;
      numArray1[97] = (short) 961;
      numArray2[97] = (short) 3;
      numArray1[98] = (short) 965;
      numArray2[98] = (short) 8;
      numArray1[99] = (short) 974;
      numArray2[99] = (short) 5;
      numArray1[100] = (short) 980;
      numArray2[100] = (short) 10;
      numArray1[101] = (short) 993;
      numArray2[101] = (short) 10;
      numArray1[102] = (short) 1002;
      numArray2[102] = (short) 10;
      numArray1[103] = (short) 1013;
      numArray2[103] = (short) 10;
      numArray1[104] = (short) 1024;
      numArray2[104] = (short) 23;
      numArray1[105] = (short) 1048;
      numArray2[105] = (short) 3;
      numArray1[106] = (short) 1052;
      numArray2[106] = (short) 3;
      numArray1[107] = (short) 1056;
      numArray2[107] = (short) 3;
      numArray1[108] = (short) 1060;
      numArray2[108] = (short) 3;
      numArray1[109] = (short) 1064;
      numArray2[109] = (short) 11;
      numArray1[110] = (short) 1076;
      numArray2[110] = (short) 20;
      numArray1[111] = (short) 1197;
      numArray2[111] = (short) 12;
      numArray1[112] = (short) 1110;
      numArray2[112] = (short) 10;
      numArray1[113] = (short) 1121;
      numArray2[113] = (short) 10;
      numArray1[114] = (short) 1132;
      numArray2[114] = (short) 10;
      numArray1[115] = (short) 1143;
      numArray2[115] = (short) 10;
      numArray1[116] = (short) 1154;
      numArray2[116] = (short) 10;
      numArray1[117] = (short) 1165;
      numArray2[117] = (short) 10;
      numArray1[118] = (short) 1176;
      numArray2[118] = (short) 10;
      numArray1[119] = (short) 1187;
      numArray2[119] = (short) 2;
      numArray1[120] = (short) 1190;
      numArray2[120] = (short) 10;
      scOrderImportInfo scOrderImportInfo = (scOrderImportInfo) null;
      ArrayList arrayList2 = new ArrayList();
      while (streamReader.Peek() >= 0)
      {
        Thread.CurrentThread.Join(0);
        string str1 = streamReader.ReadLine();
        short num1 = 0;
        bool flag;
        do
        {
          int Start = (int) numArray1[(int) num1];
          int Length = (int) numArray2[(int) num1];
          int num2 = checked ((int) (short) unchecked ((int) numArray1[(int) num1] + (int) numArray2[(int) num1]) - 1);
          string str2 = Microsoft.VisualBasic.Strings.Mid(str1, Start, Length);
          switch (num1)
          {
            case 0:
              string str3 = str2;
              flag = false;
              if (SEPlant.PlantDesin.Contains(str3))
              {
                scOrderImportInfo = new scOrderImportInfo();
                flag = true;
                scOrderImportInfo.SEPlant = SEPlant;
              }
              if (flag)
                break;
              goto label_21;
            case 1:
              scOrderImportInfo.OrderFO = str2;
              break;
            case 2:
              scOrderImportInfo.OrderLineNum = str2;
              break;
            case 3:
              scOrderImportInfo.OrderLineSL = str2;
              break;
            case 4:
              scOrderImportInfo.OrderLineSS = str2;
              break;
            case 10:
              try
              {
                scOrderImportInfo.OrderLineShippedDt = Conversions.ToDate(str2);
                break;
              }
              catch (Exception ex)
              {
                ProjectData.SetProjectError(ex);
                scOrderImportInfo.OrderLineShippedDt = Conversions.ToDate("01/01/2000");
                ProjectData.ClearProjectError();
                break;
              }
            case 93:
              string str4 = str2;
              scLevels[] scLevelsArray = AssemblyLines;
              int index = 0;
              while (index < scLevelsArray.Length)
              {
                scLevels scLevels = scLevelsArray[index];
                if (scLevels.LevelAbbrv.Contains(str4))
                {
                  scOrderImportInfo.AssemblyLine = scLevels;
                  break;
                }
                checked { ++index; }
              }
              break;
          }
          ++num1;
        }
        while ((int) num1 <= 120);
label_21:
        if (flag)
        {
          scOrderImportInfo.OrderLineShipped = DateTime.Compare(scOrderImportInfo.OrderLineShippedDt, Conversions.ToDate("01/01/2009")) > 0;
          arrayList2.Add((object) scOrderImportInfo);
        }
      }
      streamReader.Close();
      arrayList1 = arrayList2;
label_26:
      return arrayList1;
    }

    public void UpdateShippedLines(scOrderImportInfo ShippedOrders)
    {
      // ISSUE: object of a compiler-generated type is created
      // ISSUE: variable of a compiler-generated type
      clsShipments._Closure\u0024__134 closure134 = new clsShipments._Closure\u0024__134();
      // ISSUE: reference to a compiler-generated field
      closure134.\u0024VB\u0024Local_ldShippedOrders = new scOrderImportInfo();
      // ISSUE: reference to a compiler-generated field
      closure134.\u0024VB\u0024Local_ldShippedOrders = ShippedOrders;
      // ISSUE: reference to a compiler-generated field
      closure134.\u0024VB\u0024Local_ldOrderLine = (OrderLine) null;
      using (SE0085CTEntities1 se0085CtEntities1 = new SE0085CTEntities1())
      {
        se0085CtEntities1.Database.Connection.ConnectionString = this._CTConnection;
        // ISSUE: method reference
        // ISSUE: reference to a compiler-generated field
        // ISSUE: method reference
        // ISSUE: reference to a compiler-generated field
        // ISSUE: method reference
        // ISSUE: reference to a compiler-generated field
        // ISSUE: method reference
        // ISSUE: reference to a compiler-generated field
        IQueryable<OrderLine> source1 = (IQueryable<OrderLine>) Queryable.Select(Queryable.Where((IQueryable<M0>) Queryable.Join((IQueryable<M0>) se0085CtEntities1.SEOrders, (IEnumerable<M1>) se0085CtEntities1.OrderLines, (Expression<Func<M0, M2>>) (o => o.OrderId), (Expression<Func<M1, M2>>) (l => l.SEOrder.OrderId), (Expression<Func<M0, M1, M3>>) ((o, l) => new{ o = o, l = l })), (Expression<Func<M0, bool>>) (data => Expression.Call((Expression) null, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Operators.CompareString)), data.o.OrderFO, closure134.\u0024VB\u0024Local_ldShippedOrders.OrderFO, false) == 0 & Expression.Call((Expression) null, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Operators.CompareString)), data.l.OrderLineNum, closure134.\u0024VB\u0024Local_ldShippedOrders.OrderLineNum, false) == 0 & Expression.Call((Expression) null, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Operators.CompareString)), data.l.OrderLineSL, closure134.\u0024VB\u0024Local_ldShippedOrders.OrderLineSL, false) == 0 & Expression.Call((Expression) null, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Operators.CompareString)), data.l.OrderLineSS, closure134.\u0024VB\u0024Local_ldShippedOrders.OrderLineSS, false) == 0)), (Expression<Func<M0, M1>>) (data => data.l));
        bool flag1 = false;
        if (source1.Count<OrderLine>() == 0)
          return;
        if (source1.Count<OrderLine>() == 1)
        {
          try
          {
            // ISSUE: reference to a compiler-generated field
            closure134.\u0024VB\u0024Local_ldOrderLine = source1.First<OrderLine>();
            bool flag2 = true;
            int num1;
            bool? nullable1;
            bool? nullable2;
            bool? nullable3;
            if ((0 & (num1 == 3 | num1 == 4 | num1 == 7 | num1 == 8 ? 1 : 0)) != 0)
            {
              ParameterExpression parameterExpression;
              // ISSUE: reference to a compiler-generated field
              IQueryable<int?> source2 = (IQueryable<int?>) Queryable.Select<OrdFASExt, int?>(Queryable.Where<OrdFASExt>((IQueryable<M0>) se0085CtEntities1.OrdFASExts, (Expression<Func<M0, bool>>) Expression.Lambda<Func<OrdFASExt, bool>>((Expression) Expression.Equal(fq.OrderLine.OrderLineId, closure134.\u0024VB\u0024Local_ldOrderLine.OrderLineId, true, (MethodInfo) null), new ParameterExpression[1]
              {
                parameterExpression
              })), (Expression<Func<M0, M1>>) (fq => fq.FASCmplQty));
              if (source2 != null && source2.Count<int?>() > 0)
              {
                // ISSUE: reference to a compiler-generated field
                int? orderLineQty = closure134.\u0024VB\u0024Local_ldOrderLine.OrderLineQty;
                int num2 = orderLineQty.HasValue ? 1 : 0;
                int? nullable4 = source2.First<int?>();
                int num3 = nullable4.HasValue ? 1 : 0;
                bool? nullable5;
                if ((num2 & num3) == 0)
                {
                  nullable5 = new bool?();
                }
                else
                {
                  nullable1 = new bool?(orderLineQty.GetValueOrDefault() == nullable4.GetValueOrDefault());
                  nullable5 = nullable1;
                }
                nullable2 = nullable5;
                bool? nullable6;
                if (!nullable2.HasValue)
                {
                  nullable6 = new bool?();
                }
                else
                {
                  nullable3 = new bool?(!nullable2.GetValueOrDefault());
                  nullable6 = nullable3;
                }
                if (nullable6.GetValueOrDefault())
                  flag2 = false;
              }
            }
            if (flag2)
            {
              // ISSUE: reference to a compiler-generated field
              DateTime orderLineShippedDt1 = closure134.\u0024VB\u0024Local_ldShippedOrders.OrderLineShippedDt;
              // ISSUE: reference to a compiler-generated field
              DateTime? orderLineShippedDt2 = closure134.\u0024VB\u0024Local_ldOrderLine.OrderLineShippedDt;
              bool? nullable4 = orderLineShippedDt2.HasValue ? new bool?(DateTime.Compare(orderLineShippedDt2.GetValueOrDefault(), orderLineShippedDt1) == 0) : new bool?();
              // ISSUE: reference to a compiler-generated field
              bool orderLineShipped1 = closure134.\u0024VB\u0024Local_ldShippedOrders.OrderLineShipped;
              // ISSUE: reference to a compiler-generated field
              bool? orderLineShipped2 = closure134.\u0024VB\u0024Local_ldOrderLine.OrderLineShipped;
              bool? nullable5;
              bool? nullable6;
              if (!orderLineShipped2.HasValue)
              {
                nullable6 = new bool?();
              }
              else
              {
                nullable5 = new bool?(orderLineShipped2.GetValueOrDefault() == orderLineShipped1);
                nullable6 = nullable5;
              }
              bool? nullable7 = nullable6;
              nullable3 = !nullable4.HasValue || nullable4.GetValueOrDefault() ? (nullable7.HasValue ? (nullable7.GetValueOrDefault() ? nullable4 : new bool?(false)) : new bool?()) : new bool?(false);
              bool? nullable8;
              if (!nullable3.HasValue)
              {
                nullable8 = new bool?();
              }
              else
              {
                nullable2 = new bool?(!nullable3.GetValueOrDefault());
                nullable8 = nullable2;
              }
              nullable1 = nullable8;
              if (nullable1.GetValueOrDefault())
              {
                // ISSUE: reference to a compiler-generated field
                // ISSUE: reference to a compiler-generated field
                closure134.\u0024VB\u0024Local_ldOrderLine.OrderLineShippedDt = (DateTime?) closure134.\u0024VB\u0024Local_ldShippedOrders.OrderLineShippedDt;
                // ISSUE: reference to a compiler-generated field
                // ISSUE: reference to a compiler-generated field
                closure134.\u0024VB\u0024Local_ldOrderLine.OrderLineShipped = (bool?) closure134.\u0024VB\u0024Local_ldShippedOrders.OrderLineShipped;
                flag1 = true;
              }
              // ISSUE: reference to a compiler-generated field
              orderLineShippedDt2 = closure134.\u0024VB\u0024Local_ldOrderLine.OrderLineShippedDt;
              int num2 = !orderLineShippedDt2.HasValue ? 1 : 0;
              // ISSUE: reference to a compiler-generated field
              nullable5 = closure134.\u0024VB\u0024Local_ldOrderLine.OrderLineShipped;
              int num3 = !nullable5.HasValue ? 1 : 0;
              if ((num2 | num3) != 0)
              {
                // ISSUE: reference to a compiler-generated field
                // ISSUE: reference to a compiler-generated field
                closure134.\u0024VB\u0024Local_ldOrderLine.OrderLineShippedDt = (DateTime?) closure134.\u0024VB\u0024Local_ldShippedOrders.OrderLineShippedDt;
                // ISSUE: reference to a compiler-generated field
                // ISSUE: reference to a compiler-generated field
                closure134.\u0024VB\u0024Local_ldOrderLine.OrderLineShipped = (bool?) closure134.\u0024VB\u0024Local_ldShippedOrders.OrderLineShipped;
                flag1 = true;
              }
            }
          }
          catch (Exception ex)
          {
            ProjectData.SetProjectError(ex);
            // ISSUE: reference to a compiler-generated field
            int num = (int) Interaction.MsgBox((object) ("Error importing data, aborting MES import for Order; " + closure134.\u0024VB\u0024Local_ldShippedOrders.OrderFO), MsgBoxStyle.Information, (object) "ONE QMS MES Import Error - E0001");
            ProjectData.ClearProjectError();
            return;
          }
          if (flag1)
            se0085CtEntities1.SaveChanges();
          se0085CtEntities1.Database.Connection.Close();
        }
        else
        {
          // ISSUE: reference to a compiler-generated field
          int num4 = (int) Interaction.MsgBox((object) ("Multiple Order numbers found, aborting MES import for Order; " + closure134.\u0024VB\u0024Local_ldShippedOrders.OrderFO), MsgBoxStyle.Information, (object) "ONE QMS MES Import Error - E0001");
        }
      }
    }

    public void UpdateQ2CShippedOrders(DateTime ShipDate)
    {
      List<scmdsbodq2c> scmdsbodq2cList = new List<scmdsbodq2c>();
      List<scmdsbodq2c> byShipDtmdsbodq2c = this.lcQ2C.getByShipDtmdsbodq2c(ShipDate);
      int num1 = 0;
      using (SE0085CTEntities1 se0085CtEntities1 = new SE0085CTEntities1())
      {
        se0085CtEntities1.Database.Connection.ConnectionString = this._CTConnection;
        List<scmdsbodq2c>.Enumerator enumerator;
        try
        {
          enumerator = byShipDtmdsbodq2c.GetEnumerator();
          while (enumerator.MoveNext())
          {
            // ISSUE: object of a compiler-generated type is created
            // ISSUE: variable of a compiler-generated type
            clsShipments._Closure\u0024__135 other1 = new clsShipments._Closure\u0024__135(other1);
            scmdsbodq2c current = enumerator.Current;
            checked { ++num1; }
            // ISSUE: reference to a compiler-generated field
            other1.\u0024VB\u0024Local_ldq2c_nbr = current.q2c_nbr;
            // ISSUE: reference to a compiler-generated field
            other1.\u0024VB\u0024Local_ldln_itm = current.ln_itm;
            // ISSUE: reference to a compiler-generated field
            other1.\u0024VB\u0024Local_ldsub_ln_itm_id = current.sub_ln_itm_id;
            // ISSUE: reference to a compiler-generated field
            other1.\u0024VB\u0024Local_ldshp_sched_id = current.shp_sched_id;
            // ISSUE: object of a compiler-generated type is created
            // ISSUE: variable of a compiler-generated type
            clsShipments._Closure\u0024__135._Closure\u0024__136 other2 = new clsShipments._Closure\u0024__135._Closure\u0024__136(other2);
            // ISSUE: reference to a compiler-generated field
            other2.\u0024VB\u0024Local_ldSEOrder = (SEOrder) null;
            // ISSUE: method reference
            // ISSUE: reference to a compiler-generated field
            IQueryable<SEOrder> source1 = (IQueryable<SEOrder>) Queryable.Select<SEOrder, SEOrder>(Queryable.Where<SEOrder>((IQueryable<M0>) se0085CtEntities1.SEOrders, (Expression<Func<M0, bool>>) (o => Expression.Call((Expression) null, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Operators.CompareString)), o.OrderFO, other1.\u0024VB\u0024Local_ldq2c_nbr, false) == 0)), (Expression<Func<M0, M1>>) (o => o));
            if (source1.Count<SEOrder>() != 0)
            {
              if (source1.Count<SEOrder>() == 1)
              {
                try
                {
                  // ISSUE: reference to a compiler-generated field
                  other2.\u0024VB\u0024Local_ldSEOrder = source1.First<SEOrder>();
                }
                catch (Exception ex)
                {
                  ProjectData.SetProjectError(ex);
                  // ISSUE: reference to a compiler-generated field
                  int num2 = (int) Interaction.MsgBox((object) ("Error loading MES Order data, aborting MES import for Order; " + other1.\u0024VB\u0024Local_ldq2c_nbr), MsgBoxStyle.Information, (object) "ONE QMS MES Import Error - E0001");
                  ProjectData.ClearProjectError();
                  goto label_46;
                }
                // ISSUE: reference to a compiler-generated field
                other2.\u0024VB\u0024Local_ldOrderLine = (OrderLine) null;
                ParameterExpression parameterExpression1;
                // ISSUE: reference to a compiler-generated field
                // ISSUE: method reference
                // ISSUE: method reference
                // ISSUE: field reference
                // ISSUE: method reference
                // ISSUE: method reference
                // ISSUE: field reference
                // ISSUE: method reference
                // ISSUE: method reference
                // ISSUE: field reference
                IQueryable<OrderLine> source2 = (IQueryable<OrderLine>) Queryable.Select<OrderLine, OrderLine>(Queryable.Where<OrderLine>((IQueryable<M0>) se0085CtEntities1.OrderLines, (Expression<Func<M0, bool>>) Expression.Lambda<Func<OrderLine, bool>>((Expression) Expression.And((Expression) Expression.And((Expression) Expression.And((Expression) Expression.Equal(l.SEOrder.OrderId, other2.\u0024VB\u0024Local_ldSEOrder.OrderId, true, (MethodInfo) null), (Expression) Expression.Equal((Expression) Expression.Call((Expression) null, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Operators.CompareString)), (Expression) Expression.Property((Expression) parameterExpression1, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineNum))), (Expression) Expression.Field((Expression) Expression.Constant((object) other1, typeof (clsShipments._Closure\u0024__135)), FieldInfo.GetFieldFromHandle(__fieldref (clsShipments._Closure\u0024__135.\u0024VB\u0024Local_ldln_itm))), (Expression) Expression.Constant((object) false, typeof (bool))), (Expression) Expression.Constant((object) 0, typeof (int)))), (Expression) Expression.Equal((Expression) Expression.Call((Expression) null, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Operators.CompareString)), (Expression) Expression.Property((Expression) parameterExpression1, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineSL))), (Expression) Expression.Field((Expression) Expression.Constant((object) other1, typeof (clsShipments._Closure\u0024__135)), FieldInfo.GetFieldFromHandle(__fieldref (clsShipments._Closure\u0024__135.\u0024VB\u0024Local_ldsub_ln_itm_id))), (Expression) Expression.Constant((object) false, typeof (bool))), (Expression) Expression.Constant((object) 0, typeof (int)))), (Expression) Expression.Equal((Expression) Expression.Call((Expression) null, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Operators.CompareString)), (Expression) Expression.Property((Expression) parameterExpression1, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineSS))), (Expression) Expression.Field((Expression) Expression.Constant((object) other1, typeof (clsShipments._Closure\u0024__135)), FieldInfo.GetFieldFromHandle(__fieldref (clsShipments._Closure\u0024__135.\u0024VB\u0024Local_ldshp_sched_id))), (Expression) Expression.Constant((object) false, typeof (bool))), (Expression) Expression.Constant((object) 0, typeof (int)))), new ParameterExpression[1]
                {
                  parameterExpression1
                })), (Expression<Func<M0, M1>>) (l => l));
                bool flag1 = false;
                if (source2.Count<OrderLine>() != 0)
                {
                  if (source2.Count<OrderLine>() == 1)
                  {
                    try
                    {
                      // ISSUE: reference to a compiler-generated field
                      other2.\u0024VB\u0024Local_ldOrderLine = source2.First<OrderLine>();
                      bool flag2 = true;
                      // ISSUE: reference to a compiler-generated field
                      int assemLineId = other2.\u0024VB\u0024Local_ldOrderLine.AssemblyLine.AssemLineId;
                      bool? nullable1;
                      bool? nullable2;
                      bool? nullable3;
                      if ((0 & (assemLineId == 3 | assemLineId == 4 | assemLineId == 7 | assemLineId == 8 ? 1 : 0)) != 0)
                      {
                        ParameterExpression parameterExpression2;
                        // ISSUE: reference to a compiler-generated field
                        IQueryable<int?> source3 = (IQueryable<int?>) Queryable.Select<OrdFASExt, int?>(Queryable.Where<OrdFASExt>((IQueryable<M0>) se0085CtEntities1.OrdFASExts, (Expression<Func<M0, bool>>) Expression.Lambda<Func<OrdFASExt, bool>>((Expression) Expression.Equal(fq.OrderLine.OrderLineId, other2.\u0024VB\u0024Local_ldOrderLine.OrderLineId, true, (MethodInfo) null), new ParameterExpression[1]
                        {
                          parameterExpression2
                        })), (Expression<Func<M0, M1>>) (fq => fq.FASCmplQty));
                        if (source3 != null && source3.Count<int?>() > 0)
                        {
                          // ISSUE: reference to a compiler-generated field
                          int? orderLineQty = other2.\u0024VB\u0024Local_ldOrderLine.OrderLineQty;
                          int num2 = orderLineQty.HasValue ? 1 : 0;
                          int? nullable4 = source3.First<int?>();
                          int num3 = nullable4.HasValue ? 1 : 0;
                          bool? nullable5;
                          if ((num2 & num3) == 0)
                          {
                            nullable5 = new bool?();
                          }
                          else
                          {
                            nullable1 = new bool?(orderLineQty.GetValueOrDefault() == nullable4.GetValueOrDefault());
                            nullable5 = nullable1;
                          }
                          nullable2 = nullable5;
                          bool? nullable6;
                          if (!nullable2.HasValue)
                          {
                            nullable6 = new bool?();
                          }
                          else
                          {
                            nullable3 = new bool?(!nullable2.GetValueOrDefault());
                            nullable6 = nullable3;
                          }
                          if (nullable6.GetValueOrDefault())
                            flag2 = false;
                        }
                      }
                      if (flag2)
                      {
                        DateTime shpdDt = current.shpd_dt;
                        // ISSUE: reference to a compiler-generated field
                        DateTime? orderLineShippedDt = other2.\u0024VB\u0024Local_ldOrderLine.OrderLineShippedDt;
                        bool? nullable4 = orderLineShippedDt.HasValue ? new bool?(DateTime.Compare(orderLineShippedDt.GetValueOrDefault(), shpdDt) == 0) : new bool?();
                        bool flag3 = true;
                        // ISSUE: reference to a compiler-generated field
                        bool? orderLineShipped = other2.\u0024VB\u0024Local_ldOrderLine.OrderLineShipped;
                        bool? nullable5;
                        bool? nullable6;
                        if (!orderLineShipped.HasValue)
                        {
                          nullable6 = new bool?();
                        }
                        else
                        {
                          nullable5 = new bool?(orderLineShipped.GetValueOrDefault() == flag3);
                          nullable6 = nullable5;
                        }
                        bool? nullable7 = nullable6;
                        nullable3 = !nullable4.HasValue || nullable4.GetValueOrDefault() ? (nullable7.HasValue ? (nullable7.GetValueOrDefault() ? nullable4 : new bool?(false)) : new bool?()) : new bool?(false);
                        bool? nullable8;
                        if (!nullable3.HasValue)
                        {
                          nullable8 = new bool?();
                        }
                        else
                        {
                          nullable2 = new bool?(!nullable3.GetValueOrDefault());
                          nullable8 = nullable2;
                        }
                        nullable1 = nullable8;
                        if (nullable1.GetValueOrDefault())
                        {
                          // ISSUE: reference to a compiler-generated field
                          other2.\u0024VB\u0024Local_ldOrderLine.OrderLineShippedDt = (DateTime?) current.shpd_dt;
                          // ISSUE: reference to a compiler-generated field
                          other2.\u0024VB\u0024Local_ldOrderLine.OrderLineShipped = (bool?) true;
                          flag1 = true;
                        }
                        else
                        {
                          clsShipments.ueUpdateProgressEventHandler updateProgressEvent = this.ueUpdateProgressEvent;
                          if (updateProgressEvent != null)
                            updateProgressEvent((object) this, new ProgressChangedEventArgs(checked ((int) Math.Round(unchecked ((double) num1 / (double) byShipDtmdsbodq2c.Count))), (object) ("Shipped Date Valid for " + current.q2c_nbr + "-" + current.ln_itm + "-" + current.sub_ln_itm_id + "-" + current.shp_sched_id)));
                        }
                        // ISSUE: reference to a compiler-generated field
                        orderLineShippedDt = other2.\u0024VB\u0024Local_ldOrderLine.OrderLineShippedDt;
                        int num2 = !orderLineShippedDt.HasValue ? 1 : 0;
                        // ISSUE: reference to a compiler-generated field
                        nullable5 = other2.\u0024VB\u0024Local_ldOrderLine.OrderLineShipped;
                        int num3 = !nullable5.HasValue ? 1 : 0;
                        if ((num2 | num3) != 0)
                        {
                          // ISSUE: reference to a compiler-generated field
                          other2.\u0024VB\u0024Local_ldOrderLine.OrderLineShippedDt = (DateTime?) current.shpd_dt;
                          // ISSUE: reference to a compiler-generated field
                          other2.\u0024VB\u0024Local_ldOrderLine.OrderLineShipped = (bool?) true;
                          flag1 = true;
                        }
                      }
                      else
                      {
                        clsShipments.ueUpdateProgressEventHandler updateProgressEvent = this.ueUpdateProgressEvent;
                        if (updateProgressEvent != null)
                          updateProgressEvent((object) this, new ProgressChangedEventArgs(checked ((int) Math.Round(unchecked ((double) num1 / (double) byShipDtmdsbodq2c.Count))), (object) ("Update ABORTED for " + current.q2c_nbr + "-" + current.ln_itm + "-" + current.sub_ln_itm_id + "-" + current.shp_sched_id)));
                      }
                    }
                    catch (Exception ex)
                    {
                      ProjectData.SetProjectError(ex);
                      // ISSUE: reference to a compiler-generated field
                      int num2 = (int) Interaction.MsgBox((object) ("Error importing data, aborting MES import for Order; " + other1.\u0024VB\u0024Local_ldq2c_nbr), MsgBoxStyle.Information, (object) "ONE QMS MES Import Error - E0001");
                      ProjectData.ClearProjectError();
                      goto label_46;
                    }
                    if (flag1)
                    {
                      if (se0085CtEntities1.SaveChanges() > 0)
                      {
                        clsShipments.ueUpdateProgressEventHandler updateProgressEvent = this.ueUpdateProgressEvent;
                        if (updateProgressEvent != null)
                          updateProgressEvent((object) this, new ProgressChangedEventArgs(checked ((int) Math.Round(unchecked ((double) num1 / (double) byShipDtmdsbodq2c.Count))), (object) ("Shipped Date Updated for " + current.q2c_nbr + "-" + current.ln_itm + "-" + current.sub_ln_itm_id + "-" + current.shp_sched_id)));
                      }
                      else
                      {
                        clsShipments.ueUpdateProgressEventHandler updateProgressEvent = this.ueUpdateProgressEvent;
                        if (updateProgressEvent != null)
                          updateProgressEvent((object) this, new ProgressChangedEventArgs(checked ((int) Math.Round(unchecked ((double) num1 / (double) byShipDtmdsbodq2c.Count))), (object) ("Updated Failed for " + current.q2c_nbr + "-" + current.ln_itm + "-" + current.sub_ln_itm_id + "-" + current.shp_sched_id)));
                      }
                    }
                  }
                  else
                  {
                    // ISSUE: reference to a compiler-generated field
                    int num4 = (int) Interaction.MsgBox((object) ("Multiple Order numbers found, aborting MES import for Order; " + other1.\u0024VB\u0024Local_ldq2c_nbr), MsgBoxStyle.Information, (object) "ONE QMS MES Import Error - E0001");
                  }
                }
              }
              else
              {
                // ISSUE: reference to a compiler-generated field
                int num5 = (int) Interaction.MsgBox((object) ("Multiple Order numbers found, aborting MES import for Order; " + other1.\u0024VB\u0024Local_ldq2c_nbr), MsgBoxStyle.Information, (object) "ONE QMS MES Import Error - E0001");
              }
            }
label_46:;
          }
        }
        finally
        {
          enumerator.Dispose();
        }
        se0085CtEntities1.Database.Connection.Close();
      }
    }

    public delegate void ueUpdateProgressEventHandler(object sender, ProgressChangedEventArgs e);
  }
}
