public void Run()
        {
            try
            {
                using (ConnectionMilkoscanBottling bottlingdb = new ConnectionMilkoscanBottling())
                {
                    using (ConnectionMilkoscan serverbd = new ConnectionMilkoscan())
                    {
                        Log.WriteLine("textcomponents start of the survey");
                        int SampleIndexMSSQL = bottlingdb.
                                               TextComponents.
                                               OrderByDescending(d => d.SampleIndex).
                                               ToList()[0].
                                               SampleIndex;
                        int sampleIndexMySQL;
                        if (TestCheck.checkingPresenceColumn <TextComponentsC>(new ConnectionMilkoscan()))
                        {
                            sampleIndexMySQL = serverbd.
                                               textcomponent.
                                               OrderByDescending(d => d.SampleIndex).
                                               ToList()[0].
                                               SampleIndex;
                        }
                        else
                        {
                            sampleIndexMySQL = 0;
                        }

                        if (sampleIndexMySQL != SampleIndexMSSQL)
                        {
                            //serverbd.Database.ExecuteSqlInterpolated($"DELETE FROM textcomponent WHERE SampleIndex >= {sampleIndexMySQL}");

                            serverbd.result.AddRange(
                                bottlingdb.
                                Results.
                                Where(d => d.SampleIndex > sampleIndexMySQL).
                                ToList());

                            serverbd.textcomponent.AddRange(
                                bottlingdb.
                                TextComponents.
                                Include(p => p.Results).
                                Where(d => d.SampleIndex > sampleIndexMySQL).
                                ToList());

                            serverbd.doublecomponent.AddRange(
                                bottlingdb.
                                DoubleComponents.
                                Include(p => p.Results).
                                Where(d => d.SampleIndex > sampleIndexMySQL).
                                ToList());

                            serverbd.SaveChanges();
                            Log.WriteLine("Entry intakedb textcomponents");
                        }
                        else
                        {
                            Log.WriteLine("No entry intakedb textcomponents");
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Log.WriteLine(e.Message);
                new CreaterTables().create();
            }
        }
Example #2
0
 public void Run()
 {
     try
     {
         using (ConnectionFoodscanCurd foodscandb = new ConnectionFoodscanCurd())
         {
             using (ConnectionMilkoscan ServerPCdbPredicted = new ConnectionMilkoscan())
             {
                 Log.WriteLine("fsprediction start of the survey");
                 long PredirectedIDMSSQL = foodscandb.
                                           tblMfCdPredictedValue.
                                           OrderByDescending(s => s.PredictedValueID).
                                           Take(1).
                                           ToList()[0].
                                           PredictedValueID;
                 long predirectedIDMySQL;
                 if (TestCheck.checkingPresenceColumn <tblMfCdPredictedValueC>(new ConnectionMilkoscan()))
                 {
                     predirectedIDMySQL = ServerPCdbPredicted.
                                          fsprediction.
                                          OrderByDescending(s => s.PredictedValueID).
                                          Take(1).ToList()[0].
                                          PredictedValueID;
                 }
                 else
                 {
                     predirectedIDMySQL = 0;
                 }
                 if (PredirectedIDMSSQL != predirectedIDMySQL)
                 {
                     ServerPCdbPredicted.fsprediction.AddRange(
                         foodscandb.
                         tblMfCdPredictedValue.
                         Where(p => p.PredictedValueID > predirectedIDMySQL).ToList());
                     ServerPCdbPredicted.SaveChanges();
                     Log.WriteLine("Entry intakedb fsprediction");
                 }
                 else
                 {
                     Log.WriteLine("No entry intakedb fsprediction");
                 }
             }
             using (ConnectionMilkoscan ServerPCdbProduct = new ConnectionMilkoscan())
             {
                 Log.WriteLine("fsproduct start of the survey");
                 long ProductIDMSSQL = foodscandb.
                                       tblMfCdProduct.
                                       OrderByDescending(p => p.ProductID).
                                       Take(1).ToList()[0].
                                       ProductID;
                 long productIDMySQL;
                 if (TestCheck.checkingPresenceColumn <tblMfCdProductC>(new ConnectionMilkoscan()))
                 {
                     productIDMySQL = ServerPCdbProduct.
                                      fsproduct.
                                      OrderByDescending(p => p.ProductID).
                                      Take(1).
                                      ToList()[0].
                                      ProductID;
                 }
                 else
                 {
                     productIDMySQL = 0;
                 }
                 if (ProductIDMSSQL != productIDMySQL)
                 {
                     ServerPCdbProduct.fsproduct.AddRange(
                         foodscandb.
                         tblMfCdProduct.
                         Where(p => p.ProductID > productIDMySQL).ToList());
                     ServerPCdbProduct.SaveChanges();
                     Log.WriteLine("Entry intakedb fsproduct");
                 }
                 else
                 {
                     Log.WriteLine("No entry intakedb fsproduct");
                 }
             }
             using (ConnectionMilkoscan ServerPCdbSample = new ConnectionMilkoscan())
             {
                 Log.WriteLine("fssample start of the survey");
                 long SampleIDMSSQL = foodscandb.
                                      tblMfCdSample.
                                      OrderByDescending(s => s.SampleID).
                                      Take(1).
                                      ToList()[0].
                                      SampleID;
                 long sampleIDMySQL;
                 if (TestCheck.checkingPresenceColumn <tblMfCdSampleC>(new ConnectionMilkoscan()))
                 {
                     sampleIDMySQL = ServerPCdbSample.
                                     fssample.
                                     OrderByDescending(s => s.SampleID).
                                     Take(1).
                                     ToList()[0].
                                     SampleID;
                 }
                 else
                 {
                     sampleIDMySQL = 0;
                 }
                 if (sampleIDMySQL != SampleIDMSSQL)
                 {
                     ServerPCdbSample.fssample.AddRange(
                         foodscandb.
                         tblMfCdSample.
                         Where(s => s.SampleID > sampleIDMySQL).
                         ToList());
                     ServerPCdbSample.SaveChanges();
                     Log.WriteLine("Entry intakedb fssample");
                 }
                 else
                 {
                     Log.WriteLine("No entry intakedb fssample");
                 }
             }
             using (ConnectionMilkoscan ServerPCdbSubSample = new ConnectionMilkoscan())
             {
                 Log.WriteLine("fssubsample start of the survey");
                 long SubSampleIDMSSQL = foodscandb.
                                         tblMfCdSubSample.
                                         OrderByDescending(s => s.SubSampleID).
                                         Take(1).
                                         ToList()[0].
                                         SubSampleID;
                 long subSampleIDMySQL;
                 if (TestCheck.checkingPresenceColumn <tblMfCdSubSampleC>(new ConnectionMilkoscan()))
                 {
                     subSampleIDMySQL = ServerPCdbSubSample.
                                        fssubsample.
                                        OrderByDescending(s => s.SubSampleID).
                                        Take(1).
                                        ToList()[0].
                                        SubSampleID;
                 }
                 else
                 {
                     subSampleIDMySQL = 0;
                 }
                 if (subSampleIDMySQL != SubSampleIDMSSQL)
                 {
                     ServerPCdbSubSample.fssubsample.AddRange(
                         foodscandb.
                         tblMfCdSubSample.
                         Where(s => s.SubSampleID > subSampleIDMySQL).
                         ToList());
                     ServerPCdbSubSample.SaveChanges();
                     Log.WriteLine("Entry intakedb fsSubSample");
                 }
                 else
                 {
                     Log.WriteLine("No entry intakedb fsSubSample");
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.WriteLine(e.Message);
         new CreaterTables().create();
     }
 }
Example #3
0
 public void Run()
 {
     try
     {
         using (ConnectMilkoscanIntake Intakedb = new ConnectMilkoscanIntake())
         {
             using (ConnectionMilkoscan ServerPCdbSample = new ConnectionMilkoscan())
             {
                 Log.WriteLine("sample start of the survey");
                 int sampleIDMySQL;
                 int SampleIDMSSQL = Intakedb.Sample.OrderByDescending(s => s.SampNo).Take(1).ToList()[0].SampNo;
                 if (TestCheck.checkingPresenceColumn <SampleC>(new ConnectionMilkoscan()))
                 {
                     sampleIDMySQL =
                         ServerPCdbSample.
                         sample.
                         OrderByDescending(s => s.SampNo).
                         Take(1).
                         ToList()[0].
                         SampNo;
                 }
                 else
                 {
                     sampleIDMySQL = 0;
                 }
                 if (sampleIDMySQL != SampleIDMSSQL)
                 {
                     Log.WriteLine("Entry intakedb sample");
                     ServerPCdbSample.sample.AddRange(Intakedb.Sample.Where(s => s.SampNo > sampleIDMySQL).ToList());
                     ServerPCdbSample.SaveChanges();
                 }
                 else
                 {
                     Log.WriteLine("No entry intakedb sample");
                 }
                 Log.WriteLine("Entry intakedb prediction");
                 ServerPCdbSample.Database.ExecuteSqlInterpolated($"DELETE FROM prediction WHERE SampRef >= {sampleIDMySQL}");
                 ServerPCdbSample.prediction.AddRange(Intakedb.Prediction.Where(p => p.SampRef >= sampleIDMySQL).ToList());
                 ServerPCdbSample.SaveChanges();
             }
             using (ConnectionMilkoscan ServerPCdbProduct = new ConnectionMilkoscan())
             {
                 Log.WriteLine("product start of the survey");
                 int prodNoMySQL;
                 int ProdNoMSSQL = Intakedb.Product.OrderByDescending(p => p.ProdNo).Take(1).ToList()[0].ProdNo;
                 if (TestCheck.checkingPresenceColumn <ProductC>(new ConnectionMilkoscan()))
                 {
                     prodNoMySQL =
                         ServerPCdbProduct.
                         product.
                         OrderByDescending(p => p.ProdNo).
                         Take(1).
                         ToList()[0].
                         ProdNo;
                 }
                 else
                 {
                     prodNoMySQL = 0;
                 }
                 if (prodNoMySQL != ProdNoMSSQL)
                 {
                     ServerPCdbProduct.product.AddRange(Intakedb.Product.Where(p => p.ProdNo > prodNoMySQL).ToList());
                     ServerPCdbProduct.SaveChanges();
                     Log.WriteLine("Entry intakedb product");
                 }
                 else
                 {
                     Log.WriteLine("No entry intakedb product");
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.WriteLine(e.Message);
         new CreaterTables().create();
     }
 }