Ejemplo n.º 1
0
        public static void CopyWOKittableToDB(List <WOKittingGroupedExport> dataSet, long UID, DateTime DateRun)
        {
            ConnectProdDbEntities connect = null;

            try
            {
                connect = new ConnectProdDbEntities();
                connect.Configuration.AutoDetectChangesEnabled = false;

                int count = 0;
                foreach (var line in dataSet)
                {
                    ++count;
                    var record = new WOKittableResultSet();
                    record.WONumber           = line.WONumber;
                    record.DateRun            = DateRun.Date;
                    record.BatchNotes         = line.BatchNotes;
                    record.CommercialNotes    = line.CommercialNotes;
                    record.OverKitted         = line.OverKitted;
                    record.PartsNotFound      = line.PartsNotFound;
                    record.ResponsibilityCode = line.ResponsibilityCode;
                    record.TotalActualKitNeed = line.totalActualKitNeed;
                    record.TotalActualQty     = line.TotalActualQty;
                    record.TotalKittable      = line.TotalKittable;
                    record.TotalPlannedQty    = line.TotalPlannedQty;
                    record.WOTotalPlannedQty  = line.WOTotalPlannedQty;
                    record.UID = UID;

                    connect = AddToContextWOKittable(connect, record, count, 500, true);
                }
                connect.SaveChanges();
            }
            finally
            {
                if (connect != null)
                {
                    connect.Dispose();
                }
            }
        }
Ejemplo n.º 2
0
        private static ConnectProdDbEntities AddToContextWOKittable(ConnectProdDbEntities context, WOKittableResultSet entity, int count, int commitCount, bool recreateContext)
        {
            context.Set <WOKittableResultSet>().Add(entity);

            if (count % commitCount == 0)
            {
                context.SaveChanges();
                if (recreateContext)
                {
                    context.Dispose();
                    context = new ConnectProdDbEntities();
                    context.Configuration.AutoDetectChangesEnabled = false;
                }
            }
            return(context);
        }