public string GetPrefabPath(PathTypeEnum pathType, string path) { List <PathInfo> tempPaths = Paths.FindAll(x => x.PathType == pathType); int pathIndex = 0; for (int i = 0; i < tempPaths.Count; i++) { pathIndex = path.IndexOf(tempPaths [i].PathName); if (pathIndex > -1) { //remove the path from the asset path path = path.Remove(0, pathIndex + tempPaths [i].PathName.Length + 1); } pathIndex = path.IndexOf("."); if (pathIndex > -1) { path = path.Remove(pathIndex); } } return(path); }
private static LinksModel BuildLinks(IEnumerable <string> paths, string relatedTo) { LinksModel result = new LinksModel(); foreach (string path in paths) { PathTypeEnum type = path.GetPathType(); switch (type) { case PathTypeEnum.Directory: result.Directories.Add(new Link(path.GetFriendlyPath(relatedTo), ActionBuilder.PathOpenUri(path))); break; case PathTypeEnum.File: result.Files.Add(new Link(path.GetFriendlyPath(relatedTo), ActionBuilder.PathOpenUri(path))); break; case PathTypeEnum.NonExistent: result.NonExists.Add(new Link(path.GetFriendlyPath(relatedTo), ActionBuilder.PathUri(path))); break; } } return(result); }
private DocumentQuery GetDocuments(string path, string className, PathTypeEnum pathType) { return(DocumentHelper.GetDocuments(className) .Path(path, pathType) .WhereEquals("ClassName", className) .Culture(LocalizationContext.CurrentCulture.CultureCode) .CheckPermissions() .NestingLevel(1) .OnCurrentSite() .Published()); }
public string GetProjectPath(PathTypeEnum pathType) { string path = ""; string projectFolderPrefix = Paths.Find(x => x.PathType == PathTypeEnum.FolderPrefix).PathName; if (projectFolderPrefix.Length > 0) { path += projectFolderPrefix + "/"; } path += "Resources/" + GetPathName(pathType); return(path); }
static void Main(string[] args) { if (args == null || args.Length == 0 || args.Length > 2) { _logger.Log(Level.Error, "Invalid argument(s) specified.\n" + USAGE); } if (args.Length == 1) { string inputPath = args[0]; if (IsPathValid(args[0])) { PathTypeEnum pathType = GetPathType(inputPath); new ReportUnitService().CreateReport(pathType, inputPath); } } if (args.Length == 2) { string inputPath = args[0]; string outputPath = args[1]; if (IsPathValid(inputPath) && IsPathValid(outputPath)) { PathTypeEnum pathTypeInput = GetPathType(inputPath); String directoryNameOutput = outputPath; if (pathTypeInput == PathTypeEnum.File) { directoryNameOutput = Path.GetDirectoryName(outputPath); } Directory.CreateDirectory(directoryNameOutput); new ReportUnitService().CreateReport(pathTypeInput, inputPath, outputPath); } } }
/// <summary> /// Filters the data to include only documents on given path. /// </summary> /// <typeparam name="TQuery">Type of the data query</typeparam> /// <param name="condition">The query being filtered upon</param> /// <param name="path">Document path</param> /// <param name="type">Path type to define selection scope</param> /// <returns>The filtered query</returns> /// <remarks> /// DocumentQuery.Path() adds parameters to a property "Paths", but if you are building a where condition that needs to 'OR' the path filter, /// it won't work since DocumentQuery.Path() doesn't add the path filter into the Where logic until query execution. /// </remarks> public static TQuery WhereInPath <TQuery>(this WhereConditionBase <TQuery> condition, string path, PathTypeEnum type = PathTypeEnum.Explicit) where TQuery : WhereConditionBase <TQuery>, new() { var paths = new List <string>(); switch (type) { case PathTypeEnum.Single: { path = SqlHelper.EscapeLikeQueryPatterns(path, true, true, true); paths.Add(path); break; } case PathTypeEnum.Children: { path = SqlHelper.EscapeLikeQueryPatterns(path, true, true, true); paths.Add(TreePathUtils.EnsureChildPath(path)); break; } case PathTypeEnum.Section: { path = SqlHelper.EscapeLikeQueryPatterns(path, true, true, true); paths.Add(TreePathUtils.EnsureChildPath(path)); paths.Add(TreePathUtils.EnsureSinglePath(path)); break; } case PathTypeEnum.Explicit: break; default: break; } bool combined = paths.Count > 1; var customWhereCondition = new WhereCondition(); foreach (string current in paths) { customWhereCondition.Or().Where(new IWhereCondition[] { TreePathUtils.GetAliasPathCondition(current, false, combined) }); } return(condition.Where(customWhereCondition)); }
public void CreateReport(PathTypeEnum pathType, string inputPath, string outputPath = null) { IEnumerable <FileInfo> filePathList; if (pathType.Equals(PathTypeEnum.Directory)) { filePathList = new DirectoryInfo(inputPath).GetFiles("*.xml", SearchOption.AllDirectories) .OrderByDescending(f => f.CreationTime); } else { String directory = Path.GetDirectoryName(inputPath); filePathList = new DirectoryInfo(directory).GetFiles(Path.GetFileName(inputPath)); } InitializeRazor(); var compositeTemplate = new CompositeTemplate(); foreach (var filePath in filePathList) { var testRunner = GetTestRunner(filePath.FullName); try { IParser parser = ParserFactory.GetParser(testRunner); var report = parser.Parse(filePath.FullName); compositeTemplate.AddReport(report); } catch (NotSupportedException ex) { _logger.Log(Level.Error, ex.Message); } } if (!compositeTemplate.ReportList.Any()) { Logger.GetLogger().Fatal("No reports added - invalid files?"); return; } if (pathType == PathTypeEnum.Directory) { if (String.IsNullOrEmpty(outputPath)) { outputPath = inputPath; } compositeTemplate.SideNavLinks = compositeTemplate.SideNavLinks.Insert(0, Templates.SideNav.IndexLink); string summary = Engine.Razor.RunCompile(Templates.TemplateManager.GetSummaryTemplate(), "summary", typeof(Model.CompositeTemplate), compositeTemplate, null); File.WriteAllText(Path.Combine(outputPath, "Index.html"), summary); foreach (var report in compositeTemplate.ReportList) { report.SideNavLinks = compositeTemplate.SideNavLinks; var html = Engine.Razor.RunCompile(Templates.TemplateManager.GetFileTemplate(), "report", typeof(Model.Report), report, null); File.WriteAllText(Path.Combine(outputPath, report.FileName + ".html"), html); } } else { var report = compositeTemplate.ReportList.FirstOrDefault(); var html = Engine.Razor.RunCompile(Templates.TemplateManager.GetFileTemplate(), "report", typeof(Model.Report), report, null); if (String.IsNullOrEmpty(outputPath)) { outputPath = Path.Combine(Path.GetDirectoryName(inputPath), Path.GetFileNameWithoutExtension(inputPath) + ".html"); } File.WriteAllText(outputPath, html); } }
public IEnumerable <ITreeNode> GetDocuments(string SinglePath, PathSelectionEnum PathType, string[] PageTypes = null, string OrderBy = null, string WhereCondition = null, int MaxLevel = -1, int TopNumber = -1, string[] Columns = null, bool IncludeCoupledColumns = false) { using (MultiDocumentQuery Query = new MultiDocumentQuery()) { if (PageTypes != null && PageTypes.Length > 0) { if (PageTypes.Length == 1) { Query.Type(PageTypes[0]); } else { Query.Types(PageTypes); } } if (IncludeCoupledColumns) { Query.ExpandColumns(); } // Handle culture and versioning and site Query.Culture(cultureName) .CombineWithDefaultCulture() .CombineWithAnyCulture() .Published(!latestVersionEnabled) .LatestVersion(latestVersionEnabled) .OnSite(_SiteRepo.CurrentSiteName()); PathTypeEnum KenticoPathType = PathTypeEnum.Explicit; switch (PathType) { case PathSelectionEnum.ChildrenOnly: KenticoPathType = PathTypeEnum.Children; break; case PathSelectionEnum.ParentAndChildren: KenticoPathType = PathTypeEnum.Section; break; case PathSelectionEnum.ParentOnly: KenticoPathType = PathTypeEnum.Single; break; } Query.Path(SinglePath, KenticoPathType); if (!string.IsNullOrWhiteSpace(OrderBy)) { Query.OrderBy(OrderBy); } if (!string.IsNullOrWhiteSpace(WhereCondition)) { Query.Where(WhereCondition); } if (Columns != null && Columns.Length > 0) { Query.Columns(Columns); } if (MaxLevel >= 0) { Query.NestingLevel(MaxLevel); } if (TopNumber >= 0) { Query.TopN(TopNumber); } return(Query.TypedResult); } }
public string GetPathName(PathTypeEnum pathType) { string pathRetrieve = Paths.Find(x => x.PathType == pathType).PathName; return(pathRetrieve); }