public JsonResult UploadImages(string activityKey, List<AdminImageModel> activityImages) { ImagesHelper imageHelper = new ImagesHelper(); imageHelper.ResizeAndUpload(activityImages.Where(e => e.Result != null).ToList(), false); List<string> images = new List<string>(); foreach (var item in activityImages) { images.Add(item.Name); } _activitiesService.SaveActivityImages(activityKey, images); return Json(true, JsonRequestBehavior.AllowGet); }
public NewClient(Guid clientToModGuid) { InitializeComponent(); new Task(() => { Dispatcher.BeginInvoke(new Action(() => { _CIVILITE_.ItemsSource = EnumsHelper.GetAllValuesAndDescriptions <PersonTitles>(); _STATUT.ItemsSource = EnumsHelper.GetAllValuesAndDescriptions <CustomerStatus>(); _NATIONALITY.ItemsSource = App.Store.Customers.AllNationalities(); if (clientToModGuid == Guid.Empty) { _isAdd = true; var obj = new Customer { Matricule = App.Store.Customers.NewMatricule(), CustomerStatus = CustomerStatus.Default, Person = new Person { Title = PersonTitles.Mr, HealthState = HealthStates.Normal, BirthDate = DateTime.Today.AddYears(-20) } }; _GRID.DataContext = obj; } else { var data = App.Store.Customers.GetCustomer(clientToModGuid); _PHOTO_IDENTITY.Source = ImagesHelper.DecodePhoto(data.Person.PhotoIdentity); _MATRICULE_VALIDATOR.IsAdd = false; _GRID.DataContext = data; _MATRICULE.IsEnabled = false; } })); }).Start(); }
public static byte[] CreateAvatar(Stream fileStream) { var image = Image.FromStream(fileStream); var size = Math.Min(image.Width, image.Height); var xOffset = (image.Width - size) / 2; var yOffset = (image.Height - size) / 2; var area = new Rectangle(xOffset, yOffset, size, size); var square = CropImage(image, area); var scale = 60f / size; var avatar = ImagesHelper.ResizeImage((Bitmap)square, scale); byte[] result; using (var stream = new MemoryStream()) { avatar.Save(stream, ImageFormat.Png); stream.Close(); result = stream.ToArray(); } return(result); }
public void HitCardSplit(bool leftDeck) { int card = Random.Next(2, 12); GameHelper.AddAcesSplit(Player, card, leftDeck); if (leftDeck) { Player.SplitDeck.ImagesLeft[Player.SplitDeck.CurrentImageLeft].Source = ImagesHelper.RandomColorCard(CardImages.First(x => x.Key == card).Value); Player.SplitDeck.CurrentImageLeft++; Player.SplitDeck.ScoreLeft += card; if (Player.SplitDeck.ScoreLeft > 21 && !GameHelper.HasAcesSplit(Player, true)) { Player.SplitDeck.FinishedLeft = true; if (Player.SplitDeck.FinishedRight) { Stand(true); } } View.DisplayPointsSplit(Player); } else { Player.SplitDeck.ImagesRight[Player.SplitDeck.CurrentImageRight].Source = ImagesHelper.RandomColorCard(CardImages.First(x => x.Key == card).Value); Player.SplitDeck.CurrentImageRight++; Player.SplitDeck.ScoreRight += card; if (Player.SplitDeck.ScoreRight > 21 && !GameHelper.HasAcesSplit(Player, false)) { Player.SplitDeck.FinishedRight = true; if (Player.SplitDeck.FinishedLeft) { Stand(true); } } View.DisplayPointsSplit(Player); } }
public async Task <IActionResult> CreatePlant([FromBody] CreatePlantDto input) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = await _plantService.CreatePlant(input); try { ImagesHelper.SaveImages(input.Slike, _env.ContentRootPath); // foreach (var slika in input.Slike) // { // byte[] bytes = Convert.FromBase64String(slika.SlikaBase64); // var path = Path.Combine(_env.ContentRootPath, "wwwroot", "images", slika.Slika); // System.IO.File.WriteAllBytes(path, bytes); // } } catch (System.Exception) { // } try { ImagesHelper.SaveImages(input.SlikeUPrirodi, _env.ContentRootPath); // foreach (var slika in input.SlikeUPrirodi) // { // byte[] bytes = Convert.FromBase64String(slika.SlikaBase64); // var path = Path.Combine(_env.ContentRootPath, "wwwroot", "images", slika.Slika); // System.IO.File.WriteAllBytes(path, bytes); // } } catch (System.Exception) { // } return(Ok(result)); }
public async Task <ActionResult <Officer> > PostOfficer([FromForm] Officer officer, IFormFile image) { _context.officers.Add(officer); string image_name = ImagesHelper.save(image); await _context.SaveChangesAsync(); var officer_id = _context.officers.Find(officer.id).id; _context.images.Add(new Image { name = image_name, imageable_id = officer_id, imageable_type = "Officer" }); await _context.SaveChangesAsync(); return(CreatedAtAction("GetOfficer", new { id = officer.id }, officer)); }
public static string[] LoadImages(List <long> ids) { dbService = new DatabaseService(); ImagesHelper imagesHelper = ImagesHelper.GetInstance(); if (!imagesHelper.AreAllAdded) { for (int i = 0; i < ids.Count; i++) { if (imagesHelper.AllImages[i] == null) { imagesHelper.AllImages[i] = ConvertByteArrayToString(GetHero(ids[i])); } if (imagesHelper.AllImages.Where(ai => ai == null).Count() == 0) { imagesHelper.AreAllAdded = true; } } } return(imagesHelper.AllImages); }
/// <summary> /// transaction /// </summary> public TransactionCard(Transaction transaction) { TransactionGuid = transaction.TransactionGuid; Designation = transaction.Designation; TransactionReference = "Ref: " + transaction.TransactionReference; PaymentMethodeString = "Par " + transaction.PaymentMethode; TransactionDateString = transaction.TransactionDate.GetValueOrDefault().ToShortDateString(); Description = transaction.Description; TresorereName = ""; //todo get tresorer Name if (transaction.Amount > 0) { AmountString = transaction.Amount.ToString("0.##", CultureInfo.CurrentCulture) + " dhs"; UpDownImage = ImagesHelper.ImageToByteArray(Resources.Down); } else { AmountString = (-transaction.Amount).ToString("0.##", CultureInfo.CurrentCulture) + " dhs"; UpDownImage = ImagesHelper.ImageToByteArray(Resources.Up); } }
/// <summary> /// SchoolFeeWrapper /// </summary> /// <param name="schoolFee"></param> public SchoolFeeCard(SchoolFee schoolFee) { SchoolFeeGuid = schoolFee.SchoolFeeGuid; Designation = schoolFee.Designation; if (schoolFee.IsPaid) { NumeroReference = "Ref: " + schoolFee.NumeroReference; Observations = schoolFee.NetAmount.ToString(CultureInfo.CurrentCulture) + " dhs" + " Payer par " + schoolFee.IsPaidBy + " a Finance User le " + schoolFee.DatePaid.GetValueOrDefault().ToShortDateString() + " par " + schoolFee.PaymentMethode.GetEnumDescription(); YesNoImage = ImagesHelper.ImageToByteArray(Resources.yes); } else { Observations = schoolFee.NetAmount.ToString(CultureInfo.CurrentCulture) + " dhs"; YesNoImage = ImagesHelper.ImageToByteArray(Resources.No); } }
public async Task <bool> StoreProfilePictureAsync(string base64Image) { var user = await this.GetApplicationUserAsync(); try { var bytes = ImagesHelper.GetImageBytesFromBase64String(base64Image); if (bytes.IsNullOrEmpty()) { return(false); } var fileId = Guid.NewGuid().ToString("N"); var filePath = await this.StorageService.StoreFileAsync(fileId, bytes); if (string.IsNullOrWhiteSpace(filePath)) { return(false); } var registeredUser = this.DbContext.RegisteredUsers.WithUserId(user.Id); var oldFileId = registeredUser.PictureId; registeredUser.PictureId = fileId; this.DbContext.SaveChanges(); if (!string.IsNullOrWhiteSpace(oldFileId)) { this.StorageService.DeleteFile(oldFileId); } return(true); } catch (Exception exception) { Logger.LogError(exception, exception.Message); return(false); } }
private void CreateThumbnailImage(HttpContext context, ImagesHelper ih, string originalPath) { var ext = Path.GetExtension(originalPath); var rndFolder = Path.GetFileNameWithoutExtension(originalPath); string[] platformNames = Enum.GetNames(typeof(Platform)); var index = 0; foreach (string name in platformNames) { string sizeAppend = WebConfigurationManager.AppSettings[name]; string[] sizeArr = sizeAppend.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < sizeArr.Length; i++) { string bmsPath = string.Format("{0}\\{1}_{2}{3}{4}", Path.GetDirectoryName(originalPath), rndFolder, index, i + 1, ext); string[] wh = sizeArr[i].Split('*'); ih.CreateThumbnailImage(originalPath, bmsPath, int.Parse(wh[0]), int.Parse(wh[1]), "DB", ext); } index++; } }
public async Task <ActionResult <Staff> > PostStaff([FromForm] Staff staff, IFormFile image) { staff.password = SecurePasswordHasher.Hash(staff.password); _context.staffs.Add(staff); await _context.SaveChangesAsync(); string image_name = ImagesHelper.save(image); var staff_id = _context.staffs.Find(staff.id).id; _context.images.Add(new Image { name = image_name, imageable_id = staff_id, imageable_type = "Staff" }); await _context.SaveChangesAsync(); return(CreatedAtAction("GetStaff", new { id = staff.id }, staff)); }
public ActionResult Create(PostViewModel postViewModel) { if (!ModelState.IsValid) { return(View(postViewModel)); } if (postViewModel.CategoryId == 0) { ModelState.AddModelError("Category", "Please Choose category"); return(View(postViewModel)); } var category = _categoryService.GetById(postViewModel.CategoryId); var model = _mapper.Map <PostViewModel, Post>(postViewModel); string path = Server.MapPath("~/Photos/"); var photo = ImagesHelper.GetPhotosUrl(postViewModel.Photo, path); model.ImageUrl = photo; model.Category = category; _postsService.Insert(model); return(RedirectToAction("Index")); }
public async Task <ActionResult <Question> > PostQuestion([FromForm] QuestionRequest request, IFormFile image) { var list = new List <string>(); foreach (string option in request.option) { list.Add(option); } request.options = JsonConvert.SerializeObject(list); var question = new Question { title = request.title, options = request.options, theory_exam_id = request.theory_exam_id, correct_answer = request.correct_answer }; _context.questions.Add(question); await _context.SaveChangesAsync(); var image_name = ImagesHelper.save(image); _context.images.Add(new Image { name = image_name, imageable_id = question.id, imageable_type = "Question" }); await _context.SaveChangesAsync(); return(CreatedAtAction("GetQuestion", new { id = question.id }, question)); }
public async Task <ActionResult> Upload(HttpPostedFileBase[] uploadImages) { if (uploadImages != null && uploadImages.Any()) { List <int> ids = new List <int>(); foreach (var image in uploadImages) { var dbimage = await ImagesHelper.SaveImageAsync(image, DbContext); if (dbimage != null) { ids.Add(dbimage.ImageId); } else { throw new HttpException(500, "Whoops."); } } return(Json(new { IsSuccess = true, Ids = ids })); } throw new HttpException(400, "No image provided."); }
public void FillMemberCard(ref string nombre, ref byte[] foto, ref string puesto, ref string empresa) { DataUsuario = new UsuariosController().GetMemberName(localStorage.Get("Usuario_Id"), localStorage.Get("Usuario_Tipo")); nombre = DataUsuario[(int)CamposMiembro.Usuario_Nombre]; foto = new UploadImages().DownloadFileFTP(DataUsuario[(int)CamposMiembro.Usuario_Fotografia], usuario_imagen_path); puesto = DataUsuario[(int)CamposMiembro.Usuario_Puesto]; empresa = DataUsuario[(int)CamposMiembro.Usuario_Empresa_Nombre]; ImageView imgFoto = context.FindViewById <ImageView>(Resource.Id.imgProfileMenu); if (foto.Length != 0) { imgFoto.SetImageBitmap(ImagesHelper.GetRoundedShape(BitmapFactory.DecodeByteArray(foto, 0, foto.Length))); } else { imgFoto.SetImageResource(Resource.Mipmap.ic_profile_empty); } TextView NombreUsuario = context.FindViewById <TextView>(Resource.Id.lblNombreMenu); NombreUsuario.Text = nombre; NombreUsuario.SetMaxWidth(context.Resources.DisplayMetrics.WidthPixels - 110); context.FindViewById <TextView>(Resource.Id.lblEmpresaMenu).Text = empresa; context.FindViewById <GridLayout>(Resource.Id.glPerfil).Click += (sender, e) => ShowPerfilCard(new UsuariosController().GetMemberData(localStorage.Get("Usuario_Id"), localStorage.Get("Usuario_Tipo"))); }
/// <summary> /// 内容相册上传 /// </summary> /// <param name="context"></param> private void OnUploadPictureContent(HttpContext context) { context.Response.ContentType = "text/plain"; string errorMsg = ""; try { HttpFileCollection files = context.Request.Files; if (files.Count == 0) { context.Response.Write("{\"success\": false,\"message\": \"未找到任何可上传的文件,请检查!\"}"); return; } object userId = WebCommon.GetUserId(); int effect = 0; UploadFilesHelper ufh = new UploadFilesHelper(); ImagesHelper ih = new ImagesHelper(); using (TransactionScope scope = new TransactionScope()) { foreach (string item in files.AllKeys) { HttpPostedFile file = files[item]; if (file == null || file.ContentLength == 0) { continue; } int fileSize = file.ContentLength; int uploadFileSize = int.Parse(WebConfigurationManager.AppSettings["UploadFileSize"]); if (fileSize > uploadFileSize) { throw new ArgumentException("文件【" + file.FileName + "】大小超出字节" + uploadFileSize + ",无法上传,请正确操作!"); } if (!UploadFilesHelper.IsFileValidated(file.InputStream, fileSize)) { throw new ArgumentException("文件【" + file.FileName + "】为受限制的文件,请正确操作!"); } string fileName = file.FileName; PictureContent bll = new PictureContent(); if (bll.IsExist(userId, file.FileName, fileSize)) { throw new ArgumentException("文件【" + file.FileName + "】已存在,请勿重复上传!"); } string originalUrl = UploadFilesHelper.UploadOriginalFile(file, "PictureContent"); //获取随机生成的文件名代码 string randomFolder = UploadFilesHelper.GetRandomFolder(originalUrl); PictureContentInfo model = new PictureContentInfo(); model.UserId = userId; model.FileName = VirtualPathUtility.GetFileName(originalUrl); model.FileSize = fileSize; model.FileExtension = VirtualPathUtility.GetExtension(originalUrl).ToLower(); model.FileDirectory = VirtualPathUtility.GetDirectory(originalUrl.Replace("~", "")); model.RandomFolder = randomFolder; model.LastUpdatedDate = DateTime.Now; bll.Insert(model); CreateThumbnailImage(context, ih, originalUrl, model.FileDirectory, model.RandomFolder, model.FileExtension); effect++; } scope.Complete(); } if (effect == 0) { context.Response.Write("{\"success\": false,\"message\": \"未找到任何可上传的文件,请检查!\"}"); return; } context.Response.Write("{\"success\": true,\"message\": \"已成功上传文件数:" + effect + "个\"}"); return; } catch (Exception ex) { errorMsg = ex.Message; } context.Response.Write("{\"success\": false,\"message\": \"" + errorMsg + "\"}"); }
public async Task <IActionResult> PutNews(int id, [FromForm] NewsRequest request, IFormFile image) { var identity = User.Identity as System.Security.Claims.ClaimsIdentity; IEnumerable <System.Security.Claims.Claim> claims = identity.Claims; var national_code = claims.Where(p => p.Type == "national_code").FirstOrDefault()?.Value; var staff = _context.staffs.Where(q => q.national_code == national_code).FirstOrDefault(); if (staff == null) { return(Unauthorized()); } if (id != request.id) { return(BadRequest()); } var news = new News { title = request.title, content = request.content, slide = request.slide, updated_at = DateTime.Now, staff_id = staff.id, }; _context.Entry(news).State = EntityState.Modified; if (request.categories != null) { _context.Entry(_context.category_news.Where(q => q.news_id == news.id)).State = EntityState.Deleted; foreach (int category_id in request.categories) { var category = _context.categories.Find(category_id); _context.category_news.Add(new CategoryNews { news_id = news.id, category_id = category_id }); } } if (image != null) { string image_name; var pImage = _context.images.Where(i => (i.imageable_id == request.id && i.imageable_type == "News")).FirstOrDefault(); ImagesHelper.delete(pImage.name); image_name = ImagesHelper.save(image); var local = _context.Set <Image>().Local.FirstOrDefault(i => i.id == pImage.id); if (local != null) { _context.Entry(local).State = EntityState.Detached; } _context.Entry(new Image { id = pImage.id, name = image_name, imageable_id = request.id, imageable_type = "News" }).State = EntityState.Modified; } try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!NewsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public LocalStorage() { dbHelper = DBHelper.Instance; imagesHelper = new ImagesHelper(); coworkingsHelper = new CoworkingsHelper(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.PerfilCardEditarLayout); miembro = JsonConvert.DeserializeObject <UsuarioModel>(Intent.GetStringExtra("Miembro")); FindViewById <ImageButton>(Resource.Id.ibCerrar).Click += (sender, e) => OnBackPressed(); imgPerfil = FindViewById <ImageView>(Resource.Id.ivPerfil); if (!string.IsNullOrEmpty(miembro.Usuario_Fotografia)) { miembro.Usuario_Fotografia_Perfil = new UploadImages().DownloadFileFTP(miembro.Usuario_Fotografia, usuario_imagen_path); photo = BitmapFactory.DecodeByteArray(miembro.Usuario_Fotografia_Perfil, 0, miembro.Usuario_Fotografia_Perfil.Length); imgPerfil.SetImageBitmap(ImagesHelper.GetRoundedShape(BitmapFactory.DecodeByteArray(miembro.Usuario_Fotografia_Perfil, 0, miembro.Usuario_Fotografia_Perfil.Length))); } else { imgPerfil.SetImageResource(Resource.Mipmap.ic_profile_empty); } imgFondo = FindViewById <ImageView>(Resource.Id.imgFondo); if (!string.IsNullOrEmpty(miembro.Usuario_Fotografia_Fondo)) { miembro.Usuario_Fotografia_FondoPerfil = new UploadImages().DownloadFileFTP(miembro.Usuario_Fotografia_Fondo, usuario_imagen_path); background = BitmapFactory.DecodeByteArray(miembro.Usuario_Fotografia_FondoPerfil, 0, miembro.Usuario_Fotografia_FondoPerfil.Length); imgFondo.SetImageBitmap(background); } FindViewById <Button>(Resource.Id.btnGuardar).Click += delegate { System.IO.MemoryStream stream = new System.IO.MemoryStream(); photo?.Compress(Bitmap.CompressFormat.Jpeg, 0, stream); miembro.Usuario_Fotografia_Perfil = stream?.ToArray(); stream = new System.IO.MemoryStream(); background?.Compress(Bitmap.CompressFormat.Jpeg, 0, stream); miembro.Usuario_Fotografia_FondoPerfil = stream?.ToArray(); if (new UsuariosController().UpdateDataMiembros(miembro.Usuario_Id, FindViewById <EditText>(Resource.Id.txtNombre).Text, FindViewById <EditText>(Resource.Id.txtApellidos).Text, miembro.Usuario_Correo_Electronico, miembro.Usuario_Telefono, miembro.Usuario_Celular, miembro.Usuario_Descripcion, DateTime.Parse(miembro.Usuario_Fecha_Nacimiento), miembro.Usuario_Fotografia_Perfil, miembro.Usuario_Fotografia_FondoPerfil)) { miembro.Redes_Sociales.AsParallel().ToList().ForEach(red => { if (!string.IsNullOrEmpty(red.Usuario_Red_Social_Id) || !string.IsNullOrEmpty(red.Red_Social_Enlace)) { new RedesSocialesController().SetRedSocial(miembro.Usuario_Id, miembro.Usuario_Tipo, red.Red_Social_Id, red.Red_Social_Enlace, red.Usuario_Red_Social_Id); } }); new EmpresaController().UpdateUsuarioEmpresaPerfil(miembro.Empresa_Actual.Empresa_Id, miembro.Usuario_Id, "", miembro.Empresa_Actual.Empresa_Nombre, miembro.Empresa_Actual.Empresa_Correo_Electronico, miembro.Empresa_Actual.Empresa_Pagina_Web, miembro.Usuario_Puesto, miembro.Empresa_Actual.Empresa_Logotipo_Perfil); Toast.MakeText(this, Resource.String.str_general_save, ToastLength.Short).Show(); Intent intent = new Intent(this, typeof(PerfilCardActivity)); intent.PutExtra("Miembro", JsonConvert.SerializeObject(new UsuariosController().GetMemberData(miembro.Usuario_Id, miembro.Usuario_Tipo))); StartActivity(intent); Finish(); } else { Toast.MakeText(this, Resource.String.str_general_save_error, ToastLength.Short).Show(); } }; FindViewById <ImageView>(Resource.Id.btnCamara).Click += delegate { Width = Height = 400; CreateDirectoryForPictures(); IsThereAnAppToTakePictures(); Intent intent = new Intent(MediaStore.ActionImageCapture); _file = new File(_dir, String.Format("{0}.jpg", Guid.NewGuid())); intent.PutExtra(MediaStore.ExtraOutput, Android.Net.Uri.FromFile(_file)); StartActivityForResult(intent, TakePicture); flag = true; }; FindViewById <ImageView>(Resource.Id.btnCamaraFondo).Click += delegate { Width = 1500; Height = 500; CreateDirectoryForPictures(); IsThereAnAppToTakePictures(); Intent intent = new Intent(MediaStore.ActionImageCapture); _file = new File(_dir, String.Format("{0}.jpg", Guid.NewGuid())); intent.PutExtra(MediaStore.ExtraOutput, Android.Net.Uri.FromFile(_file)); StartActivityForResult(intent, TakePicture); flag = false; }; FindViewById <EditText>(Resource.Id.txtNombre).Text = miembro.Usuario_Nombre; FindViewById <EditText>(Resource.Id.txtApellidos).Text = miembro.Usuario_Apellidos; FindViewById <TextView>(Resource.Id.lblEmpresa).Text = miembro.Usuario_Empresa_Nombre; ViewPager _viewPager = FindViewById <ViewPager>(Resource.Id.vpPerfil); _viewPager.Adapter = new PerfilEditarPageAdapter(this, new List <string> { Resources.GetString(Resource.String.str_profile_about_me), Resources.GetString(Resource.String.str_profile_social), Resources.GetString(Resource.String.str_profile_work) }, ref miembro); PagerSlidingTabStrip tabs = FindViewById <PagerSlidingTabStrip>(Resource.Id.tabs); tabs.SetTextColorResource(Resource.Color.comment_pressed); tabs.SetViewPager(_viewPager); }
public AutoService(IMapper mapper, SPNDbContext dbContext, IUserService userService, Cloudinary cloudinary, ImagesHelper imagesHelper) : base(mapper, dbContext) { this.userService = userService; this.cloudinary = cloudinary; this.imagesHelper = imagesHelper; }
async private void loadImage(Wrapper wrapper, string url) { await ImagesHelper.SetImageFromUrlAsync(wrapper.Miniature, url, context); }
public async Task <IActionResult> PutLicense(int id, [FromForm] LicenseRequest request, IFormFile image) { var list = new List <string>(); foreach (string condition in request.condition) { list.Add(condition); } request.conditions = JsonConvert.SerializeObject(list); var license = new License { id = request.id, name = request.name, cost = request.cost, conditions = request.conditions, updated_at = DateTime.Now, }; _context.Entry(license).State = EntityState.Modified; if (image != null) { string image_name; var pImage = _context.images.Where(i => (i.imageable_id == request.id && i.imageable_type == "License")).FirstOrDefault(); ImagesHelper.delete(pImage.name); image_name = ImagesHelper.save(image); var local = _context.Set <Image>().Local.FirstOrDefault(i => i.id == pImage.id); if (local != null) { _context.Entry(local).State = EntityState.Detached; } _context.Entry(new Image { id = pImage.id, name = image_name, imageable_id = request.id, imageable_type = "License" }).State = EntityState.Modified; } try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LicenseExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.PerfilCardLayout); miembro = JsonConvert.DeserializeObject <UsuarioModel>(Intent.GetStringExtra("Miembro")); FindViewById <ImageButton>(Resource.Id.ibCerrar).Click += (sender, e) => OnBackPressed(); imgPerfil = FindViewById <ImageView>(Resource.Id.ivPerfil); if (!string.IsNullOrEmpty(miembro.Usuario_Fotografia)) { miembro.Usuario_Fotografia_Perfil = new UploadImages().DownloadFileFTP(miembro.Usuario_Fotografia, usuario_imagen_path); photo = BitmapFactory.DecodeByteArray(miembro.Usuario_Fotografia_Perfil, 0, miembro.Usuario_Fotografia_Perfil.Length); imgPerfil.SetImageBitmap(ImagesHelper.GetRoundedShape(BitmapFactory.DecodeByteArray(miembro.Usuario_Fotografia_Perfil, 0, miembro.Usuario_Fotografia_Perfil.Length))); } else { imgPerfil.SetImageResource(Resource.Mipmap.ic_profile_empty); } imgFondo = FindViewById <ImageView>(Resource.Id.imgFondo); if (!string.IsNullOrEmpty(miembro.Usuario_Fotografia_Fondo)) { miembro.Usuario_Fotografia_FondoPerfil = new UploadImages().DownloadFileFTP(miembro.Usuario_Fotografia_Fondo, usuario_imagen_path); background = BitmapFactory.DecodeByteArray(miembro.Usuario_Fotografia_FondoPerfil, 0, miembro.Usuario_Fotografia_FondoPerfil.Length); imgFondo.SetImageBitmap(background); } FindViewById <TextView>(Resource.Id.lblNombre).Text = miembro.Usuario_Nombre + " " + miembro.Usuario_Apellidos; FindViewById <TextView>(Resource.Id.lblEmpresa).Text = miembro.Usuario_Empresa_Nombre; Button btnSeguir = FindViewById <Button>(Resource.Id.btnSeguir); FindViewById <Button>(Resource.Id.btnSendMessage).Click += delegate { Intent intent = PackageManager.GetLaunchIntentForPackage("mx.worklabs"); if (intent == null) { intent = new Intent(Intent.ActionView, Android.Net.Uri.Parse("https://play.google.com/store/apps/details?id=mx.worklabs")); } intent.AddFlags(ActivityFlags.NewTask); StartActivity(intent); }; if (miembro.Usuario_Id == storage.Get("Usuario_Id") && miembro.Usuario_Tipo == storage.Get("Usuario_Tipo")) { FindViewById <Button>(Resource.Id.btnSendMessage).Visibility = Android.Views.ViewStates.Gone; btnSeguir.Visibility = Android.Views.ViewStates.Gone; ImageView editar = FindViewById <ImageView>(Resource.Id.btnEditar); editar.Visibility = Android.Views.ViewStates.Visible; editar.Click += delegate { Intent intent = new Intent(this, typeof(PerfilCardEditarActivity)); intent.PutExtra("Miembro", Intent.GetStringExtra("Miembro")); StartActivity(intent); Finish(); }; } isFavorite = new UsuariosController().IsMiembroFavorito(storage.Get("Usuario_Id"), storage.Get("Usuario_Tipo"), miembro.Usuario_Id, miembro.Usuario_Tipo); if (!isFavorite.Value) { btnSeguir.Text = Resources.GetString(Resource.String.str_social_network_unfollow); } FindViewById <Button>(Resource.Id.btnSeguir).Click += delegate { if (isFavorite.Value) { if (new UsuariosController().RemoveMiembroFavorito(isFavorite)) { btnSeguir.Text = Resources.GetString(Resource.String.str_social_network_follow); } else { btnSeguir.Text = Resources.GetString(Resource.String.str_social_network_unfollow); } } }; ViewPager _viewPager = FindViewById <ViewPager>(Resource.Id.vpPerfil); _viewPager.Adapter = new PerfilPageAdapter(this, new List <string> { Resources.GetString(Resource.String.str_profile_about_me), Resources.GetString(Resource.String.str_profile_social), Resources.GetString(Resource.String.str_profile_work) }, miembro); PagerSlidingTabStrip tabs = FindViewById <PagerSlidingTabStrip>(Resource.Id.tabs); tabs.SetTextColorResource(Resource.Color.comment_pressed); tabs.SetViewPager(_viewPager); if (storage.Get("Usuario_Id") == miembro.Usuario_Id && storage.Get("Usuario_Tipo") == miembro.Usuario_Tipo) { imgPerfil.Click += delegate { Width = Height = 400; CreateDirectoryForPictures(); IsThereAnAppToTakePictures(); Intent intent = new Intent(MediaStore.ActionImageCapture); _file = new File(_dir, String.Format("{0}.jpg", Guid.NewGuid())); intent.PutExtra(MediaStore.ExtraOutput, Android.Net.Uri.FromFile(_file)); StartActivityForResult(intent, TakePicture); flag = true; }; imgFondo.Click += delegate { Width = 1500; Height = 500; CreateDirectoryForPictures(); IsThereAnAppToTakePictures(); Intent intent = new Intent(MediaStore.ActionImageCapture); _file = new File(_dir, String.Format("{0}.jpg", Guid.NewGuid())); intent.PutExtra(MediaStore.ExtraOutput, Android.Net.Uri.FromFile(_file)); StartActivityForResult(intent, TakePicture); flag = false; }; } }
public async Task <ActionResult <BaseResponse <CustomerDTO[]> > > Get() { return(CreateResponse(true, ImagesHelper.FillImagesURL(_mapper.Map <CustomerDTO[]>(await _repo.Get()), _options.ImagesBaseUrl))); }
async Task FillPosts() { AndHUD.Shared.Show(this, null, -1, MaskType.Black); if (page == 0) { tlPost.RemoveAllViews(); } await Task.Delay(500); posts.AsParallel().ToList().ForEach(post => { LayoutInflater liView = LayoutInflater; View PostView = liView.Inflate(Resource.Layout.PostLayout, null, true); KeyValuePair <string, string> current = new KeyValuePair <string, string>(post.Usuario.Usuario_Id, post.Usuario.Usuario_Tipo); PostView.SetMinimumWidth(Resources.DisplayMetrics.WidthPixels); ImageButton imgPerfil = PostView.FindViewById <ImageButton>(Resource.Id.imgPerfil); if (Usuario_Fotos_Perfil.ContainsKey(current)) { if (Usuario_Fotos_Perfil[current] != null && Usuario_Fotos_Perfil[current].Length != 0) { imgPerfil.SetImageBitmap(ImagesHelper.GetRoundedShape(BitmapFactory.DecodeByteArray(Usuario_Fotos_Perfil[current], 0, Usuario_Fotos_Perfil[current].Length))); } else { imgPerfil.SetImageResource(Resource.Mipmap.ic_profile_empty); } } else { post.Usuario.Usuario_Fotografia_Perfil = new UploadImages().DownloadFileFTP(post.Usuario.Usuario_Fotografia, usuario_imagen_path); Usuario_Fotos_Perfil.Add(current, post.Usuario.Usuario_Fotografia_Perfil); if (post.Usuario.Usuario_Fotografia_Perfil != null && post.Usuario.Usuario_Fotografia_Perfil.Length != 0) { imgPerfil.SetImageBitmap(ImagesHelper.GetRoundedShape(BitmapFactory.DecodeByteArray(post.Usuario.Usuario_Fotografia_Perfil, 0, post.Usuario.Usuario_Fotografia_Perfil.Length))); } else { imgPerfil.SetImageResource(Resource.Mipmap.ic_profile_empty); } } imgPerfil.Click += (sender, e) => ShowPerfilCard(new UsuariosController().GetMemberData(post.Usuario.Usuario_Id, post.Usuario.Usuario_Tipo)); TextView lblNombre = PostView.FindViewById <TextView>(Resource.Id.lblNombre); lblNombre.Text = post.Usuario.Usuario_Nombre; lblNombre.Click += (sender, e) => ShowPerfilCard(new UsuariosController().GetMemberData(post.Usuario.Usuario_Id, post.Usuario.Usuario_Tipo)); TextView lblPuesto = PostView.FindViewById <TextView>(Resource.Id.lblPuesto); lblPuesto.Text = post.Usuario.Usuario_Puesto; lblPuesto.Click += (sender, e) => ShowPerfilCard(new UsuariosController().GetMemberData(post.Usuario.Usuario_Id, post.Usuario.Usuario_Tipo)); TextView lblFecha = PostView.FindViewById <TextView>(Resource.Id.lblFecha); lblFecha.Text = post.Publicacion_Fecha; lblFecha.Click += (sender, e) => ShowPerfilCard(new UsuariosController().GetMemberData(post.Usuario.Usuario_Id, post.Usuario.Usuario_Tipo)); TextView lblPost = PostView.FindViewById <TextView>(Resource.Id.lblPost); lblPost.Text = post.Publicacion_Contenido; TextView lblLike = PostView.FindViewById <TextView>(Resource.Id.lblLikeText); lblLike.Text = post.Publicacion_Me_Gustan_Cantidad + " " + Resources.GetString(Resource.String.str_dashboard_likes); lblLike.Click += (sender, e) => ShowMeGusta(lblLike.Text, post.Publicacion_Id); ImageView imgLike = PostView.FindViewById <ImageView>(Resource.Id.imgLikes); imgLike.SetColorFilter(new Color(ContextCompat.GetColor(this, Resource.Color.button_unpressed))); imgLike.Click += delegate { string transaccion = "ALTA"; if (post.Publicacion_Me_Gusta_Usuario == ((int)TiposMeGusta.Activo).ToString()) { transaccion = "BAJA"; } else if (post.Publicacion_Me_Gusta_Usuario == ((int)TiposMeGusta.Baja).ToString()) { transaccion = "MODIFICAR"; } if (new EscritorioController().PostLike(post.Publicacion_Id, localStorage.Get("Usuario_Id"), localStorage.Get("Usuario_Tipo"), transaccion)) { lblLike.Text = new EscritorioController().GetLikesPublish(post.Publicacion_Id) + " " + Resources.GetString(Resource.String.str_dashboard_likes); if (transaccion == "BAJA") { post.Publicacion_Me_Gusta_Usuario = "0"; lblLike.SetTextColor(Color.Black); imgLike.SetColorFilter(Resources.GetColor(Resource.Color.button_unpressed)); } else { post.Publicacion_Me_Gusta_Usuario = "1"; imgLike.SetColorFilter(Resources.GetColor(Resource.Color.like_heart_pressed)); lblLike.SetTextColor(Color.Rgb(57, 87, 217)); } } }; if (post.Publicacion_Me_Gusta_Usuario == ((int)TiposMeGusta.Activo).ToString()) { imgLike.SetColorFilter(new Color(ContextCompat.GetColor(this, Resource.Color.like_heart_pressed))); } ImageView imgPost = PostView.FindViewById <ImageView>(Resource.Id.imgPost); if (!string.IsNullOrEmpty(post.Publicacion_Imagen)) { post.Publicacion_Imagen_Post = new UploadImages().DownloadFileFTP(post.Publicacion_Imagen, publicaciones_imagen_path); if (post.Publicacion_Imagen_Post != null && post.Publicacion_Imagen_Post.Length != 0) { imgPost.Visibility = ViewStates.Visible; Bitmap img = BitmapFactory.DecodeByteArray(post.Publicacion_Imagen_Post, 0, post.Publicacion_Imagen_Post.Length); imgPost.SetImageBitmap(Bitmap.CreateScaledBitmap(img, Resources.DisplayMetrics.WidthPixels, img.Height * Resources.DisplayMetrics.WidthPixels / img.Width, true)); imgPost.Click += delegate { //AndHUD.Shared.ShowImage(this, Drawable.CreateFromStream()); }; } } TextView lblComentario = PostView.FindViewById <TextView>(Resource.Id.lblComentariosText); lblComentario.Text = post.Publicacion_Comentarios_Cantidad + " " + Resources.GetString(Resource.String.str_social_network_comments); ImageView imgComentario = PostView.FindViewById <ImageView>(Resource.Id.imgComments); imgComentario.SetColorFilter(Resources.GetColor(Resource.Color.button_unpressed)); imgComentario.Click += delegate { Intent intent = new Intent(this, typeof(CommentsActivity)); intent.PutExtra("post_id", post.Publicacion_Id); intent.PutExtra("comments_total", post.Publicacion_Comentarios_Cantidad); StartActivity(intent); }; if (post.Publicacion_Comentarios_Cantidad != "0") { imgComentario.SetColorFilter(Resources.GetColor(Resource.Color.comment_pressed)); } if (localStorage.Get("Usuario_id") == post.Usuario.Usuario_Id && localStorage.Get("Usuario_Tipo") == post.Usuario.Usuario_Tipo) { PostView.FindViewById <ImageView>(Resource.Id.imgMore).Click += delegate { using (PopupMenu menuPost = new PopupMenu(this, PostView.FindViewById <ImageView>(Resource.Id.imgMore), GravityFlags.Center)) { menuPost.Inflate(Resource.Menu.post_reporte_menu); menuPost.MenuItemClick += async delegate { if (DashboardController.OcultarPost(post.Usuario.Usuario_Id, post.Usuario.Usuario_Tipo, post.Publicacion_Id)) { Toast.MakeText(this, "Publicación eliminada", ToastLength.Short).Show(); page = 0; posts = DashboardController.GetMuroPosts(localStorage.Get("Usuario_Id"), localStorage.Get("Usuario_Tipo"), page, sizePage); await FillPosts(); } else { Toast.MakeText(this, "Existió un error al eliminar la publicación", ToastLength.Short).Show(); } }; menuPost.Show(); } }; } else { PostView.FindViewById <ImageView>(Resource.Id.imgMore).Visibility = ViewStates.Gone; } TableRow row = new TableRow(this); row.AddView(PostView); tlPost.AddView(row); }); AndHUD.Shared.Dismiss(this); }
public void FillDirectorioUsuario(List <UsuarioModel> miembros) { LinearLayout llDirectorio = new LinearLayout(context) { LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent), Orientation = Orientation.Vertical }; string aux = ""; miembros.ForEach((miembro) => { KeyValuePair <string, string> current = new KeyValuePair <string, string>(miembro.Usuario_Id, miembro.Usuario_Tipo); if (miembro.Usuario_Nombre[0].ToString() != aux) { LinearLayout llList = new LinearLayout(context); llList.SetBackgroundColor(Color.Rgb(149, 214, 255)); TextView lblCapital = new TextView(context); LinearLayout.LayoutParams ll = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent) { LeftMargin = 50 }; lblCapital.LayoutParameters = ll; aux = miembro.Usuario_Nombre[0].ToString(); lblCapital.Text = aux; llList.AddView(lblCapital); llDirectorio.AddView(llList); } LayoutInflater liView = (LayoutInflater)context.GetSystemService(Context.LayoutInflaterService); View PersonaCard = liView.Inflate(Resource.Layout.PreViewListLayout, null, true); ImageButton ibProfile = PersonaCard.FindViewById <ImageButton>(Resource.Id.ibProfile); if (imagenes.ContainsKey(current)) { ibProfile.SetImageBitmap(ImagesHelper.GetRoundedShape(BitmapFactory.DecodeByteArray(imagenes[current], 0, imagenes[current].Length))); } else if (!string.IsNullOrEmpty(miembro.Usuario_Fotografia)) { imagenes.Add(current, new UploadImages().DownloadFileFTP(miembro.Usuario_Fotografia, usuario_imagen_path)); ibProfile.SetImageBitmap(ImagesHelper.GetRoundedShape(BitmapFactory.DecodeByteArray(imagenes[current], 0, imagenes[current].Length))); } else { ibProfile.SetImageResource(Resource.Mipmap.ic_profile_empty); } TextView lblNombre = PersonaCard.FindViewById <TextView>(Resource.Id.lblTitle); lblNombre.Text = miembro.Usuario_Nombre + " " + miembro.Usuario_Apellidos; lblNombre.Click += delegate { ShowPerfilCard(miembro); }; PersonaCard.FindViewById <Button>(Resource.Id.btnSeguir).Visibility = ViewStates.Gone; TextView lblEmpresa = PersonaCard.FindViewById <TextView>(Resource.Id.lblSubTitle); lblEmpresa.Text = miembro.Usuario_Empresa_Nombre; llDirectorio.AddView(PersonaCard); }); svDirectorio.AddView(llDirectorio); }
async void OpenDashboard() { SetContentView(Resource.Layout.DashboardLayout); Toolbar toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); SetActionBar(toolbar); ActionBar.Title = Resources.GetString(Resource.String.Escritorio); ActionBar.SetDisplayHomeAsUpEnabled(true); ActionBar.SetHomeAsUpIndicator(Resource.Mipmap.ic_menu_white); menu.FillMemberCard(ref nombre, ref foto, ref puesto, ref empresa); Usuario_Fotos_Perfil.Add(new KeyValuePair <string, string>(localStorage.Get("Usuario_Id"), localStorage.Get("Usuario_Tipo")), foto); menu.FillMenu(); FindViewById <TextView>(Resource.Id.lblNombre).Text = nombre; FindViewById <TextView>(Resource.Id.lblPuesto).Text = puesto; ImageView imgPerfil = FindViewById <ImageView>(Resource.Id.imgPerfil); if (foto.Length != 0) { imgPerfil.SetImageBitmap(ImagesHelper.GetRoundedShape(BitmapFactory.DecodeByteArray(foto, 0, foto.Length))); } else { imgPerfil.SetImageResource(Resource.Mipmap.ic_profile_empty); } scroll = FindViewById <ScrollView>(Resource.Id.post_scroll); tlPost = FindViewById <TableLayout>(Resource.Id.post_table); FindViewById <Button>(Resource.Id.btnInitPublish).Click += (sender, e) => ShowPublish(); SwipeRefreshLayout refresher = FindViewById <SwipeRefreshLayout>(Resource.Id.swipe_container); refresher.SetColorSchemeColors(Color.Gray, Color.LightGray, Color.Gray, Color.DarkGray, Color.Black, Color.DarkGray); refresher.Refresh += async(sender, e) => { page = 0; posts = DashboardController.GetMuroPosts(localStorage.Get("Usuario_Id"), localStorage.Get("Usuario_Tipo"), page, sizePage); await FillPosts(); ((SwipeRefreshLayout)sender).Refreshing = false; }; posts = DashboardController.GetMuroPosts(localStorage.Get("Usuario_Id"), localStorage.Get("Usuario_Tipo"), page, sizePage); await FillPosts(); scroll.ScrollChange += async(sender, e) => { if (posts.Count / (page + 1) > sizePage - 1) { if ((((ScrollView)sender).ScrollY / (page + 1)) > ((scroll.Height) / 2)) { ++page; posts = DashboardController.GetMuroPosts(localStorage.Get("Usuario_Id"), localStorage.Get("Usuario_Tipo"), page, sizePage); await FillPosts(); } } }; SearchView svBuscar = FindViewById <SearchView>(Resource.Id.svBuscar); svBuscar.QueryTextSubmit += async(sender, e) => { ((SearchView)sender).ClearFocus(); page = 0; if (((SearchView)sender).Query.Length != 0) { posts = posts.Where(post => post.Publicacion_Contenido.IndexOf(((SearchView)sender).Query, StringComparison.OrdinalIgnoreCase) >= 0 || post.Usuario.Usuario_Nombre.IndexOf(((SearchView)sender).Query, StringComparison.OrdinalIgnoreCase) >= 0).ToList(); } await FillPosts(); }; svBuscar.QueryTextChange += async(sender, e) => { if (((SearchView)sender).Query.Length == 0) { ((SearchView)sender).ClearFocus(); page = 0; posts = DashboardController.GetMuroPosts(localStorage.Get("Usuario_Id"), localStorage.Get("Usuario_Tipo"), page, sizePage); await FillPosts(); } }; IsPlayServicesAvailable(); Console.WriteLine("Test" + FirebaseInstanceId.Instance.Token); }
private void OnUploadCommunionPicture(HttpContext context) { context.Response.ContentType = "text/plain"; string errorMsg = ""; try { HttpFileCollection files = context.Request.Files; if (files.Count == 0) { context.Response.Write("{\"success\": false,\"message\": \"未找到任何可上传的文件,请检查!\"}"); return; } int effect = 0; UploadFilesHelper ufh = new UploadFilesHelper(); ImagesHelper ih = new ImagesHelper(); using (TransactionScope scope = new TransactionScope()) { foreach (string item in files.AllKeys) { HttpPostedFile file = files[item]; if (file == null || file.ContentLength == 0) { continue; } int fileSize = file.ContentLength; int uploadFileSize = int.Parse(ConfigHelper.GetValueByKey("UploadFileSize")); if (fileSize > uploadFileSize) { throw new ArgumentException("文件【" + file.FileName + "】大小超出字节" + uploadFileSize + ",无法上传,请正确操作!"); } if (!UploadFilesHelper.IsFileValidated(file.InputStream, fileSize)) { throw new ArgumentException("文件【" + file.FileName + "】为受限制的文件,请正确操作!"); } CommunionPicture bll = new CommunionPicture(); if (bll.IsExist(file.FileName, fileSize)) { throw new ArgumentException("文件【" + file.FileName + "】已存在,请勿重复上传!"); } string originalUrl = UploadFilesHelper.UploadOriginalFile(file, "CommunionPicture"); //获取随机生成的文件名代码 string randomFolder = string.Format("{0}_{1}", DateTime.Now.ToString("MMdd"), UploadFilesHelper.GetRandomFolder("cmp")); CommunionPictureInfo model = new CommunionPictureInfo(); model.FileName = VirtualPathUtility.GetFileName(originalUrl); model.FileSize = fileSize; model.FileExtension = VirtualPathUtility.GetExtension(originalUrl).ToLower(); model.FileDirectory = VirtualPathUtility.GetDirectory(originalUrl.Replace("~", "")); model.RandomFolder = randomFolder; model.LastUpdatedDate = DateTime.Now; bll.Insert(model); string rndDirFullPath = context.Server.MapPath(string.Format("~{0}{1}", model.FileDirectory, model.RandomFolder)); if (!Directory.Exists(rndDirFullPath)) { Directory.CreateDirectory(rndDirFullPath); } File.Copy(context.Server.MapPath(originalUrl), string.Format("{0}\\{1}{2}", rndDirFullPath, randomFolder, model.FileExtension), true); string[] platformNames = Enum.GetNames(typeof(EnumData.Platform)); foreach (string name in platformNames) { string platformUrl = string.Format("{0}/{1}/{2}", model.FileDirectory, model.RandomFolder, name); string platformUrlFullPath = context.Server.MapPath("~" + platformUrl); if (!Directory.Exists(platformUrlFullPath)) { Directory.CreateDirectory(platformUrlFullPath); } string sizeAppend = ConfigHelper.GetValueByKey(name); string[] sizeArr = sizeAppend.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < sizeArr.Length; i++) { string bmsPicUrl = string.Format("{0}\\{1}_{2}{3}", platformUrlFullPath, model.RandomFolder, i, model.FileExtension); string[] wh = sizeArr[i].Split('*'); ih.CreateThumbnailImage(context.Server.MapPath(originalUrl), bmsPicUrl, int.Parse(wh[0]), int.Parse(wh[1]), "DB", model.FileExtension); } } effect++; } scope.Complete(); } if (effect == 0) { context.Response.Write("{\"success\": false,\"message\": \"未找到任何可上传的文件,请检查!\"}"); return; } context.Response.Write("{\"success\": true,\"message\": \"已成功上传文件数:" + effect + "个\"}"); return; } catch (Exception ex) { errorMsg = ex.Message; } context.Response.Write("{\"success\": false,\"message\": \"" + errorMsg + "\"}"); }
public void AddNewTab(TabControlTabAddingEventArgs e) { e.Item = NaturePhoto.Create("New Las Vegas Photo", ImagesHelper.GetRandomLasVegasPhoto()); }
private void UploadPdaOrderProcess(HttpContext context) { #region 请求参数集 var Id = Guid.Empty; if (context.Request.Form["Id"] != null) { Guid.TryParse(context.Request.Form["Id"], out Id); } if (Id.Equals(Guid.Empty)) { throw new ArgumentException(MC.Request_Params_InvalidError); } //string orderCode = string.Empty; //if (context.Request.Form["OrderCode"] != null) orderCode = context.Request.Form["OrderCode"].Trim(); //string customerCode = string.Empty; //if (context.Request.Form["CustomerCode"] != null) customerCode = context.Request.Form["CustomerCode"].Trim(); string stepName = string.Empty; if (context.Request.Form["OrderStep"] != null) { stepName = context.Request.Form["OrderStep"].Trim(); } string staffCode = string.Empty; if (context.Request.Form["LoginId"] != null) { staffCode = context.Request.Form["LoginId"].Trim(); } var picture = string.Empty; string deviceId = string.Empty; if (context.Request.Form["DeviceId"] != null) { deviceId = context.Request.Form["DeviceId"].Trim(); } string latlng = string.Empty; if (context.Request.Form["Latlng"] != null) { latlng = context.Request.Form["Latlng"].Trim(); } string latlngPlace = string.Empty; string ip = HttpClientHelper.GetClientIp(context); string ipPlace = string.Empty; #endregion new CustomException(string.Format("Id:{0}--stepName:{1}--staffCode:{2}--picture:{3}--deviceId:{4}--latlng:{5}--ip:{6}", Id, stepName, staffCode, picture, deviceId, latlng, ip)); HttpFileCollection files = context.Request.Files; if (files.Count > 0) { ImagesHelper ih = new ImagesHelper(); foreach (string item in files.AllKeys) { HttpPostedFile file = files[item]; if (file == null || file.ContentLength == 0) { continue; } FileValidated(file); string originalUrl = UploadFilesHelper.UploadOriginalFile(file, "PdaPictures"); picture = originalUrl.Trim('~'); CreateThumbnailImage(context, ih, context.Server.MapPath(originalUrl)); } } var pictures = new List <string>(); //var orderId = Guid.Empty; //var oldOrderInfo = new OrderMake().GetModel(orderCode, customerCode); //if (oldOrderInfo != null) orderId = oldOrderInfo.Id; var opBll = new OrderProcess(); var effect = 0; var currTime = DateTime.Now; var opInfo = new OrderProcessInfo(Id, Guid.Empty, staffCode, stepName, picture, deviceId, latlng, latlngPlace, ip, ipPlace, currTime, currTime); var oldOpInfo = opBll.GetModel(Id); if (oldOpInfo != null) { opInfo.OrderId = oldOpInfo.OrderId; if (!string.IsNullOrWhiteSpace(oldOpInfo.Pictures)) { pictures = oldOpInfo.Pictures.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries).ToList(); if (!pictures.Any(s => s.Equals(picture))) { pictures.Add(picture); } } else { pictures.Add(picture); } opInfo.Pictures = string.Join("|", pictures); if (oldOpInfo.Ip == ip) { opInfo.IpPlace = oldOpInfo.IpPlace; } if (oldOpInfo.Latlng == latlng) { opInfo.LatlngPlace = oldOpInfo.LatlngPlace; } effect = opBll.Update(opInfo); } else { throw new ArgumentException(MC.Data_NotExist); } if (effect > 0) { context.Response.Write(ResResult.ResJsonString(true, "", string.Join("|", pictures))); } else { context.Response.Write(ResResult.ResJsonString(false, MC.M_Save_Error, "")); } }
public JsonResult UploadImages(List<AdminImageModel> locationImages) { ImagesHelper imageHelper = new ImagesHelper(); imageHelper.ResizeAndUpload(locationImages.Where(e => e.Result != null).ToList(), true); return Json(true, JsonRequestBehavior.AllowGet); }