Пример #1
0
    private void saveGeofence(double _lat, double _lng, decimal _radius)
    {
        try
        {

            string _comID = Session["trkCompany"].ToString();
            string _listValue = _hListValue.Value;
            string[] _listItem = _listValue.Split(';');
            bool isActive = _rdoON.Checked;
            if (_rdUnits.Checked)
            {

                for (int i = 0; i < _listItem.Length - 1; i++)
                {
                    ProcessSafetyZone _unitInsert = new ProcessSafetyZone();
                    Geofence _geoObj = new Geofence();

                    _geoObj.ComID = int.Parse(_comID);
                    _geoObj.UnitID = int.Parse(_listItem[i].ToString());
                    _geoObj.Name = _txtZoneName.Text.ToString();
                    _geoObj.Email =_txtEmail.Text.ToString() ;
                    _geoObj.CenterLat = decimal.Parse(_lat.ToString()) ;
                    _geoObj.CenterLong =decimal.Parse(_lng.ToString() );
                    _geoObj.Radius = _radius ;
                    _geoObj.IsActive = isActive;

                    _unitInsert.GeoInfo = _geoObj;
                    _unitInsert.GeofenceUnitInsert();

                    //_lblMessage.Text = "Sucessfull";

                }

            }

            else if (_rdUnitGroup.Checked)
            {
                for (int i = 0; i < _listItem.Length - 1; i++)
                {
                    ProcessSafetyZone _unitInsert = new ProcessSafetyZone();
                    Geofence _geoObj = new Geofence();

                    _geoObj.ComID = int.Parse(_comID);
                    _geoObj.UnitGroupID = int.Parse(_listItem[i].ToString());
                    _geoObj.Name = _txtZoneName.Text.ToString();
                    _geoObj.Email = _txtEmail.Text.ToString();
                    _geoObj.CenterLat = decimal.Parse(_lat.ToString());
                    _geoObj.CenterLong = decimal.Parse(_lng.ToString());
                    _geoObj.Radius = _radius;
                    _geoObj.IsActive = isActive;

                    _unitInsert.GeoInfo = _geoObj;
                    _unitInsert.GeofenceUnitGroupInsert();
                }
            }
        }

        catch (Exception ex)
        {
            throw new Exception (" XtremeK::Map::Geofence " + ex.Message);
        }
    }