public async Task <Unit> Handle(AddImageToBlogPostRequest request, CancellationToken cancellationToken) { var post = await unitOfWork.BlogPostRepository.GetById(request.BlogPostId); if (request.Image != null) { var image = new AppImage() { ImageByteArray = ImageConverter.ConvertToByteArray(request.Image) }; await unitOfWork.ImageRepository.Create(image); post.AppImage = image; await unitOfWork.BlogPostRepository.Update(post); } var success = await unitOfWork.SaveAsync() > 0; if (success) { return(Unit.Value); } throw new Exception(); }
public ImageViewer() { ResultColImages = new AppImage[StaticGameData.CountResultColumns]; GameColImages = new AppImage[StaticGameData.CountGameColumns]; AdditionalColImages = new AppImage[GameWindowConstants.CountAdditionalColumns]; DeckColImage = new AppImage(); }
public void CapNhat(ChucNang cn) { try { List <SqlParameter> lstParameter = new List <SqlParameter>(); lstParameter.Add(new SqlParameter("@MaChucNang", cn.ModuleID)); lstParameter.Add(new SqlParameter("@MaChucNangBacTren", cn.MaChucNangBacTren)); lstParameter.Add(new SqlParameter("@TenChucNang", cn.ModuleName)); lstParameter.Add(new SqlParameter("@TenForm", cn.GUIName)); lstParameter.Add(new SqlParameter("@ThuTu", cn.Order)); lstParameter.Add(new SqlParameter("@PhanLoai", cn.PhanLoai)); lstParameter.Add(new SqlParameter("@HinhAnh", AppImage.ImageToBase64String(cn.HinhAnh, ImageFormat.Png))); lstParameter.Add(new SqlParameter("@HinhAnhForm", AppImage.ImageToBase64String(cn.AnhChup, ImageFormat.Png))); lstParameter.Add(new SqlParameter("@IDGridView", cn.MaGridView)); lstParameter.Add(new SqlParameter("@SelectStore", cn.SelectStore)); lstParameter.Add(new SqlParameter("@InsertStore", cn.InsertStore)); lstParameter.Add(new SqlParameter("@DeleteStore", cn.DeleteStore)); lstParameter.Add(new SqlParameter("@UpdateStore", cn.UpdateStore)); lstParameter.Add(new SqlParameter("@TrangThai", cn.TrangThai)); DataProvider.ExecNonQueryStore("sp_ChucNang_CapNhat", lstParameter); } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Image,AppId")] AppImage appImage) { if (id != appImage.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(appImage); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AppImageExists(appImage.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["AppId"] = new SelectList(_context.Apps, "Id", "Name", appImage.AppId); return(View(appImage)); }
private void Checkpoint() { if (mEyes == null) { mAct.Error = "Applitools Eyes is not opened"; mAct.ExInfo = "You require to add Eyes.Open Action on step before."; return; } SetEyesMatchLevel(); AppImage response = mEyes.CheckImage(mDriver.GetScreenShot()); mAct.AddOrUpdateReturnParamActual("ExactMatches", response.IsMatch.ToString()); bool FailActionOnMistmach = Boolean.Parse(mAct.GetInputParamValue(ApplitoolsAnalyzer.FailActionOnMistmach)); if (response.IsMatch == true || !FailActionOnMistmach) { mAct.Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Passed; if (!FailActionOnMistmach) { mAct.ExInfo = "Created new baseline in Applitools or Mismatch between saved baseline and target checkpoint image"; } } else if (response.IsMatch == false) { mAct.Error = "Created new baseline in Applitools or Mismatch between saved baseline and target checkpoint image"; } }
private List <AppImage> GetNewImages(string title) { var images = new List <AppImage>(); var sql = string.Format("SELECT * from Image " + "where Title = '{0}' order by ID", title); try { using (var cmd = new MySqlCommand(sql, _connection)) { using (var r = cmd.ExecuteReader()) { while (r.Read()) { var img = new AppImage { Abstract = r.GetString("Abstract"), Title = r.GetString("Title"), URL = r.GetString("Location") }; images.Add(img); } } } } catch (Exception ex) { var stackFrame = new StackFrame(); var methodBase = stackFrame.GetMethod(); Database.InsertErrorToDb(methodBase.Name, ex.Message, ex.ToString()); } return(images); }
public HScrollViewCell2() { this.BackgroundColor = Color.Transparent; this.Padding = peopleListOffset; profileImage = new AppImage() { WidthRequest = profileImageWidth, HeightRequest = profileImageHeight, VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.Center, BackgroundColor = Color.Transparent, StrokeWidth = profileStrokeWidth, StrokeColor = Color.Black, }; profileImage.SetBinding(AppImage.StrokeColorProperty, "strokeColor"); var profileImageContent = new ContentView { Content = profileImage, }; Label peopleName = new Label { VerticalOptions = LayoutOptions.End, HorizontalOptions = LayoutOptions.Center, FontSize = peopleNameFontSize, BackgroundColor = Color.Transparent, }; peopleName.SetBinding(AppLabel.TextProperty, "name"); var peopleNameContent = new StackLayout { Children = { peopleName } }; var viewLayout = new StackLayout() { Orientation = StackOrientation.Vertical, Children = { profileImageContent, peopleNameContent }, BackgroundColor = Color.Transparent }; Content = viewLayout; }
public void Should_serialize_and_deserialize() { var appImage = new AppImage("image/png"); var serialized = appImage.SerializeAndDeserialize(); Assert.Equal(appImage, serialized); }
public void Should_serialize_and_deserialize() { var appImage = new AppImage("image/png"); var serialized = appImage.SerializeAndDeserialize(); serialized.Should().BeEquivalentTo(appImage); }
private void card_Drop(object sender, DragEventArgs e) { AppImage tempImage = sender as AppImage; int iCol = Grid.GetColumn(tempImage); int iRow = Grid.GetRow(tempImage); AddIntoNewPlace(iCol, iRow); }
public SearchesTemplate() { var searchImageWidth = 20; var searchImageHeight = 20; var searchLabelHeadingSize = MainPage.PageHeight / 45.636; var searchLabelDetailSize = MainPage.PageHeight / 60.636; var searchOffset = 5; searchImage = new AppImage { WidthRequest = searchImageWidth, HeightRequest = searchImageHeight, Source = "clock_gray", }; searchLabelHeading = new AppLabel { FontSize = searchLabelHeadingSize, }; searchLabelHeading.SetBinding(AppLabel.TextProperty, "searchHeading"); searchLabelDetail = new AppLabel { FontSize = searchLabelDetailSize, Opacity = 0.5, }; searchLabelDetail.SetBinding(AppLabel.TextProperty, "searchDetail"); searchDetailContent = new StackLayout { VerticalOptions = LayoutOptions.StartAndExpand, Spacing = 0, Children = { searchLabelHeading, searchLabelDetail } }; var searchLeftOffset = MainPage.PageHeight / 67.342; searchFinalContent = new StackLayout { Padding = new Thickness(searchLeftOffset, searchOffset, 0, 0), Orientation = StackOrientation.Horizontal, Children = { searchImage, searchDetailContent } }; View = searchFinalContent; }
public IEnumerable <AppImage> GetImagesFromDb(string title, string link) { var images = new List <AppImage>(); var imagesNotInDb = false; try { _connection.Open(); var sql = string.Format("SELECT Location, Abstract from Image " + "where Title = '{0}' order by ID", title); using (var cmd = new MySqlCommand(sql, _connection)) { using (var r = cmd.ExecuteReader()) { if (r.HasRows) { while (r.Read()) { var img = new AppImage { URL = r.GetString("Location"), Abstract = r.GetString("Abstract") }; images.Add(img); } } else { imagesNotInDb = true; } } } if (imagesNotInDb) { //no images in db so insert them GetImages(title, link); //now get them and send back to phone images = GetNewImages(title); } } catch (Exception ex) { var stackFrame = new StackFrame(); var methodBase = stackFrame.GetMethod(); Database.InsertErrorToDb(methodBase.Name, ex.Message, ex.ToString()); } finally { _connection.Close(); } return(images); }
public void Should_create_app_image() { var imageEtag = "etag"; var imageMime = "image/png"; var appImage = new AppImage(imageMime, imageEtag); Assert.Equal(imageEtag, appImage.Etag); Assert.Equal(imageMime, appImage.MimeType); }
public int SaveRecordImageAsync(AppImage image) { if (image.tableID != 0) { return(database.Update(image)); } else { return(database.Insert(image)); } }
protected override void OnElementChanged(ElementChangedEventArgs <Image> args) { base.OnElementChanged(args); _appImage = (this.Element as AppImage); //var appImage = (this.Element as AppImage); //if (appImage != null) // appImage.Source = appImage.ImageUri; this.CreateCircle(); }
private void InitialzeResultColumnImages(Grid grid) { for (int index = 0; index < ResultColImages.Length; index++) { ResultColImages[index] = new AppImage { ImageSource = Helper.GetImageSourceFromResource("Resources/Ace.png") }; grid.Children.Add(ResultColImages[index]); Grid.SetRow(ResultColImages[index], GameWindowConstants.iRowResColsGrid); Grid.SetColumn(ResultColImages[index], grid.GetResGridColIndex(index)); } }
private void Checkpoint() { if (mEyes == null) { mAct.Error = "Applitools Eyes is not opened"; mAct.ExInfo = "You require to add Eyes.Open Action on step before."; return; } SetEyesMatchLevel(); AppImage response = mEyes.CheckImage(mDriver.GetScreenShot()); mAct.Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Passed; }
protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Image> args) { base.OnElementChanged(args); _appImage = (this.Element as AppImage); if (args.OldElement == null) { if ((int)Android.OS.Build.VERSION.SdkInt < 18) { this.SetLayerType(LayerType.Software, null); } } }
private void InitializeGameColumnImages(Grid grid) { for (int index = 0; index < GameColImages.Length; index++) { GameColImages[index] = new AppImage { ImageSource = Helper.GetImageSourceFromResource("Resources/King.png") }; grid.Children.Add(GameColImages[index]); Grid.SetRow(GameColImages[index], GameWindowConstants.iRowGameColsGrid); Grid.SetColumn(GameColImages[index], grid.GetGameGridColIndex(index)); } }
public async Task <IActionResult> Create([Bind("Id,Name,Image")] AppImage appImage) { if (ModelState.IsValid) { appImage.AppId = 1; //default before change in app's create _context.Add(appImage); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["AppId"] = new SelectList(_context.Apps, "Id", "Name"); return(View(appImage)); }
void ShowProfilePicture() { Device.BeginInvokeOnMainThread(() => { try { AppImage image = App.Database.GetUserProfilePicture(Ultis.Settings.SessionUserItem.DriverId); profilePic.Source = (image != null) ? ImageSource.FromStream(() => new MemoryStream(image.imageData)) : "user_icon.png"; } catch { } }); loading.IsVisible = false; }
public SignUpPage() { InitializeComponent(); var tapGestureRecognizer = new TapGestureRecognizer(); tapGestureRecognizer.Tapped += (sender, e) => { AppImage theImage = (AppImage)sender; Image1.Opacity = 0.4; Image2.Opacity = 0.4; imagePicked = theImage.ImageName; theImage.Opacity = 1; }; Image1.GestureRecognizers.Add(tapGestureRecognizer); Image2.GestureRecognizers.Add(tapGestureRecognizer); }
protected override PMSObject PhanTichDataRow(DataRow dr) { ChucNang cn = new ChucNang(); cn.ModuleID = (string)XuLyKieuDuLieu.ThayTheNull(dr["ModuleID"], typeof(string)); cn.Order = (int)XuLyKieuDuLieu.ThayTheNull(dr["Order"], typeof(int)); //cn.ChucNangBacTren = LayDuLieu((string)XuLyKieuDuLieu.ThayTheNull(dr["MaChucNangBacTren"], typeof(string))); cn.MaChucNangBacTren = (string)XuLyKieuDuLieu.ThayTheNull(dr["MaChucNangBacTren"], typeof(string)); cn.ModuleName = (string)XuLyKieuDuLieu.ThayTheNull(dr["ModuleName"], typeof(string)); cn.GUIName = (string)XuLyKieuDuLieu.ThayTheNull(dr["GUIName"], typeof(string)); cn.LoaiChucNang = new LoaiChucNang_Data().LayDuLieu((string)dr["PhanLoai"]); cn.HinhAnh = AppImage.Base64StringToImage((string)XuLyKieuDuLieu.ThayTheNull(dr["HinhAnh"], null)); cn.MaGridView = (string)XuLyKieuDuLieu.ThayTheNull(dr["IDGridView"], typeof(string)); cn.SelectStore = (string)XuLyKieuDuLieu.ThayTheNull(dr["SelectStore"], typeof(string)); cn.InsertStore = (string)XuLyKieuDuLieu.ThayTheNull(dr["InsertStore"], typeof(string)); cn.DeleteStore = (string)XuLyKieuDuLieu.ThayTheNull(dr["DeleteStore"], typeof(string)); cn.UpdateStore = (string)XuLyKieuDuLieu.ThayTheNull(dr["UpdateStore"], typeof(string)); cn.TrangThai = (bool)XuLyKieuDuLieu.ThayTheNull(dr["TrangThai"], typeof(bool)); cn.ListModuleGetData = _dataModule.LayModuleCungCapDuLieu(cn.ModuleID); return(cn); }
public async Task uploadProfileImage(int userId, string image) { try { AppImage appImage = new AppImage(); appImage.fileName = userId.ToString() + ".jpeg"; appImage.image = Convert.FromBase64String(image); appImage.storage = Storage.ProfileStorage; var profileUrl = await imageService.SaveFile(appImage); var user = await _contexto.Users.FindAsync(userId); user.ProfileImage = profileUrl; await _contexto.SaveChangesAsync(); } catch (Exception e) { throw e; } }
/// <summary> /// Uploads image file to storage /// </summary> /// <param name="pathFile">Full path to picture file</param> /// <returns>(<see cref="AppImage"/>) App image object</returns> public static AppImage UploadImage(string pathFile) { string hash, token; using (var stream = File.Open(pathFile, FileMode.Open, FileAccess.Read, FileShare.Read)) { hash = RestController.GetMd5Hash(stream); var resp1 = RestController.HttpRequestJson( UriCxm.AppsGetImageSas, Method.GET); token = JsonConvert.DeserializeObject <string>(resp1.Content); var blob = new CloudBlockBlob(new Uri(token)); stream.Position = 0; blob.UploadFromStream(stream); blob.SetProperties(); } var response = RestController.HttpRequestJson( UriCxm.AppsCreateThumbnails, Method.POST, new { hash = hash, sas = token } ); var tnUrl = JsonConvert.DeserializeObject <string>(response.Content); var result = new AppImage { ImageName = hash, FullImageUrl = string.Empty, ShowImageUrl = tnUrl, ThumbnailUrl = tnUrl }; return(result); }
private void AddThumbnailToImageGrid(Image image, AppImage appImage) { image.HeightRequest = imageWidth; image.HorizontalOptions = LayoutOptions.FillAndExpand; image.VerticalOptions = LayoutOptions.FillAndExpand; image.Aspect = Aspect.AspectFill; var tapGestureRecognizer = new TapGestureRecognizer(); tapGestureRecognizer.CommandParameter = appImage; tapGestureRecognizer.Tapped += async(sender, e) => { await Navigation.PushAsync(new ImageViewer((AppImage)((TappedEventArgs)e).Parameter)); }; image.GestureRecognizers.Add(tapGestureRecognizer); int noOfImages = imageGrid.Children.Count(); int noOfCols = imageGrid.ColumnDefinitions.Count(); int rowNo = noOfImages / noOfCols; int colNo = noOfImages - (rowNo * noOfCols); imageGrid.Children.Add(image, colNo, rowNo); }
private void InitializeAdditionalColumnImages(Grid grid) { for (int index = 0; index < AdditionalColImages.Length; index++) { AdditionalColImages[index] = new AppImage(); grid.Children.Add(AdditionalColImages[index]); Grid.SetRow(AdditionalColImages[index], GameWindowConstants.iRowAdditionalColsGrid); } //deck grid.Children.Add(DeckColImage); Grid.SetRow(DeckColImage, GameWindowConstants.iRowAdditionalColsGrid); //static data DeckColImage.ImageSource = Helper.GetImageSourceFromResource("Resources/CardBack/2.png"); AdditionalColImages[GameWindowConstants.iImageKing].ImageSource = Helper.GetImageSourceFromResource("Resources/King.png"); AdditionalColImages[GameWindowConstants.iImageJoker].ImageSource = Helper.GetImageSourceFromResource("Resources/Empty.png"); Grid.SetColumn(DeckColImage, _gameWindowData.iGridColDeck); Grid.SetColumn(AdditionalColImages[GameWindowConstants.iImageKing], _gameWindowData.iGridColKing); Grid.SetColumn(AdditionalColImages[GameWindowConstants.iImageJoker], _gameWindowData.iGridColJoker); }
public async Task <string> SaveFile(AppImage appImage) { CloudStorageAccount account = CloudStorageAccount.Parse(_config["StorageAccount:BlobConnection"]); CloudBlobClient blobClient = account.CreateCloudBlobClient(); CloudBlobContainer container; if (appImage.storage == Storage.CoverStorage) { container = blobClient.GetContainerReference("cover-images"); } else { container = blobClient.GetContainerReference("profile-images"); } CloudBlockBlob blockBlob = container.GetBlockBlobReference(appImage.fileName); await blockBlob.UploadFromByteArrayAsync(appImage.image, 0, appImage.image.Length); return(blockBlob.Uri.ToString()); }
//covert signature to image and store in local db public static async Task StoreSignature(string id, Stream signature, ContentPage contentPage) { try { byte[] signatureAsBytes; using (var memoryStream = new MemoryStream()) { signature.CopyTo(memoryStream); signature.Dispose(); signatureAsBytes = memoryStream.ToArray(); } string systemDate = DateTime.Now.ToShortDateString(); string[] date = systemDate.Split('/'); string customDate = date[2].ToString() + date[1].ToString() + date[0].ToString(); Random random = new Random(); int randomID = random.Next(1000000); AppImage captureSignature = new AppImage(); captureSignature.id = id; captureSignature.imageData = signatureAsBytes; captureSignature.photoFileLocation = ""; captureSignature.photoFileName = "SIGN_" + customDate + "_" + randomID + ".png"; captureSignature.photoThumbnailFileLocation = ""; captureSignature.photoScaledFileLocation = ""; captureSignature.scaleResolution = 0; captureSignature.Uploaded = false; captureSignature.type = "signature"; App.Database.SaveRecordImageAsync(captureSignature); } catch { await contentPage.DisplayAlert("Reminder", "Please sign the job.", "OK"); } }
public AppImage Add(AppImage image) { this.images.Add(image); this.images.SaveChanges(); return(image); }
public AppImage Add(AppImage image) { this.images.Add(image); this.images.SaveChanges(); return image; }