public async Task SetDamage(PhotoInspection photoInspection, string typrCar, string pathScan) { if (photoInspection.Damages != null) { foreach (var damage in photoInspection.Damages) { Image img1 = Bitmap.FromFile(pathScan); Image img2 = Bitmap.FromFile($"../Damages/Damage{damage.TypeCurrentStatus}{damage.IndexDamage}.png"); img2 = img2.GetThumbnailImage((int)((double)damage.WidthDamage * 0.30), (int)((double)damage.HeightDamage * 0.30), null, IntPtr.Zero); Bitmap res = new Bitmap(img1); Graphics g = Graphics.FromImage(res); int x = GetCordinatX(photoInspection.IndexPhoto.ToString(), damage.XInterest); int y = GetCordinatY(photoInspection.IndexPhoto.ToString(), damage.YInterest); if (photoInspection.IndexPhoto == 2 || photoInspection.IndexPhoto == 3 || photoInspection.IndexPhoto == 4 || photoInspection.IndexPhoto == 5 || photoInspection.IndexPhoto == 6 || photoInspection.IndexPhoto == 7 || photoInspection.IndexPhoto == 9 || photoInspection.IndexPhoto == 10 || photoInspection.IndexPhoto == 11 || photoInspection.IndexPhoto == 12 || photoInspection.IndexPhoto == 13) { g.DrawImage(img2, x, y); } else if (photoInspection.IndexPhoto == 14) { g.DrawImage(img2, y, x); } string tempPath = pathScan + "1"; res.Save($"{pathScan.Replace(".jpg", "")}1.jpg"); img1.Dispose(); res.Dispose(); g.Dispose(); img1 = null; res = null; g = null; File.Delete(pathScan); File.Move($"{pathScan.Replace(".jpg", "")}1.jpg", pathScan); } } }
public async Task <VehiclwInformation> SavePhotoInspectionInDb(string idVe, PhotoInspection photoInspection) { VehiclwInformation vehiclwInformation = context.VehiclwInformation.Where(v => v.Id.ToString() == idVe) .Include(v => v.Ask) .Include(v => v.Scan) .Include("PhotoInspections.Photos") .Include("PhotoInspections.Damages") .FirstOrDefault(); if (vehiclwInformation.PhotoInspections == null) { vehiclwInformation.PhotoInspections = new List <PhotoInspection>(); } if (photoInspection.IndexPhoto == 1 && photoInspection.CurrentStatusPhoto == "PikedUp") { Photo photo = new Photo(); photo.path = $"../Photo/{vehiclwInformation.Id}/scan.jpg"; photo.Base64 = Convert.ToBase64String(File.ReadAllBytes($"../Scans/scan{vehiclwInformation.Ask.TypeVehicle.Replace(" ", "")}.jpg")); vehiclwInformation.Scan = photo; } vehiclwInformation.PhotoInspections.Add(photoInspection); await context.SaveChangesAsync(); return(vehiclwInformation); }
public async Task SavePhotoInspection(string idVe, string photoInspectionJson) { PhotoInspection photoInspection = JsonConvert.DeserializeObject <PhotoInspection>(photoInspectionJson); VehiclwInformation vehiclwInformation = await sqlCommandApiMobile.SavePhotoInspectionInDb(idVe, photoInspection); Task.Run(async() => { ITypeScan typeScan = GetTypeScan(vehiclwInformation.Ask.TypeVehicle.Replace(" ", "")); await typeScan.SetDamage(photoInspection, vehiclwInformation.Ask.TypeVehicle.Replace(" ", ""), vehiclwInformation.Scan.path); }); }
public int SavePhoto(string token, string id, PhotoInspection photoInspection, ref string description) { IRestResponse response = null; string content = null; try { if (photoInspection.Damages != null) { photoInspection.Damages.ForEach((dm) => { dm.Image = null; dm.ImageSource = null; }); } string strPhotoInspection = JsonConvert.SerializeObject(photoInspection); RestClient client = new RestClient(Config.BaseReqvesteUrl); RestRequest request = new RestRequest("Mobile/Save/Photo", Method.POST); client.Timeout = 60000; request.AddHeader("Accept", "application/json"); request.AddParameter("token", token); request.AddParameter("idVe", id); request.AddParameter("jsonStr", Compress(strPhotoInspection)); response = client.Execute(request); content = response.Content; } catch (Exception e) { return(4); } if (content == "" || response.StatusCode == System.Net.HttpStatusCode.NotFound) { return(4); } else { return(GetData(content, ref description)); } }