/// <summary>
        /// 上传车辆图片0。
        /// </summary>
        private void UploadCarPhoto0(HttpContext context)
        {
            string thumbDirPath = context.Server.MapPath("~/UploadFile/CarPhoto/");
            string dirPath = context.Server.MapPath("~/UploadFile/CarPhoto/thumbCarPhoto/");
            string tel = context.Request.Form["tel"].ToString();
            string photoindex = context.Request.Form["index"].ToString();
            string filename = context.Request.Form["filename"].ToString();

            filename = Path.GetFileName(filename);

            if (!Directory.Exists(dirPath))
            {
                Directory.CreateDirectory(dirPath);
                if (!Directory.Exists(thumbDirPath))
                {
                    Directory.CreateDirectory(thumbDirPath);
                }
            }
            try
            {
                HttpFileCollection files = context.Request.Files;
                //保存缩略图
                HttpPostedFile file = context.Request.Files[0];
                // string fileName = DateTime.Now.ToString("yyyyMMddHHmmssffff") + ".jpg";
                //string filePath = dirPath + "thumb_" + fileName;//file.FileName;
                string filePath = dirPath + filename;
                file.SaveAs(filePath);
                //保存原图
                //HttpPostedFile thumbFile = context.Request.Files[1];
                //string thumbFileName = fileName;
                //string thumbFilePath = thumbDirPath + thumbFileName;//file.FileName;
                //thumbFile.SaveAs(thumbFilePath);
                //更新数据库
                BLL.carInfo bll = new BLL.carInfo();
                List<Model.carInfo> carList = bll.GetModelList(" user_telphone='" + tel + "'");
                if (carList == null || carList.Count == 0)
                {
                    Model.carInfo info = new Model.carInfo();
                    info.user_telphone = tel;
                    if (photoindex == "1")
                    {
                        info.car_photo1 = "/UploadFile/CarPhoto/" + "thumbCarPhoto/" + filename;
                    }
                    if (photoindex == "2")
                    {
                        info.car_photo2 = "/UploadFile/CarPhoto/" + "thumbCarPhoto/" + filename;
                    }
                    if (photoindex == "3")
                    {
                        info.car_photo3 = "/UploadFile/CarPhoto/" + "thumbCarPhoto/" + filename;
                    }
                    bll.Add(info);
                }
                else
                {
                    Model.carInfo info = carList[0];
                    if (photoindex == "1")
                    {
                        info.car_photo1 = "/UploadFile/CarPhoto/" + "thumbCarPhoto/" + filename;
                    }
                    if (photoindex == "2")
                    {
                        info.car_photo2 = "/UploadFile/CarPhoto/" + "thumbCarPhoto/" + filename;
                    }
                    if (photoindex == "3")
                    {
                        info.car_photo3 = "/UploadFile/CarPhoto/" + "thumbCarPhoto/" + filename;
                    }
                    bll.Update(info);
                }
                string result = "{\"Status\":\"success\",\"Msg\":\"上传成功\",\"data\":{}}";
                context.Response.Write(result);
            }
            catch (Exception e)
            {
                string result = "{\"Status\":\"faild\",\"Msg\":\"上传失败," + e.Message + "\",\"data\":{}}";
                context.Response.Write(result);
            }
        }
示例#2
0
        public string UpdateCarInfo(object carJsonstring)
        {
            Dictionary<string, object> dic = carJsonstring as Dictionary<string, object>;
            Model.carInfo info = new Model.carInfo();
            //Dictionary<string, object> dic = carJsonstring;
            info.user_telphone = dic["user_telphone"].ToString();
            info.car_level = dic["car_level"].ToString();
            info.car_brand = dic["car_brand"].ToString();
            info.car_type = dic["car_type"].ToString();
            string temp = "";
            string data = "";
            string result = "{\"status\":";
            //Model.carInfo info = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize<Model.carInfo>(carJsonstring);
            string tel = info.user_telphone;
            List<Model.carInfo> carInfoL = new BLL.carInfo().GetModelList(" user_telphone='" + tel + "'");

            if (carInfoL == null || carInfoL.Count == 0)
            {
                new BLL.carInfo().Add(info);
            }
            else
            {
                try
                {
                    Model.carInfo car = carInfoL[0];
                    car.car_level = info.car_level;
                    car.car_brand = info.car_brand;
                    car.car_type = info.car_type;
                    temp = new BLL.carInfo().Update(car).ToString();
                }
                catch (Exception ex)
                {
                    temp = ex.Message;
                }

                //temp = car.user_telphone + "ff" +car.car_id.ToString();
            }

            result = result + "\"success\",";
            result = result + "\"msg\":\"" + temp + "\",";
            result = result + "\"data\":{}}";
            return result;
        }
        /// <summary>
        /// 上传车辆图片。
        /// </summary>
        private void UploadCarPhoto(HttpContext context)
        {
            string dirPath = context.Server.MapPath("~/UploadFile/CarPhoto/");
            string tel = context.Request.Form["tel"].ToString();
            string photoindex = context.Request.Form["index"].ToString();
            if (!Directory.Exists(dirPath))
            {
                Directory.CreateDirectory(dirPath);
            }
            try
            {
                HttpFileCollection files = context.Request.Files;
                if (files.Count > 0)
                {
                    for (int i = 0; i < files.Count; i++)
                    {
                        HttpPostedFile file = context.Request.Files[i];
                        string fileName = DateTime.Now.ToString("yyyyMMddHHmmssffff") + ".jpg";
                        string filePath = dirPath + fileName;//file.FileName;
                        file.SaveAs(filePath);
                        DataServer.Util.MakeThumbnail(filePath, dirPath + "thumbCarPhoto/thumb_" + fileName, 160, 120, "W", "jpg");

                        BLL.carInfo bll = new BLL.carInfo();
                        List<Model.carInfo> carList = bll.GetModelList(" user_telphone='" + tel + "'");
                        if (carList == null || carList.Count == 0)
                        {
                            Model.carInfo info = new Model.carInfo();
                            info.user_telphone = tel;
                            if (photoindex == "1")
                            {
                                info.car_photo1 = "/UploadFile/CarPhoto/" + "thumbCarPhoto/thumb_" + fileName;
                            }
                            if (photoindex == "2")
                            {
                                info.car_photo2 = "/UploadFile/CarPhoto/" + "thumbCarPhoto/thumb_" + fileName;
                            }
                            if (photoindex == "3")
                            {
                                info.car_photo3 = "/UploadFile/CarPhoto/" + "thumbCarPhoto/thumb_" + fileName;
                            }
                            bll.Add(info);

                        }
                        else
                        {
                            Model.carInfo info = carList[0];
                            if (photoindex == "1")
                            {
                                info.car_photo1 = "/UploadFile/CarPhoto/" + "thumbCarPhoto/thumb_" + fileName;
                            }
                            if (photoindex == "2")
                            {
                                info.car_photo2 = "/UploadFile/CarPhoto/" + "thumbCarPhoto/thumb_" + fileName;
                            }
                            if (photoindex == "3")
                            {
                                info.car_photo3 = "/UploadFile/CarPhoto/" + "thumbCarPhoto/thumb_" + fileName;
                            }
                            bll.Update(info);
                        }
                    }
                }
                string result = "{\"Status\":\"success\",\"Msg\":\"上传成功\",\"data\":{}}";
                context.Response.Write(result);
            }
            catch (Exception e)
            {
                string result = "{\"Status\":\"faild\",\"Msg\":\"上传失败," + e.Message + "\",\"data\":{}}";
                context.Response.Write(result);
            }
        }
示例#4
0
        public string getCarInfo(string tel)
        {
            string result = "{\"status\":";
            List<Model.carInfo> carInfoL = new BLL.carInfo().GetModelList(" user_telphone='" + tel + "'");
            try
            {
                if (carInfoL == null || carInfoL.Count == 0)
                {
                    result = result + "\"success\",";
                    result = result + "\"msg\":\"没有找到车辆信息\",";
                    result = result + "\"data\":{}}";
                    return result;
                }
                else
                {
                    Model.carInfo car = carInfoL[0];
                    string data = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(car);
                    result = result + "\"success\",";
                    result = result + "\"msg\":\"success\",";
                    result = result + "\"data\":";
                    result = result + data;
                    result = result + "}";
                    return result;
                }
            }
            catch (Exception ex)
            {
                result = result + "\"faild\",";
                result = result + "\"msg\":\"" + ex.Message + "\",";
                result = result + "\"data\":{}}";
                return result;

            }
        }