예제 #1
0
 public ContentVersionPath(TextContent content)
 {
     var contentPath = new TextContentPath(content);
     var basePath = Kooboo.CMS.Common.Runtime.EngineContext.Current.Resolve<Kooboo.CMS.Common.IBaseDir>();
     var versionPath = Path.Combine(basePath.Cms_DataPhysicalPath, VersionPathName);
     this.PhysicalPath = contentPath.PhysicalPath.Replace(basePath.Cms_DataPhysicalPath, versionPath);            
 }
예제 #2
0
 public ContentVersionPath(TextContent content)
 {
     var contentPath = new TextContentPath(content);
     var basePath = Path.Combine(Kooboo.Settings.BaseDirectory, RepositoryPath.Cms_Data);
     var versionPath = Path.Combine(basePath, VersionPathName);
     this.PhysicalPath = contentPath.PhysicalPath.Replace(basePath, versionPath);
     //  this.VirtualPath = UrlUtility.Combine(contentPath.VirtualPath, VersionPathName);
 }
예제 #3
0
        public void Receive(IEventContext context)
        {
            if (context is ContentEventContext && HttpContext.Current != null)
            {
                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)
                        {
                            try
                            {
                                var imgParam = JsonHelper.Deserialize<ImageParam>(HttpContext.Current.Request.Form[field + "-hidden"].ToString());

                                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;
                            }
                            catch (Exception e)
                            {

                            }

                        }

                    }
                    foreach (var r in toRemove)
                    {
                        if (File.Exists(r))
                        {
                            File.Delete(r);
                        }

                    }

                }
            }
        }
예제 #4
0
파일: WorkflowPath.cs 프로젝트: Epitomy/CMS
        public WorkflowHistoryPath(WorkflowHistory history)
        {
            var folder = new TextFolder(history.Repository, history.ContentFolder);

            var content = folder.CreateQuery().WhereEquals("UUID", history.ContentUUID).FirstOrDefault();

            ContentPath  = new TextContentPath(content);
            PhysicalPath = SettingFile = Path.Combine(ContentPath.PhysicalPath, PATH_NAME, GetFile(history));
            VirtualPath  = UrlUtility.Combine(ContentPath.VirtualPath, PATH_NAME, GetFile(history));
        }
예제 #5
0
        public string Save(TextContent content, ContentFile file)
        {
            var extension = Path.GetExtension(file.FileName);
            var fileName = Kooboo.Extensions.StringExtensions.NormalizeUrl(Path.GetFileNameWithoutExtension(file.FileName)) + extension;
            TextContentPath contentPath = new TextContentPath(content);
            string filePath = Path.Combine(contentPath.PhysicalPath, fileName);
            file.Stream.SaveAs(filePath, true);

            return UrlUtility.Combine(contentPath.VirtualPath, fileName);
        }
예제 #6
0
 public void DeleteFiles(TextContent content)
 {
     var contentPath = new TextContentPath(content);
     try
     {
         if (Directory.Exists(contentPath.PhysicalPath))
         {
             IOUtility.DeleteDirectory(contentPath.PhysicalPath, true);
         }
     }
     catch (Exception e)
     {
         Kooboo.HealthMonitoring.Log.LogException(e);
     }
 }
예제 #7
0
파일: WorkflowPath.cs 프로젝트: Epitomy/CMS
 public WorkflowHistoryPath(TextContent content)
 {
     ContentPath  = new TextContentPath(content);
     PhysicalPath = Path.Combine(ContentPath.PhysicalPath, PATH_NAME);
     VirtualPath  = UrlUtility.Combine(ContentPath.VirtualPath, PATH_NAME);
 }
예제 #8
0
파일: WorkflowPath.cs 프로젝트: Godoy/CMS
        public WorkflowHistoryPath(WorkflowHistory history)
        {
            var folder = new TextFolder(history.Repository, history.ContentFolder);

            var content = folder.CreateQuery().WhereEquals("UUID", history.ContentUUID).FirstOrDefault();

            ContentPath = new TextContentPath(content);
            PhysicalPath = SettingFile = Path.Combine(ContentPath.PhysicalPath, PATH_NAME, GetFile(history));
            VirtualPath = UrlUtility.Combine(ContentPath.VirtualPath, PATH_NAME, GetFile(history));

        }
예제 #9
0
파일: WorkflowPath.cs 프로젝트: Godoy/CMS
 public WorkflowHistoryPath(TextContent content)
 {
     ContentPath = new TextContentPath(content);
     PhysicalPath = Path.Combine(ContentPath.PhysicalPath, PATH_NAME);
     VirtualPath = UrlUtility.Combine(ContentPath.VirtualPath, PATH_NAME);
 }