Esempio n. 1
0
        public void InsertOrThrow(MineralScanResult result)
        {
            var id = Db.Query().CommandText(@"insert into mineralscan (ownerid,creation,zoneid,materialtype,x1,y1,x2,y2,scanAccuracy) 
                                                        values (@ownerid,@creation,@zoneid,@materialtype,@x1,@y1,@x2,@y2,@scanAccuracy);select cast(scope_identity() as int)")
                     .SetParameter("@ownerId", _owner.Id)
                     .SetParameter("@creation", DateTime.Now)
                     .SetParameter("@zoneid", result.ZoneId)
                     .SetParameter("@materialType", (byte)result.MaterialType)
                     .SetParameter("@x1", result.Area.X1)
                     .SetParameter("@y1", result.Area.Y1)
                     .SetParameter("@x2", result.Area.X2)
                     .SetParameter("@y2", result.Area.Y2)
                     .SetParameter("@scanAccuracy", result.ScanAccuracy)
                     .SetParameter("@quality", result.Quality)
                     .ExecuteScalar <int>().ThrowIfEqual(0, ErrorCodes.SQLInsertError);

            result.Id = id;
        }
Esempio n. 2
0
        public MineralScanResult ToScanResult()
        {
            var dictionary = _info.Value;

            if (dictionary.IsNullOrEmpty())
            {
                return(null);
            }

            var result = new MineralScanResult();

            result.ScanAccuracy = dictionary.GetValue <double>(k.scanAccuracy);
            result.FoundAny     = true;
            result.Area         = dictionary.GetValue <Area>(k.area);
            result.MaterialType = dictionary.GetValue <string>(k.mineral).ToMaterialType();
            result.ZoneId       = dictionary.GetValue <int>(k.zone);
            result.Creation     = dictionary.GetValue <DateTime>(k.date);

            return(result);
        }
Esempio n. 3
0
        private static MineralScanResult CreateFromRecord(IDataRecord record)
        {
            var result = new MineralScanResult();

            result.Id           = record.GetValue <int>("id");
            result.Folder       = record.GetValue <string>("folder");
            result.FoundAny     = true;
            result.MaterialType = (MaterialType)Convert.ToInt32(record.GetValue("materialType"));
            result.ZoneId       = record.GetValue <int>("zoneId");
            result.Creation     = record.GetValue <DateTime>("creation");
            result.Quality      = record.GetValue <long>("quality");

            var x1 = record.GetValue <int>("x1");
            var y1 = record.GetValue <int>("y1");
            var x2 = record.GetValue <int>("x2");
            var y2 = record.GetValue <int>("y2");

            result.Area         = new Area(x1, y1, x2, y2);
            result.ScanAccuracy = record.GetValue <double>("scanaccuracy");

            return(result);
        }