public Task Populate(string inputFile, CancellationToken cancellationToken = default) { dgvOtherBooks.Rows.Clear(); var authorProfile = JsonUtil.DeserializeFile <AuthorProfile>(inputFile); var author = authorProfile.Authors?.FirstOrDefault(); if (author != null) { lblAuthorMore.Text = $" Kindle Books By {author.Name}"; Text = $"About {author.Name}"; lblBiography.Text = author.Bio ?? ""; if (author.Picture != null) { pbAuthorImage.Image = ImageUtil.Base64ToImage(author.Picture); } } if (authorProfile.OtherBooks != null) { foreach (var book in authorProfile.OtherBooks) { dgvOtherBooks.Rows.Add($" {book.Title}"); } } return(Task.CompletedTask); }
public Task Populate(string inputFile, CancellationToken cancellationToken = default) { string input; using (var streamReader = new StreamReader(inputFile, Encoding.UTF8)) input = streamReader.ReadToEnd(); dgvOtherBooks.Rows.Clear(); var ap = JObject.Parse(input); var tempData = ap["u"]?[0]; if (tempData != null) { lblAuthorMore.Text = $" Kindle Books By {tempData["n"]}"; Text = $"About {lblAuthorMore.Text}"; lblBiography.Text = tempData["b"]?.ToString() ?? ""; var image64 = tempData["i"]?.ToString() ?? ""; if (image64 != "") { pbAuthorImage.Image = ImageUtil.Base64ToImage(image64).ToGrayscale3(); } } tempData = ap["o"]; if (tempData != null) { foreach (var rec in tempData) { dgvOtherBooks.Rows.Add(" " + rec["t"], Resources.arrow_right); } } return(Task.Delay(1, cancellationToken)); }
private long CreatePartyAttribute(long ID) { PartyAttribute attribute = null; if (ID == 0) { attribute = new PartyAttribute(); attribute.ID = 0; } else { attribute = PartyAttribute.Find(iSabayaContext, ID); if (attribute == null) { return(0); } // Set Properties } if (ctrlAttributeKey.SelectedNode == null) { return(0); } attribute.Party = this.GetPartyOwner(); attribute.AttributeKey = ctrlAttributeKey.SelectedNode; attribute.AttributeKeyRootNode = ctrlAttributeKey.SelectedNode.Root; DateTime dateFrom = ctrlEffectiveFrom.Date; dateFrom = new DateTime(dateFrom.Year, dateFrom.Month, dateFrom.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second); attribute.EffectivePeriod = new TimeInterval(dateFrom, ctrlEffectiveTo.Date); attribute.ValueDate = ctrlValueDate.Date; if (!string.IsNullOrEmpty(hddValueImage.Value)) { attribute.ValueImage = ImageUtil.Base64ToImage(hddValueImage.Value); } attribute.ValueMLS = ctrlValueMLS.Value; attribute.ValueNode = null; attribute.ValueNodeRoot = null; attribute.ValueNumber = Convert.ToSingle(spnValueNumber.Value); attribute.ValueText = txtValueText.Text; if (OwnerID != 0) { attribute.Save(iSabayaContext); } else { ICategorizedTemporalList <PartyAttribute> attributes = PartyAttributes; for (int i = 0; i < attributes.Count; i++) { if (attributes[i].AttributeKey.NodeID == attribute.AttributeKey.NodeID) { attributes.Remove(attributes[i]); break; } } PartyAttributes.Add(attribute); } return(attribute.ID); }
protected void cbpValueImage_Callback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e) { if (!string.IsNullOrEmpty(e.Parameter)) { System.Drawing.Image originalimage = ImageUtil.Base64ToImage(e.Parameter); Size aspectSize = ImageUtil.GetAspectSize(originalimage.Size, 100); ctrlValueImage.ContentBytes = ImageUtil.ImageToBytes(originalimage); ctrlValueImage.Width = aspectSize.Width; ctrlValueImage.Height = aspectSize.Height; hddValueImage.Value = e.Parameter; } }
public bool IsValid <T>(T value) { var data = value as UserPhotoUpdateRequest; if (string.IsNullOrEmpty(data.PhotoUrl)) { Errors = GetErrors(new ArgumentNullException(data.PhotoUrl)); } var image = ImageUtil.Base64ToImage(data.PhotoUrl); if (image.Width < 100 || image.Height < 100) { Errors = GetErrors(new PhotoSizeInvalidException(nameof(data.PhotoUrl))); } return(Errors == null || !Errors.Any()); }
public bool IsValid <T>(T value) { try { if (value == null) { return(false); } ImageUtil.Base64ToImage(value.ToString()); return(true); } catch (Exception e) { Errors = GetErrors(e); return(false); } }