public async Task <Content> CreateContent(ContentRequest payload) { Contract.Requires <ArgumentNullException>(payload != null); using (var request = CreateMessage(HttpMethod.Post, Uri.Combine("content"), payload)) return(await SendAsync <Content>(request)); }
public Task <ContentServiceResponse> GetContentAsync(ContentRequest request, CancellationToken cancellationToken = default(CancellationToken)) { IBasicProperties props = channel.CreateBasicProperties(); var correlationId = Guid.NewGuid().ToString(); props.CorrelationId = correlationId; props.ReplyTo = replyQueueName; Byte[] messageBytes; var formatter = new BinaryFormatter(); using (var stream = new MemoryStream()) { formatter.Serialize(stream, request); messageBytes = stream.ToArray(); } var tcs = new TaskCompletionSource <ContentServiceResponse>(); callbackMapper.TryAdd(correlationId, tcs); channel.BasicConsume(consumer: consumer, queue: replyQueueName, autoAck: true); channel.BasicPublish(exchange: "", routingKey: QUEUE_NAME, mandatory: false, basicProperties: props, body: messageBytes); cancellationToken.Register(() => callbackMapper.TryRemove(correlationId, out var tmp)); return(tcs.Task); }
public async Task <ActionResult <ContentResult> > Edit([FromBody] ContentRequest request) { if (request.FileType == "html") { if (!await _authManager.HasSitePermissionsAsync(request.SiteId, Types.SitePermissions.TemplatesIncludes)) { return(Unauthorized()); } } else { if (!await _authManager.HasSitePermissionsAsync(request.SiteId, Types.SitePermissions.TemplatesAssets)) { return(Unauthorized()); } } var site = await _siteRepository.GetAsync(request.SiteId); if (site == null) { return(NotFound()); } return(await SaveFile(request, site, false)); }
public async Task <ActionResult <ContentResult> > Add([FromBody] ContentRequest request) { if (_settingsManager.IsSafeMode) { return(this.Error(Constants.ErrorSafeMode)); } if (request.FileType == "html") { if (!await _authManager.HasSitePermissionsAsync(request.SiteId, MenuUtils.SitePermissions.TemplatesIncludes)) { return(Unauthorized()); } } else { if (!await _authManager.HasSitePermissionsAsync(request.SiteId, MenuUtils.SitePermissions.TemplatesAssets)) { return(Unauthorized()); } } var site = await _siteRepository.GetAsync(request.SiteId); if (site == null) { return(NotFound()); } return(await SaveFile(request, site, false)); }
public ContentViewModel Create(ContentRequest request) { Authorized(); var content = new Content(); content.Title = request.Title; content.Body = request.Body; content.HtmlBody = Markdown.Encode(content.Body); content.UserId = user.Id; content.Type = request.Type; var id = ContentApi.Insert(content); TagManager.SetTagsForContent(id, request.Tags); if (request.ParentId != null) { ContentApi.Relate(request.ParentId.Value, id); } return(ContentApi.Select(id).AsViewModel() .WithChildren() .WithChildrenCount() .WithTags()); }
public async Task <ActionResult> SetContentTemplate() { var content = new ContentRequest { Template = new Template { Id = 123456 } }; try { await Manager.Content.AddOrUpdateAsync("d4688e21b2", content); return(RedirectToAction("Detail")); } catch (MailChimpException mce) { return(new HttpStatusCodeResult(HttpStatusCode.BadGateway, mce.Message)); } catch (Exception ex) { return(new HttpStatusCodeResult(HttpStatusCode.ServiceUnavailable, ex.Message)); } }
public void Get(ContentRequest request) { var fullPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "Content", request.filePath); Response.WriteFile(fullPath); Response.End(); }
private static string CreateCampignWithContent(CreativeVm model) { IMailChimpManager manager = new MailChimpManager(); //AddLog(db, model.OrderNumber, "Creating campaign with contents"); var campaign = manager.Campaigns.AddAsync(new MailChimp.Net.Models.Campaign { Settings = new Setting { ReplyTo = "*****@*****.**", Title = model.SubjectLine, FromName = "Josh Silver", SubjectLine = model.SubjectLine, }, Type = CampaignType.Regular, }).ConfigureAwait(false); var campaignId = campaign.GetAwaiter().GetResult().Id; var content = new ContentRequest { //PlainText = model.Creatives, Html = model.Creatives, }; manager.Content.AddOrUpdateAsync(campaignId, content); return(campaignId); }
public ContentViewModel Update(ContentRequest request) { Authorized(); if (request.ContentId == null) { throw new ArgumentNullException(nameof(request.ContentId)); } var userId = user?.Id; if (userId == null) { throw new ArgumentNullException(nameof(request), "User must be set to update an answer"); } TagManager.SetTagsForContent((int)request.ContentId, request.Tags); var htmlBody = Markdown.Encode(request.Body); ContentApi.Update(request.ContentId.Value, request.Title, request.Body, htmlBody, (int)userId); return(ContentApi.Select(request.ContentId.Value) .AsViewModel() .WithAll()); }
public ContentViewModel Create(ContentRequest request) { Authorized(); var content = new Content(); content.Title = request.Title; content.Body = request.Body; content.HtmlBody = Markdown.Encode(content.Body); content.UserId = user.Id; content.Type = request.Type; var id = ContentApi.Insert(content); TagManager.SetTagsForContent(id, request.Tags); if (request.ParentId != null) { ContentApi.Relate(request.ParentId.Value, id); } var item = ContentApi.Select(id).AsViewModel() .WithChildren() .WithChildrenCount() .WithUser() .WithTags(); Searcher.Instance.Index(new Searchable() { Id = id, Type = item.Type, Title = item.Title, Body = item.Body, Username = item.User.DisplayName }); ContentApi.MarkAsIndexed(id); return(item); }
public ContentViewModel Update(ContentRequest request) { Authorized(); if (request.ContentId == null) { throw new ArgumentNullException(nameof(request.ContentId)); } var userId = user?.Id; if (userId == null) { throw new ArgumentNullException(nameof(request), "User must be set to update an answer"); } TagManager.SetTagsForContent((int)request.ContentId, request.Tags); var htmlBody = Markdown.Encode(request.Body); ContentApi.Update(request.ContentId.Value, request.Title, request.Body, htmlBody, (int)userId); var item = ContentApi.Select(request.ContentId.Value) .AsViewModel() .WithAll(); Searcher.Instance.Index(new Searchable() { Id = item.Id, Type = item.Type, Title = item.Title, Body = item.Body, Username = item.User.DisplayName }); ContentApi.MarkAsIndexed(item.Id); return(item); }
/// <summary> /// Get the full content of a recently sent message. /// </summary> /// <param name="request"> /// The content. /// </param> /// <returns> /// The <see cref="GetContent" /> /// </returns> public async Task <Content> GetContent(ContentRequest request) { string path = "messages/content.json"; Content response = await Post <Content>(path, request).ConfigureAwait(false); return(response); }
internal void AddUsageReference() { ++objectReferences; if (request == null) { request = new ContentRequest(); } }
private async Task <ContentServiceResponse> GetContentAsync(ContentRequest request, CancellationToken cancellationToken = default(CancellationToken)) { var contentProvider = new ContentProvider(); var response = await contentProvider.GetContentAsync(request); return(response); }
/// <summary> /// Set information about one of your urls. /// </summary> /// <param name="request"></param> /// <returns></returns> /// <seealso cref="http://docs.sailthru.com/api/content"/> public SailthruResponse SetContent(ContentRequest request) { Hashtable hashForPost = new Hashtable(); hashForPost.Add("json", JsonConvert.SerializeObject(request, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })); return(this.ApiPost("content", hashForPost)); }
/// <summary> /// The validate response. /// </summary> /// <param name="request"> /// The request. /// </param> /// <returns> /// The <see cref="IEnumerable"/>. /// </returns> public override IEnumerable<string> ValidateResponse(ContentRequest request) { if (string.IsNullOrEmpty(request.CategoryId)) { return new List<string> { ContentConfiguration.ContentIdError }; } return new List<string>(); }
public ActionResult AddOrUpdateContent(string campaignId, ContentRequest request = null) { Task <Content> result = null; if (campaignId != null) { result = mailChimpManager.Content.AddOrUpdateAsync(campaignId, request); } return(View(result.Result)); }
/// <summary> /// The add or update async. /// </summary> /// <param name="campaignId"> /// The campaign id. /// </param> /// <param name="content"> /// The content. /// </param> /// <returns> /// The <see cref="Task"/>. /// </returns> /// <exception cref="ArgumentNullException"><paramref> /// <name>uriString</name> /// </paramref> /// is null. </exception> /// <exception cref="UriFormatException">In the .NET for Windows Store apps or the Portable Class Library, catch the base class exception, <see cref="T:System.FormatException" />, instead.<paramref name="uriString" /> is empty.-or- The scheme specified in <paramref name="uriString" /> is not correctly formed. See <see cref="M:System.Uri.CheckSchemeName(System.String)" />.-or- <paramref name="uriString" /> contains too many slashes.-or- The password specified in <paramref name="uriString" /> is not valid.-or- The host name specified in <paramref name="uriString" /> is not valid.-or- The file name specified in <paramref name="uriString" /> is not valid. -or- The user name specified in <paramref name="uriString" /> is not valid.-or- The host or authority name specified in <paramref name="uriString" /> cannot be terminated by backslashes.-or- The port number specified in <paramref name="uriString" /> is not valid or cannot be parsed.-or- The length of <paramref name="uriString" /> exceeds 65519 characters.-or- The length of the scheme specified in <paramref name="uriString" /> exceeds 1023 characters.-or- There is an invalid character sequence in <paramref name="uriString" />.-or- The MS-DOS path specified in <paramref name="uriString" /> must start with c:\\.</exception> /// <exception cref="MailChimpException"> /// Custom Mail Chimp Exception /// </exception> public async Task <Content> AddOrUpdateAsync(string campaignId, ContentRequest content) { using (var client = CreateMailClient("campaigns/")) { var response = await client.PutAsJsonAsync($"{campaignId}/content", content).ConfigureAwait(false); await response.EnsureSuccessMailChimpAsync().ConfigureAwait(false); return(await response.Content.ReadAsAsync <Content>().ConfigureAwait(false)); } }
/// <summary> /// Add or update content sync /// </summary> /// <param name="campaignId"></param> /// <param name="content"></param> /// <returns></returns> public Content AddOrUpdate(string campaignId, ContentRequest content) { //Crate a web request with MC us1 URLS string requestUrl = $"campaigns/{campaignId}/content"; var jsonHttpWebRequest = this.CreateJsonWebRequest(requestUrl, "PUT"); //Get JSON content for the request string responseJsonContent = this.GetJsonResponseFromRequest(jsonHttpWebRequest, content); return(JsonConvert.DeserializeObject <Content>(responseJsonContent)); }
private bool LoadFromProvider() { for (int i = loadedItems; i < xnaBundle.items.Length; ++i) { ContentRequest request = xnaBundle.items[i].Request; request.Asset = PlatformInstances.AssetLoadingInfo.LoadFromAssetDatabase(xnaBundle.itemUnityPaths[i]); ++loadedItems; return(false); } return(true); }
public static int SendRequest(PlayHavenBinding.RequestType type, string placement, bool showsOverlayImmediately) { IPlayHavenRequest request = null; switch (type) { case PlayHavenBinding.RequestType.Open: request = new OpenRequest(placement); // placement is actually customUDID request.OnSuccess += HandleOpenRequestOnSuccess; request.OnError += HandleOpenRequestOnError; break; case PlayHavenBinding.RequestType.Metadata: request = new MetadataRequest(placement); request.OnSuccess += HandleMetadataRequestOnSuccess; request.OnError += HandleMetadataRequestOnError; request.OnWillDisplay += HandleMetadataRequestOnWillDisplay; request.OnDidDisplay += HandleMetadataRequestOnDidDisplay; break; case PlayHavenBinding.RequestType.Content: request = new ContentRequest(placement); request.OnError += HandleContentRequestOnError; request.OnDismiss += HandleContentRequestOnDismiss; request.OnReward += HandleContentRequestOnReward; request.OnPurchasePresented += HandleRequestOnPurchasePresented; request.OnWillDisplay += HandleContentRequestOnWillDisplay; request.OnDidDisplay += HandleContentRequestOnDidDisplay; break; case PlayHavenBinding.RequestType.Preload: request = new ContentPreloadRequest(placement); request.OnError += HandleContentRequestOnError; request.OnSuccess += HandlePreloadRequestOnSuccess; break; case PlayHavenBinding.RequestType.CrossPromotionWidget: request = new ContentRequest("more_games"); request.OnError += HandleCrossPromotionWidgetRequestOnError; request.OnDismiss += HandleCrossPromotionWidgetRequestOnDismiss; request.OnWillDisplay += HandleCrossPromotionWidgetRequestOnWillDisplay; request.OnDidDisplay += HandleCrossPromotionWidgetRequestOnDidDisplay; break; } if (request != null) { request.Send(showsOverlayImmediately); return(request.HashCode); } return(0); }
public Return CreateAndSendCampaign(string listId, string fromName, string fromEmailAddress, string subject, string title, string htmlMessage) { var returnObj = BaseMapper.GenerateReturn(); var campaign = new Campaign { Type = CampaignType.Regular, Recipients = new Recipient { ListId = listId }, Settings = new Setting { SubjectLine = subject, Title = title, FromName = fromName, ReplyTo = fromEmailAddress }, Tracking = new Tracking { Opens = true, HtmlClicks = true, TextClicks = true }, ReportSummary = new ReportSummary(), DeliveryStatus = new DeliveryStatus(), }; try { var mailChimpCampaign = MailChimpManager.Campaigns.AddOrUpdateAsync(campaign).Result; var ContentRequest = new ContentRequest { Html = htmlMessage }; var content = MailChimpManager.Content.AddOrUpdateAsync(mailChimpCampaign.Id, ContentRequest).Result; MailChimpManager.Campaigns.SendAsync(mailChimpCampaign.Id); return(returnObj); } catch (Exception ex) { ErrorHelper.LogException(ex); returnObj.Error = ErrorHelper.CreateError(ex); return(returnObj); } }
public async Task sendAlert(CampaignSettings settings, string listid, string plantilla, DateTime fecha_transaccion) { MailChimpManager _mailChimpManager = new MailChimpManager(apiKey); Setting _campaignSettings = new Setting { ReplyTo = settings.ReplyTo, FromName = settings.FromName, Title = settings.Title, SubjectLine = settings.SubjectLine }; var content = new ContentRequest { PlainText = string.Empty, Html = string.Empty }; plantilla = System.Web.Hosting.HostingEnvironment.MapPath(plantilla); using (var reader = File.OpenText(plantilla)) { content.Html = reader.ReadToEnd(); content.Html = content.Html.Replace("@dominio", dominio); content.Html = content.Html.Replace("@fullname", "Alejandro Jimenez"); content.Html = content.Html.Replace("@username", "desarrollo"); content.Html = content.Html.Replace("@password", "loyalty"); content.Html = content.Html.Replace("@URL", "http://74.205.86.171:8051/Account/Login"); content.Html = content.Html.Replace("@creationDate", fecha_transaccion.ToString("dd/MM/yyyy")); } try { var campaign = _mailChimpManager.Campaigns.AddAsync(new Campaign { Settings = _campaignSettings, Recipients = new Recipient { ListId = listid }, Type = CampaignType.Regular, }).Result; await _mailChimpManager.Content.AddOrUpdateAsync(campaign.Id.ToString(), content); _mailChimpManager.Campaigns.SendAsync(campaign.Id.ToString()).Wait(); } catch (MailChimpException mce) { //return new HttpStatusCodeResult(HttpStatusCode.BadGateway, mce.Message); } catch (Exception ex) { //return new HttpStatusCodeResult(HttpStatusCode.ServiceUnavailable, ex.Message); } }
public CacheServiceManager() { var factory = new ConnectionFactory() { HostName = "rabbitmq" }; connection = factory.CreateConnection(); channel = connection.CreateModel(); channel.QueueDeclare(queue: QUEUE_NAME, durable: false, exclusive: false, autoDelete: false, arguments: null); channel.BasicQos(0, 1, false); consumer = new EventingBasicConsumer(channel); consumer.Received += (model, ea) => { var request = ea.Body; var props = ea.BasicProperties; var replyProps = channel.CreateBasicProperties(); replyProps.CorrelationId = props.CorrelationId; CacheRequest deserializedRequest; var formatter = new BinaryFormatter(); using (var stream = new MemoryStream(request)) deserializedRequest = (CacheRequest)formatter.Deserialize(stream); var contentRequest = new ContentRequest() { ContentKey = deserializedRequest.ContentKey }; var contentResponse = GetContentAsync(contentRequest).Result; var cacheResponse = new CacheServiceResponse() { PageTitle = contentResponse.PageTitle }; Byte[] serializedResponse; using (var stream = new MemoryStream()) { formatter.Serialize(stream, cacheResponse); serializedResponse = stream.ToArray(); } channel.BasicPublish(exchange: "", routingKey: props.ReplyTo, basicProperties: replyProps, body: serializedResponse); channel.BasicAck(deliveryTag: ea.DeliveryTag, multiple: false); }; channel.BasicConsume(queue: QUEUE_NAME, autoAck: false, consumer: consumer); }
private Task CreatePullRequest( Repository repo, Branch defaultBranch, Reference prBranch, Comment comment, ContentRequest fileRequest) { var pullRequest = new NewPullRequest(fileRequest.Message, prBranch.Ref, defaultBranch.Name) { Body = $"avatar: <img src=\"{comment.avatar}\" />{NewLine}{NewLine}{comment.message}" }; return(_githubRepoClient.PullRequest.Create(repo.Id, pullRequest)); }
public async Task <IActionResult> PutContent([FromRoute] int id, [FromBody] ContentRequest request) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != request.Id) { return(BadRequest()); } var oldContent = await _dataContext.Contents.Include(c => c.User).FirstOrDefaultAsync(c => c.Id == request.Id); if (oldContent == null) { return(BadRequest("La Publicacion No Existe.")); } if (request.UserId != oldContent.User.Id) { return(BadRequest("El Usuario No es el Propietario De La Publicacion.")); } var contentType = await _dataContext.ContentTypes.FindAsync(request.ContentType); if (contentType == null) { return(BadRequest("El Tipo De Publicacion no Es Valido.")); } var park = await _dataContext.Parks.FindAsync(request.Park); if (park == null) { return(BadRequest("Parque No Existe.")); } oldContent.Description = request.Description; oldContent.Date = request.Date; oldContent.ContentType = contentType; oldContent.Park = park; oldContent.User = await _dataContext.Users.FindAsync(request.UserId); _dataContext.Contents.Update(oldContent); await _dataContext.SaveChangesAsync(); return(Ok(true)); }
public static ContentRequest AsRequest(this Content c) { var tags = TagManager.GetTagStringForContentAndAvailable(c.Id); ContentRequest request = new ContentRequest { ContentId = c.Id, Title = c.Title, Body = c.Body, Type = c.Type, AvailableTags = tags.Item2, Tags = tags.Item1 }; return(request); }
public IActionResult Ask(ContentRequest request) { var user = GetCurrentUser(); var manager = new ContentManager(user); if (request.ContentId == null) { var id = manager.Create(request).Id; return(RedirectToAction("Show", new { Id = id })); } else { manager.Update(request); return(RedirectToAction("Show", new { Id = request.ContentId })); } }
public JsonResponse <CmsContent> GetContent(ContentRequest request) { using (var db = new MoneyNoteDbContext()) { var exited = db.CmsContents.FirstOrDefault(i => i.Id == request.id); if (exited != null) { exited.CountView = exited.CountView + 1; db.SaveChanges(); } return(new JsonResponse <CmsContent> { data = exited }); } }
private static IContent CreateContent(ContentRequest contentRequest, DivvyTypeMapping mapping) { // Run the event. The target node might change in here var e = new DivvyEventArgs() { ContentRequest = contentRequest, IntendedParent = mapping.ParentNode, IntendedTypeName = mapping.EpiserverPageTypeName }; OnBeforeContentCreation(null, e); if (e.CancelAction) { return(null); } var parent = repo.Get <PageData>(e.IntendedParent); DivvyLogManager.LogRequest($"Creating New Content", new { Type = e.IntendedTypeName, ParentId = parent.ContentGuid, ParentName = parent.Name }); try { // Get the type ID. For whatever reason, we can't create content with a type name, we have to have the ID... var type = typeRepo.Load(e.IntendedTypeName); // Create the content var content = repo.GetDefault <IContent>(e.IntendedParent, type.ID); content.Name = contentRequest.Title; repo.Save(content, AccessLevel.NoAccess); // There's an edge case where we have a mappng already because the Episerver content got deleted if (!DivvyContentMapping.HasDivvyMapping(content.ContentLink.ID)) { DivvyContentMapping.Create(content.ContentLink.ID, contentRequest.Id); } DivvyLogManager.LogRequest("Created New Content", new { Id = content.ContentGuid }); return(content); } catch (Exception ex) { DivvyLogManager.LogRequest($"Error Creating New Content", ex); return(null); } }
public async Task <Content> AddOrUpdateAsync(string campaignId, ContentRequest content) { try { using (var client = CreateMailClient("campaigns/")) { var response = await client.PutAsJsonAsync($"{campaignId}/contents", content); response.EnsureSuccessStatusCode(); return(await response.Content.ReadAsAsync <Content>()); } } catch (Exception ex) { } return(null); }
/// <summary> /// The populate response. /// </summary> /// <param name="request"> /// The request. /// </param> /// <param name="response"> /// The response. /// </param> public override void PopulateResponse(ContentRequest request, ContentResponse response) { response.Content = ContentDao.GetContent(request.ContentId); }
/// <summary> /// The populate response. /// </summary> /// <param name="request"> /// The request. /// </param> /// <param name="response"> /// The response. /// </param> public override void PopulateResponse(ContentRequest request, ContentResponse response) { response.ContentList = ContentDao.GetContentByCategory(request.CategoryId); }
void EditEvent(string settings) { try { string webserviceURL = sitePath + "/widgets/Flash/FlashHandler.ashx"; // Register JS JS.RegisterJSInclude(this, JS.ManagedScript.EktronJS); Ektron.Cms.API.JS.RegisterJSInclude(this, Ektron.Cms.API.JS.ManagedScript.EktronJQueryClueTipJS); JS.RegisterJSInclude(this, JS.ManagedScript.EktronScrollToJS); JS.RegisterJSInclude(this, sitePath + "/widgets/Flash/behavior.js", "FlashWidgetBehaviorJS"); // Insert CSS Links Css.RegisterCss(this, sitePath + "/widgets/Flash/FlashStyle.css", "FlashWidgetCSS"); //cbstyle will include the other req'd stylesheets JS.RegisterJSBlock(this, "Ektron.PFWidgets.Flash.webserviceURL = \"" + webserviceURL + "\"; Ektron.PFWidgets.Flash.setupAll('" + uniqueId + "');", "EktronPFWidgetsFlashInit" + this.ID); txtWidth.Text = Width; txtHeight.Text = Height; chkAutostart.Checked = AutoStart; chkAutostart.Enabled = false; ViewSet.SetActiveView(Edit); thumbChange.Style.Add(HtmlTextWriterStyle.Display, "none"); thumbRemove.Style.Add(HtmlTextWriterStyle.Display, "none"); if (ContentBlockId > 0) { long folderid = _api.GetFolderIdForContentId(ContentBlockId); ContentBase cb = _api.EkContentRef.LoadContent(ContentBlockId, false); txtSource.InnerText = cb.Title; if (cb.AssetInfo != null && cb.AssetInfo.FileExtension.ToLower() == "flv") txtSource.InnerText += " (flv)"; thumbChange.Style.Clear(); if (ThumbnailID > 0) { ContentRequest req = new ContentRequest(); req.ContentType = EkEnumeration.CMSContentType.AllTypes; req.GetHtml = false; req.Ids = ThumbnailID.ToString(); req.MaxNumber = 1; req.RetrieveSummary = false; Ektron.Cms.Common.ContentResult imageresult = _api.LoadContentByIds(ref req, Page); if (imageresult != null && imageresult.Count > 0) { thumbnailImg.InnerHtml = "<img alt=\"thumbnail\" style=\"width:250px; height:auto;\" src=\"" + imageresult.Item[0].AssetInfo.FileName + "\"/>"; hdnThumbFile.Value = imageresult.Item[0].AssetInfo.FileName; thumbRemove.Style.Clear(); } } else if (Thumbnail != string.Empty) { thumbnailImg.InnerHtml = "<img alt=\"thumbnail\" style=\"width:250px; height:auto;\" src=\"" + Thumbnail + "\"/>"; } hdnThumbID.Value = ThumbnailID.ToString(); hdnThumbFolderPath.Value = ""; if (ThumbnailID > 0) { long thumbfolid = _api.GetFolderIdForContentId(ThumbnailID); hdnThumbFolderPath.Value = thumbfolid.ToString(); while (thumbfolid != 0) { thumbfolid = _api.GetParentIdByFolderId(thumbfolid); if (thumbfolid > 0) hdnThumbFolderPath.Value += "," + thumbfolid.ToString(); } } hdnContentId.Value = ContentBlockId.ToString(); if (ContentBlockId == 0) { hdnFolderId.Value = "-1"; } else { hdnFolderId.Value = folderid.ToString(); } hdnVideoFolderPath.Value = folderid.ToString(); while (folderid != 0) { folderid = _api.GetParentIdByFolderId(folderid); if (folderid > 0) hdnVideoFolderPath.Value += "," + folderid.ToString(); } if (cb.AssetInfo != null && cb.AssetInfo.FileExtension == "flv") { chkAutostart.Enabled = true; } } enableResize = false; } catch (Exception e) { errorLb.Text = e.Message + e.Data + e.StackTrace + e.Source + e.ToString(); _host.Title = _host.Title + " error"; ViewSet.SetActiveView(View); enableResize = true; } }
protected void MainView() { if (ContentBlockId > -1) { ContentAPI capi = new ContentAPI(); PageBuilder page = (Page as PageBuilder); if (ContentBlockId > 0) { contentBlock.DefaultContentID = ContentBlockId; if (page != null && page.CacheInterval > 0) { contentBlock.CacheInterval = page.CacheInterval; } contentBlock.Fill(); if (contentBlock.EkItem != null) { if (contentBlock.EkItem.Title != null) _host.Title = contentBlock.EkItem.Title; if (contentBlock.EkItem.AssetInfo != null && contentBlock.EkItem.AssetInfo.FileExtension != null && contentBlock.EkItem.AssetInfo.FileExtension.ToLower() == "flv") { StringBuilder sbflash = new StringBuilder(); //need object tag here sbflash.Append("<embed id=\"ply\" width=\"" + Width + "\" height=\"" + Height + "\""); sbflash.Append("flashvars=\"file=" + contentBlock.EkItem.AssetInfo.FileName); if (ThumbnailID > 0) { ContentRequest req = new ContentRequest(); req.ContentType = EkEnumeration.CMSContentType.AllTypes; req.GetHtml = false; req.Ids = ThumbnailID.ToString(); req.MaxNumber = 1; req.RetrieveSummary = false; Ektron.Cms.Common.ContentResult imageresult = capi.LoadContentByIds(ref req, Page); if (imageresult != null && imageresult.Count > 0) { sbflash.Append("&image=" + imageresult.Item[0].AssetInfo.FileName); } } else if (Thumbnail != string.Empty) { sbflash.Append("&image=" + Thumbnail); } sbflash.Append("&autostart=" + AutoStart.ToString().ToLower() + "\""); sbflash.Append("allowscriptaccess=\"always\" allowfullscreen=\"true\" quality=\"high\" bgcolor=\"#CCCCCC\" name=\"ply\" style=\"\""); sbflash.Append("src=\"" + sitePath + "/widgets/Flash/player.swf\" wmode=\"transparent\" type=\"application/x-shockwave-flash\"/>"); ltrFlash.Text = sbflash.ToString(); Ektron.Cms.API.JS.RegisterJSInclude(this, sitePath + "/widgets/flash/swfobject.js", "widgetFlash.js"); contentBlock.Visible = false; ltrFlash.Visible = true; } else { //Ektron.Cms.Controls.ContentBlock contentBlock; if (contentBlock.Text != "") { string html = contentBlock.Text; int startwidth = -1, endwidth = -1, startheight = -1, endheight = -1; startwidth = html.IndexOf("width=\"") + 7; if (startwidth > 0) { endwidth = html.IndexOf("px", startwidth); } startheight = html.IndexOf("height=\"") + 8; if (startheight > 0) { endheight = html.IndexOf("px", startheight); } if (startwidth > 0 && endwidth > startwidth && startheight > 0 && endheight > startheight) { string pixelwidth = html.Substring(startwidth, endwidth - startwidth); string pixelheight = html.Substring(startheight, endheight - startheight); int storedheight = 0; int storedwidth = 0; int.TryParse(Width, out storedwidth); int.TryParse(Height, out storedheight); if (storedheight > 0) html = html.Replace(pixelheight, storedheight.ToString()); if (storedwidth > 0) html = html.Replace(pixelwidth, storedwidth.ToString()); } ltrFlash.Text = html; contentBlock.Visible = false; ltrFlash.Visible = true; } } } } } enableResize = true; }