Exemplo n.º 1
0
        public FishModels.NewFishInfo GetNewFishInfo()
        {
            try
            {
                FishModels.NewFishInfo NewFishInfo = new FishModels.NewFishInfo();

                NewFishInfo.fishID      = MiniGuid.NewGuid(); //https://github.com/jasonholloway/miniguid
                NewFishInfo.LastSpecies = 9;                  //todo - fix

                //todo get the rest...
                //  gps cords
                //  species caught


                return(NewFishInfo);
            }
            catch (Exception ex)
            {
                error.logError(ex.Message, ex.Source, ex.StackTrace, "Enter Fish", "DatabaseClass", "getNewFishInfo", HttpContext.Current.User.Identity.Name, null);
                FishModels.NewFishInfo NewFishInfo = new FishModels.NewFishInfo();
                return(NewFishInfo);
            }
        }
Exemplo n.º 2
0
        //imp! TODO: changed build config for debugging, change it back for publishing: Right click Project in solution explorer -> properties >



        //*************************************************************************************************************************************************************
        //** Main Page Actions **
        //***********************
        public ActionResult EnterFish()
        {
            //imp !  Use a ViewModel for enter fish, it handles multiple errors really nicely. Look at register and login pages for examples of how to use.

            //load last 5 species caught into session
            // todo: change this to get all recent data like last location and... ?? other stuff maybe
            //   do it all in once DB call

            // https://github.com/jasonholloway/miniguid

            // fill TempData stuff needed for a new fish
            FishModels.NewFishInfo NewFishInfo = dbClass.GetNewFishInfo();    //todo implement this later
            Session["NewFishInfo"] = NewFishInfo;

            var recentSpecies = dbClass.getRecentSpeciesByAnglerID();

            Session["RecentSpecies"] = recentSpecies;

            FishModels.Fish fish = new FishModels.Fish();   //new 11/11/18
            fish.FishID = NewFishInfo.fishID;               //new 11/11/18

            //return View("EnterFish");
            return(View("EnterFish", fish));                       //new 11/11/18
        }
Exemplo n.º 3
0
        public JsonResult AsyncUpload(IEnumerable <HttpPostedFileBase> files)
        {
            int count = 0;
            //string thumbNail;
            string   fishID        = "";
            string   imageUrl      = "";
            decimal  imageLat      = 0;
            decimal  imageLong     = 0;
            DateTime imageDateTime = new DateTime();

            if (files != null)
            {
                foreach (var file in files)
                {
                    if (file != null && file.ContentLength > 0 && file.ContentLength / 1000 < 4096)
                    {
                        //resize
                        MemoryStream           s1          = resizeImage(file, "thumb");
                        FishModels.AmazonS3Url thumbUrl    = UploadToS3(s1, "thumb");
                        MemoryStream           s2          = resizeImage(file, "1000");
                        FishModels.AmazonS3Url fullSizeUrl = UploadToS3(s2, "1000");

                        ////get Exif Data
                        Stream s = file.InputStream;
                        FishModels.ExifData e = GetExifData(s);

                        FishModels.FishImage   image       = new FishModels.FishImage();
                        FishModels.NewFishInfo newFishInfo = (FishModels.NewFishInfo)Session["NewFishInfo"];
                        image.FishID   = newFishInfo.fishID;
                        image.ExifData = e;
                        image.thumb    = thumbUrl;
                        image.fullSize = fullSizeUrl;

                        //get some stuff from first image only
                        if (count == 0)
                        {
                            imageUrl      = fullSizeUrl.url;
                            imageLat      = image.ExifData.GPSLatitude;
                            imageLong     = image.ExifData.GPSLongitude;
                            imageDateTime = image.ExifData.dateTimeTaken;
                        }

                        //save image data to DB
                        dbClass.SaveImage(image);
                        fishID = image.FishID;
                        // get weather data
                        //getWeatherData(imageLat, imageLong, image.ExifData.dateTimeTaken);
                    }

                    //upload to amazon S3
                    //save S3 key to DB

                    //get exif data
                    //save exif data to DB

                    //start API calls for weather, water level, etc...

                    //file.SaveAs(path);
                    count++;
                }
            }

            var result = new { url = imageUrl,
                               //imageKey  = fishID,
                               latitude  = imageLat,
                               longitude = imageLong,
                               imageDate = imageDateTime.ToShortDateString(),
                               imageTime = imageDateTime.ToShortTimeString() };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }