示例#1
0
        public ContentResult BookingLocByCheckCode(string checkcode)
        {
            Location loc = new AllocateLocByBook().AllocateLoc(checkcode);

            return(Content(loc.Address));
        }
示例#2
0
        /// <summary>
        /// APP,预定、取消预定车位
        /// </summary>
        /// <returns></returns>
        public ActionResult RemoteBookLoc()
        {
            Response resp = new Response();
            Log      log  = LogFactory.GetLogger("RemoteBookLoc");

            #region
            try
            {
                byte[] bytes = new byte[Request.InputStream.Length];
                Request.InputStream.Read(bytes, 0, bytes.Length);
                string req = System.Text.Encoding.UTF8.GetString(bytes);
                //显示,记录
                log.Info(req);
                JObject jo    = (JObject)JsonConvert.DeserializeObject(req);
                string  type  = jo["ptype"].ToString();
                string  wh    = jo["warehouse"].ToString();
                string  proof = jo["proof"].ToString();
                string  plate = jo["platenum"].ToString();

                if (string.IsNullOrEmpty(proof) ||
                    string.IsNullOrEmpty(type))
                {
                    log.Error("参数错误,车位尺寸或接口类型 有为空的!");
                    resp.Message = "参数错误";
                    return(Json(resp));
                }
                if (string.IsNullOrEmpty(plate))
                {
                    log.Error("参数错误:车位预定时,车牌为空的!");
                    resp.Message = "参数错误";
                    return(Json(resp));
                }
                CWLocation cwlctn = new CWLocation();

                int deftype = Convert.ToInt32(type);
                //车位预定
                if (deftype == 3)
                {
                    Location lctn = cwlctn.FindLocation(l => l.PlateNum == plate);
                    if (lctn != null)
                    {
                        if (lctn.Status == EnmLocationStatus.Book)
                        {
                            resp.Message = "当前车辆已预约";
                        }
                        else
                        {
                            resp.Message = "当前车辆已存车";
                        }
                        log.Error("当前车辆已存在,不允许预约!");
                        return(Json(resp));
                    }

                    string checkcode = "122";
                    if (proof == "111")
                    {
                        checkcode = "121";
                    }
                    Location loc = new AllocateLocByBook().AllocateLoc(checkcode);
                    if (loc != null)
                    {
                        loc.Status   = EnmLocationStatus.Book;
                        loc.PlateNum = plate;
                        loc.InDate   = DateTime.Now;
                        cwlctn.UpdateLocation(loc);

                        resp.Code    = 1;
                        resp.Message = "预定成功";

                        log.Info("预定成功, checkcode - " + proof + " ,address - " + loc.Address + " ,locsize - " + loc.LocSize);
                    }
                    else
                    {
                        resp.Message = "找不到合适车位";
                    }
                }
                else if (deftype == 4)
                {
                    Location loc = cwlctn.FindLocation(lc => lc.PlateNum == plate && lc.Status == EnmLocationStatus.Book);
                    if (loc != null)
                    {
                        loc.Status   = EnmLocationStatus.Space;
                        loc.PlateNum = "";
                        loc.InDate   = DateTime.Parse("2017-1-1");
                        cwlctn.UpdateLocation(loc);

                        resp.Code    = 1;
                        resp.Message = "取消预定成功";
                    }
                    else
                    {
                        resp.Message = "车辆没有预定车位";
                    }
                }
                else
                {
                    resp.Message = "接口类型不正确,type- " + type;
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
                resp.Message = "系统异常";
            }
            #endregion
            return(Json(resp));
        }