Exemple #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);
 }
Exemple #2
0
 public void InsertArticleReference(ArticleReferences articleReference)
 {
     using (var db = new TSPDSContext())
     {
         var query = from b in db.ArticleReferences where b.DOINumber == articleReference.DOINumber select b;
         if (query.Any())
         {
             throw new DALAlreadyExistsException("The DOI number already exists");
         }
         db.ArticleReferences.Add(articleReference);
         db.SaveChanges();
     }
 }