/// <summary>
        /// load dropdownlist 
        /// </summary>
        /// <param name="ddl">System.Web.UI.WebControls.DropDownList ddl</param>
        public static void fillDropDownItems(System.Web.UI.WebControls.DropDownList ddl, string comID, string type)
        {
            try
            {

                RulesData _r = new RulesData();
                Geofence _g = new Geofence();
                Units _u = new Units();

                if (type == "rules")
                {
                    new RulesDataSelect().RulesDropDownList(_r._dropDownList, comID);

                    ddl.DataSource = _r._dropDownList;

                    ddl.DataTextField = "Name";
                    ddl.DataValueField = "Value";
                    ddl.DataBind();
                }
                else if ( type == "geo")
                {
                    new RulesDataSelect("geo").GeoDropDownList(_g._dropDownList, comID);
                    ddl.DataSource = _g._dropDownList;

                    ddl.DataTextField = "Name";
                    ddl.DataValueField = "Value";
                    ddl.DataBind();
                }

                else if (type == "units")
                {
                    new RulesDataSelect("units").UnitsDropDownList(_u._dropDownList, comID);
                    ddl.DataSource = _u._dropDownList;

                    ddl.DataTextField = "Name";
                    ddl.DataValueField = "Value";
                    ddl.DataBind();
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ddl = null;
            }
        }
    protected void _grdZones_ItemCommand(object source, DataGridCommandEventArgs e)
    {
        string _unitID = Request.QueryString["unitID"].ToString();
        if (e.CommandName == "Edit")
        {

            Label geofenceID = (Label)e.Item.FindControl("_lblGeofenceID");
            Session["geofenceID"] = geofenceID.Text;
            Response.Redirect("~/Map/SafetyZoneSetup.aspx?unitID=" + _unitID + "");
        }
        else if (e.CommandName == "Delete")
        {

            Geofence _gf = new Geofence();
            ProcessSafetyZone _zone = new ProcessSafetyZone(AlarmasABC.BLL.InvokeOperations.operations.DELETE);

            Label geofenceID = (Label)e.Item.FindControl("_lblGeofenceID");
            string _comID = Session["trkCompany"].ToString();

            try
            {
                _gf.UnitID = int.Parse(_unitID);
                _gf.Id = int.Parse(geofenceID.Text);
                _gf.ComID = int.Parse(_comID);

                _zone.GeoInfo = _gf;
                _zone.invoke();
                LoadZoneList(_unitID);

                _lblMessage.Text = "Safety Zone Deleted Successfully.";

                if (_grdZones.Items.Count < 1)
                {
                    _lblMessage.Text = "No Safety Zone for this Unit";
                    _grdZones.Visible = false;
                }
            }
            catch(Exception ex)
            {

            }

        }
    }
Beispiel #3
0
 public TreeColor4(Geofence _geofence)
 {
     this.Geofence = _geofence;
     Command = @"SELECT centerLat,centerLng,radius FROM tblGeofence" +
               @" WHERE comID = :comID and id = :id;";
 }
    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);
        }
    }
    private void updateGeofence()
    {
        try
        {
            GoogleLocation _location = GoogleLocation.Parse(_centerPoint.Value);
            Geofence _geoObj = new Geofence();

            ProcessSafetyZone _safetyZoneUpdate = new ProcessSafetyZone(AlarmasABC.BLL.InvokeOperations.operations.UPDATE);
            _geoObj.Id = int.Parse(geofenceID);
            _geoObj.ComID = int.Parse(Session["trkCompany"].ToString());
            _geoObj.Name = _txtZoneName.Text.ToString();
            _geoObj.Email = _txtEmail.Text.ToString();
            _geoObj.UnitID = int.Parse(Request.QueryString["unitID"].ToString());
            _geoObj.CenterLat = decimal.Parse(_location.Latitude.ToString());
            _geoObj.CenterLong = decimal.Parse(_location.Longitude.ToString());
            _geoObj.Radius = decimal.Parse(_Radius.Value);
            _geoObj.IsActive = _rdoON.Checked;
            _geoObj.SpeedingPhoneNum = _txtPhoneNumber.Text.Trim();
            _geoObj.IsSMS = _ckOnSMS.Checked;

            _safetyZoneUpdate.GeoInfo = _geoObj;
            _safetyZoneUpdate.invoke();

            _lblMessage.ForeColor = System.Drawing.Color.Green;
            _lblMessage.Text = "Geofence update successfully ";
            _Update.Value = "";

        }
        catch (Exception ex)
        {
            ex.Message.ToString();

            _lblMessage.ForeColor = System.Drawing.Color.Red;
            _lblMessage.Text = "Geofence update fail";

        }
    }
    private void loadGeofence(string ID)
    {
        double _lat, _lng;
        string deviceID = getDeviceID(Request.QueryString["unitID"].ToString());
        try
        {
            string _sql = "SELECT lat,long FROM tblGPRS WHERE deviceID = " + deviceID +
                          " AND recTime= (SELECT MAX(recTime) FROM tblGPRS WHERE deviceID = " + deviceID + " AND direction = 0);";

            ExecuteSQL exeSql = new ExecuteSQL();
            DataTable _dt = new DataTable();

            _dt = exeSql.ExecuteSQLQuery(_sql);

            _lng = double.Parse(_dt.Rows[0]["long"].ToString());
            _lat = double.Parse(_dt.Rows[0]["lat"].ToString());

            string _name = "";
            string _Rad = "";

            ProcessSafetyZone _pGeoData = new ProcessSafetyZone();
            Geofence _geoInput = new Geofence();

            _geoInput.ComID = int.Parse(Session["trkCompany"].ToString());
            if (ID != "")
                _geoInput.Id = int.Parse(ID);
            _geoInput.UnitID = int.Parse(Request.QueryString["unitID"].ToString());
            _pGeoData.GeoInfo = _geoInput;
            _pGeoData.LoadGeoData();

            DataSet _ds = new DataSet();
            _ds = _pGeoData.Ds;

            StringBuilder bfMarker = new StringBuilder();
            StringBuilder bfMarkerScript = new StringBuilder();

                if (_ds.Tables[0].Rows.Count > 0)
                {
                    _name = _ds.Tables[0].Rows[0]["name"].ToString();
                    _Rad = _ds.Tables[0].Rows[0]["radius"].ToString();
                    _txtEmail.Text = _ds.Tables[0].Rows[0]["email"].ToString();

                    try
                    {
                        _txtPhoneNumber.Text = _ds.Tables[0].Rows[0]["phoneNumber"].ToString();
                        bool isSMS = bool.Parse(_ds.Tables[0].Rows[0]["isSMS"].ToString());
                        if (isSMS)
                        {
                            _ckOnSMS.Checked = true;
                            _chkOffSMS.Checked = false;
                        }
                        else
                        {
                            _ckOnSMS.Checked = false;
                            _chkOffSMS.Checked = true;
                        }
                    }
                    catch (Exception ex)
                    {
                        if (!_ckOnSMS.Checked)
                            _chkOffSMS.Checked = true;
                    }

                    if (_ds.Tables[0].Rows.Count > 0)
                    {

                        if (_ds.Tables[0].Rows[0]["isActive"].ToString() == "True")
                            _rdoON.Checked = bool.Parse(_ds.Tables[0].Rows[0]["isActive"].ToString());
                        else
                            _rdoOFF.Checked = true;
                    }

                    _txtZoneName.Text = _name;
                    _lblRadius.Text = _Rad;

                     double _radius = ((double.Parse(_Rad) / 1.60934) * 5280) / 3.2808399;

                    _Radius.Value = _ds.Tables[0].Rows[0]["Radius"].ToString();
                    _Lat.Value = _ds.Tables[0].Rows[0]["centerLat"].ToString();
                    _Long.Value = _ds.Tables[0].Rows[0]["centerLng"].ToString();

                    string _imageName = getImageName();

                    bfMarker.Append("<script language=\"javascript\">");

                    bfMarker.Append("   myMap = new GMap2(document.getElementById('map')); ");
                    bfMarker.Append(" var rad = document.getElementById('_Radius');");
                    bfMarker.Append(" var gName = document.getElementById('_txtGeofenceName');");
                    bfMarker.Append(" var _Lat = document.getElementById('_Lat');");
                    bfMarker.Append(" var _Long = document.getElementById('_Long'); ");

                    bfMarker.Append(" myMap.addControl(new GSmallMapControl());");
                    bfMarker.Append(" myMap.addControl(new GMapTypeControl());");
                    bfMarker.Append(" myMap.enableScrollWheelZoom();");
                    bfMarker.Append(" myMap.setCenter(new GLatLng(_Lat.value,_Long.value),15,G_HYBRID_MAP);");
                    bfMarker.Append(" GEvent.addListener(myMap,'click',clickedMap);");

                    bfMarker.Append(" var _radius=((rad.value/1.60934)*5280)/3.2808399;  ");
                    bfMarker.Append(" createCircle(new GLatLng(_Lat.value,_Long.value),_radius);");
                    bfMarker.Append(" clear=true;");

                    bfMarkerScript.Append(" cPoint=new GLatLng(" + _lat + "," + _lng + ");");
                    bfMarkerScript.Append(" var icon0 = new GIcon();");
                    bfMarkerScript.Append(" icon0.image = \\'../Icon/" + _imageName + ".png\\';");
                    bfMarkerScript.Append(" icon0.iconSize = new GSize(" + iconHeight + "," + iconWidth + ");");
                    bfMarkerScript.Append(" icon0.iconAnchor = new GPoint(" + iconHeight / 2 + "," + iconWidth / 2 + ");");
                    bfMarkerScript.Append(" icon0.infoWindowAnchor = new GPoint(15, 15);");
                    bfMarkerScript.Append(" icon0.infoShadowAnchor = new GPoint(18, 25);");
                    bfMarkerScript.Append(" var marker=new GMarker(cPoint,icon0);");

                    bfMarkerScript.Append(" myMap.addOverlay(marker,icon0);");

                    bfMarker.Append(" setTimeout('evalMarker(\"" + bfMarkerScript.ToString() + "\")',1000); ");
                    bfMarker.Append("</script>");
                    Page.RegisterStartupScript("marker", bfMarker.ToString());

             }

            else
            {
                try
                {
                    string _iconName = getImageName();

                    bfMarker.Append("<script language=\"javascript\">");

                    bfMarker.Append("   myMap = new GMap2(document.getElementById('map')); ");
                    bfMarker.Append(" myMap.addControl(new GSmallMapControl()); ");
                    bfMarker.Append(" myMap.addControl(new GMapTypeControl()); ");
                    bfMarker.Append(" myMap.enableScrollWheelZoom();");
                    bfMarkerScript.Append(" myMap.setCenter(new GLatLng(" + _lat + "," + _lng + "),14,G_HYBRID_MAP);");
                    bfMarker.Append(" GEvent.addListener(myMap,'click',clickedMap);");

                    bfMarkerScript.Append(" cPoint=new GLatLng(" + _lat + "," + _lng + ");");
                    bfMarkerScript.Append(" var icon0 = new GIcon();");
                    bfMarkerScript.Append(" icon0.image = \\'../Icon/" + _iconName + ".png\\';");
                    bfMarkerScript.Append(" icon0.iconSize = new GSize(" + iconHeight + "," + iconWidth + ");");
                    bfMarkerScript.Append(" icon0.iconAnchor = new GPoint(" + iconHeight / 2 + "," + iconWidth / 2 + ");");
                    bfMarkerScript.Append(" icon0.infoWindowAnchor = new GPoint(15, 15);");
                    bfMarkerScript.Append(" icon0.infoShadowAnchor = new GPoint(18, 25);");
                    bfMarkerScript.Append(" var marker=new GMarker(cPoint,icon0);");

                    bfMarkerScript.Append(" myMap.addOverlay(marker);");

                    bfMarker.Append(" setTimeout('evalMarker(\"" + bfMarkerScript.ToString() + "\")',100); ");
                    bfMarker.Append("</script>");
                    Page.RegisterStartupScript("marker", bfMarker.ToString());

                }

                catch (Exception ex)
                {
                    throw new Exception(ex.Message.ToString());
                }

            }
        }
        catch (Exception ex)
        {
            throw new Exception("loadGeofence(): " + ex.Message.ToString());

        }
    }
 public UnitInsertParams(Geofence _geoInfos)
 {
     this._geoInfo = _geoInfos;
     buildUnit();
 }
 public UnitInsertParams(Geofence _geoInfos, string _group)
 {
     this._geoInfo = _geoInfos;
     buildUnitGroup();
 }
 public GeofenceUpdateParams(Geofence _geoinfo)
 {
     this._geoData = _geoinfo;
     build();
 }
 public SafetyInsertParams(Geofence _geoInfos)
 {
     this._geoInfo = _geoInfos;
     build();
 }
 public makeGeoParam(Geofence _geoinfo)
 {
     this._geoData = _geoinfo;
         build();
 }