private void attach_Parameters(Parameter entity) { this.SendPropertyChanging(); entity.Sample = this; }
private void detach_Parameters(Parameter entity) { this.SendPropertyChanging(); entity.Sample = null; }
partial void DeleteParameter(Parameter instance);
partial void UpdateParameter(Parameter instance);
partial void InsertParameter(Parameter instance);
/// <summary> /// Creates web service data object from database obejct. /// </summary> /// <param name="parameter">A WebMech.Web.Parameter that specifies /// row of Parameter table.</param> /// <returns>A WebMech.Web.ParamterData that specifies /// data object of parameter.</returns> private ParameterData ParameterToData(Parameter parameter) { return new ParameterData { Name = parameter.name, Value = parameter.value }; }
/// <summary> /// Uploads sample into database. /// </summary> /// <param name="surfaceData">A WebMech.Web.SurfaceData that specifies /// data object of surface.</param> /// <param name="imageName">A System.String that specifies /// the file name of sample image.</param> /// <param name="imageArray">A System.Byte[] that specifies /// byte array of image file</param> /// <param name="pointsName">A System.String that specifies /// the file name of text file with 3D points.</param> /// <param name="pointsArray">A System.String that specifies /// byte array of text file with 3D points.</param> /// <returns>A WebMech.Web.SampleData that specifies /// data object of sample.</returns> public SampleData UploadSample(SurfaceData surfaceData, string imageName, byte[] imageArray, string pointsName, byte[] pointsArray) { LogIt.Info("UploadSample(Id = " + surfaceData.Id.ToString() + ", Name = " + surfaceData.Name + ", ImageName = " + imageName + ", PointsName = " + pointsName + ")"); WebMechDataContext db = new WebMechDataContext(); StatisticSurface process = new StatisticSurface(surfaceData.Name, imageName, imageArray, pointsName, pointsArray); process.Process(); DateTime date = DateTime.Now; Sample sample = new Sample(); sample.surface_id = surfaceData.Id; sample.sample_date = sample.upload_date = sample.modification_date = date; sample.filename = process.ImageName; db.Samples.InsertOnSubmit(sample); db.SubmitChanges(); sample = db.Samples.Single(s => s.surface_id == surfaceData.Id && s.upload_date == date); Statistic statistic = new Statistic(); statistic.sample_id = sample.sample_id; statistic.x_min = process.XMin; statistic.x_max = process.XMax; statistic.y_min = process.YMin; statistic.y_max = process.YMax; statistic.z_min = process.ZMin; statistic.z_max = process.ZMax; statistic.z_mean = process.ZMean; db.Statistics.InsertOnSubmit(statistic); db.SubmitChanges(); for (int idx = 0; idx < process.VisualizePointList.Count; idx++) { Point point = process.VisualizePointList[idx]; point.sample_id = sample.sample_id; point.order = idx; db.Points.InsertOnSubmit(point); if ((idx % 100) == 0) db.SubmitChanges(); } db.SubmitChanges(); for (int idx = 0; idx < process.ParameterList.Count; idx++) { Parameter parameter = new Parameter { sample_id = sample.sample_id, order = idx, name = process.ParameterList[idx].Name, value = process.ParameterList[idx].Value }; db.Parameters.InsertOnSubmit(parameter); } db.SubmitChanges(); return SampleToData(sample); }