예제 #1
0
    protected void GetAlerts(string date)
    {
        try
        {
            string unitID = Request.QueryString["unitID"].ToString();
            string _strSQL = "SELECT alertType,alertMessage,alertTime FROM tblAlert WHERE comID = " +
                             Session["trkCompany"].ToString() + " AND unitID = " + unitID +
                             " and alertTime::date = '" + date + "' ORDER BY alertTime DESC;";

            ExecuteSQL _executeSQL = new ExecuteSQL();
            DataSet _ds = _executeSQL.getDataSet(_strSQL);
            Session["_ds"] = _ds;
            _grdAlert.DataSource = _ds;
            _grdAlert.DataBind();

            if (_grdAlert.Rows.Count < 1)
            {
                DateTime dateTime = new DateTime();
                dateTime = DateTime.Parse(date);
                _lblMessage.Text = "No alerts occured for this unit on " +
                                   dateTime.ToString(dateFormat) + ".";
                _grdAlert.Visible = false;
            }
            else
            {
                _lblMessage.Text = "";
                _grdAlert.Visible = true;
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message.ToString());
        }
    }
    public void btnStatus_Click(object sender, EventArgs e)
    {
        status_div.Visible = true;
        Timer.Enabled = false;

        try
        {
            AlertData alert = getLastAlert();

            string deviceID = Session["deviceID"].ToString();
            string strSQL = "SELECT lat,long,recTimeRevised AS recDateTime,velocity,deviceID,unitName FROM unitRecords WHERE recTimeRevised = '" +
                            alert.AlertTime + "' AND deviceID = " + deviceID;
            ExecuteSQL exec = new ExecuteSQL();
            DataSet ds = new DataSet();
            ds = exec.getDataSet(strSQL);

            unitInfo.Text =  "Type: " + alert.AlertType + "<br/>";
            unitInfo.Text += "Message: " + alert.AlertMessage + "<br/><br/>";

            unitInfo.Text += MapDataCommon.GetCoreDataSetMarkerText(ds, 0);
        }
        catch (Exception ex)
        {
            Console.WriteLine("btnStatus_Click(): " + ex.Message);
        }
    }
예제 #3
0
    public void SaveUpdateInfo(bool saveInfo)
    {
        try
        {
            int comID, unitID;
            bool isActive, isSMS;
            string strSQL;
            ExecuteSQL exec = new ExecuteSQL();

            isActive = _chkOn.Checked ? true : false;
            isSMS = _ckOnSMS.Checked ? true : false;

            comID = int.Parse(Session["trkCompany"].ToString());
            unitID = int.Parse(Request.QueryString["unitID"].ToString());
            if (saveInfo)
            {
                strSQL = "insert into tblAlertRules(unitID, comID, email, phoneNumber, isSMS, isActive)" +
                     	" VALUES (" + unitID + "," + comID + ",'" + _txtNotificationEmails.Text.ToString() + "','" +
                     	_txtPhoneNumber.Text.Trim() + "','" + isSMS + "','" + isActive + "');";
            }
            else
            {
                strSQL = "update tblAlertRules set email = '" + _txtNotificationEmails.Text.ToString() +
                      	"', phoneNumber = '" + _txtPhoneNumber.Text.Trim() + "', isSMS = '" + isSMS + "', isActive = '" +
                      	isActive + "' where unitID = " + unitID + " and comID = " + comID + ";";
            }

           	exec.ExecuteNonQuery(strSQL);

            _lblMessage.ForeColor = System.Drawing.Color.Green;
            if (saveInfo)
            {
               _lblMessage.Text = "Saved info successfully.";
            }
            else
            {
                _lblMessage.Text = "Updated info successfully.";
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine("SaveUpdateInfo(): " + ex.Message.ToString());
           _lblMessage.ForeColor = System.Drawing.Color.Red;
           _lblMessage.Text = "Could not save info.";
        }
    }
예제 #4
0
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     string _sql = "SELECT * FROM tblUnitType WHERE comID = " + Session["trkCompany"].ToString() +
                   " AND typeName = '"+_txtTypeName.Text.ToString()+"';";
     ExecuteSQL haveData = new ExecuteSQL();
     if (!haveData.IsExistData(_sql))
     {
         if (_txtTypeName.Text.Length > 0)
         {
             SaveUnitType();
         }
     }
     else
     {
         _lblMessage.ForeColor = System.Drawing.Color.Red;
         _lblMessage.Text = "Unit type " + _txtTypeName.Text.ToString() + " already exist for this company ";
     }
 }
예제 #5
0
        public static bool isExist(string _SQL)
        {
            bool rc = false;

            ExecuteSQL _execSQL = new ExecuteSQL();
            try
            {
                rc = _execSQL.IsExistData(_SQL);
            }
            catch (Exception ex)
            {
                throw new Exception("Utilities::Utility::"+ex.Message);
            }
            finally
            {
                _execSQL = null;
            }

            return rc;
        }
    private bool isCorrect(string answer)
    {
        try
        {
            DataSet _ds = new DataSet();
            ExecuteSQL exec = new ExecuteSQL();
            _ds = exec.getDataSet("SELECT securityAnswer FROM tblUser WHERE" +
                                  " uID = " + Session["userID"].ToString());
            if (_ds.Tables[0].Rows.Count > 0)
            {
                if (answer == _ds.Tables[0].Rows[0]["securityAnswer"].ToString())
                {
                    return true;
                }
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine("PasswordRetrive::isCorrect(): " + ex.Message.ToString());
        }

        return false;
    }
    private void sendMessage()
    {
        DataSet _ds = new DataSet();

        try
        {
            ExecuteSQL exec = new ExecuteSQL();
            _ds = exec.getDataSet("SELECT password FROM tblUser WHERE uID = " + Session["userID"].ToString());
            if (_ds.Tables[0].Rows.Count > 0)
            {
                string password = EncDec.GetDecryptedText(_ds.Tables[0].Rows[0]["password"].ToString());

               	string subject = "Password Recovery";
                string body = "This message was sent to you because you";
                body += " reqested to recover a lost password. \r\n\r\n";
                body += "Login Name: " + Session["userName"].ToString() + " \r\n";
                body += "Password: "******"\r\n\r\n";

                SendEmail(Session["email"].ToString(), subject, body);

                lblMessage.Text = "Your password has been sent to your email address.";
                lblMessage.ForeColor = System.Drawing.Color.Green;
                txtAnswer.Text = "";

                Session["userID"] = null;
                Session["userName"] = null;
                Session["securityQID"] = null;
                Session["email"] = null;
            }
            else
            {
               lblMessage.Text = "There was an error trying to recover your password.";
                lblMessage.ForeColor = System.Drawing.Color.Red;
            }

        }
        catch (Exception ex)
        {
            Console.WriteLine("PasswordRetrive::sendMessage(): " + ex.Message.ToString());
        }
        finally
        {
            _ds = null;
        }
    }
예제 #8
0
    private bool UnitExist(string uID)
    {
        ExecuteSQL _execute = new ExecuteSQL();

        try
        {

            string _strSQL = "SELECT * FROM tblUnits JOIN tblUnitType" +
                             " ON (tblUnits.typeID = tblUnitType.typeID)" +
                             " WHERE tblUnits.typeID = " + uID +
                             " AND coalesce(tblUnits.isDelete,'0' ) != '1';";
            if (_execute.IsExistData(_strSQL))
                return true;
            else
                return false;

        }
        catch (Exception exp)
        {
            exp.Message.ToString();
            return true;
        }
        finally
        {
            _execute = null;
        }

        return true;
    }
예제 #9
0
    private bool UserExist(string gID)
    {
        ExecuteSQL _execute = new ExecuteSQL();

        try
        {

            string _strSQL = "SELECT * FROM tblUser JOIN tblGroup ON" +
                             " (tblGroup.groupID = tblUser.groupID) WHERE tblGroup.groupID=" + gID +
                             " AND coalesce(tblUser.isDelete,'0' ) != '1';";
            if (_execute.IsExistData(_strSQL))
                return true;
            else
                return false;

        }
        catch (Exception exp)
        {
            exp.Message.ToString();
            return true;
        }
        finally
        {
            _execute = null;
        }

        return true;
    }
예제 #10
0
    private bool isValidData()
    {
        ExecuteSQL _execute=new ExecuteSQL();
        try
        {
            string _comID = Session["trkCompany"].ToString();
            string _strSQL = "SELECT * FROM tblGroup WHERE groupName='" + _txtGroupName.Text +
                             "' AND comID=" + _comID + "";

            if (_txtGroupName.Text == "")
            {
                _lblMessage.Text = "Please Enter Group Name";
                _lblMessage.ForeColor = System.Drawing.Color.Red;
                return false;
            }
            else if (_execute.IsExistData(_strSQL))
            {
                _lblMessage.Text = "Group Name Already Exists.";
                _lblMessage.ForeColor = System.Drawing.Color.Red;
                return false;
            }
        }
        catch (Exception ex)
        {
            ex.Message.ToString();
        }

        finally
        {
            _execute = null;
        }

        return true;
    }
    private void loadSecurityScheme()
    {
        try
        {
            DataSet _ds = new DataSet();

            int _comID = int.Parse(Session["trkCompany"].ToString());
            ProcessScheme.fillDropDownItems(_ddlSecurityScheme,_comID);

            string _strSQL = "SELECT id FROM tblSecurityScheme WHERE comID = "
                              + _comID + " AND defaultScheme = '1';";

            ExecuteSQL _sql = new ExecuteSQL();

            _ds = _sql.getDataSet(_strSQL);
            if (_ds.Tables[0].Rows.Count > 0)
                _ddlSecurityScheme.SelectedValue = _ds.Tables[0].Rows[0]["ID"].ToString();

        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message.ToString());
        }
    }
    private bool checkPassword()
    {
        string strSQL = "SELECT password FROM tblUser WHERE uID = " + Session["uID"].ToString();
        ExecuteSQL exec = new ExecuteSQL();
        DataSet ds = new DataSet();

        ds = exec.getDataSet(strSQL);

        if (ds.Tables[0].Rows.Count > 0)
        {
            if (ds.Tables[0].Rows[0]["password"].ToString() == EncDec.GetEncryptedText(txtPassword.Text))
            {
                return true;
            }
        }

        return false;
    }
    private string GetMarkerText()
    {
        string _iconName = "";
        double _lat, _lng;
        StringBuilder _bfMarkerScript = new StringBuilder();
        string _deviceID = getDeviceID(Request.QueryString["unitID"].ToString());

        try
        {
            string _sql = "SELECT lat,long FROM tblGPRS WHERE deviceID =" + _deviceID + "";
            _sql += "AND recTime= (SELECT MAX(recTime) FROM tblGPRS WHERE deviceID = " + _deviceID + ");";

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

            _dt = _exeSql.ExecuteSQLQuery(_sql);

            if (_dt.Rows.Count > 0)
            {
                _lng = double.Parse(_dt.Rows[0]["long"].ToString());
                _lat = double.Parse(_dt.Rows[0]["lat"].ToString());
                _iconName = getImageName();

                _bfMarkerScript.Append(" myMap.clearOverlays(); ");
                _bfMarkerScript.Append(" cPoint=new GPoint(" + _lng + "," + _lat + ");");
                _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,icon0);");

                return _bfMarkerScript.ToString();
            }

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

        return " myMap.clearOverlays(); ";
    }
    public string getMarker()
    {
        StringBuilder bfMarker = new StringBuilder();
        StringBuilder bfMarkerScript = new StringBuilder();
        //bfMarker.AppendFormat("{0}.clearOverlays();", );

        try
        {
            string unitID = Session["unitID"].ToString();
            string deviceID = getDeviceID(unitID);
            string _comID = Session["trkCompany"].ToString();
            GoogleMarker _currentMarker = new GoogleMarker();

            double _lat = 0, _lng = 0;

            DataTable _dt = new DataTable();

            string _strSQL = "SELECT unitName,lat,long,deviceID,city,state,country,CAST(velocity*0.621 AS INT) AS velocity," +
                             "recTimeRevised,recTime,iconName FROM vwUnitRecords WHERE recTime IN " +
                             "(SELECT MAX(recTime) FROM vwUnitRecords WHERE deviceID IN (SELECT deviceID FROM " +
                             "vwUserWiseUnits WHERE uID = " + Session["trkUID"].ToString() + " AND deviceID = " + deviceID +
                             ") GROUP BY deviceID) AND comID = " + _comID + " AND deviceID = " + deviceID + ";";

            ExecuteSQL _exeSQL = new ExecuteSQL();
            _dt = _exeSQL.ExecuteSQLQuery(_strSQL);

            if (_dt.Rows.Count > 0)
            {
                _lat = double.Parse(_dt.Rows[0]["lat"].ToString());
                _lng = double.Parse(_dt.Rows[0]["long"].ToString());
                bfMarker.Append("<script language=\"javascript\">");

                //}

                if (_dt.Rows[0]["iconName"].ToString() != "")
                {
                    bfMarkerScript.Append("cPoint=new GPoint(" + JsUtil.Encode(_lng) + "," + JsUtil.Encode(_lat) + ");");
                    bfMarkerScript.Append(" var icon0 = new GIcon();");
                    bfMarker.Append("icon0.image = '../Icon/" + _dt.Rows[0]["iconName"].ToString() + ".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=new GMap2(document.getElementById(\\'map\\'));");
                bfMarkerScript.Append("myMap.setCenter(new GLatLng(" + _lat + "," + _lng + "),5,G_HYBRID_MAP);");

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

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

            }

        }
        catch (Exception ex)
        {

        }
        return bfMarker.ToString();
    }
예제 #15
0
    private bool UserExist(string sID)
    {
        ExecuteSQL _execute = new ExecuteSQL();

        try
        {

            string _strSQL = "SELECT * from tblUserWiseScheme WHERE schemeID = " + sID + ";";
            if (_execute.IsExistData(_strSQL))
                return true;
            else
                return false;

        }
        catch (Exception ex)
        {
            ex.Message.ToString();
            return true;
        }
        finally
        {
            _execute = null;
        }

        return true;
    }
예제 #16
0
    private void LoadSchemes()
    {
        try
        {
            string _comID = Session["trkCompany"].ToString();

            string _strSQL = "SELECT * FROM tblSecurityScheme WHERE comID = " + _comID + "; ";
            _strSQL += " SELECT * FROM tblSecurityScheme WHERE comID = " + _comID + " AND defaultScheme = 1 ;";
            _strSQL += " SELECT s.ID,f.formName,s.schemeName,p.fullaccess,p.delete,p.view,p.insert,p.edit";
            _strSQL += " FROM tblSchemePermission p INNER JOIN tblSecurityScheme s ON p.schemeID = s.ID";
            _strSQL += " INNER JOIN tblForms f ON f.ID = p.formID ORDER BY s.ID;";

            ExecuteSQL _ex = new ExecuteSQL();
            DataSet _ds = new DataSet();

            _ds = _ex.getDataSet(_strSQL);

            _grdScheme.DataSource = _ds;
            _grdScheme.DataBind();

        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
    }
 private void loadSecurityQuestion()
 {
     try
     {
         DataSet _ds = new DataSet();
         ExecuteSQL exec = new ExecuteSQL();
         _ds = exec.getDataSet("SELECT question FROM tblSecurityQuestion WHERE" +
                               " id = " + Session["securityQID"].ToString());
         if (_ds.Tables[0].Rows.Count > 0)
         {
             lblQuestion.Text = _ds.Tables[0].Rows[0]["question"].ToString();
         }
     }
     catch (Exception ex)
     {
        Console.WriteLine("PasswordRetrive::loadSecurityQuestion(): " + ex.Message.ToString());
     }
 }
    private void loadUnit()
    {
        if (Request.QueryString["unitID"] != null)
        {
            try
            {
                string strSQL = "SELECT unitName,deviceID FROM tblUnits WHERE unitID = '" + Request.QueryString["unitID"] + "' AND comID = " + Session["trkCompany"].ToString() + ";";
                ExecuteSQL exec = new ExecuteSQL();
                DataSet ds = new DataSet();

                ds = exec.getDataSet(strSQL);

                if (ds.Tables[0].Rows.Count > 0)
                {
                    Session["deviceID"] = ds.Tables[0].Rows[0]["deviceID"].ToString();
                    unitName.Text = "Selected Unit: " + ds.Tables[0].Rows[0]["unitName"].ToString();
                }
            }
            catch (Exception ex)
            {
                throw new Exception("loadUnit(): " + ex.Message.ToString());
                Console.WriteLine("loadUnit(): " + ex.Message.ToString());
            }
        }
    }
    private string getUnitName()
    {
        try
        {
            string strSQL = "SELECT unitName FROM tblUnits WHERE deviceID = " + Session["deviceID"] + " AND comID = " + Session["trkCompany"].ToString() + ";";
            ExecuteSQL exec = new ExecuteSQL();
            DataSet ds = new DataSet();

            ds = exec.getDataSet(strSQL);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return ds.Tables[0].Rows[0]["unitName"].ToString();
            }
        }
        catch (Exception ex)
        {
            throw new Exception("getUnitName(): " + ex.Message.ToString());
            Console.WriteLine("getUnitName(): " + ex.Message.ToString());
        }

        return "";
    }
    private string getDeviceID(string unitID)
    {
        try
        {
            string _strSQL = "SELECT deviceID FROM tblUnits WHERE unitID = " + unitID + ";";
            DataTable _dt = new DataTable();
            //Database _db = new Database();

            ExecuteSQL _exSQl = new ExecuteSQL();
            _dt=  _exSQl.ExecuteSQLQuery(_strSQL);

            if (_dt.Rows.Count > 0)
            {
                return _dt.Rows[0]["deviceID"].ToString();
            }
            else
                return "";
        }
        catch (Exception ex)
        {
            return "";
        }
    }
    private string getImageName()
    {
        string deviceID = getDeviceID(Request.QueryString["unitID"].ToString());
        string _imageName ="";
        string _comID = "";
        try
        {
            _comID = Session["trkCompany"].ToString();

        string _strSQL = "SELECT * FROM unitRecords WHERE deviceID=" + deviceID +
                         " AND recTime = (SELECT MAX(recTime) FROM unitRecords" +
                         " WHERE deviceID = " + deviceID + ") AND comID =" + _comID + ";";

        DataTable table = new DataTable();
        ExecuteSQL exSQl = new ExecuteSQL();

        table = exSQl.ExecuteSQLQuery(_strSQL);
            if(table.Rows.Count>0)
            {
             _imageName = table.Rows[0]["iconName"].ToString();
            }
        }
        catch (Exception ex)
        {
            return _imageName;
        }

        return _imageName;
    }
예제 #22
0
    private bool isDemoUser()
    {
        string _userID = Session["uID"].ToString();
        string _comID = Session["trkCompany"].ToString();
        string _strSQL = "SELECT login FROM tblUser WHERE uID = " + _userID + " AND comID = " + _comID;

        DataSet _ds = new DataSet();
        ExecuteSQL exec = new ExecuteSQL();
        _ds = exec.getDataSet(_strSQL);

        if (_ds.Tables[0].Rows.Count > 0)
        {
            Console.WriteLine(_ds.Tables[0].Rows[0]["login"]);
            if (_ds.Tables[0].Rows[0]["login"].ToString() == "demo")
            {
                return true;
            }
        }

        return false;
    }
    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 AlertData getLastAlert()
    {
        string strSQL = "SELECT * FROM tblAlert WHERE unitID = " +
                        "(SELECT DISTINCT unitID FROM tblUnits WHERE deviceID = " + Session["deviceID"].ToString() +
                        " AND comID = " + Session["trkCompany"].ToString() + ") ORDER BY id DESC LIMIT 1;";
        ExecuteSQL exec = new ExecuteSQL();
        DataSet ds = new DataSet();
        AlertData alert = new AlertData();

        try
        {
            ds = exec.getDataSet(strSQL);

            if (ds.Tables[0].Rows.Count > 0)
            {
                alert.AlertTime = ds.Tables[0].Rows[0]["alertTime"].ToString();
                alert.AlertMessage = ds.Tables[0].Rows[0]["alertMessage"].ToString();
                alert.AlertType = ds.Tables[0].Rows[0]["alertType"].ToString();

            }
        }
        catch (Exception ex)
        {
            throw new Exception ("getLastAlert(): " + ex.Message + "\n" + strSQL);
        }

        return alert;
    }
예제 #25
0
    private void LoadAlerts(string unitID)
    {
        try
        {
            string _strSQL = "SELECT alertType,alertMessage,alertTime FROM tblAlert WHERE comID=" +
                             Session["trkCompany"].ToString() + " AND unitID = " + unitID +
                             " ORDER BY alertTime DESC;";

            ExecuteSQL _executeSQL = new ExecuteSQL();
            DataSet _ds = _executeSQL.getDataSet(_strSQL);

            Session["_ds"] = _ds;
            _grdAlert.DataSource = _ds;
            _grdAlert.DataBind();
        }
        catch (Exception ex)
        {

        }
    }
    private void LoadUnits(string _comID)
    {
        string _strSQL = "SELECT unitID AS id,unitName,t.typeName," +
                         " CAST((CASE u.isActive WHEN '1' THEN '1' WHEN '0' THEN '0' ELSE '0' END) AS BOOLEAN) AS status" +
                         " FROM tblUnits u INNER JOIN tblUnitType t ON t.typeID = u.typeID" +
                         " WHERE coalesce(u.isDelete,'0') != '1' AND u.comID = " + _comID + ";";

        ExecuteSQL _exc = new ExecuteSQL();

        _grdUnit.DataSource = _exc.getDataSet(_strSQL);
        //_grdUnit.DataBind();
    }
예제 #27
0
    private string getTreeColor(int unitID)
    {
        int comID = int.Parse(Session["trkCompany"].ToString());
        string strSQL;
        DataSet ds = new DataSet();
        ExecuteSQL exec = new ExecuteSQL();

        strSQL = "select * from tblAlert where unitID = " + unitID.ToString() + " and comID = "
                 + comID.ToString() + " and alertTime > 'now'::timestamp" +
                 " - interval '5 minutes' order by alertTime limit 1";

        try
        {
            ds = exec.getDataSet(strSQL);
        }
        catch (Exception ex)
        {
            Console.WriteLine("getTreeColor(): " + ex.Message.ToString());
        }

        if (ds.Tables[0].Rows.Count < 1)
        {
            strSQL = "select deviceID from tblUnits where unitID = " + unitID.ToString() +
                     " and comID = " + comID.ToString();
            ds = exec.getDataSet(strSQL);
            int deviceID ;

            if (ds.Tables[0].Rows.Count > 0) {
                deviceID = int.Parse(ds.Tables[0].Rows[0]["deviceID"].ToString());
            } else {
                return "Green";
            }

            DataSet ds2 = new DataSet();
            strSQL = "select * from tblGPRS where deviceID = " + deviceID +
                     " and recTimeRevised > 'now'::timestamp - interval '12 hours' limit 1";
            ds2 = exec.getDataSet(strSQL);

            if(ds2.Tables[0].Rows.Count < 1) {
                strSQL = "select * from tblGPRS where deviceID = " + deviceID + " limit 5";
                ds2 = exec.getDataSet(strSQL);

                if (ds2.Tables[0].Rows.Count < 1) {
                    return "Black";
                } else {
                    return "Gray";
                }
            }
            return "Green";
        }
        else
        {
            string alertType = ds.Tables[0].Rows[0]["alertType"].ToString();
            if (alertType == "Event")
            {
                return "Yellow";
            }
            else
            {
                return "Red";
            }
        }
    }
    private void LoadUser(string _comID)
    {
        string _strSQL = "SELECT uID AS id,login,userName,groupName,email," +
                         " CAST((CASE u.isActive WHEN '1' THEN '1' WHEN '0' THEN '0' ELSE '0' END) AS BOOLEAN) AS status" +
                         " FROM tblUser u INNER JOIN tblGroup gr ON u.groupID=gr.groupID" +
                         " WHERE coalesce(u.isDelete,'0') != '1' AND u.comID = " + _comID + ";";

        ExecuteSQL _exc = new ExecuteSQL();

        _grdUser.DataSource = _exc.getDataSet(_strSQL);

        //_grdUser.DataBind();
    }
예제 #29
0
    private void setUserRights()
    {
        string _userID = Session["uID"].ToString();
        string _comID = Session["trkCompany"].ToString();
        bool _hasPermission = false;
        Telerik.Web.UI.RadMenuItem _menu = new RadMenuItem();

        if (isDemoUser())
        {
            // Remote all from admin
            foreach (RadMenuItem item in menuAdministration.Items)
            {
                item.Visible = false;
            }

            // Remove all from fleet
            foreach (RadMenuItem item in menuFleet.Items)
            {
                item.Visible = false;
            }
        }
        else
        {
            string _strSQL = "SELECT id,moduleName FROM tblModule";

            DataSet _ds = new DataSet();
            ExecuteSQL exec = new ExecuteSQL();
            _ds = exec.getDataSet(_strSQL);

            for (int i = 0; i < _ds.Tables[0].Rows.Count; i++)
            {
                _strSQL = "SELECT * FROM tblForms WHERE id IN";
                _strSQL += " (SELECT formID FROM tblSchemePermission WHERE schemeID = ";
                _strSQL += " (SELECT MAX(schemeID) FROM tblUserWiseScheme WHERE userID = ";
                _strSQL += _userID + " AND comID = " + _comID + ") AND view = '1') AND moduleID = ";
                _strSQL += _ds.Tables[0].Rows[i]["id"].ToString() + ";";

                DataSet _dsForms = exec.getDataSet(_strSQL);

                if (_dsForms.Tables[0].Rows.Count > 0)
                {
                    if (_ds.Tables[0].Rows[i]["moduleName"].ToString() == "Administration")
                    {
                        _menu = menuAdministration;
                    }
                    else if (_ds.Tables[0].Rows[i]["moduleName"].ToString() == "Fleet Management")
                    {
                        _menu = menuFleet;
                    }
                    else
                    {
                        continue;
                    }

                    foreach (RadMenuItem item in _menu.Items)
                    {
                        _hasPermission = false;

                        for (int j = 0; j < _dsForms.Tables[0].Rows.Count; j++)
                        {
                            string _formName = _dsForms.Tables[0].Rows[j]["formName"].ToString();
                            if (_formName == item.Text)
                            {
                                _hasPermission = true;
                                break;
                            }
                        }

                        if (!_hasPermission && item.Value == "Admin") {
                            item.Visible = false;
                        }
                    }
                }
                else
                {
                    if (_ds.Tables[0].Rows[i]["moduleName"].ToString() == "Administration")
                    {
                        menuAdministration.Visible = false;
                    }
                    else if (_ds.Tables[0].Rows[i]["moduleName"].ToString() == "Fleet Management")
                    {
                        menuFleet.Items.Clear();
                    }
                }
            }
        }
    }
예제 #30
0
        private bool SpeedRule()
        {
            try
            {
                DataSet _ds = new DataSet();
                string _strSQL = "select RulesValue from tblrules r inner join tblunitwiserules ur on r.RulesID=ur.RulesID where UnitID=" + this.UnitID.ToString() + " and comid=" + this.ComID.ToString() + "; ";
                _strSQL += "select top 1 velocity from tblGprs where deviceID=(select deviceID from tblunits where unitid=" + this.UnitID.ToString() + " and comid=" + this.ComID.ToString() + ") order by rectime desc ";

                ExecuteSQL _execute = new ExecuteSQL();
                _ds = _execute.getDataSet(_strSQL);

                if (_ds != null)
                {
                    if (_ds.Tables[0].Rows.Count > 0)
                    {
                        if (int.Parse(_ds.Tables[0].Rows[0]["RulesValue"].ToString()) < int.Parse(_ds.Tables[1].Rows[0]["velocity"].ToString()))
                        {
                            return true;
                        }
                    }
                }

            }
            catch (Exception ex)
            {
                throw new Exception("GetColor::SpeedRule::" + ex.Message);
            }

            return false;
        }