Example #1
0
 public void InsertDataset(List<DataPoint> dataPoints, TargetMaterial impactMaterial,
     Projectile projectile, Dataformat orginalDataformat, Dataformat converteDataformat, Revision rev, User user, Revision prevRevision = null,
     ArticleReferences AR = null, Method method = null,
     StateOfAggregation stateOfAggregation = null)
 {
     if (impactMaterial.Id == 0)
         throw new DALInfoNotSpecifiedException("impactmaterial id was not specified");
     if (projectile.Id == 0)
         throw new DALInfoNotSpecifiedException("Projectile id was not specified");
     if (AR != null)
     {
         if (AR.Id == 0)
             throw new DALInfoNotSpecifiedException("ArtivleReference id was not specified");
     }
     if (method != null)
     {
         if (method.Id == 0)
             throw new DALInfoNotSpecifiedException("Method id was not specified");
     }
     if (stateOfAggregation != null)
     {
         if (stateOfAggregation.Id == 0)
         {
             throw new DALInfoNotSpecifiedException("State Of Aggregation Id was not specified");
         }
     }
     foreach (var item in dataPoints)
     {
         if (item.ConvertetData == null)
         {
             throw new DALInfoNotSpecifiedException(
                 "One or more DataPoints had unspecificed converted data");
         }
         if (item.EqEnergy == null)
         {
             throw new DALInfoNotSpecifiedException("One or more DataPoints had unspecificed eqEnergy");
         }
         if (item.StoppingPower == null)
         {
             throw new DALInfoNotSpecifiedException("One or more DataPoints had unspecificed StoppingPower");
         }
     }
     var tempCollection = new List<ArticleReferences>();
     tempCollection.Add(AR);
     var dataset = new Dataset()
     {
         Projectile_Id = projectile.Id,
         TargetMaterial_Id = impactMaterial.Id,
         ArticleReferences = AR,
         Projectile = projectile,
         Method = method,
         StateOfAggregation = stateOfAggregation,
         TargetMaterial = impactMaterial,
     };
     if (AR != null) dataset.ArticleReferences_Id = AR.Id;
     if (method != null) dataset.Method_Id = method.Id;
     if (stateOfAggregation != null) dataset.StateOfAggregation_Id = stateOfAggregation.Id;
     using (var db = new TSPDSContext())
     {
         db.Entry(dataset).State = EntityState.Modified;
         db.Dataset.Add(dataset);
         db.SaveChanges();
     }
     InsertDataPoint(dataPoints, dataset, orginalDataformat, converteDataformat);
     InsertRevision(dataset, rev, user, prevRevision);
 }
Example #2
0
        private void InsertDataPoint(List<DataPoint> dataPoints, Dataset dataset, Dataformat originalFormat,
            Dataformat convertedFormat)
        {
            using (var db = new TSPDSContext())
            {
                var query = from b in db.Dataformat
                    where b.Id == originalFormat.Id
                    where b.Id == convertedFormat.Id
                    select b;

                if (query.Any())
                {
                    foreach (var dataPoint in dataPoints)
                    {
                        dataPoint.DataformatForConverted_Id = convertedFormat.Id;
                        dataPoint.DataformatForOriginal_Id = originalFormat.Id;
                        dataPoint.ConvertedDataformat = convertedFormat;
                        dataPoint.OriginalDataformat = originalFormat;
                        dataPoint.Dataset = dataset;
                        dataPoint.DatasetDatasetId = dataset.Id;
                        db.Entry(dataPoint).State = EntityState.Modified;
                        db.DataPoint.Add(dataPoint);
                    }
                    db.SaveChanges();
                }
            }
        }
Example #3
0
 public void InsertDataFormat(Dataformat dataformat)
 {
     if (dataformat.DataNotiation == null)
         throw new DALInfoNotSpecifiedException("DataFormat notation was not specified");
     using (var db = new TSPDSContext())
     {
         var query = from m in db.Dataformat
             where m.DataNotiation.ToLower() == dataformat.DataNotiation.ToLower()
             select m;
         if (query.Any())
         {
             throw new DALAlreadyExistsException("Dataformat already excist");
         }
         db.Dataformat.Add(dataformat);
         db.SaveChanges();
     }
 }