Ejemplo n.º 1
0
 public ContentVersionPath(TextContent content)
 {
     var contentPath = new TextContentPath(content);
     var basePath = EngineContext.Current.Resolve<IBaseDir>();
     var versionPath = Path.Combine(basePath.DataPhysicalPath, VersionPathName);
     this.PhysicalPath = contentPath.PhysicalPath.Replace(basePath.DataPhysicalPath, versionPath);
 }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
 public WorkflowHistoryPath(TextContent content)
 {
     ContentPath = new TextContentPath(content);
     PhysicalPath = Path.Combine(ContentPath.PhysicalPath, PATH_NAME);
     VirtualPath = UrlUtility.Combine(ContentPath.VirtualPath, PATH_NAME);
 }
Ejemplo n.º 4
0
        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["BSC-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 = UrlUtility.Combine(contentPath.VirtualPath, "BSC-crop-" + Path.GetFileName(imgParam.Url));

                                    IOUtility.EnsureDirectoryExists(contentPath.PhysicalPath);

                                    var phyPath = HttpContext.Current.Server.MapPath(vPath);

                                    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;
        }