Exemplo n.º 1
0
        public ActionResult _EditPhoto(string spaceKey, PhotoEditModel photoEditModel)
        {
            IUser currentUser = UserContext.CurrentUser;

            if (currentUser == null)
            {
                return(Json(new StatusMessageData(StatusMessageType.Hint, "您尚未登录!")));
            }

            Photo photo = photoEditModel.AsPhoto();

            if (!authorizer.Photo_Edit(photo))
            {
                return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel
                {
                    Body = "没有编辑照片的权限",
                    Title = "没有权限",
                    StatusMessageType = StatusMessageType.Hint
                })));
            }

            //设置标签
            string relatedTags = Request.Form.Get <string>("RelatedTags");

            if (!string.IsNullOrEmpty(relatedTags))
            {
                tagService.ClearTagsFromItem(photo.PhotoId, photo.UserId);
                tagService.AddTagsToItem(relatedTags, photo.UserId, photo.PhotoId);
            }

            photoService.UpdatePhoto(photo, currentUser.UserId);

            return(Json(new { description = photo.Description }));
        }
Exemplo n.º 2
0
        public IActionResult UploadFile(IList <IFormFile> files, int?parentFolder, [FromServices] SavePhotoCommand savePhotoCommand)
        {
            var list = new List <string>();

            foreach (var file in files)
            {
                var model = new PhotoEditModel();
                model.FileName       = Path.GetFileName(file.FileName);
                model.Thumbnail      = Path.GetFileName(file.FileName);
                model.ParentFolderId = parentFolder;
                model.File           = file;

                var img       = ImageFile.FromStream(file.OpenReadStream());
                var latObject = (GPSLatitudeLongitude)img.Properties.FirstOrDefault(p => p.Name == "GPSLatitude");
                var lonObject = (GPSLatitudeLongitude)img.Properties.FirstOrDefault(p => p.Name == "GPSLongitude");
                if (latObject != null && lonObject != null)
                {
                    model.Latitude  = latObject.ToFloat();
                    model.Longitude = lonObject.ToFloat();
                }

                list.AddRange(savePhotoCommand.Validate(model));

                savePhotoCommand.Execute(model);
            }

            ViewBag.Messages = list;

            return(View());
        }
Exemplo n.º 3
0
        public IActionResult UploadFile(IList <IFormFile> files, int?parentFolder, [FromServices] SavePhotoCommand savePhotoCommand)
        {
            var list = new List <string>();

            foreach (var file in files)
            {
                var model = new PhotoEditModel();
                model.FileName       = Path.GetFileName(file.FileName);
                model.Thumbnail      = Path.GetFileName(file.FileName);
                model.ParentFolderId = parentFolder;
                model.File           = file;

                var img = ExifLibrary.ImageFile.FromStream(file.OpenReadStream());
                foreach (var prop in img.Properties)
                {
                    Debug.WriteLine(prop.Name + ": " + prop.Value);
                }
                list.AddRange(savePhotoCommand.Validate(model));

                savePhotoCommand.Execute(model);
            }

            ViewBag.Messages = list;

            return(View());
        }
Exemplo n.º 4
0
        public ActionResult UploadNormal(string spaceKey, long albumId = 0)
        {
            string errorMessage = string.Empty;

            if (!authorizer.Photo_Create(photoService.GetAlbum(albumId), out errorMessage))
            {
                return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel
                {
                    Body = errorMessage,
                    Title = "没有权限",
                    StatusMessageType = StatusMessageType.Hint
                })));
            }

            string photoIds          = Request.Form["photoIds"];
            RouteValueDictionary dic = new RouteValueDictionary();

            for (int i = 0; i < Request.Files.Count; i++)
            {
                HttpPostedFileBase postFile = Request.Files[i];
                if (!string.IsNullOrEmpty(postFile.FileName))
                {
                    PhotoEditModel photoEditModel = new PhotoEditModel();
                    photoEditModel.AlbumId = albumId;
                    Photo photo = photoEditModel.AsPhoto();
                    try
                    {
                        photoService.CreatePhoto(photo, postFile);
                        photoIds += photo.PhotoId + ",";
                        TempData["photoCount"] = i + 1;
                    }
                    catch (System.Exception e)
                    {
                        photoService.DeletePhoto(photo);
                        TempData["photoIds"]     = photoIds;
                        TempData["errorMessage"] = e.Message.Replace("\r\n", "");
                        TempData["albumId"]      = albumId;
                        TempData["isContinue"]   = bool.Parse(Request.Form["isContinue"]);
                        return(RedirectToAction("UploadEdit"));
                    }
                }
            }
            TempData["photoIds"]     = photoIds;
            TempData["errorMessage"] = "success";
            TempData["albumId"]      = albumId;
            TempData["isContinue"]   = bool.Parse(Request.Form["isContinue"]);
            return(RedirectToAction("UploadEdit"));
        }
Exemplo n.º 5
0
        public IActionResult Edit(int id)
        {
            var item = _dataContext.Photos.FirstOrDefault(i => i.Id == id);

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

            var model = new PhotoEditModel();

            model.Title = item.Title;
            model.Id    = item.Id;

            return(View(model));
        }
Exemplo n.º 6
0
        private void Image_MouseDown(object sender, MouseButtonEventArgs e)
        {
            //SelectedImage.Imagepath = ImageLIstBox.
            Image clickedOnItem = (Image)GetParentDependencyObjectFromVisualTree((DependencyObject)e.MouseDevice.DirectlyOver, typeof(Image));

            if (clickedOnItem != null)
            {
                __Pathupdate         = PathUpdate.getInstance();
                __Pathupdate.PathImg = ((ImageDetails)clickedOnItem.DataContext).Path_Orginal;                                   //clickedOnItem.Source.ToString();
                ServiceProvider.Settings.EditImageByte = DSLR_Tool_PC.StaticClass.ConvertImageToByteArray(__Pathupdate.PathImg); //.Substring(8)) ;// ; //converterDemo(clickedOnItem);
                ServiceProvider.Settings.SelectedBitmap.DisplayEditImage = (WriteableBitmap)BitmapLoader.Instance.LoadImage(__Pathupdate.PathImg, BitmapLoader.LargeThumbSize, 0);

                //PhotoEditModel.GetInstance().ImagePath = Pathupdate.PathImg.Substring(8);
                PhotoEditModel.GetInstance().ImageData = ServiceProvider.Settings.EditImageByte;
            }
        }
Exemplo n.º 7
0
        public IActionResult Edit(PhotoEditModel model, [FromServices] EditCommand editCmd)
        {
            var item = _dataContext.Photos.FirstOrDefault(i => i.Id == model.Id);

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

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            editCmd.Execute(model);

            return(RedirectToAction("Details", new { id = model.Id }));
        }
Exemplo n.º 8
0
        public IActionResult Edit(PhotoEditModel model)
        {
            var item = _dataContext.Photos.FirstOrDefault(i => i.Id == model.Id);

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

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            item.Title = model.Title;

            _dataContext.SaveChanges();

            return(RedirectToAction("Details", new { id = model.Id }));
        }
Exemplo n.º 9
0
        public IActionResult UploadFile(IList <IFormFile> files, int?parentFolder, [FromServices] SavePhotoCommand savePhotoCommand)
        {
            var list = new List <string>();

            foreach (var file in files)
            {
                var model = new PhotoEditModel();
                model.FileName       = Path.GetFileName(file.FileName);
                model.Thumbnail      = Path.GetFileName(file.FileName);
                model.ParentFolderId = parentFolder;
                model.File           = file;

                list.AddRange(savePhotoCommand.Validate(model));

                savePhotoCommand.Execute(model);
            }

            ViewBag.Messages = list;

            return(View());
        }
Exemplo n.º 10
0
        public ActionResult UploadPhoto(string spaceKey, long albumId = 0)
        {
            if (albumId <= 0)
            {
                return(Json("请选择相册!"));
            }
            string errorMessage = string.Empty;

            if (!authorizer.Photo_Create(photoService.GetAlbum(albumId), out errorMessage))
            {
                return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel
                {
                    Body = errorMessage,
                    Title = "没有权限",
                    StatusMessageType = StatusMessageType.Hint
                })));
            }

            //上传照片及创建照片记录
            HttpPostedFileBase postFile       = Request.Files["fileData"];
            PhotoEditModel     photoEditModel = new PhotoEditModel();

            photoEditModel.AlbumId = albumId;
            Photo photo = photoEditModel.AsPhoto();

            try
            {
                photoService.CreatePhoto(photo, postFile);
            }
            catch (System.Exception e)
            {
                photoService.DeletePhoto(photo);
                return(Json(e.Message));
            }

            return(Json(photo.PhotoId));
        }
Exemplo n.º 11
0
 private void IntiService()
 {
     __photoEditModel = PhotoEditModel.GetInstance();
     __photoEditModel.ExecuteInti(this);
 }