partial void DeleteStatistic(Statistic instance);
partial void UpdateStatistic(Statistic instance);
/// <summary> /// Creates web service data object from database obejct. /// </summary> /// <param name="statistic">A WebMech.Web.Parameter that specifies /// row of Statistic table.</param> /// <returns>A WebMech.Web.Model3DData that specifies /// data object of 3D model with basic statistic data and list of 3D points.</returns> private Model3DData StatisticToData(Statistic statistic) { return new Model3DData { Xmin = statistic.x_min, Xmax = statistic.x_max, Ymin = statistic.y_min, Ymax = statistic.y_max, Zmin = statistic.z_min, Zmax = statistic.z_max, Zmean = statistic.z_mean, PointList = new List<PointData>() }; }
partial void InsertStatistic(Statistic instance);
/// <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); }