Example #1
0
 public int Add(LongLatData model)
 {
     string cmdText = @"
     DECLARE @NEWID INT
     INSERT INTO [LongLatData] (Deviceid,Longitude,Latitude,Datetime,AddDatetime)
     values (@Deviceid,@Longitude,@Latitude,@Datetime,GETDATE())
     SET @NEWID=@@IDENTITY
     SELECT @NEWID";
     SqlParameter[] parameters =
     {
         SqlParamHelper.MakeInParam("@Deviceid",SqlDbType.VarChar,50,model.Deviceid),
         SqlParamHelper.MakeInParam("@Longitude",SqlDbType.VarChar,50,model.Longitude),
         SqlParamHelper.MakeInParam("@Latitude",SqlDbType.VarChar,50,model.Latitude),
         SqlParamHelper.MakeInParam("@Datetime",SqlDbType.DateTime,20,model.Datetime),
         SqlParamHelper.MakeInParam("@AddDatetime",SqlDbType.DateTime,20,model.AddDatetime)
     };
     int id = 0;
     using (IDataReader dataReader = SqlHelper.ExecuteReader(WriteConnectionString,CommandType.Text,cmdText,parameters)){
         if(dataReader.Read()){
             object obj = dataReader[0];
             if(obj != null && obj != DBNull.Value){
                 id = Convert.ToInt32(obj);
             }
         }
     }
     return id;
 }
Example #2
0
 private void GetJWDData()
 {
     int recordCount = 0;
     string keyword = Server.UrlDecode(GetRequestString("deviceid"));
     LongLatData filter = new LongLatData();
     filter.Deviceid = keyword;
     List<LongLatData> list = _LongLatDataService.GetLongLatDataList(filter,PageSize,PageIndex,ref recordCount);
     if(list != null && list.Count > 0){
         Json(list);
     }
     else{
         Json(new {Result = "False"});
     }
 }
Example #3
0
 public List<LongLatData> GetLongLatDatas(LongLatData filter,int pageSize,int pageIndex,ref int recordCount)
 {
     SqlParameter[] parameters =
     {
         SqlParamHelper.MakeParam("@RecordNum",SqlDbType.Int,4,ParameterDirection.InputOutput,recordCount),
         SqlParamHelper.MakeInParam("@SelectList",SqlDbType.VarChar,2000,LongLatData_INFO_FIELDS),
         SqlParamHelper.MakeInParam("@TableSource",SqlDbType.VarChar,100,"[LongLatData]"),
         SqlParamHelper.MakeInParam("@SearchCondition",SqlDbType.VarChar,2000,GetSearchCondition(filter)),
         SqlParamHelper.MakeInParam("@OrderExpression",SqlDbType.VarChar,1000,"[Datetime]"),
         SqlParamHelper.MakeInParam("@PageSize",SqlDbType.Int,4,pageSize),
         SqlParamHelper.MakeInParam("@PageIndex",SqlDbType.Int,4,pageIndex)
     };
     List<LongLatData> list = new List<LongLatData>();
     using (IDataReader dr = SqlHelper.ExecuteReader(ReadConnectionString,CommandType.StoredProcedure,"PR_GetDataByPageIndex",parameters)){
         while(dr.Read()){
             list.Add(BindLongLatData(dr));
         }
     }
     recordCount = Convert.ToInt32(parameters[0].Value);
     return list;
 }
Example #4
0
 public bool UpdateLongLatData(LongLatData model)
 {
     return _LongLatDataRepository.Update(model) > 0;
 }
Example #5
0
 public List<LongLatData> GetLongLatDataList(LongLatData filter,int pageSize,int pageIndex,ref int recordCount)
 {
     return _LongLatDataRepository.GetLongLatDatas(filter,pageSize,pageIndex,ref recordCount);
 }
Example #6
0
 public int AddLongLatData(LongLatData model)
 {
     return _LongLatDataRepository.Add(model);
 }
Example #7
0
        private string GetSearchCondition(LongLatData filter)
        {
            StringBuilder condition = new StringBuilder("1=1");
            if(filter.Id != 0){
                condition.Append(string.Format(" and Id = {0}",filter.Id));
            }
            if(!string.IsNullOrEmpty(filter.Deviceid)){
                condition.Append(string.Format(" and Deviceid ='{0}'",filter.Deviceid));
            }

            return condition.ToString();
        }
Example #8
0
 public int Update(LongLatData model)
 {
     string cmdText = @"UPDATE [LongLatData]  SET Deviceid=@Deviceid,Longitude=@Longitude,Latitude=@Latitude,Datetime=@Datetime,AddDatetime=GETDATE() WHERE Id=@id";
     SqlParameter[] parameters =
     {
         SqlParamHelper.MakeInParam("@id",SqlDbType.Int,4,model.Id),
         SqlParamHelper.MakeInParam("@Deviceid",SqlDbType.VarChar,50,model.Deviceid),
         SqlParamHelper.MakeInParam("@Longitude",SqlDbType.VarChar,50,model.Longitude),
         SqlParamHelper.MakeInParam("@Latitude",SqlDbType.VarChar,50,model.Latitude),
         SqlParamHelper.MakeInParam("@Datetime",SqlDbType.DateTime,20,model.Datetime)
     };
     return SqlHelper.ExecuteNonQuery(WriteConnectionString,CommandType.Text,cmdText,parameters);
 }
Example #9
0
        private void UploadLatitudeAndLongitude()
        {
            string result = string.Empty;
            string errstr = "False";
            try{
                using (StreamReader readStream = new StreamReader(Request.InputStream,Encoding.UTF8)){
                    result = readStream.ReadToEnd();
                }
                if(string.IsNullOrEmpty(result)){
                    errstr = "接收数据为空或者NULL!";
                }
                else{
                    List<LatitudeAndLongitudeAPI> list = JsonConvert.DeserializeObject<List<LatitudeAndLongitudeAPI>>(result);
                    //LatitudeAndLongitudeAPI LatitudeAndLongitudeapi = JsonConvert.DeserializeObject<LatitudeAndLongitudeAPI>(result);
                    if(list == null || list.Count <= 0){
                        errstr = "数据格式不对!";
                    }
                    else{
                        foreach(LatitudeAndLongitudeAPI model in list){
                            string deviceId = model.Deviceid;
                            string longitude = model.Longitude;
                            string latitude = model.Latitude;
                            string sign = model.Sign;
                            string datetimestr = model.Datetime;

                            if(string.IsNullOrEmpty(deviceId) || string.IsNullOrEmpty(longitude) || string.IsNullOrEmpty(latitude) || string.IsNullOrEmpty(sign) || string.IsNullOrEmpty(datetimestr)){
                                errstr = "存在不完整的数据!";
                                break;
                            }
                            if(sign != "hcsmdbapi" + deviceId && sign != CryptoHelper.MD5_Encrypt("hcsmdbapi" + deviceId)) //单兵发送内容  由于MD5无法对应上 先不用MD5加密
                            {
                                errstr = "非法入侵!";
                            }
                            else{
                                //把经纬度数据存储到数据库中
                                LongLatData longlatmode = new LongLatData();
                                longlatmode.Deviceid = deviceId;
                                longlatmode.Longitude = longitude;
                                longlatmode.Latitude = latitude;
                                longlatmode.Datetime = Convert.ToDateTime(datetimestr);
                                longlatmode.AddDatetime = DateTime.Now;
                                _LongLatDataService.AddLongLatData(longlatmode);
                                errstr = "True";
                            }
                        }
                    }
                }
                Json(new {Result = errstr});
            }
            catch(Exception ex){
                Json(new {Result = ex.Message});
            }
        }