Пример #1
0
        public SchemaPath(Schema schema)
        {
            if (schema == null)
                return;

            string schemaName = schema.Name;

            RepositoryPath repositoryPath = new RepositoryPath(schema.Repository);
            var schemaPath = Path.Combine(repositoryPath.PhysicalPath, "Schemas", schema.Name);

            //Schema is link
            //
            if (!Directory.Exists(schemaPath) && File.Exists(schemaPath + ".lnk"))
            {
                PhysicalPath = LinkHelper.ResolveShortcut(schemaPath + ".lnk");
                SettingFile = Path.Combine(PhysicalPath, PathHelper.SettingFileName);
                VirtualPath = UrlUtility.GetVirtualPath(PhysicalPath);
            }
            else
            {
                var basePhysicalPath = GetBaseDir(schema.Repository);
                this.PhysicalPath = Path.Combine(basePhysicalPath, schemaName);
                this.SettingFile = Path.Combine(PhysicalPath, PathHelper.SettingFileName);

                VirtualPath = UrlUtility.RawCombine(repositoryPath.VirtualPath, PATH_NAME, schemaName);
            }
        }
Пример #2
0
 public DataPath(string repositoryName)
 {
     var repository = new Repository(repositoryName);
     var repositoryPath = new RepositoryPath(repository);
     this.PhysicalPath = Path.Combine(repositoryPath.PhysicalPath, DirName);
     this.VirtualPath = UrlUtility.Combine(repositoryPath.VirtualPath, DirName);
 }
Пример #3
0
 public SchemaPath(Schema schema)
 {
     RepositoryPath repositoryPath = new RepositoryPath(schema.Repository);
     var basePhysicalPath = GetBaseDir(schema.Repository);
     this.PhysicalPath = Path.Combine(basePhysicalPath, schema.Name);
     this.SettingFile = Path.Combine(PhysicalPath, PathHelper.SettingFileName);
     VirtualPath = UrlUtility.RawCombine(repositoryPath.VirtualPath, PATH_NAME, schema.Name);
 }
Пример #4
0
        public PendingWorkflowItemPath(PendingWorkflowItem pendingWorkflowItem)
        {
            var repositoryPath = new RepositoryPath(pendingWorkflowItem.Repository);

            this.PhysicalPath = SettingFile = Path.Combine(repositoryPath.PhysicalPath, PATH_NAME, pendingWorkflowItem.RoleName, GetFileName(pendingWorkflowItem));

            this.VirtualPath = UrlUtility.Combine(repositoryPath.VirtualPath, PATH_NAME, pendingWorkflowItem.RoleName, GetFileName(pendingWorkflowItem));
        }
Пример #5
0
        public void TestPhysicalPath()
        {
            var name = "repository1";
            var expected = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Cms_Data", "Contents", name);

            RepositoryPath path = new RepositoryPath(new Repository(name));

            Assert.AreEqual(expected, path.PhysicalPath, true);
        }
Пример #6
0
        public WorkflowPath(Repository repository)
        {
            var repositoryPath = new RepositoryPath(repository);

            PhysicalPath = Path.Combine(repositoryPath.PhysicalPath, PATH_NAME);

            VirtualPath = UrlUtility.Combine(repositoryPath.VirtualPath, PATH_NAME);

            IO.IOUtility.EnsureDirectoryExists(PhysicalPath);
        }
Пример #7
0
        public PendingWorkflowItemPath(Repository repository, string roleName)
        {
            var repositoryPath = new RepositoryPath(repository);

            PhysicalPath = Path.Combine(repositoryPath.PhysicalPath, PATH_NAME, roleName);

            VirtualPath = UrlUtility.Combine(repositoryPath.VirtualPath, PATH_NAME, roleName);

            IO.IOUtility.EnsureDirectoryExists(PhysicalPath);
        }
Пример #8
0
 /// <summary>
 /// Remote attribute
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public virtual ActionResult IsNameAvailable(string name)
 {
     Repository repository = new Repository(name);
     RepositoryPath path = new RepositoryPath(repository);
     if (!path.Exists())
     {
         return Json(true, JsonRequestBehavior.AllowGet);
     }
     int i = 1;
     while (path.Exists())
     {
         repository = new Repository(name + i.ToString());
         path = new RepositoryPath(repository);
     }
     return Json(string.Format("{0} is not available. Try {1}.", name, repository.Name), JsonRequestBehavior.AllowGet);
 }
Пример #9
0
        public virtual ActionResult TempFile()
        {
            var entry = new JsonResultEntry();

            try
            {

                if (Request.Files.Count > 0 && Request.Files[0].ContentLength > 0)
                {
                    var postFile = Request.Files[0];
                    var repositoryPath = new RepositoryPath(Repository);
                    var tempPath = Kooboo.Web.Url.UrlUtility.Combine(repositoryPath.VirtualPath, "Temp");
                    Kooboo.IO.IOUtility.EnsureDirectoryExists(Server.MapPath(tempPath));

                    var fileUrl = Kooboo.Web.Url.UrlUtility.Combine(tempPath, UniqueIdGenerator.GetInstance().GetBase32UniqueId(24) + Path.GetExtension(postFile.FileName));

                    postFile.SaveAs(Server.MapPath(fileUrl));
                    entry.Model = Url.Content(fileUrl);
                }
                else
                {
                    entry.SetFailed().AddMessage("It is not a valid image file.".Localize());
                }
            }
            catch (Exception e)
            {
                entry.AddException(e);
            }

            return Json(entry);
        }
Пример #10
0
        public virtual ActionResult ImageCrop()
        {
            var data = new JsonResultData(ModelState);

            data.RunWithTry((resultData) =>
            {
                if (Request.Files.Count > 0 && Request.Files[0].ContentLength > 0)
                {
                    var postFile = Request.Files[0];
                    var repositoryPath = new RepositoryPath(Repository);
                    var tempPath = Kooboo.Web.Url.UrlUtility.Combine(repositoryPath.VirtualPath, "Temp");
                    Kooboo.IO.IOUtility.EnsureDirectoryExists(Server.MapPath(tempPath));

                    var fileUrl = Kooboo.Web.Url.UrlUtility.Combine(tempPath, UniqueIdGenerator.GetInstance().GetBase32UniqueId(24) + Path.GetExtension(postFile.FileName));

                    postFile.SaveAs(Server.MapPath(fileUrl));
                    resultData.Model = new { ImageUrl = Url.Content(fileUrl), PreviewUrl = this.Url.Action("ResizeImage", "Resource", new { siteName = Site.FullName, url = fileUrl, area = "", width = 600, height = 400, preserverAspectRatio = true, quality = 80 }) };
                }
                else
                {
                    resultData.AddErrorMessage("It is not a valid image file.".Localize());
                }
            });

            return Json(data);
        }
Пример #11
0
 private static string GetFileName(Repository repository, string providerName)
 {
     RepositoryPath path = new RepositoryPath(repository);
     return System.IO.Path.Combine(path.PhysicalPath, "Logs", string.Format("{0}-{1}.log", providerName, DateTime.Now.ToString("yyyyMMdd")));
 }
Пример #12
0
 public BroadcastingPath(Repository repository)
 {
     var repositoryPath = new RepositoryPath(repository);
     this.PhysicalPath = Path.Combine(repositoryPath.PhysicalPath, DIR);
 }
Пример #13
0
 public static string GetDataDir(string repositoryName)
 {
     var repository = new Repository(repositoryName);
     var repositoryPath = new RepositoryPath(repository);
     return Path.Combine(repositoryPath.PhysicalPath, DirName);
 }
Пример #14
0
 public static string GetBasePhysicalPath(Repository repository)
 {
     var repositoryPath = new RepositoryPath(repository);
     return Path.Combine(repositoryPath.PhysicalPath, SearchDir.DirName);
 }
Пример #15
0
        public static string GetBaseDir <T>(Repository repository)
        {
            var repositoryPath = new RepositoryPath(repository);

            return(Path.Combine(repositoryPath.PhysicalPath, GetRootPath(typeof(T))));
        }
Пример #16
0
        public BroadcastingPath(Repository repository)
        {
            var repositoryPath = new RepositoryPath(repository);

            this.PhysicalPath = Path.Combine(repositoryPath.PhysicalPath, DIR);
        }