Esempio n. 1
0
        /// <summary>
        /// Gets the relative paths for files that are relevant to this deployment
        /// </summary>
        public IEnumerable <string> GetRelevantRelativePaths(bool forServerDeployment)
        {
            List <string> result = new List <string>(m_filesNames.Count);

            foreach (var fileName in m_filesNames)
            {
                string extension = Path.GetExtension(fileName);
                if (!string.IsNullOrEmpty(extension) &&
                    (extension.Equals(".dll", StringComparison.OrdinalIgnoreCase) ||
                     extension.Equals(".exe", StringComparison.OrdinalIgnoreCase) ||
                     // For the server deployment we want to copy .pdb files in order to get symbols when crashes happen.
                     // But it's wasteful to hash them for sake of the engine version. So exclude them in that context.
                     (forServerDeployment ? extension.Equals(".pdb", StringComparison.OrdinalIgnoreCase) : false) ||
                     extension.Equals(".config", StringComparison.OrdinalIgnoreCase) ||
                     ExtensionUtilities.IsScriptExtension(extension) ||
                     extension.Equals(".ts", StringComparison.OrdinalIgnoreCase) ||
                     extension.Equals(".json", StringComparison.OrdinalIgnoreCase)) ||
                    string.Equals(BuildXLBrandingManifestFileName, fileName, StringComparison.OrdinalIgnoreCase)
                    )
                {
                    // E.g. BuildXLEngine.DefaultCacheConfigFileName, EnlistmentLibrary configs
                    result.Add(fileName);
                }
            }

            // Sort the list by path so the hash computed is consistent run to run on the same machine.
            result.Sort();

            // Lets sanitize if we are on Unix based systems and make sure the paths are correct
            return(OperatingSystemHelper.IsUnixOS ? result.Select(entry => NormalizePath(entry)) : result);
        }
        public static string ExtendedScripts(
            Context context,
            int deptId,
            List <int> groups,
            int userId,
            bool siteTop,
            long siteId,
            long id,
            string controller,
            string action)
        {
            var scripts = (siteTop && !context.TopScript.IsNullOrEmpty()
                ? context.TopScript + '\n'
                : string.Empty)
                          + ExtensionUtilities.ExtensionWhere <ExtendedScript>(
                extensions: Parameters.ExtendedScripts,
                name: null,
                deptId: deptId,
                groups: groups,
                userId: userId,
                siteId: siteId,
                id: id,
                controller: controller,
                action: action)
                          .Select(o => o.Script)
                          .Join("\n");

            return(scripts);
        }
Esempio n. 3
0
        protected bool IsConfigFile(AbsolutePath path)
        {
            Contract.Requires(path.IsValid);

            var name = path.GetName(Context.PathTable).ToString(Context.StringTable);

            return(ExtensionUtilities.IsGlobalConfigurationFile(name));
        }
Esempio n. 4
0
        private bool IsPackageConfigFile(AbsolutePath path)
        {
            Contract.Requires(path.IsValid);

            var name = path.GetName(Context.PathTable).ToString(Context.StringTable);

            return(ExtensionUtilities.IsModuleConfigurationFile(name));
        }
            public dynamic ExecuteDataSet(string name, object _params = null)
            {
                dynamic dataSet = ExtensionUtilities.ExecuteDataSetAsDynamic(
                    context: Context,
                    name: name,
                    _params: _params?.ToString().Deserialize <Dictionary <string, object> >());

                return(dataSet);
            }
Esempio n. 6
0
        public ContentResult Sql(Context context)
        {
            var log    = new SysLogModel(context: context);
            var result = context.Authenticated
                ? ExtensionUtilities.Sql(context: context)
                : ApiResults.Unauthorized(context: context);

            log.Finish(context: context, responseSize: result.Content.Length);
            return(result);
        }
Esempio n. 7
0
        private static void CollectAllPathsToProjects(IFileSystem fileSystem, AbsolutePath pathToPackageDirectory, List <AbsolutePath> projects)
        {
            var pathTable = fileSystem.GetPathTable();
            var files     =
                fileSystem.EnumerateFiles(pathToPackageDirectory)
                .Where(pathToFile => ExtensionUtilities.IsNonConfigurationFile(Path.GetFileName(pathToFile.ToString(pathTable))));

            foreach (var file in files)
            {
                AddProjectSynchronized(projects, file);
            }
        }
 public static string ExtendedHtmls(
     Context context,
     string id,
     string columnName = null)
 {
     return(ExtensionUtilities.ExtensionWhere <ExtendedHtml>(
                context: context,
                extensions: Parameters.ExtendedHtmls,
                columnName: columnName)
            .Select(o => o.Html.Display(
                        context: context,
                        id: id))
            .Join("\n"));
 }
Esempio n. 9
0
        public SpecWriter CreateSpecWriter(string absolutePath)
        {
            switch (m_language)
            {
            case Language.DScript:
                if (!ExtensionUtilities.IsLegacyFileExtension(Path.GetExtension(absolutePath)))
                {
                    absolutePath = Path.ChangeExtension(absolutePath, Names.DotDscExtension);
                }

                return(new DScriptSpecWriter(absolutePath));

            default:
                throw new NotImplementedException(m_language.ToString());
            }
        }
        public async Task <HttpResponseMessage> Sql()
        {
            var body = await Request.Content.ReadAsStringAsync();

            var context = new Context(
                sessionStatus: User?.Identity?.IsAuthenticated == true,
                sessionData: User?.Identity?.IsAuthenticated == true,
                apiRequestBody: body);
            var log    = new SysLogModel(context: context);
            var result = context.Authenticated
                ? ExtensionUtilities.Sql(context: context)
                : ApiResults.Unauthorized(context: context);

            log.Finish(context: context, responseSize: result.Content.Length);
            return(result.ToHttpResponse(Request));
        }
Esempio n. 11
0
 public static string ExtendedScripts(
     int deptId,
     int userId,
     long siteId,
     long id,
     string controller,
     string action)
 {
     return(ExtensionUtilities.ExtensionWhere <ExtendedScript>(
                extensions: Parameters.ExtendedScripts,
                deptId: deptId,
                userId: userId,
                siteId: siteId,
                id: id,
                controller: controller,
                action: action)
            .Select(o => o.Script)
            .Join("\n"));
 }
Esempio n. 12
0
        private static RuleAnalysisScope GetFileScope(ISourceFile file)
        {
            var fileName = Path.GetFileName(file.Path.AbsolutePath);

            if (ExtensionUtilities.IsModuleConfigurationFile(fileName))
            {
                return(RuleAnalysisScope.PackageConfig);
            }

            if (ExtensionUtilities.IsGlobalConfigurationFile(fileName))
            {
                return(RuleAnalysisScope.RootConfig);
            }

            if (ExtensionUtilities.IsBuildListFile(fileName))
            {
                return(RuleAnalysisScope.BuildListFile);
            }

            return(RuleAnalysisScope.SpecFile);
        }
Esempio n. 13
0
        internal override void VisitProcess(Process process, ProcessType pipCategory)
        {
            string friendlyQualifier = Context.QualifierTable.GetCanonicalDisplayString(process.Provenance.QualifierId);

            // TODO: After fixing the qualifier in the DS, I will start using the qualifier id instead of friendly qualifier name
            // Context.QualifierTable.GetQualifiedOutputDirectoryPart(Context.StringTable, qualifierId).ToString(Context.StringTable);
            var arguments = Context.GetArgumentsDataFromProcess(process);

            Project project;

            if (!ProjectsByQualifier.TryGetValue(friendlyQualifier, out project))
            {
                project = CreateProject(process);
                project.SetProperty("PlatformToolset", "v140");

                FillProjectConfigurations(project);
                AddHeaderFiles(project);

                ProjectsByQualifier.Add(friendlyQualifier, project);
            }

            switch (pipCategory)
            {
            case ProcessType.Cl:
                IterateClArguments(project, arguments);
                break;

            case ProcessType.Link:
                IterateLinkArguments(project, arguments);

                // If this is DS, use WorkingDirectory as an output folder.
                var outputDir = ExtensionUtilities.IsScriptExtension(SpecFilePath.GetExtension(Context.PathTable).ToString(Context.StringTable)) ?
                                process.WorkingDirectory :
                                process.UniqueOutputDirectory;
                SetOutputDirectory(project, outputDir, OutputDirectoryType.Build);

                break;
            }
        }
        private static List <ParameterAccessor.Parts.ExtendedNavigationMenu> ExtendedNavigationMenu(
            int deptId,
            List <int> groups,
            int userId,
            long siteId,
            long id,
            string controller,
            string action)
        {
            var extendedNavigationMenus = ExtensionUtilities.ExtensionWhere <ParameterAccessor.Parts.ExtendedNavigationMenu>(
                extensions: Parameters.ExtendedNavigationMenus,
                name: null,
                deptId: deptId,
                groups: groups,
                userId: userId,
                siteId: siteId,
                id: id,
                controller: controller,
                action: action);

            return(extendedNavigationMenus.ToList());
        }
Esempio n. 15
0
 public static HtmlBuilder ExtendedSql(
     this HtmlBuilder hb,
     Context context)
 {
     ExtensionUtilities.ExtensionWhere <ExtendedSql>(
         context: context,
         extensions: Parameters.ExtendedSqls
         ?.Where(o => o.Html)
         .Where(o => !o.CommandText.IsNullOrEmpty()))
     .ForEach(extendedSql =>
     {
         var dataSet = DataSources.Repository.ExecuteDataSet(
             context: context,
             statements: new SqlStatement(commandText: extendedSql.CommandText
                                          .Replace("{{SiteId}}", context.SiteId.ToString())
                                          .Replace("{{Id}}", context.Id.ToString())));
         foreach (DataTable dataTable in dataSet.Tables)
         {
             var table = new List <Dictionary <string, object> >();
             foreach (DataRow dataRow in dataTable.Rows)
             {
                 var row = new Dictionary <string, object>();
                 foreach (DataColumn dataColumn in dataTable.Columns)
                 {
                     row.AddIfNotConainsKey(
                         dataColumn.ColumnName,
                         dataRow[dataColumn.ColumnName]);
                 }
                 table.Add(row);
             }
             hb.Hidden(
                 controlId: dataSet.Tables.Count > 1
                         ? $"{extendedSql.Name}_{dataTable.TableName}"
                         : $"{extendedSql.Name}",
                 value: table.ToJson());
         }
     });
     return(hb);
 }
Esempio n. 16
0
        /// <nodoc />
        public static bool IsScriptFile([NotNull] this ISourceFile sourceFile)
        {
            Contract.Requires(sourceFile != null);

            return(sourceFile.OverrideIsScriptFile || ExtensionUtilities.IsScriptExtension(Path.GetExtension(sourceFile.FileName)) || sourceFile.FileName.StartsWith("Prelude."));
        }
Esempio n. 17
0
        /// <summary>
        /// Whether <param name="filePath"/> (created with <param name="pathTable"/> looks like a DScript project file.
        /// </summary>
        public static bool IsPathToProjectFile(AbsolutePath filePath, PathTable pathTable)
        {
            var fileName = filePath.GetName(pathTable).ToString(pathTable.StringTable);

            return(ExtensionUtilities.IsNonConfigurationFile(fileName));
        }
Esempio n. 18
0
        /// <nodoc />
        public static bool IsProjectFileExtension([NotNull] this ISourceFile sourceFile)
        {
            Contract.Requires(sourceFile != null);

            return(ExtensionUtilities.IsProjectFileExtension(Path.GetExtension(sourceFile.FileName)));
        }
Esempio n. 19
0
        /// <nodoc />
        public static bool IsBuildListFile([NotNull] this ISourceFile sourceFile)
        {
            Contract.Requires(sourceFile != null);

            return(ExtensionUtilities.IsBuildListFile(sourceFile.FileName));
        }
Esempio n. 20
0
 private static bool IsModuleConfigFileName(PathAtom fileName, StringTable stringTable)
 {
     return(ExtensionUtilities.IsModuleConfigurationFile(fileName.ToString(stringTable)));
 }