public EventResult Receive(IEventContext context) { EventResult eventResult = new EventResult(); if (context is ContentEventContext) { try { ContentEventContext contentEventContext = (ContentEventContext)context; if (contentEventContext.ContentAction == ContentAction.Add && contentEventContext.Content is TextContent) { var textContent = (TextContent)contentEventContext.Content; var folder = (TextFolder)textContent.GetFolder().AsActual(); if (folder.EnabledWorkflow && !string.IsNullOrEmpty(contentEventContext.Content.UserId)) { Services.ServiceFactory.WorkflowManager.StartWorkflow(textContent.GetRepository() , folder.WorkflowName , textContent , contentEventContext.Content.UserId); } } } catch (Exception e) { eventResult.Exception = e; } } return(eventResult); }
public EventResult Receive(IEventContext context) { EventResult eventResult = new EventResult(); if (context is ContentEventContext && HttpContext.Current != null) { try { ContentEventContext contentEventContext = (ContentEventContext)context; var content = contentEventContext.Content; var result = (contentEventContext.ContentAction & ContentAction.PreAdd) == ContentAction.PreAdd || (contentEventContext.ContentAction & ContentAction.PreUpdate) == ContentAction.PreUpdate; if (result) { var cropField = HttpContext.Current.Request.Form["Kooboo-Image-Crop-Field"]; var toRemove = new List <string>(); if (!string.IsNullOrEmpty(cropField)) { var fields = cropField.Split(','); foreach (var field in fields) { var imgParam = JsonHelper.Deserialize <ImageParam>(HttpContext.Current.Request.Form[field + "_param"].ToString()); if (imgParam != null) { string sourceFilePath = HttpContext.Current.Server.MapPath(imgParam.Url); toRemove.Add(sourceFilePath); var contentPath = new TextContentPath(content); var vPath = Kooboo.Web.Url.UrlUtility.Combine(contentPath.VirtualPath, "kooboo-crop-" + Path.GetFileName(imgParam.Url)); Kooboo.IO.IOUtility.EnsureDirectoryExists(contentPath.PhysicalPath); var phyPath = HttpContext.Current.Server.MapPath(vPath); Kooboo.Drawing.ImageTools.CropImage(sourceFilePath, phyPath, imgParam.X, imgParam.Y, imgParam.Width, imgParam.Height); content[field] = vPath; } } } foreach (var r in toRemove) { if (File.Exists(r)) { File.Delete(r); } } } } catch (Exception e) { eventResult.Exception = e; } } return(eventResult); }
protected virtual SendingSetting AllowSending(TextContent content, Repository repository, ContentEventContext eventContext) { if (!repository.EnableBroadcasting) { return null; } var list = Providers.DefaultProviderFactory.GetProvider<ISendingSettingProvider>().All(repository).Select(o => Providers.DefaultProviderFactory.GetProvider<ISendingSettingProvider>().Get(o)); foreach (var item in list) { if (AllowSendingSetting(content, item, eventContext)) { return item; } } return null; }
public void Receive(IEventContext context) { if (context is ContentEventContext) { ContentEventContext contentEventContext = (ContentEventContext)context; if (contentEventContext.ContentAction == ContentAction.Add && contentEventContext.Content is TextContent) { var textContent = (TextContent)contentEventContext.Content; var folder = (TextFolder)textContent.GetFolder().AsActual(); if (folder.EnabledWorkflow && string.IsNullOrEmpty(contentEventContext.Content.UserId)) { Services.ServiceFactory.WorkflowManager.StartWorkflow(textContent.GetRepository() , folder.WorkflowName , textContent , contentEventContext.Content.UserId); } } } }
protected virtual bool AllowSendingSetting(TextContent content, SendingSetting sendingSetting, ContentEventContext eventContext) { if (!string.IsNullOrEmpty(sendingSetting.FolderName) && !sendingSetting.FolderName.Equals(content.FolderName, StringComparison.CurrentCultureIgnoreCase)) { return(false); } if (!string.IsNullOrEmpty(content.OriginalUUID)) { if (content.IsLocalized == null || content.IsLocalized.Value == false) { if ((sendingSetting.SendReceived == null || sendingSetting.SendReceived.Value == false)) { return(false); } } } return(true); }
protected virtual SendingSetting AllowSending(TextContent content, Repository repository, ContentEventContext eventContext) { if (!repository.EnableBroadcasting) { return(null); } var list = Providers.DefaultProviderFactory.GetProvider <ISendingSettingProvider>().All(repository).Select(o => Providers.DefaultProviderFactory.GetProvider <ISendingSettingProvider>().Get(o)); foreach (var item in list) { if (AllowSendingSetting(content, item, eventContext)) { return(item); } } return(null); }
protected virtual bool AllowSendingSetting(TextContent content, SendingSetting sendingSetting, ContentEventContext eventContext) { if (!string.IsNullOrEmpty(sendingSetting.FolderName) && !sendingSetting.FolderName.Equals(content.FolderName, StringComparison.CurrentCultureIgnoreCase)) { return false; } if (!string.IsNullOrEmpty(content.OriginalUUID)) { if (content.IsLocalized == null || content.IsLocalized.Value == false) { if ((sendingSetting.SendReceived == null || sendingSetting.SendReceived.Value == false)) { return false; } } } return true; }
protected virtual void SendToChildSites(Site site, ContentEventContext eventContext, bool keepStatus) { List<Repository> repositoryList = new List<Repository>(); GetAllRepositories(Kooboo.CMS.Sites.Services.ServiceFactory.SiteManager.ChildSites(site), repositoryList); foreach (var repository in repositoryList) { ServiceFactory.ReceiveSettingManager.ProcessMessage(repository, eventContext.Content, eventContext.Content.FolderName, keepStatus, eventContext.ContentAction); } }