public static DataObjectNews CreateNews(DataObjectNews receivedDataObject) { WebServiceLogEntry log = new WebServiceLogEntry() { ServiceType = WebServiceType.REST, ServiceName = "IDataService", Method = "CreateNews", Parameters = "DataObjectNews" }; try { DataServiceHelper.Create(log, receivedDataObject, Common.Helper.GetObjectType("News").NumericId); Helper.GetImages(log, receivedDataObject, null); receivedDataObject.Update(UserDataContext.GetUserDataContext(OperationContext.Current.ServiceSecurityContext.PrimaryIdentity.Name)); if (receivedDataObject.State == ObjectState.Saved) { log.Write(HttpStatusCode.OK.ToString()); return(receivedDataObject); } throw new RESTException(HttpStatusCode.NotFound, "Not Updated (specific)"); } catch (RESTException e) { log.Message = e.StatusDescription; log.Write(e.StatusCode.ToString()); return(null); } catch (Exception e) { Helper.SetResponseStatus(log, HttpStatusCode.InternalServerError, string.Format("Not Created -> {0}", e.Message)); log.ExtendedMessage = e.StackTrace; log.Write(); return(null); } }
public static DataObjectNews GetNews(string externalObjectId) { WebServiceLogEntry log = new WebServiceLogEntry() { ServiceType = WebServiceType.REST, ServiceName = "IDataService", Method = "GetNews", Parameters = externalObjectId }; try { DataObjectNews dataObject = (DataObjectNews)DataServiceHelper.Get(log, externalObjectId, Common.Helper.GetObjectType("News").NumericId); log.Write(HttpStatusCode.OK.ToString()); return(dataObject); } catch (RESTException e) { log.Message = e.StatusDescription; log.Write(e.StatusCode.ToString()); return(null); } catch (Exception e) { Helper.SetResponseStatus(log, HttpStatusCode.InternalServerError, string.Format("Not Found -> {0}", e.Message)); log.ExtendedMessage = e.StackTrace; log.Write(); return(null); } }
protected void Page_Load(object sender, EventArgs e) { // Disable tooltip managers by default -> tooltip managers without targets don't work this.RTTM.Visible = false; this.RTTMIMG.Visible = false; this.news = (DataObjectNews)dataObject; if (news != null) { foreach (string tooltipId in _4screen.CSB.DataAccess.Business.AdWordHelper.GetCampaignObjectIds(news.ObjectID.Value)) { this.RTTM.TargetControls.Add(tooltipId, true); this.RTTM.Visible = true; } } this.LitDate.Text = news.StartDate.ToShortDateString() + " " + news.StartDate.ToShortTimeString(); this.LitDescription.Text = news.DescriptionLinked; this.LitContent.Text = news.NewsTextLinked; StringBuilder sb = new StringBuilder(); foreach (Link link in news.Links) { sb.AppendFormat("<div><a href=\"{0}\">{1}</a></div>", link.URL, link.Title); } this.LitLinks.Text = sb.ToString(); newsPictures = DataObjects.Load <DataObjectPicture>(new QuickParameters { RelationParams = new RelationParams { ParentObjectID = news.ObjectID }, ShowState = ObjectShowState.Published, Amount = 0, Direction = QuickSortDirection.Asc, PageNumber = 0, PageSize = 999999, SortBy = QuickSort.RelationSortNumber, Udc = UserDataContext.GetUserDataContext(), ObjectType = Helper.GetObjectTypeNumericID("Picture") }); foreach (DataObject picture in newsPictures) { string imageId = "Img_" + picture.ObjectID.Value.ToString(); this.RTTMIMG.TargetControls.Add(imageId, true); this.RTTMIMG.Visible = true; LiteralControl image = new LiteralControl(string.Format("<div style=\"float:left;width:110px;\"><div><img class ='articlepic' src=\"{0}{1}\" id=\"{2}\" /></div><div>{3}</div></div>", _4screen.CSB.Common.SiteConfig.MediaDomainName, picture.GetImage(PictureVersion.XS), imageId, picture.Title)); this.PhNewsImgs.Controls.Add(image); } }
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++; } } } }
public DataObjectNews UpdateNews(DataObjectNews receivedNews) { return(DataServiceNews.UpdateNews(receivedNews)); }
protected void Page_Load(object sender, EventArgs e) { news = DataObject.Load <DataObjectNews>(ObjectID, null, true); if (news.State == ObjectState.Added) { news.ObjectID = ObjectID; news.Title = GuiLanguage.GetGuiLanguage("Shared").GetString("LabelUnnamed"); news.CommunityID = CommunityID; news.ShowState = ObjectShowState.Draft; news.Insert(UserDataContext.GetUserDataContext()); news.Title = string.Empty; } if (!string.IsNullOrEmpty(Request.QueryString["TG"])) { news.TagList = Server.UrlDecode(Request.QueryString["TG"]); } if (!string.IsNullOrEmpty(Request.QueryString["OS"])) { news.Status = (ObjectStatus)int.Parse(Request.QueryString["OS"]); } if (!string.IsNullOrEmpty(Request.QueryString["SS"])) { news.ShowState = (ObjectShowState)int.Parse(Request.QueryString["SS"]); } if (!string.IsNullOrEmpty(Request.QueryString["CR"])) { news.Copyright = int.Parse(Request.QueryString["CR"]); } if (!string.IsNullOrEmpty(Request.QueryString["GC"])) { string[] geoLatLong = Request.QueryString["GC"].Split(','); double geoLat, geoLong = double.MinValue; if (geoLatLong.Length == 2) { if (double.TryParse(geoLatLong[0], out geoLat) && double.TryParse(geoLatLong[1], out geoLong)) { news.Geo_Lat = geoLat; news.Geo_Long = geoLong; } } } if (!string.IsNullOrEmpty(Request.QueryString["ZP"])) { news.Zip = Server.UrlDecode(Request.QueryString["ZP"]); } if (!string.IsNullOrEmpty(Request.QueryString["CI"])) { news.City = Server.UrlDecode(Request.QueryString["CI"]); } if (!string.IsNullOrEmpty(Request.QueryString["RE"])) { news.Street = Server.UrlDecode(Request.QueryString["RE"]); } if (!string.IsNullOrEmpty(Request.QueryString["CO"])) { news.CountryCode = Server.UrlDecode(Request.QueryString["CO"]); } FillEditForm(); }