public static OloMatterDirectory Parse(string fileSystemPath)
        {
            OloMatter matter = OloMatter.Parse(fileSystemPath);

            // Trim down to just the directory
            if (Utilities.IsFile(fileSystemPath).Value)
            {
                fileSystemPath = Path.GetDirectoryName(fileSystemPath);
            }

            string afterMatter = fileSystemPath.Replace(matter.ToString(), "");

            while (afterMatter.EndsWith("\\") || afterMatter.EndsWith("/"))
            {
                afterMatter = afterMatter.TrimEnd('\\').TrimEnd('/');
            }

            if (afterMatter.IndexOf(Path.DirectorySeparatorChar) > 0)
            { // Has relative path
                return(new OloMatterDirectory()
                {
                    Matter = matter,
                    MatterRelativePath = Path.DirectorySeparatorChar + afterMatter.Substring(0, afterMatter.LastIndexOf(Path.DirectorySeparatorChar))
                });
            }
            else
            {
                return(new OloMatterDirectory()
                {
                    Matter = matter,
                    MatterRelativePath = ""
                });
            }
        }
示例#2
0
        public static OloFile Parse(string fileSystemPath)
        {
            OloFile            file   = new OloFile();
            OloMatter          Matter = OloMatter.Parse(fileSystemPath);
            OloMatterDirectory Dir    = OloMatterDirectory.Parse(fileSystemPath);

            string afterMatter = fileSystemPath.Replace(Matter.ToString(), "");

            while (afterMatter.EndsWith("\\") || afterMatter.EndsWith("/"))
            {
                afterMatter = afterMatter.TrimEnd('\\').TrimEnd('/');
            }

            if (afterMatter.IndexOf(Path.DirectorySeparatorChar) > 0)
            { // Has relative path
                file.Title     = afterMatter.Substring(afterMatter.LastIndexOf(Path.DirectorySeparatorChar));
                file.Extension = file.Title.Substring(file.Title.LastIndexOf("."));
                file.Title     = file.Title.Substring(0, file.Title.LastIndexOf(".") - 1);
            }
            else
            {
                file.Extension = afterMatter.Substring(afterMatter.LastIndexOf("."));
                file.Title     = afterMatter.Substring(0, afterMatter.LastIndexOf(".") - 1);
            }

            return(file);
        }
示例#3
0
        public static OloMatter Parse(string fileSystemPath)
        {
            string    wholeName;
            OloMatter matter = new OloMatter();

            string afterRoot = fileSystemPath.Replace(OpenLawOffice.Common.Settings.Manager.Instance.FileStorage.MattersPath, "");

            if (string.IsNullOrEmpty(afterRoot))
            {
                throw new ArgumentException("Invalid path.");
            }

            if (afterRoot.IndexOf(Path.DirectorySeparatorChar) < 1)
            { // Just a matter folder
                wholeName = afterRoot;
            }
            else
            { // Filer or folder within a matter
                wholeName = afterRoot.Substring(0, afterRoot.IndexOf(Path.DirectorySeparatorChar));
            }

            if (wholeName.LastIndexOf("(") > 0)
            { // Has case number
                matter.Title      = wholeName.Substring(0, wholeName.LastIndexOf("(")).Trim();
                matter.CaseNumber = wholeName.Substring(wholeName.LastIndexOf("(") + 1);
                matter.CaseNumber = matter.CaseNumber.Substring(0, matter.CaseNumber.LastIndexOf(")"));
            }
            else
            {
                matter.Title = wholeName.Trim();
            }

            return(matter);
        }
示例#4
0
        public static OloMatter Parse(string fileSystemPath)
        {
            string wholeName;
            OloMatter matter = new OloMatter();

            string afterRoot = fileSystemPath.Replace(OpenLawOffice.Common.Settings.Manager.Instance.FileStorage.MattersPath, "");

            if (string.IsNullOrEmpty(afterRoot))
                throw new ArgumentException("Invalid path.");

            if (afterRoot.IndexOf(Path.DirectorySeparatorChar) < 1)
            { // Just a matter folder
                wholeName = afterRoot;
            }
            else
            { // Filer or folder within a matter
                wholeName = afterRoot.Substring(0, afterRoot.IndexOf(Path.DirectorySeparatorChar));
            }

            if (wholeName.LastIndexOf("(") > 0)
            { // Has case number
                matter.Title = wholeName.Substring(0, wholeName.LastIndexOf("(")).Trim();
                matter.CaseNumber = wholeName.Substring(wholeName.LastIndexOf("(") + 1);
                matter.CaseNumber = matter.CaseNumber.Substring(0, matter.CaseNumber.LastIndexOf(")"));
            }
            else
            {
                matter.Title = wholeName.Trim();
            }

            return matter;
        }