protected virtual bool TryPrepareValue(DbConnection connection, ColumnMapper columnMapper, TableInfo table, string columnName, ref object value)
        {
            if (columnName.Equals(table.TenantColumn, StringComparison.OrdinalIgnoreCase))
            {
                var tenantMapping = columnMapper.GetTenantMapping();
                if (tenantMapping < 1)
                {
                    return(false);
                }
                value = tenantMapping;
                return(true);
            }

            if (table.UserIDColumns.Any(x => columnName.Equals(x, StringComparison.OrdinalIgnoreCase)))
            {
                var strVal      = Convert.ToString(value);
                var userMapping = columnMapper.GetUserMapping(strVal);
                if (userMapping == null)
                {
                    return(helpers.IsEmptyOrSystemUser(strVal));
                }
                value = userMapping;
                return(true);
            }

            var mapping = columnMapper.GetMapping(table.Name, columnName, value);

            if (mapping != null)
            {
                value = mapping;
            }

            return(true);
        }
Exemple #2
0
        public override Stream PrepareData(string key, Stream stream, ColumnMapper columnMapper)
        {
            if (!key.EndsWith("body.html"))
            {
                return(stream);
            }

            using (var streamReader = new StreamReader(stream, Encoding.UTF8, true, 1024, true))
            {
                var data = streamReader.ReadToEnd();
                data = Regex.Replace(data, @"(htmleditorfiles|aggregator)(\/0\/|\/[\d]+\/\d\d\/\d\d\/)([-\w]+(?=/))",
                                     match => "/" + TenantPath.CreatePath(columnMapper.GetTenantMapping().ToString()) + "/" + columnMapper.GetUserMapping(match.Groups[3].Value));

                var content = Encoding.UTF8.GetBytes(data);

                stream.Position = 0;
                stream.Write(content, 0, content.Length);
            }

            return(stream);
        }
Exemple #3
0
 public override bool TryAdjustFilePath(bool dump, ColumnMapper columnMapper, ref string filePath)
 {
     //todo: hack: will be changed later
     filePath = Regex.Replace(filePath, @"^[-\w]+(?=/)", match => dump ? match.Value : columnMapper.GetUserMapping(match.Value));
     return(!filePath.StartsWith("/"));
 }
        protected virtual bool TryPrepareValue(IDbConnection connection, ColumnMapper columnMapper, TableInfo table, string columnName, ref object value)
        {
            if (columnName.Equals(table.TenantColumn, StringComparison.OrdinalIgnoreCase))
            {
                int tenantMapping = columnMapper.GetTenantMapping();
                if (tenantMapping < 1)
                    return false;
                value = tenantMapping;
                return true;
            }

            if (table.UserIDColumns.Any(x => columnName.Equals(x, StringComparison.OrdinalIgnoreCase)))
            {
                var strVal = Convert.ToString(value);
                string userMapping = columnMapper.GetUserMapping(strVal);
                if (userMapping == null)
                    return Helpers.IsEmptyOrSystemUser(strVal);
                value = userMapping;
                return true;
            }

            var mapping = columnMapper.GetMapping(table.Name, columnName, value);
            if (mapping != null)
                value = mapping;

            return true;
        }
 public override bool TryAdjustFilePath(ColumnMapper columnMapper, ref string filePath)
 {
     //todo: hack: will be changed later
     filePath = Regex.Replace(filePath, @"^[-\w]+(?=/)", match => columnMapper.GetUserMapping(match.Value));
     return !filePath.StartsWith("/");
 }