public async Task <IHttpActionResult> PutCarLocation(int id, CarLocation carLocation)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != carLocation.Id)
            {
                return(BadRequest());
            }

            db.Entry(carLocation).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CarLocationExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(CarLocation model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into CarLocation(");
            strSql.Append("LSH,CASEID,CCCC,CLID,SJ,JD,WD,SD,FX,ADDTIME)");
            strSql.Append(" values (");
            strSql.Append(":LSH,:CASEID,:CCCC,:CLID,:SJ,:JD,:WD,:SD,:FX,:ADDTIME)");
            OracleParameter[] parameters =
            {
                new OracleParameter(":LSH",     DBOpHelper.GetString(model.LSH)),
                new OracleParameter(":CASEID",  DBOpHelper.GetString(model.CASEID)),
                new OracleParameter(":CCCC",    DBOpHelper.GetNumber(model.CCCC)),
                new OracleParameter(":CLID",    DBOpHelper.GetString(model.CLID)),
                new OracleParameter(":SJ",      DBOpHelper.GetDateTime(model.SJ)),
                new OracleParameter(":JD",      DBOpHelper.GetString(model.JD)),
                new OracleParameter(":WD",      DBOpHelper.GetString(model.WD)),
                new OracleParameter(":SD",      DBOpHelper.GetNumber(model.SD)),
                new OracleParameter(":FX",      DBOpHelper.GetString(model.FX)),
                new OracleParameter(":ADDTIME", DBOpHelper.GetDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")))
            };

            int rows = DbHelperOra.ExecuteSql(SysParameters.DBConnectString, strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 3
0
        public void HandleCarLocation(CarLocation cl)
        {
            try
            {
                //Save Database
                // DBCarLocation db = new DBCarLocation();
                //20160802 修改人:朱星汉 修改内容:速度字符串过长
                cl.SD = Math.Round((Decimal)cl.SD, 2);
                IDBCarLocation db = DataAccess.DataAccess.GetDBCarLocation();
                db.Add(cl);

                CarLocationManagerDelegateClient client = new CarLocationManagerDelegateClient();
                client.addCarLocationCompleted += new EventHandler <addCarLocationCompletedEventArgs>(Service_Completed);
                CredentialSoapHeader header = new CredentialSoapHeader();
                header.Username = SysParameters.AppAPIUsername;
                header.Password = SysParameters.AppAPIPassword;
                string strJson = ConvertModelToJson(cl);

                WebserviceUserState UserState = new WebserviceUserState();
                UserState.TIMES   = 1;
                UserState.MESSAGE = strJson;

                client.addCarLocationAsync(header, strJson, UserState);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog("", ex);
            }
        }
Esempio n. 4
0
        private CarLocation getClFromVp(VehiclePointResponse vp)
        {
            CarLocation cl = new CarLocation();
            try
            {
                Decimal i;
                int j;
                DateTime dt;
                cl.CASEID = vp.caseid;
                if (int.TryParse(vp.cc, out j)) cl.CCCC = int.Parse(vp.cc);
                if (DateTime.TryParse(vp.sj, out dt)) cl.SJ = DateTime.Parse(vp.sj);
                cl.CLID = vp.id;
                cl.FX= vp.fx;
                cl.JD = vp.jd;
                cl.LSH = vp.lsh;
                if (Decimal.TryParse(vp.sd, out i)) cl.SD = Decimal.Parse(vp.sd);
                cl.WD = vp.wd;
                

            }
            catch (Exception ex)
            {
                LOG.LogHelper.WriteLog("", ex);
            }
            return cl;
        }
Esempio n. 5
0
 public Player(string name)
 {
     this.name = name;
     carLocation = CarLocation.NotInCar;
     worldLocation = 0;
     LocationsPictured = new List<int>();
 }
Esempio n. 6
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(CarLocation model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into carlocation(");
            strSql.Append("LSH,CASEID,CCCC,CLID,SJ,JD,WD,SD,FX,ADDTIME)");
            strSql.Append(" values (");
            strSql.Append("@LSH,@CASEID,@CCCC,@CLID,@SJ,@JD,@WD,@SD,@FX,@ADDTIME)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@LSH",     DBOpHelper.GetString(model.LSH)),
                new MySqlParameter("@CASEID",  DBOpHelper.GetString(model.CASEID)),
                new MySqlParameter("@CCCC",    DBOpHelper.GetNumber(model.CCCC)),
                new MySqlParameter("@CLID",    DBOpHelper.GetString(model.CLID)),
                new MySqlParameter("@SJ",      DBOpHelper.GetDateTime(model.SJ)),
                new MySqlParameter("@JD",      DBOpHelper.GetString(model.JD)),
                new MySqlParameter("@WD",      DBOpHelper.GetString(model.WD)),
                new MySqlParameter("@SD",      DBOpHelper.GetNumber(model.SD)),
                new MySqlParameter("@FX",      DBOpHelper.GetString(model.FX)),
                new MySqlParameter("@ADDTIME", DBOpHelper.GetDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")))
            };

            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 发送车辆轨迹信息给route server
        /// </summary>
        /// <param name="cl"></param>
        public void SendCarLocation(CarLocation cl)
        {
            Hashtable      ht      = GetCarLocationHashtableByModel(cl);
            ScsTextMessage message = new ScsTextMessage(JSON.Encode(ht));

            SendMessage(message);
        }
Esempio n. 8
0
            public async Task <Response> Handle(Request request, CancellationToken cancellationToken)
            {
                var locationService = new GoogleLocationService("AIzaSyCNSEn1UjPshpFTg55dn8IsJimWQbDbdao");

                List <CarLocation> carLocations = new List <CarLocation>();

                var cars = await _session.Query <Car>()
                           .ToListAsync();

                foreach (var car in cars)
                {
                    var address = car.LocationPickUp;
                    var point   = locationService.GetLatLongFromAddress(address);
                    if (point != null)
                    {
                        var lat = point.Latitude;
                        var lon = point.Longitude;

                        var coordinate = new Coordinate(lat, lon);
                        //coordinates.Add(coordinate);
                        var carLocation = new CarLocation(car.Id, coordinate);
                        carLocations.Add(carLocation);
                    }
                }

                //TODO
                // return the car with her coordinates

                return(new Response
                {
                    //Coordinates = coordinates
                    CarLocations = carLocations
                });
            }
Esempio n. 9
0
        public Hashtable GetCarLocationHashtableByModel(CarLocation cl)
        {
            /*
             * lsh;	String	流水号	Varchar2(19) not null	19	必填,主键,120生成
             *  caseId	String	CaseID	Varchar2(50)	50	必填,由APP提供
             *  cccc	Integer	出车车次	Number(2)	2	必填
             *  clid	String	车俩ID	Varchar2(10) not null	10	必填
             *  sj	Date    坐标数据时间	Date
             *  jd	String	经度	Varchar2(30)	30
             *  wd	String	纬度	Varchar2(30)	30
             *  sd	Double	速度	Number(8,3)	8	单位:KM/H
             *  fx	String	方向	Varchar2(20)	20
             */
            Hashtable ht = new Hashtable();

            ht.Add("messageName", "CarLocation");
            ht.Add("caseId", cl.CASEID);
            ht.Add("cccc", cl.CCCC);
            ht.Add("clid", cl.CLID);
            ht.Add("fx", cl.FX);
            ht.Add("jd", cl.JD);
            ht.Add("wd", cl.WD);
            ht.Add("lsh", cl.LSH);
            ht.Add("sj", string.Format("{0:yyyy-MM-dd HH:mm:ss}", cl.SJ));
            ht.Add("sd", cl.SD);
            return(ht);
        }
Esempio n. 10
0
        public async Task <IActionResult> CreateAsync(Car car)
        {
            var categories = await _categoriesRepository.GetCategoriesAsync();

            var bodyTypes = await _carTypesRepository.GetBodyTypesAsync();

            var locations = await _locationsRepository.GetLocationsAsync();

            List <string> categorieNames = new List <string>();
            List <string> typeNames      = new List <string>();

            /*get the existing categories name and body types name*/
            foreach (var item in categories)
            {
                categorieNames.Add(item.Category_Name);
            }
            foreach (var item in bodyTypes)
            {
                typeNames.Add(item.Name);
            }

            ViewBag.Category_Names = categorieNames;
            ViewBag.TypeNames      = typeNames;
            ViewBag.LocationNames  = locations;

            /*get selections from dropdown form*/
            string categSelection    = Request.Form["Category_Name"].ToString();
            string bodySelection     = Request.Form["TypeName"].ToString();
            var    selectedLocations = Request.Form["AreChecked"].ToList();

            var selectedCategory = await _categoriesRepository.GetCategoryByIDAsync(categSelection);

            var selectedBodyType = await _carTypesRepository.GetBodyTypeByNameAsync(bodySelection);

            car.Category = selectedCategory;
            /*Increment the number of cars in this category*/
            car.Category.NumberOfCars += 1;
            car.Type = selectedBodyType;

            foreach (var sel in selectedLocations)
            {
                CarLocation carLocation = new CarLocation();
                carLocation.Car = car;

                var location = await _locationsRepository.GetLocationByIDAsync(Int32.Parse(sel));

                carLocation.Location = location;

                car.CarLocations.Add(carLocation);
            }

            _carRepository.InsertCar(car);
            await _carRepository.SaveAsync();

            return(View(car));
        }
        public async Task <IHttpActionResult> GetCarLocation(int id)
        {
            CarLocation carLocation = await db.CarLocations.FindAsync(id);

            if (carLocation == null)
            {
                return(NotFound());
            }

            return(Ok(carLocation));
        }
        public async Task <IHttpActionResult> PostCarLocation(CarLocation carLocation)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.CarLocations.Add(carLocation);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = carLocation.Id }, carLocation));
        }
Esempio n. 13
0
        /// <summary>
        /// 获取穿梭车的位置
        /// </summary>
        /// <param name="car"></param>
        /// <returns></returns>
        public CarLocation getCarLocation(Equipment car)
        {
            CarLocation location = new CarLocation();

            location.row   = car.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == "row").Value;
            location.line  = car.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == "line").Value;
            location.layer = car.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == "layer").Value;
            //location.location = car.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == "location").Value;
            location.carNo       = car.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == "carNo").Value;
            location.controlMode = car.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == "controlMode").Value;
            return(location);
        }
Esempio n. 14
0
        //处理车辆节点消息
        private void DealVehiclePointResponse(object obj)
        {
            try
            {
                VehiclePointResponse vp = (VehiclePointResponse)obj;
                CarLocation cl = getClFromVp(vp);
                CoreService.GetInstance().OtherMsgServer.SendCarLocation(cl);

            }
            catch (Exception ex)
            {
                LOG.LogHelper.WriteLog("", ex);
            }
        }
        public async Task <IHttpActionResult> DeleteCarLocation(int id)
        {
            CarLocation carLocation = await db.CarLocations.FindAsync(id);

            if (carLocation == null)
            {
                return(NotFound());
            }

            db.CarLocations.Remove(carLocation);
            await db.SaveChangesAsync();

            return(Ok(carLocation));
        }
Esempio n. 16
0
 public static String GetCarLocationName(CarLocation location)
 {
     switch (location){
         case CarLocation.DriversSeat:
             return "Driver's Seat";
         case CarLocation.FrontSeat:
             return "Front Seat";
         case CarLocation.BackLeft:
             return "Back Left Seat";
         case CarLocation.BackRight:
             return "Back Right Seat";
         case CarLocation.NotInCar:
             return "Outside Car";
         default:
             return "ERROR";
     }
 }
Esempio n. 17
0
        private string ConvertModelToJson(CarLocation cl)
        {
            string    strJson = "";
            Hashtable ht      = new Hashtable();

            ht.Add("caseId", cl.CASEID);
            ht.Add("cccc", cl.CCCC);
            ht.Add("clid", cl.CLID);
            ht.Add("fx", cl.FX);
            ht.Add("jd", cl.JD);
            ht.Add("wd", cl.WD);
            ht.Add("lsh", cl.LSH);
            ht.Add("sj", string.Format("{0:yyyy-MM-dd HH:mm:ss}", cl.SJ));
            ht.Add("sd", cl.SD);

            strJson = JSON.Encode(ht);
            return(strJson);
        }
Esempio n. 18
0
 /// <summary>
 ///  车辆轨迹消息
 /// </summary>
 /// <param name="strMsg"></param>
 private void Handle40Message(string strMsg)
 {
     try
     {
         CarLocation     cl = GetCarLocationByMessage(strMsg);
         VehicleTaskInfo info;
         if (CoreService.GetInstance().bs.GetVehicleTaskInfoByCLID(out info, cl.CLID))
         {
             cl.CASEID = info.CaseId;
             cl.CCCC   = info.CCCC;
             cl.LSH    = info.LSH;
             CoreService.GetInstance().CarLocationServer.SendCarLocation(cl);
         }
     }
     catch (Exception ex)
     {
         LogHelper.WriteLog("", ex);
     }
 }
Esempio n. 19
0
        private CarLocation GetCarLocationByMessage(string strMsg)
        {
            //(40ID:101%SJ:2016-04-13 11:39:44%JD:118.77554321289063%WD:31.985252380371094%SD:0.0%FX:0.0%KS:%GZ:%TXZT:0%BJ:0%)
            CarLocation cl = new CarLocation();

            cl.CLID = GetValueByKey(strMsg, "ID");
            cl.FX   = GetValueByKey(strMsg, "FX");
            cl.JD   = GetValueByKey(strMsg, "JD");
            cl.WD   = GetValueByKey(strMsg, "WD");
            if (GetValueByKey(strMsg, "SD") != "")
            {
                cl.SD = decimal.Parse(GetValueByKey(strMsg, "SD"));
            }
            if (GetValueByKey(strMsg, "SJ") != "")
            {
                cl.SJ = DateTime.Parse(GetValueByKey(strMsg, "SJ"));
            }
            return(cl);
        }
Esempio n. 20
0
        private CarLocation GetCarLocationModelByHashtable(Hashtable htMessage)
        {
            CarLocation cl = new CarLocation();

            if (htMessage["caseId"] != null)
            {
                cl.CASEID = htMessage["caseId"].ToString();
            }
            if (htMessage["cccc"] != null && htMessage["cccc"].ToString() != "")
            {
                cl.CCCC = int.Parse(htMessage["cccc"].ToString());
            }
            if (htMessage["clid"] != null)
            {
                cl.CLID = htMessage["clid"].ToString();
            }
            if (htMessage["fx"] != null)
            {
                cl.FX = htMessage["fx"].ToString();
            }
            if (htMessage["jd"] != null)
            {
                cl.JD = htMessage["jd"].ToString();
            }
            if (htMessage["lsh"] != null)
            {
                cl.LSH = htMessage["lsh"].ToString();
            }
            if (htMessage["sd"] != null && htMessage["sd"].ToString() != "")
            {
                cl.SD = decimal.Parse(htMessage["sd"].ToString());
            }
            if (htMessage["sj"] != null && htMessage["sj"].ToString() != "")
            {
                cl.SJ = DateTime.Parse(htMessage["sj"].ToString());
            }
            if (htMessage["wd"] != null)
            {
                cl.WD = htMessage["wd"].ToString();
            }
            return(cl);
        }
Esempio n. 21
0
 public void SendCarLocation(CarLocation cl)
 {
     acl.HandleCarLocation(cl);
 }
Esempio n. 22
0
        private void HandleCarLocation(Hashtable htMessage)
        {
            CarLocation cl = GetCarLocationModelByHashtable(htMessage);

            Appserver.SendCarLocation(cl);
        }