Example #1
0
 private void WriteLog(CarDetail item, QueryResult result)
 {
     using (var helper = DbHelper.CreateLogDbHelper())
     {
         using (var cmd = helper.CreateCommand(@"INSERT Tuhu_log..PeccancyLog
 ( PlateNumber ,
   UserID ,
   City_code ,
   Engineno ,
   Classno ,
   Status ,
   CreateTime ,
   Channel
 )
 VALUES(
   @plateNumber,
   @userId,
   @city_code,
   @engineno,
   @classno,
   @status,
   GETDATE(),
   'APP'
 )"))
         {
             cmd.Parameters.Add(new SqlParameter("@plateNumber", item.CarNumber));
             cmd.Parameters.Add(new SqlParameter("@userId", item.UserId));
             cmd.Parameters.Add(new SqlParameter("@city_code", item.SearchCity));//车牌所在城市暂时存 查询城市
             cmd.Parameters.Add(new SqlParameter("@engineno", item.EngineNo));
             cmd.Parameters.Add(new SqlParameter("@classno", item.VinCode));
             cmd.Parameters.Add(new SqlParameter("@status", result?.ErrorCode));
             helper.ExecuteNonQuery(cmd);
         }
     }
 }
Example #2
0
        private static ListCarAttributes ConvertToListAttribute(Car car, CarDetail carDetail)
        {
            //var carDetail = await App.CarDetailManager.GetCarsDetail(car.Id);
            //var carDetail = carDetails.Find(x => x.CarId == car.Id);

            if (carDetail == null)
            {
                return(null);
            }

            var carAttributes = new ListCarAttributes
            {
                CarId              = car.Id,
                FullName           = car.FullName,
                ModelYear          = car.ModelYear,
                RemainingItp       = (carDetail.Itp.AddYears(2) - carDetail.Itp).Days.ToString(),
                RemainingRoadTax   = (carDetail.RoadTax.AddYears(1) - carDetail.RoadTax).Days.ToString(),
                RemainingOilChange = carDetail.OilChange.ToString(),
                RoadTaxValue       = carDetail.RoadTaxValue.ToString(),
                CarImage           = car.CarImage,
                TaxValue           = carDetail.TaxValue == -1 ? "Nu putem calcula" : carDetail.TaxValue.ToString()
            };


            return(carAttributes);
        }
        public static string ReturnCarCollectionOverview(DataSet dataSet)
        {
            var categoriesTable = dataSet.Tables[0];
            var detailTable     = dataSet.Tables[1];

            var collectionContainer = new CarCollectionOverview();

            for (var x = 0; x < categoriesTable.Rows.Count; x++)
            {
                var collection = new CarCollection(categoriesTable.Rows[x][0].ToString());
                collectionContainer.AddCategory(collection);
            }

            for (var i = 0; i < detailTable.Rows.Count; i++)
            {
                var car = new CarDetail(detailTable.Rows[i][0].ToString(), detailTable.Rows[i][1].ToString(),
                                        detailTable.Rows[i][2].ToString(), detailTable.Rows[i][3].ToString(),
                                        detailTable.Rows[i][4].ToString(), detailTable.Rows[i][5].ToString(),
                                        detailTable.Rows[i][6].ToString(), detailTable.Rows[i][7].ToString(),
                                        detailTable.Rows[i][8].ToString(), detailTable.Rows[i][9].ToString(),
                                        detailTable.Rows[i][10].ToString());

                var collection = collectionContainer.FindCollectionByName(detailTable.Rows[i][1].ToString());
                collection.AddCar(car);
            }

            return(collectionContainer.ToJson());
        }
Example #4
0
        public IHttpActionResult PutCarDetail(int id, CarDetail carDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != carDetail.carID)
            {
                return(BadRequest());
            }

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CarDetailExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <IActionResult> Edit(Guid id, [Bind("Id,CarPartId,BasketId,DetailPath,Name,Description,Cost")] CarDetail carDetail)
        {
            if (id != carDetail.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(carDetail);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CarDetailExists(carDetail.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BasketId"]  = new SelectList(_context.Baskets, "Id", "CreatorId", carDetail.BasketId);
            ViewData["CarPartId"] = new SelectList(_context.CarParts, "Id", "Name", carDetail.CarPartId);
            return(View(carDetail));
        }
Example #6
0
        public void Edit(CarDetailViewModel carDetailView)
        {
            CarDetail carDetail = db.CarDetails.Find(carDetailView.ID);

            carDetail.Title = carDetailView.Title;
            db.SaveChanges();
        }
Example #7
0
        public async Task <IActionResult> Edit(int id, [Bind("Id, Name, Price, CarId")] CarDetail carDetail)
        {
            if (id != carDetail.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(carDetail);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CarDetailExists(carDetail.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(carDetail));
        }
Example #8
0
        //推送
        private void Notification(CarDetail item, int templateId, Service.Push.ITemplatePushClient client)
        {
            if (item.UserId == Guid.Empty)
            {
                return;
            }
            //无论违章否,都发通知
            var replacement = Newtonsoft.Json.JsonConvert.SerializeObject(new Dictionary <string, string>
            {
                //["{{type}}"] = "customCar",
                ["{{carID}}"] = System.Web.HttpUtility.UrlEncode(item.CarId.ToString()),
                ["{{CarNo}}"] = item.CarNumber
            });
            //Logger.Info("VehicleWeiZhangNotAutoLicensePushJob 推送的数据数 CarDetail=" + JsonConvert.SerializeObject(item));

            var response = client.PushByUserIDAndBatchID(new List <string> {
                item.UserId.ToString()
            }, templateId,
                                                         new Service.Push.Models.Push.PushTemplateLog()
            {
                Replacement = replacement
            });

            Logger.Info("VehicleWeiZhangPushJob 推送的数据数 CarDetail=" + JsonConvert.SerializeObject(item) + "||结果= " + response.Success);
        }
Example #9
0
        private QueryResult GetResponse(CarDetail item)
        {
            var dic = new Dictionary <string, object>();

            dic.Add("userid", UserPassword[Env].Item1);
            dic.Add("userpwd", UserPassword[Env].Item2);
            dic.Add("carnumber", item.CarNumber);
            dic.Add("carcode", item.VinCode);
            dic.Add("cardrivenumber", item.EngineNo);
            var carNoCity = GetCityId(item);

            if (carNoCity > 0)
            {
                dic.Add("cityid", carNoCity);
            }

            try
            {
                var data = JsonConvert.DeserializeObject <QueryResult>(CheXingYiClient.GetStringAsync("CFTQueryindex.aspx?" + dic.ToHtmlString()).Result);
                //WriteLog(item, data);
                if (!string.IsNullOrEmpty(data.ErrMessage))
                {
                    Logger.Error(data.ErrMessage);
                }
                else
                {
                    return(data);
                }
            }
            catch (Exception ex)
            {
                Logger.Info("VehicleWeiZhangNotAutoLicensePushJob GetResponse  ex=" + ex.Message);
            }
            return(null);
        }
Example #10
0
        public IActionResult AddCar([Bind("Brand,Model,Price,Color,Year,CarType")] CarDetail carDetail, [Bind("IsAvailable")] Car car)
        {
            _context.CarDetails.Add(carDetail);
            _context.SaveChanges();
            int CarDetailID = carDetail.ID;

            car.CarDetailID = CarDetailID;
            car.CarOwnerID  = _userManager.GetUserId(User);
            _context.Car.Add(car);
            _context.SaveChanges();

            //calea catre folderul wwwroot ce contine fisierele statice
            string path = _hostingEnvironment.WebRootPath;
            //acces la fisierele trimise din form
            var files = HttpContext.Request.Form.Files;

            //obtinerea cailor si a extensilor
            var image_path = Path.Combine(path, @"images");
            var extension  = Path.GetExtension(files[0].FileName);

            using (var fileStream = new FileStream(Path.Combine(image_path, car.ID + extension), FileMode.Create))
            {
                files[0].CopyTo(fileStream);
            }
            car.Image = @"\" + @"images" + @"\" + car.ID + extension;
            _context.SaveChanges();
            //Console.WriteLine("Car brand: " + car.IsAvailable);

            return(RedirectToAction(nameof(Index)));
        }
Example #11
0
        private static readonly int NoWeiZhang = 2787; //没有违章的模板id

        //private static readonly int NoWeiZhang = 842;//没有违章的模板id
        public void Execute(IJobExecutionContext context)
        {
            try
            {
                Logger.Info("VehicleWeiZhangNotAutoLicensePushJob 开始执行");
                Provinces = GetProvinceCache();
                //记录推送的历史数据
                Dictionary <string, PushHistory> _PushHistoryList = new Dictionary <string, PushHistory>();

                int maxId      = GetPeccancyLogMaxPkid();
                int totalCount = GetPeccancyLogCount(maxId);

                Logger.Info("VehicleWeiZhangNotAutoLicensePushJob totalCount =" + totalCount);
                int pageIndex = 1;
                int pageSize  = 100;
                //每次查询一百条日志
                while (pageIndex <= Math.Ceiling(totalCount / (pageSize * 1.0)))
                {
                    var datas = GetPeccancyLog(pageIndex, pageSize, maxId);
                    if (datas == null || !datas.Any())
                    {
                        break;
                    }
                    foreach (var item in datas)
                    {
                        if (item.UserID == Guid.Empty)
                        {
                            continue;
                        }
                        CarDetail _CarDetail = PushCheck(item);
                        if (_CarDetail == null)
                        {
                            continue;
                        }
                        else
                        {
                            //避免重复推送
                            string key   = item.UserID.ToString() + item.PlateNumber;
                            var    check = _PushHistoryList.ContainsKey(key);
                            if (!check)
                            {
                                _PushHistoryList.Add(key, new PushHistory()
                                {
                                    PlateNumber = item.PlateNumber, UserID = item.UserID
                                });
                                Send(_CarDetail);
                            }
                        }
                    }
                    pageIndex++;
                    System.Threading.Thread.Sleep(100);
                }
                Logger.Info("VehicleWeiZhangNotAutoLicensePushJob 执行结束 推送的数据数 _PushHistoryList=" + _PushHistoryList.Count);
            }
            catch (Exception e)
            {
                Logger.Error("VehicleWeiZhangNotAutoLicensePushJob Execute Exception=" + e.Message, e);
            }
        }
        public async Task <IActionResult> Create(Guid?carPartId, CarDetailEditModel model)
        {
            if (carPartId == null)
            {
                this.NotFound();
            }

            var fileName = Path.GetFileName(ContentDispositionHeaderValue.Parse(model.DetailPath.ContentDisposition).FileName.Value.Trim('"'));
            var fileExt  = Path.GetExtension(fileName);

            if (!CarDetailsController.AllowedExtensions.Contains(fileExt))
            {
                this.ModelState.AddModelError(nameof(model.DetailPath), "This file type is prohibited");
            }

            var user = await this.userManager.GetUserAsync(this.HttpContext.User);

            var carPart = await this._context.CarParts
                          .SingleOrDefaultAsync(m => m.Id == carPartId);

            var baskets = await this._context.Baskets
                          .Include(p => p.CarDetails)
                          .Include(u => u.Creator)
                          .SingleOrDefaultAsync(m => m.Id == carPartId);

            if (carPart == null)
            {
                this.NotFound();
            }

            if (ModelState.IsValid)
            {
                var carDetail = new CarDetail
                {
                    CarPartId = carPart.Id,
                    //BasketId = baskets.Creator.Id,
                    Name        = model.Name,
                    Description = model.Description,
                    Cost        = model.Cost
                };

                var attachmentPath = Path.Combine(this.hostingEnvironment.WebRootPath, "attachments/parts", carDetail.Id.ToString("N") + fileExt);
                carDetail.DetailPath = $"/attachments/parts/{carDetail.Id:N}{fileExt}";
                using (var fileStream = new FileStream(attachmentPath, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.Read))
                {
                    await model.DetailPath.CopyToAsync(fileStream);
                }

                carDetail.Id = Guid.NewGuid();
                _context.Add(carDetail);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Details", "CarParts", new { carPartId = carPart.Id }));
            }
            ViewData["BasketId"]  = new SelectList(_context.Baskets, "Id", "CreatorId");
            ViewData["CarPartId"] = new SelectList(_context.CarParts, "Id", "Name");
            this.ViewBag.CarParts = carPart;
            return(View(model));
        }
Example #13
0
        public FinishAddingFormPage(Car car = null, CarDetail carDetail = null, CarImages carImage = null)
        {
            InitializeComponent();

            _newUserCar   = car;
            _newCarDetail = carDetail;
            _newCarImage  = carImage;
        }
Example #14
0
        public ActionResult DeleteConfirmed(int id)
        {
            CarDetail carDetail = db.CarDetails.Find(id);

            db.CarDetails.Remove(carDetail);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #15
0
 public ActionResult Edit([Bind(Include = "DetailsId,CarId,CarBrand,CarModel,CarYear")] CarDetail carDetail)
 {
     if (ModelState.IsValid)
     {
         db.Entry(carDetail).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CarId = new SelectList(db.ClassicCars, "CarId", "CarName", carDetail.CarId);
     return(View(carDetail));
 }
Example #16
0
        public void Create(CarDetailViewModel carDetail)
        {
            var item = new CarDetail()
            {
                Title      = carDetail.Title,
                CarModelID = carDetail.CarModelID,
            };

            db.CarDetails.Add(item);
            db.SaveChanges();
        }
Example #17
0
        public async Task <IActionResult> Create([Bind("Id, Name, Price, CarId")] CarDetail carDetail)
        {
            if (ModelState.IsValid)
            {
                _context.Add(carDetail);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View());
        }
Example #18
0
        public IHttpActionResult PostCarDetail(CarDetail carDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.CarDetails.Add(carDetail);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = carDetail.carID }, carDetail));
        }
        public async Task AddCarDetail(CarDetail carDetail)
        {
            var json    = JsonConvert.SerializeObject(carDetail);
            var content = new StringContent(json, Encoding.UTF8, "application/json");

            var response = await _client.PostAsync(Constants.webAPI + "CarDetails", content);

            if (response.IsSuccessStatusCode)
            {
                Debug.WriteLine("Car successfully saved");
            }
        }
Example #20
0
        public void GetInsertDetail(UserDetails insert)
        {
            using (var dbContext = new TraineeEntities())
            {
                var user = new UserDetail()
                {
                    FullName      = insert.FullName,
                    UserEmail     = insert.UserEmail,
                    PasswordHash  = insert.PasswordHash,
                    CivilIdNumber = insert.CivilIdNumber,

                    DOB      = insert.DOB,
                    MobileNo = insert.MobileNo,
                    Address  = insert.Address,
                    //RoleId = insert.RoleId,

                    ProfilePic = insert.ProfilePic,



                    CreatedDate          = insert.CreatedDate,
                    ModifiedDate         = insert.ModifiedDate,
                    IsNotificationActive = insert.IsNotificationActive,
                    IsActive             = insert.IsActive,
                    DeviceId             = insert.DeviceId,
                    DeviceType           = insert.DeviceType,
                    FcmToken             = insert.FcmToken,
                    verify        = insert.verify,
                    VerifiedBy    = insert.VerifiedBy,
                    Area          = insert.Area,
                    Block         = insert.Block,
                    Street        = insert.Street,
                    Housing       = insert.Housing,
                    Floor         = insert.Floor,
                    NewPass       = insert.NewPass,
                    ConPass       = insert.ConPass,
                    Jadda         = insert.Jadda,
                    Reason        = insert.Reason,
                    ActivatedBy   = insert.ActivatedBy,
                    ActivatedDate = insert.ActivatedDate
                };

                var car = new CarDetail()
                {
                    CarLicense = insert.CarLicense,
                    UserId     = insert.UserId
                };
                dbContext.UserDetails.Add(user);
                dbContext.CarDetails.Add(car);
                dbContext.SaveChanges();
            }
        }
        public static string ReturnCarStatus(DataSet dataSet)
        {
            var detailTable = dataSet.Tables[0];

            var car = new CarDetail(detailTable.Rows[0][0].ToString(), detailTable.Rows[0][1].ToString(),
                                    detailTable.Rows[0][2].ToString(), detailTable.Rows[0][3].ToString(),
                                    detailTable.Rows[0][4].ToString(), detailTable.Rows[0][5].ToString(),
                                    detailTable.Rows[0][6].ToString(), detailTable.Rows[0][7].ToString(),
                                    detailTable.Rows[0][8].ToString(), detailTable.Rows[0][9].ToString(),
                                    detailTable.Rows[0][10].ToString());

            return(car.ToJson());
        }
Example #22
0
        public ActionResult Delete(long id)
        {
            Car       car = db.Cars.Find(id);
            CarDetail cdt = db.CarDetails.Find(id);

            db.Cars.Remove(car);
            db.CarDetails.Remove(cdt);
            string mappedPath = Server.MapPath(@"~/Content/Upload/" + Session["path"]);

            Directory.Delete(mappedPath, true);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #23
0

        
Example #24
0
        public async Task <IActionResult> AddDetail(CarDetail newDetail)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Index"));
            }
            var successful = await _carDetailService.AddDetailAsync(newDetail);

            if (!successful)
            {
                return(BadRequest("Could not add item."));
            }
            return(RedirectToAction("Index"));
        }
Example #25
0
        public IHttpActionResult DeleteCarDetail(int id)
        {
            CarDetail carDetail = db.CarDetails.Find(id);

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

            db.CarDetails.Remove(carDetail);
            db.SaveChanges();

            return(Ok(carDetail));
        }
Example #26
0
        // GET: CarDetails/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CarDetail carDetail = db.CarDetails.Find(id);

            if (carDetail == null)
            {
                return(HttpNotFound());
            }
            return(View(carDetail));
        }
Example #27
0
        public async Task <IActionResult> OnGetAsync(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            CarDetail = Details.Find(t => t.CarNum == int.Parse(id));

            if (CarDetail == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Example #28
0
        public ActionResult EditDetail(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CarDetail carDt = db.CarDetails.Find(id);

            if (carDt == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CarId = id;
            return(View(carDt));
        }
        public async Task <bool> AddDetailAsync(CarDetail newDetail)
        {
            newDetail.Id = Guid.NewGuid();
            //newDetail.Make = ;
            //newDetail.Model =;
            //newDetail.Year =;
            //newDetail.Type =;
            //newDetail.IsNew = true;
            //newDetail.DueAt = DateTimeOffset.Now.AddDays(3);

            _context.Details.Add(newDetail);
            var saveResult = await _context.SaveChangesAsync();

            return(saveResult == 1);
        }
Example #30
0
        // GET: CarDetails/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CarDetail carDetail = db.CarDetails.Find(id);

            if (carDetail == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CarId = new SelectList(db.ClassicCars, "CarId", "CarName", carDetail.CarId);
            return(View(carDetail));
        }