/// <summary> /// Sets the value to field. /// </summary> /// <param name="args">ClientPipelineArgs</param> /// <param name="selectedImage">Selected image</param> private void ImportImageFinished(ClientPipelineArgs args, SelectedImageModel selectedImage) { var itemIdString = args.Parameters[Templates.ImportImageClientPipeline.Parameters.MediaItemId]; if (!string.IsNullOrEmpty(itemIdString)) { var itemId = new ID(itemIdString); var mediaItem = _imageService.GetImageById(itemId); if (mediaItem != null) { this.SetValue(mediaItem); this.Update(); this.SetModified(); } else { SheerResponse.Alert(_statusMessageService.GetJobStatusValueCouldNotSet()); FotoWareFieldsLog.WriteToLog("--- FotoWareImageField: Could not set field-value ---"); } } else { SheerResponse.Alert(_statusMessageService.GetJobStatusValueCouldNotSet()); FotoWareFieldsLog.WriteToLog("--- FotoWareImageField: Could not set field-value ---"); } }
/// <summary> /// Sets the value to field. /// </summary> /// <param name="args"></param> /// <param name="selectedImage"></param> private void ImportImageFinished(ClientPipelineArgs args, SelectedImageModel selectedImage) { var itemIdString = args.Parameters[Templates.ImportImageClientPipeline.Parameters.MediaItemId]; if (!string.IsNullOrEmpty(itemIdString)) { var itemId = new ID(itemIdString); var mediaUrl = _imageService.GetImageUrlById(itemId); if (!string.IsNullOrEmpty(mediaUrl)) { var imageResponse = new RichTextImageResponse { Url = mediaUrl, Alt = selectedImage.Alt }; var imageResponeJson = JsonConvert.SerializeObject(imageResponse); SheerResponse.Eval("scClose(" + StringUtil.EscapeJavascriptString(imageResponeJson) + ")"); } else { SheerResponse.Alert(_statusMessageService.GetJobStatusValueCouldNotSet()); FotoWareFieldsLog.WriteToLog("--- SelectImageFromFotoWare Dialog: Could not set field-value ---"); } } else { SheerResponse.Alert(_statusMessageService.GetJobStatusValueCouldNotSet()); FotoWareFieldsLog.WriteToLog("--- SelectImageFromFotoWare Dialog: Could not set field-value ---"); } }
/// <summary> /// Sets the value to field. /// </summary> /// <param name="args"></param> /// <param name="selectedImage"></param> private void ImportImageFinished(ClientPipelineArgs args, SelectedImageModel selectedImage) { Assert.ArgumentNotNull((object)args, nameof(args)); Item itemNotNull = Client.GetItemNotNull(args.Parameters["itemid"], Language.Parse(args.Parameters["language"])); itemNotNull.Fields.ReadAll(); Field field = itemNotNull.Fields[args.Parameters["fieldid"]]; Assert.IsNotNull((object)field, "field"); ImageField imageField = new ImageField(field, field.Value); string parameter = args.Parameters["controlid"]; string xml = args.Parameters[Templates.ImportImageClientPipeline.Parameters.FieldValue]; var itemIdString = args.Parameters[Templates.ImportImageClientPipeline.Parameters.MediaItemId]; if (!string.IsNullOrEmpty(itemIdString)) { var itemId = new ID(itemIdString); var mediaItem = _imageService.GetImageById(itemId); if (mediaItem != null) { imageField.SetAttribute("mediaid", mediaItem.ID.ToString()); if (xml.Length > 0) { XmlValue xmlValue = new XmlValue(xml, "image"); string attribute1 = xmlValue.GetAttribute("height"); if (!string.IsNullOrEmpty(attribute1)) { imageField.Height = attribute1; } string attribute2 = xmlValue.GetAttribute("width"); if (!string.IsNullOrEmpty(attribute2)) { imageField.Width = attribute2; } } SheerResponse.SetAttribute("scHtmlValue", "value", WebEditImageCommand.RenderImage(args, imageField.Value)); SheerResponse.SetAttribute("scPlainValue", "value", imageField.Value); SheerResponse.Eval("scSetHtmlValue('" + parameter + "')"); } else { SheerResponse.Alert(_statusMessageService.GetJobStatusValueCouldNotSet()); FotoWareFieldsLog.WriteToLog("--- SelectImageImageFieldCommand: Could not set field-value ---"); } } else { SheerResponse.Alert(_statusMessageService.GetJobStatusValueCouldNotSet()); FotoWareFieldsLog.WriteToLog("--- SelectImageImageFieldCommand: Could not set field-value ---"); } }