protected void OnObjectsItemDataBound(object sender, DataListItemEventArgs e) { DataObjectPicture picture = (DataObjectPicture)e.Item.DataItem; Image image = (Image)e.Item.FindControl("Img"); image.ImageUrl = _4screen.CSB.Common.SiteConfig.MediaDomainName + picture.GetImage(PictureVersion.XS); image.Attributes.Add("OnClick", string.Format("CloseWindow('{0},{1}{2},'+document.getElementById('{3}').value+','+document.getElementById('{4}').value)", picture.ObjectID.Value, _4screen.CSB.Common.SiteConfig.MediaDomainName, picture.GetImage(returnPictureVersion), ddlPicV.ClientID, ddlPicVPopup.ClientID)); }
protected void Page_Load(object sender, EventArgs e) { picture = (DataObjectPicture)dataObject; udc = UserDataContext.GetUserDataContext(); // Disable tooltip managers by default -> tooltip managers without targets don't work this.RTTM.Visible = false; if (picture != null) { foreach (string tooltipId in _4screen.CSB.DataAccess.Business.AdWordHelper.GetCampaignObjectIds(picture.ObjectID.Value)) { this.RTTM.TargetControls.Add(tooltipId, true); this.RTTM.Visible = true; } } if (Settings.ContainsKey("Width") && !string.IsNullOrEmpty(Settings["Width"].ToString())) { int width = 0; if (int.TryParse(Settings["Width"].ToString(), out width)) { if (picture.Width > width) { Img.Attributes.Add("max-width", width + "px"); } } } Img.ImageUrl = _4screen.CSB.Common.SiteConfig.MediaDomainName + picture.GetImage(PictureVersion.L); var copyrightConfig = Helper.LoadConfig("Copyrights.config", string.Format("{0}/Configurations/Copyrights.config", WebRootPath.Instance.ToString())); string copyrightText = (from copyright in copyrightConfig.Element("Copyrights").Elements("Copyright") where int.Parse(copyright.Attribute("Value").Value) == picture.Copyright select copyright.Attribute("Name").Value).Single(); LitCopyright.Text = copyrightText; if (!string.IsNullOrEmpty(picture.DescriptionLinked)) { PnlDesc.Visible = true; PnlDesc.ID = null; LitDesc.Text = picture.DescriptionLinked; } }
protected void OnAjaxUpdate(object sender, ToolTipUpdateEventArgs e) { string[] tooltipId = e.TargetControlID.Split(new char[] { '_' }); if (tooltipId.Length == 4) { Literal literal = new Literal { Text = AdWordHelper.GetCampaignContent(new Guid(tooltipId[0]), new Guid(tooltipId[1]), UserDataContext.GetUserDataContext(), tooltipId[2], "Popup") }; literal.Text = Regex.Replace(literal.Text, @"(/Pages/Other/AdCampaignRedirecter.aspx\?CID=\w{8}-\w{4}-\w{4}-\w{4}-\w{12})", "$1&OID=" + tooltipId[1] + "&Word=" + tooltipId[2] + "&Type=PopupLink"); e.UpdatePanel.ContentTemplateContainer.Controls.Add(literal); } else if (e.TargetControlID.IndexOf("Img_") > -1) { try { string pictureId = e.TargetControlID.Substring(4); DataObjectPicture picture = prodPictures.Find(x => x.ObjectID.Value == pictureId.ToGuid()); Literal literal = new Literal { Text = string.Format( "<div><div><img src=\"{0}{1}\"></div><div>{2}</div></div>", SiteConfig.MediaDomainName, picture.GetImage(PictureVersion.L), picture.Title) }; e.UpdatePanel.ContentTemplateContainer.Controls.Add(literal); } catch { } } }
protected void Page_Load(object sender, EventArgs e) { Guid? uploadSession = null; string tagWords = null; ObjectStatus? objectStatus = null; ObjectShowState?objectShowState = null; FriendType? friendType = null; int? copyright = null; double geoLat = double.MinValue; double geoLong = double.MinValue; string geoZip = null; string geoCity = null; string geoStreet = null; string geoCountry = null; if (!string.IsNullOrEmpty(Request.QueryString["UploadSession"])) { uploadSession = Request.QueryString["UploadSession"].ToGuid(); } if (!string.IsNullOrEmpty(Request.QueryString["TG"])) { tagWords = Server.UrlDecode(Request.QueryString["TG"]); } if (!string.IsNullOrEmpty(Request.QueryString["OS"])) { objectStatus = (ObjectStatus)int.Parse(Request.QueryString["OS"]); } if (!string.IsNullOrEmpty(Request.QueryString["SS"])) { objectShowState = (ObjectShowState)int.Parse(Request.QueryString["SS"]); } if (!string.IsNullOrEmpty(Request.QueryString["FT"])) { friendType = (FriendType)int.Parse(Request.QueryString["FT"]); } if (!string.IsNullOrEmpty(Request.QueryString["CR"])) { copyright = int.Parse(Request.QueryString["CR"]); } if (!string.IsNullOrEmpty(Request.QueryString["GC"])) { string[] geoLatLong = Request.QueryString["GC"].Split(','); if (geoLatLong.Length == 2) { double.TryParse(geoLatLong[0], out geoLat); double.TryParse(geoLatLong[1], out geoLong); } } if (!string.IsNullOrEmpty(Request.QueryString["ZP"])) { geoZip = Server.UrlDecode(Request.QueryString["ZP"]); } if (!string.IsNullOrEmpty(Request.QueryString["CI"])) { geoCity = Server.UrlDecode(Request.QueryString["CI"]); } if (!string.IsNullOrEmpty(Request.QueryString["RE"])) { geoStreet = Server.UrlDecode(Request.QueryString["RE"]); } if (!string.IsNullOrEmpty(Request.QueryString["CO"])) { geoCountry = Server.UrlDecode(Request.QueryString["CO"]); } picture = DataObject.Load <DataObjectPicture>(ObjectID, null, true); if (picture.State != ObjectState.Added) // Changing an existing object { if (tagWords != null) { picture.TagList = tagWords; } if (objectStatus.HasValue) { picture.Status = objectStatus.Value; } if (objectShowState.HasValue) { picture.ShowState = objectShowState.Value; } if (friendType.HasValue) { picture.FriendVisibility = friendType.Value; } if (copyright.HasValue) { picture.Copyright = copyright.Value; } if (uploadSession != null) { picture.GroupID = uploadSession; } if (geoLat != double.MinValue) { picture.Geo_Lat = geoLat; } if (geoLong != double.MinValue) { picture.Geo_Long = geoLong; } if (geoZip != null) { picture.Zip = geoZip; } if (geoCity != null) { picture.City = geoCity; } if (geoStreet != null) { picture.Street = geoStreet; } if (geoCountry != null) { picture.CountryCode = geoCountry; } // Don't save yet - save on SaveStep() FillEditForm(); } else if (uploadSession.HasValue) // Creating an new object { try { string cutFileName = FileInfo.Name.Substring(32); picture.ObjectID = Guid.NewGuid(); picture.Title = cutFileName.Substring(0, cutFileName.LastIndexOf(".")).Replace("_", " ").CropString(100); picture.CommunityID = CommunityID; if (tagWords != null) { picture.TagList = tagWords; } if (objectStatus.HasValue) { picture.Status = objectStatus.Value; } if (objectShowState.HasValue) { picture.ShowState = objectShowState.Value; } if (friendType.HasValue) { picture.FriendVisibility = friendType.Value; } if (copyright.HasValue) { picture.Copyright = copyright.Value; } if (uploadSession != null) { picture.GroupID = uploadSession; } if (geoLat != double.MinValue) { picture.Geo_Lat = geoLat; } if (geoLong != double.MinValue) { picture.Geo_Long = geoLong; } if (geoZip != null) { picture.Zip = geoZip; } if (geoCity != null) { picture.City = geoCity; } if (geoStreet != null) { picture.Street = geoStreet; } if (geoCountry != null) { picture.CountryCode = geoCountry; } _4screen.CSB.ImageHandler.Business.ImageHandler imageHandler = new _4screen.CSB.ImageHandler.Business.ImageHandler(_4screen.CSB.Common.SiteConfig.MediaDomainName, ConfigurationManager.AppSettings["ConverterRootPath"], UserProfile.Current.UserId.ToString(), picture.ObjectID.Value.ToString(), false, Server.MapPath("/Configurations")); Helper.SetActions(Helper.GetPictureFormatFromFilename(FileInfo.Name), picture.ObjectType, out saveOriginalAction, out saveLargeAction, out saveMediumAction, out saveSmallAction, out saveExtraSmallAction, out saveCropAction, imageTypes); imageHandler.DoConvert(FileInfo.FullName, saveOriginalAction, _4screen.CSB.ImageHandler.Business.ImageHandler.ReturnPath.Url); string originalImagePath = imageHandler.TargetImage; imageHandler.DoConvert(originalImagePath, saveLargeAction, _4screen.CSB.ImageHandler.Business.ImageHandler.ReturnPath.Url); picture.SizeByte = imageHandler.ImageInfo.SizeDisk; picture.Width = imageHandler.ImageInfo.Width; picture.Height = imageHandler.ImageInfo.Height; if (saveMediumAction != null) { imageHandler.DoConvert(originalImagePath, saveMediumAction, _4screen.CSB.ImageHandler.Business.ImageHandler.ReturnPath.Url); } imageHandler.DoConvert(originalImagePath, saveSmallAction, _4screen.CSB.ImageHandler.Business.ImageHandler.ReturnPath.Url); imageHandler.DoConvert(originalImagePath, saveExtraSmallAction, _4screen.CSB.ImageHandler.Business.ImageHandler.ReturnPath.Url); picture.Image = imageHandler.ImageName; foreach (var imageType in imageTypes) { picture.SetImageType(imageType.Key, imageType.Value); } if (picture.Height > 0) { picture.AspectRatio = Math.Round((decimal)picture.Width / (decimal)picture.Height, 3); } picture.Insert(UserDataContext.GetUserDataContext()); FillEditForm(); } catch (Exception ex) { this.LitMsg.Text = string.Format("{0}: ", language.GetString("MessageSaveError")) + ex.Message; } } }
protected void Page_Load(object sender, EventArgs e) { ScriptManager.GetCurrent(Page).Scripts.Add(new ScriptReference("/Library/Scripts/DragResize.js")); ScriptManager.GetCurrent(Page).Scripts.Add(new ScriptReference("/Library/Scripts/PhotoNotes.js")); ScriptManager.GetCurrent(Page).Scripts.Add(new ScriptReference("/Library/Scripts/ImageAnnotation.js")); ScriptManager.RegisterStartupScript(this, GetType(), "ImageAnnotation", "$telerik.$(function() { initImageAnnotation(); } );", true); picture = (DataObjectPicture)dataObject; udc = UserDataContext.GetUserDataContext(); btdAdd.ToolTip = language.GetString("TooltipPictureNoteAdd").StripForScript(); btnHide.ToolTip = language.GetString("TooltipPictureNoteHide").StripForScript(); btnShow.ToolTip = language.GetString("TooltipPictureNoteShow").StripForScript(); if (Request.IsAuthenticated) { btdAdd.Visible = true; } else { btdAdd.Visible = false; } // Disable tooltip managers by default -> tooltip managers without targets don't work this.RTTM.Visible = false; if (picture != null) { foreach (string tooltipId in _4screen.CSB.DataAccess.Business.AdWordHelper.GetCampaignObjectIds(picture.ObjectID.Value)) { this.RTTM.TargetControls.Add(tooltipId, true); this.RTTM.Visible = true; } } if (Settings.ContainsKey("Width") && !string.IsNullOrEmpty(Settings["Width"].ToString())) { int width = 0; if (int.TryParse(Settings["Width"].ToString(), out width)) { if (picture.Width > width) { Img.Attributes.Add("max-width", width + "px"); } } } Img.ImageUrl = _4screen.CSB.Common.SiteConfig.MediaDomainName + picture.GetImage(PictureVersion.L); LoadPictureNotes(); var copyrightConfig = Helper.LoadConfig("Copyrights.config", string.Format("{0}/Configurations/Copyrights.config", WebRootPath.Instance.ToString())); string copyrightText = (from copyright in copyrightConfig.Element("Copyrights").Elements("Copyright") where int.Parse(copyright.Attribute("Value").Value) == picture.Copyright select copyright.Attribute("Name").Value).Single(); LitCopyright.Text = copyrightText; if (!string.IsNullOrEmpty(picture.DescriptionLinked)) { PnlDesc.Visible = true; PnlDesc.ID = null; LitDesc.Text = picture.DescriptionLinked; } }
public static void GetImages(WebServiceLogEntry log, DataObjectNews receivedNews, DataObject news) { DataObject dataObject = news ?? receivedNews; DataObjectList <DataObjectPicture> newsPictures = DataObjects.Load <DataObjectPicture>(new QuickParameters() { Udc = UserDataContext.GetUserDataContext(dataObject.Nickname), RelationParams = new RelationParams() { ParentObjectID = dataObject.ObjectID, ParentObjectType = dataObject.ObjectType, ChildObjectType = Common.Helper.GetObjectType("Picture").NumericId }, IgnoreCache = true, DisablePaging = true }); foreach (DataObjectPicture newsPicture in newsPictures) { newsPicture.Delete(UserDataContext.GetUserDataContext(OperationContext.Current.ServiceSecurityContext.PrimaryIdentity.Name)); } DataObject.RelDelete(new RelationParams() { ParentObjectID = dataObject.ObjectID, ParentObjectType = dataObject.ObjectType, ChildObjectType = Common.Helper.GetObjectType("Picture").NumericId }); if (!string.IsNullOrEmpty(receivedNews.Image)) { string imageName = dataObject.ObjectID.ToString(); int width, height; decimal aspectRatio; if (GetImage(log, receivedNews.Image, Common.Helper.GetObjectType("News").NumericId, dataObject.UserID.Value, imageName, out width, out height, out aspectRatio)) { dataObject.Image = imageName; dataObject.SetImageType(PictureVersion.XS, PictureFormat.Jpg); dataObject.SetImageType(PictureVersion.S, PictureFormat.Jpg); dataObject.SetImageType(PictureVersion.L, PictureFormat.Jpg); dataObject.SetImageType(PictureVersion.A, PictureFormat.Jpg); log.FilesDownload++; } } if (receivedNews.LargePictures.Count > 0) { List <string> newsImages = receivedNews.LargePictures; List <string> newsCaptions = receivedNews.PictureCaptions; for (int i = 0; i < newsImages.Count; i++) { Guid newsPictureId = Guid.NewGuid(); int width, height; decimal aspectRatio; if (GetImage(log, newsImages[i], Common.Helper.GetObjectType("News").NumericId, dataObject.UserID.Value, newsPictureId.ToString(), out width, out height, out aspectRatio)) { DataObjectPicture newsPicture = new DataObjectPicture(UserDataContext.GetUserDataContext(dataObject.Nickname)); newsPicture.ObjectID = newsPictureId; newsPicture.Title = !string.IsNullOrEmpty(newsCaptions[i]) ? newsCaptions[i].CropString(100) : " "; newsPicture.PartnerID = dataObject.PartnerID; newsPicture.Description = newsCaptions[i]; newsPicture.TagList = dataObject.TagList; newsPicture.StartDate = dataObject.StartDate; newsPicture.EndDate = dataObject.EndDate; newsPicture.CommunityID = dataObject.CommunityID; newsPicture.Status = dataObject.Status; newsPicture.Copyright = dataObject.Copyright; newsPicture.Image = newsPictureId.ToString(); newsPicture.Width = width; newsPicture.Height = height; newsPicture.AspectRatio = aspectRatio; newsPicture.SetImageType(PictureVersion.XS, PictureFormat.Jpg); newsPicture.SetImageType(PictureVersion.S, PictureFormat.Jpg); newsPicture.SetImageType(PictureVersion.L, PictureFormat.Jpg); newsPicture.SetImageType(PictureVersion.A, PictureFormat.Jpg); newsPicture.Insert(UserDataContext.GetUserDataContext(OperationContext.Current.ServiceSecurityContext.PrimaryIdentity.Name)); DataObject.RelInsert(new RelationParams() { ParentObjectID = dataObject.ObjectID, ParentObjectType = dataObject.ObjectType, ChildObjectID = newsPicture.ObjectID, ChildObjectType = newsPicture.ObjectType }, i); log.FilesDownload++; } } } }