/// <summary> /// /// </summary> /// <param name="d"></param> /// <returns></returns> public string[,] GetDataPointsByDataSet(Dataset d) { DataPoint[] data = _dalRetrieve.GetDataPointsByDataSet(d).ToArray(); string[,] convertedlist = new string[data.Length + 1, 5]; convertedlist[0, 0] = "ProjectileCharge"; convertedlist[0, 1] = "EqEnergy"; convertedlist[0, 2] = "StoppingPower"; convertedlist[0, 3] = "ConvertetData"; convertedlist[0, 4] = "Error"; for (int i = 1; i < data.Length; i++) { convertedlist[i, 0] = data[i].ProjectileCharge.ToString(); convertedlist[i, 1] = data[i].EqEnergy.ToString(); convertedlist[i, 2] = data[i].StoppingPower.ToString(); convertedlist[i, 3] = data[i].ConvertetData.ToString(); convertedlist[i, 4] = data[i].Error.ToString(); } return convertedlist; }
private void InsertRevision(Dataset dataset, Revision rev, User user, Revision prevRevision = null) { using (var db = new TSPDSContext()) { if (user.Id == 0) throw new DALInfoNotSpecifiedException("User id was not specified"); if (dataset.Id == 0) throw new DALInfoNotSpecifiedException("Dataset id was not specified"); if (rev.Id != 0) rev.Id = 0; ValidateUser(user); var query = from b in db.Revision where b.Dataset.Id == dataset.Id select b; if (query.Any()) throw new DALAlreadyExistsException("Dataset already exists"); rev.User = user; rev.Dataset = dataset; rev.UserUserId = user.Id; rev.Dataset_Id = dataset.Id; if (prevRevision != null) { if (prevRevision.Id == 0) throw new DALInfoNotSpecifiedException("Previous revision was not null, but the id was not specified"); prevRevision.HeadRevision = rev; prevRevision.HeadRevision_Id = rev.Id; rev.HeadRevision_Id = prevRevision.Id; db.Entry(prevRevision).State = EntityState.Modified; } db.Entry(dataset).State = EntityState.Modified; db.Entry(user).State = EntityState.Modified;; db.Revision.Add(rev); db.SaveChanges(); } }
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(); } } }
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); }
public Revision GetNewestRevisionByDataset(Dataset dataset) { using (var db = new TSPDSContext()) { var query = from b in db.Revision where b.Dataset_Id == dataset.Id select b; if (query.Any()) { query = query.Include(m => m.Dataset.Projectile); query = query.Include(m => m.Dataset.Method); query = query.Include(m => m.Dataset.TargetMaterial); query = query.Include(m => m.Dataset.StateOfAggregation); query = query.Include(m => m.Dataset.ArticleReferences); query = query.Include(m => m.Dataset.DataPoint); query = query.Include(m => m.Dataset.Revision); return query.ToList().Last(); } return new Revision(); } }
/// <summary> /// /// </summary> /// <param name="dataset"></param> /// <returns></returns> public List<DataPoint> GetDataPointsByDataSet(Dataset dataset) { var datapointsList = new List<DataPoint>(); using (var db = new TSPDSContext()) { var dataPoints = from b in db.Dataset where b.Id == dataset.Id select b.DataPoint; if (dataPoints.Any()) { return dataPoints.ToList()[0].ToList(); } return new List<DataPoint>(); } }
public string[,] Datapoints(Dataset d) { return _webmodel.GetDataPointsByDataSet(d); }