Example #1
0
 public static WebResult <bool> UndoDelete(string url)
 {
     try
     {
         image currentImg = DB.images.FirstOrDefault(image => image.url == url);
         if (currentImg != null)
         {
             currentImg.isInRecycleBin = false;
         }
         DB.SaveChanges();
         return(new WebResult <bool>()
         {
             Status = true,
             Message = "Ok",
             Value = true
         });
     }
     catch (Exception e)
     {
         return(new WebResult <bool>()
         {
             Status = false,
             Message = e.Message,
             Value = false
         });
     }
     throw new NotImplementedException();
 }
Example #2
0
        public ActionResult Create(Event evt)
        {
            if (ModelState.IsValid)
            {
                db.Events.Add(evt);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(evt));
        }
Example #3
0
        //הפונקציה מוסיפה שורה לטבלת התמונות, תמונה עם כל הפרטים עליה
        private static async Task <int> InitImageDetailsAsync(string filePath, string fileName, Stream stream)
        {
            image img = new image();

            //img.url = filePath;
            img.url  = "http://localhost:50637/UploadFile/" + fileName;
            img.name = fileName;
            var resClarifai = await GetResClarifai(filePath);

            var resFacePP = getResultFacePP(stream);

            //var resGoogleVision = await GetResGoogleV(filePath);
            img.isBlur      = IsBlur(resClarifai);
            img.isClosedEye = IsClosedEye(resFacePP);
            img.isCutFace   = false;//to delete in db
            img.isDark      = IsDark(filePath);
            img.isGroom     = IsGroom(resFacePP);
            img.isLight     = IsLight(filePath);
            img.numPerson   = await NumPerson(filePath);

            img.isIndoors = IsIndoors(resClarifai);
            //bool[] whatHas = ageGroups(resClarifai);
            //img.hasChildren = HasChildren(stream);
            DB.images.Add(img);
            DB.SaveChanges();
            return(1);
        }
Example #4
0
        public static bool InsertGroom()
        {
            HttpResponseMessage response = new HttpResponseMessage();
            var    httpRequest           = HttpContext.Current.Request;
            string temp = "~/UploadFile/";
            List <Entities.ImageEntity> l = new List <Entities.ImageEntity>();

            if (httpRequest.Files.Count == 1)
            {
                var postedFile = httpRequest.Files[0];
                if (string.Equals(postedFile.ContentType, "image/jpg", StringComparison.OrdinalIgnoreCase) ||
                    string.Equals(postedFile.ContentType, "image/jpeg", StringComparison.OrdinalIgnoreCase) ||
                    string.Equals(postedFile.ContentType, "image/pjpeg", StringComparison.OrdinalIgnoreCase) ||
                    string.Equals(postedFile.ContentType, "image/gif", StringComparison.OrdinalIgnoreCase) ||
                    string.Equals(postedFile.ContentType, "image/x-png", StringComparison.OrdinalIgnoreCase) ||
                    string.Equals(postedFile.ContentType, "image/png", StringComparison.OrdinalIgnoreCase))
                {
                    var filePath = HttpContext.Current.Server.MapPath(temp + postedFile.FileName);
                    postedFile.SaveAs(filePath);
                    Groom groom = new Groom();
                    groom.url   = "http://localhost:50637/UploadFile/" + postedFile.FileName;
                    groom.token = getFaceToken(postedFile.InputStream);
                    groom.name  = postedFile.FileName;
                    DB.Grooms.Add(groom);
                    DB.SaveChanges();
                    return(true);
                }
            }

            return(false);
            //return response;
        }
Example #5
0
 public static bool DeleteImg(string url)
 {
     //image img = DB.images.FirstOrDefault(image => image.url == url);
     //if (img != null)
     //    DB.images.Remove(img);
     DB.images.Where(image => image.url == url).ToList().ForEach(f => f.isInRecycleBin = true);
     DB.SaveChanges();
     return(true);
 }
Example #6
0
        //הפונקציה מוסיפה שורה לטבלת התמונות, תמונה עם כל הפרטים עליה
        private static async Task <bool> InitImageDetailsAsync(string fileUrl, string fileName)
        {
            try
            {
                image img = new image();
                img.url  = fileUrl;
                img.name = fileName;
                var resClarifai = await GetResClarifai(fileUrl);

                var resFacePP = getResultFacePP(fileUrl);
                if (resClarifai == null || resFacePP == null)
                {
                    return(false);
                }
                img.isBlur      = IsBlur(resClarifai);
                img.isClosedEye = IsClosedEye(resFacePP);
                img.isGroom     = IsGroom(resFacePP);
                img.numPerson   = await NumPerson(fileUrl);

                if (img.numPerson == -1)
                {
                    return(false);
                }
                img.isIndoors   = IsIndoors(resClarifai);
                img.isOutdoors  = IsOutdoors(resClarifai);
                img.hasChildren = HasChildren(resClarifai);
                DB.images.Add(img);
                if (DB.SaveChanges() > 0)
                {
                    return(true);
                }
                return(false);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Example #7
0
        public static WebResult <bool> InsertGroom()
        {
            try
            {
                HttpResponseMessage response = new HttpResponseMessage();
                var httpRequest = HttpContext.Current.Request;
                List <Entities.ImageEntity> images = new List <Entities.ImageEntity>();
                if (httpRequest.Files.Count == 1)
                {
                    var postedFile = httpRequest.Files[0];
                    if (string.Equals(postedFile.ContentType, "image/jpg", StringComparison.OrdinalIgnoreCase) ||
                        string.Equals(postedFile.ContentType, "image/jpeg", StringComparison.OrdinalIgnoreCase) ||
                        string.Equals(postedFile.ContentType, "image/pjpeg", StringComparison.OrdinalIgnoreCase) ||
                        string.Equals(postedFile.ContentType, "image/gif", StringComparison.OrdinalIgnoreCase) ||
                        string.Equals(postedFile.ContentType, "image/x-png", StringComparison.OrdinalIgnoreCase) ||
                        string.Equals(postedFile.ContentType, "image/png", StringComparison.OrdinalIgnoreCase))
                    {
                        string urlStorage = InitImages.SendToStorage(postedFile.FileName, postedFile.InputStream);
                        if (urlStorage == "")
                        {
                            return new WebResult <bool>()
                                   {
                                       Status  = false,
                                       Message = "failed to load image",
                                       Value   = false
                                   }
                        }
                        ;
                        Groom groom = new Groom();
                        groom.url = urlStorage;
                        string token = getFaceToken(urlStorage);
                        if (token == "")
                        {
                            return new WebResult <bool>()
                                   {
                                       Status  = false,
                                       Message = "failed",
                                       Value   = false
                                   }
                        }
                        ;
                        groom.token = token;
                        groom.name  = postedFile.FileName;
                        DB.Grooms.Add(groom);
                        if (DB.SaveChanges() > 0)
                        {
                            return new WebResult <bool>()
                                   {
                                       Status  = true,
                                       Message = "Ok",
                                       Value   = true
                                   }
                        }
                        ;
                    }
                }

                return(new WebResult <bool>()
                {
                    Status = false,
                    Message = "That's not an image",
                    Value = false
                });
            }
            catch (Exception e)
            {
                return(new WebResult <bool>()
                {
                    Status = false,
                    Message = e.Message,
                    Value = false
                });
            }
        }