Exemplo n.º 1
0
        /// <summary>
        /// Delete sample from database.
        /// </summary>
        /// <param name="sampleData">A WebMech.Web.SampleData that specifies
        /// data object of sample.</param>
        public void DeleteSample(SampleData sampleData)
        {
            LogIt.Info("DeleteSample(Id = " + sampleData.Id.ToString() + ")");
            WebMechDataContext db = new WebMechDataContext();

            var points = (from p in db.Points
                          where p.sample_id == sampleData.Id
                          select p);
            db.Points.DeleteAllOnSubmit(points);
            db.SubmitChanges();

            var parameters = (from p in db.Parameters
                              where p.sample_id == sampleData.Id
                              select p);
            db.Parameters.DeleteAllOnSubmit(parameters);
            db.SubmitChanges();

            var statistics = (from s in db.Statistics
                              where s.sample_id == sampleData.Id
                              select s);
            db.Statistics.DeleteAllOnSubmit(statistics);
            db.SubmitChanges();

            Sample sample = db.Samples.Single(s => s.sample_id == sampleData.Id);
            db.Samples.DeleteOnSubmit(sample);
            db.SubmitChanges();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Add new surface into database.
        /// </summary>
        /// <param name="name">A System.String that specifies
        /// name of surface.</param>
        /// <returns>A WebMech.Web.SurfaceData that specifies
        /// data object of surface.</returns>
        public SurfaceData AddSurface(string name)
        {
            LogIt.Info("AddSurface(Name = " + name + ")");
            WebMechDataContext db = new WebMechDataContext();

            Surface surface = new Surface();
            surface.name = name;
            surface.creation_date =
            surface.modification_date = DateTime.Now;

            db.Surfaces.InsertOnSubmit(surface);
            db.SubmitChanges();

            return SurfaceToData(surface);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Deletes surface from database.
        /// </summary>
        /// <param name="surfaceData">A WebMech.Web.SurfaceData that specifies
        /// data object of surface.</param>
        public void DeleteSurface(SurfaceData surfaceData)
        {
            LogIt.Info("DeleteSurface(Id = " + surfaceData.Id.ToString() + ", Name = " + surfaceData.Name + ")");
            if (surfaceData != null)
            {
                WebMechDataContext db = new WebMechDataContext();

                Surface surface = db.Surfaces.Single(s => s.surface_id == surfaceData.Id);
                db.Surfaces.DeleteOnSubmit(surface);
                db.SubmitChanges();
            }
        }
Exemplo n.º 4
0
        /// <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);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Modifies surface name.
        /// </summary>
        /// <param name="surfaceData">A WebMech.Web.SurfaceData that specifies
        /// data object of surface.</param>
        public void ModifySurface(SurfaceData surfaceData)
        {
            LogIt.Info("ModifySurface(Id = " + surfaceData.Id.ToString() + ", Name = " + surfaceData.Name + ")");
            if (surfaceData != null)
            {
                WebMechDataContext db = new WebMechDataContext();

                Surface surface = db.Surfaces.Single(s => s.surface_id == surfaceData.Id);
                surface.name = surfaceData.Name;
                surface.modification_date = DateTime.Now;

                db.SubmitChanges();
            }
        }