private IEnumerable <string> GetTemplates()
        {
            string path = Path.Combine("Sites", _shellSettings.Name, ModuleGeneratorService.ModuleTemplatesPathName);

            if (!_appDataFolder.DirectoryExists(path))
            {
                _appDataFolder.CreateDirectory(path);
            }
            return((from d in _appDataFolder.ListDirectories(path)
                    select Path.GetFileName(d)).ToList());
        }
Esempio n. 2
0
        public PipelineFilePart Upload(HttpPostedFileBase input, string role, string tag)
        {
            var part        = _orchardServices.ContentManager.New <PipelineFilePart>(Common.PipelineFileName);
            var permissions = part.As <ContentPermissionsPart>();

            permissions.Enabled = true;

            permissions.ViewContent   = "Administrator";
            permissions.EditContent   = "Administrator";
            permissions.DeleteContent = "Administrator";

            permissions.ViewOwnContent   = "Authenticated";
            permissions.EditOwnContent   = "Authenticated";
            permissions.DeleteOwnContent = "Authenticated";

            if (role != "Private")
            {
                permissions.ViewContent += "," + role;
            }

            part.As <TitlePart>().Title = input.FileName;

            if (tag != string.Empty)
            {
                var tags = tag.Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries).Where(t => !t.Equals(Common.AllTag, StringComparison.OrdinalIgnoreCase)).ToArray();
                if (tags.Any())
                {
                    _tagService.UpdateTagsForContentItem(part.ContentItem, tags);
                }
            }

            var exportFile = string.Format("{0}-{1}-{2}",
                                           _orchardServices.WorkContext.CurrentUser.UserName,
                                           _clock.UtcNow.ToString(FileTimestamp),
                                           Path.GetFileName(input.FileName)
                                           );

            if (!_appDataFolder.DirectoryExists(Common.FileFolder))
            {
                _appDataFolder.CreateDirectory(Common.FileFolder);
            }

            part.FullPath  = _appDataFolder.MapPath(_appDataFolder.Combine(Common.FileFolder, exportFile));
            part.Direction = "In";
            input.SaveAs(part.FullPath);
            _orchardServices.ContentManager.Create(part);

            _orchardServices.Notifier.Information(T("{0} uploaded successfully.", Path.GetFileName(input.FileName)));

            return(part);
        }
Esempio n. 3
0
        public PipelineFilePart Upload(HttpPostedFileBase input, string role, string tag, int number)
        {
            var part        = _orchardServices.ContentManager.New <PipelineFilePart>(Common.PipelineFileName);
            var permissions = part.As <ContentPermissionsPart>();

            permissions.Enabled = true;

            permissions.ViewContent   = "Administrator";
            permissions.EditContent   = "Administrator";
            permissions.DeleteContent = "Administrator";

            permissions.ViewOwnContent   = "Authenticated";
            permissions.EditOwnContent   = "Authenticated";
            permissions.DeleteOwnContent = "Authenticated";

            if (role != "Private")
            {
                permissions.ViewContent += "," + role;
            }

            part.OriginalName           = input.FileName;
            part.As <TitlePart>().Title = input.FileName;

            if (tag != string.Empty)
            {
                var tags = tag.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Where(t => !t.Equals(Common.AllTag, StringComparison.OrdinalIgnoreCase)).ToArray();
                if (tags.Any())
                {
                    _tagService.UpdateTagsForContentItem(part.ContentItem, tags);
                }
            }

            var exportFile = Common.GetSafeFileName(_orchardServices.WorkContext.CurrentUser.UserName, Path.GetFileName(input.FileName), number);

            var path = Common.GetAppFolder();

            if (!_appDataFolder.DirectoryExists(path))
            {
                _appDataFolder.CreateDirectory(path);
            }

            part.FullPath  = _appDataFolder.MapPath(_appDataFolder.Combine(path, exportFile));
            part.Direction = "In";
            input.SaveAs(part.FullPath);
            _orchardServices.ContentManager.Create(part);

            return(part);
        }
Esempio n. 4
0
        private void ConvertToExport(string user, Process process, PipelineConfigurationPart part, string exportType, IDictionary <string, string> parameters)
        {
            var o = process.Output();

            switch (exportType)
            {
            case "xlsx":
                var folder = Common.GetAppFolder();
                if (!_appDataFolder.DirectoryExists(folder))
                {
                    _appDataFolder.CreateDirectory(folder);
                }

                var fileName = Common.GetSafeFileName(user, _slugService.Slugify(part.Title()), "xlsx");

                o.Provider = "excel";
                o.File     = _appDataFolder.MapPath(_appDataFolder.Combine(folder, fileName));
                break;

            case "geojson":
                o.Stream   = true;
                o.Provider = "geojson";
                o.File     = _slugService.Slugify(part.Title()) + ".geojson";
                break;

            case "kml":
                o.Stream   = true;
                o.Provider = "kml";
                o.File     = _slugService.Slugify(part.Title()) + ".kml";
                break;

            default:     //csv
                o.Stream    = true;
                o.Provider  = "file";
                o.Delimiter = ",";
                o.File      = _slugService.Slugify(part.Title()) + ".csv";
                break;
            }

            parameters["page"] = "0";

            foreach (var entity in process.Entities)
            {
                entity.Page = 0;
                entity.Fields.RemoveAll(f => f.System);

                foreach (var field in entity.GetAllFields())
                {
                    if (field.Alias == Common.BatchValueFieldName)
                    {
                        field.Output = false;
                    }
                    field.T      = string.Empty; // because short-hand has already been expanded
                    field.Output = field.Output && field.Export == "defer" || field.Export == "true";
                }
            }
        }
Esempio n. 5
0
        public FilePart Upload(HttpPostedFileBase input)
        {
            var part       = _orchardServices.ContentManager.New <FilePart>("File");
            var exportFile = string.Format("{0}-{1}-{2}",
                                           _orchardServices.WorkContext.CurrentUser.UserName,
                                           _clock.UtcNow.ToString(FILE_TIMESTAMP),
                                           Path.GetFileName(input.FileName)
                                           );

            if (!_appDataFolder.DirectoryExists(TRANSFORMALIZE_FOLDER))
            {
                _appDataFolder.CreateDirectory(TRANSFORMALIZE_FOLDER);
            }

            part.FullPath  = _appDataFolder.MapPath(_appDataFolder.Combine(TRANSFORMALIZE_FOLDER, exportFile));
            part.Direction = "In";
            input.SaveAs(part.FullPath);
            _orchardServices.ContentManager.Create(part);
            _orchardServices.Notifier.Information(T("{0} uploaded successfully.", Path.GetFileName(input.FileName)));

            return(part);
        }
Esempio n. 6
0
        public void Configure(DbContextOptionsBuilder optionsBuilders)
        {
            var shellPath = _appDataFolder.Combine("Sites", _shellSettings.Name);

            _appDataFolder.CreateDirectory(shellPath);

            var shellFolder = _appDataFolder.MapPath(shellPath);

            foreach (var provider in _dataServicesProviders)
            {
                provider.ConfigureContextOptions(optionsBuilders, string.Empty);
            }
        }
Esempio n. 7
0
        private void ConvertToExport(string user, Process process, PipelineConfigurationPart part, string exportType, IDictionary <string, string> parameters)
        {
            var o = process.Output();

            switch (exportType)
            {
            case "xlsx":
                if (!_appDataFolder.DirectoryExists(Common.FileFolder))
                {
                    _appDataFolder.CreateDirectory(Common.FileFolder);
                }

                var fileName = $"{user}-{_clock.UtcNow.ToString(FileTimestamp)}-{_slugService.Slugify(part.Title())}.xlsx";

                o.Provider = "excel";
                o.File     = _appDataFolder.MapPath(_appDataFolder.Combine(Common.FileFolder, fileName));
                break;

            case "geojson":
                o.Stream   = true;
                o.Provider = "geojson";
                o.File     = _slugService.Slugify(part.Title()) + ".geojson";
                break;

            case "kml":
                o.Stream   = true;
                o.Provider = "kml";
                o.File     = _slugService.Slugify(part.Title()) + ".kml";
                break;

            default:     //csv
                o.Stream    = true;
                o.Provider  = "file";
                o.Delimiter = ",";
                o.File      = _slugService.Slugify(part.Title()) + ".csv";
                break;
            }

            parameters["page"] = "0";

            foreach (var entity in process.Entities)
            {
                entity.Page = 0;
                entity.Fields.RemoveAll(f => f.System);

                foreach (var field in entity.GetAllFields())
                {
                    field.Output = field.Output && field.Export == "defer" || field.Export == "true";
                }
            }
        }
        public SessionFactoryParameters GetSessionFactoryParameters()
        {
            var shellPath = _appDataFolder.Combine("Sites", _shellSettings.Name);

            _appDataFolder.CreateDirectory(shellPath);

            var shellFolder = _appDataFolder.MapPath(shellPath);

            return(new SessionFactoryParameters {
                Provider = _shellSettings.DataProvider,
                DataFolder = shellFolder,
                ConnectionString = _shellSettings.DataConnectionString,
                RecordDescriptors = _shellBlueprint.Records,
            });
        }
        private string WriteExportFile(string exportDocument)
        {
            var exportFile = string.Format("Export-{0}-{1}.xml", _orchardServices.WorkContext.CurrentUser.UserName, DateTime.UtcNow.Ticks);

            if (!_appDataFolder.DirectoryExists(ExportsDirectory))
            {
                _appDataFolder.CreateDirectory(ExportsDirectory);
            }

            var path = _appDataFolder.Combine(ExportsDirectory, exportFile);

            _appDataFolder.CreateFile(path, exportDocument);

            return(_appDataFolder.MapPath(path));
        }
Esempio n. 10
0
        public void Configure(DbContextOptionsBuilder optionsBuilders)
        {
            var shellPath = _appDataFolder.Combine("Sites", _shellSettings.Name);

            _appDataFolder.CreateDirectory(shellPath);

            var shellFolder = _appDataFolder.MapPath(shellPath);

            _dataServicesProviderFactory.CreateProvider(
                new DataServiceParameters {
                Provider         = _shellSettings.DataProvider,
                ConnectionString = _shellSettings.DataConnectionString,
                DataFolder       = shellFolder
            })
            .ConfigureContextOptions(optionsBuilders, _shellSettings.DataConnectionString);
        }
Esempio n. 11
0
        public string WriteExportFile(XDocument recipeDocument)
        {
            var exportFile = String.Format("Export-{0}-{1}.xml", _orchardServices.WorkContext.CurrentUser.UserName, _clock.UtcNow.Ticks);

            if (!_appDataFolder.DirectoryExists(ExportsDirectory))
            {
                _appDataFolder.CreateDirectory(ExportsDirectory);
            }

            var path = _appDataFolder.Combine(ExportsDirectory, exportFile);

            using (var writer = new XmlTextWriter(_appDataFolder.CreateFile(path), Encoding.UTF8)) {
                writer.Formatting = Formatting.Indented;
                recipeDocument.WriteTo(writer);
            }

            return(_appDataFolder.MapPath(path));
        }
        public DbContextOptions BuildConfiguration()
        {
            lock (this)
            {
                if (_dbContextOptions == null)
                {
                    var shellPath = _appDataFolder.Combine("Sites", _shellSettings.Name);
                    _appDataFolder.CreateDirectory(shellPath);

                    var shellFolder = _appDataFolder.MapPath(shellPath);

                    _dbContextOptions = _dataServicesProviderFactory.CreateProvider(
                        new DataServiceParameters
                    {
                        Provider         = _shellSettings.DataProvider,
                        ConnectionString = _shellSettings.DataConnectionString,
                        DataFolder       = shellFolder
                    })
                                        .BuildContextOptions();
                }
            }
            return(_dbContextOptions);
        }
        private void ConvertToExport(string user, Process process, PipelineConfigurationPart part, string exportType)
        {
            var o = process.Output();

            switch (exportType)
            {
            case "xlsx":
                var folder = Common.GetAppFolder();
                if (!_appDataFolder.DirectoryExists(folder))
                {
                    _appDataFolder.CreateDirectory(folder);
                }

                var fileName = Common.GetSafeFileName(user, _slugService.Slugify(part.Title()), "xlsx");

                o.Provider = "excel";
                o.File     = _appDataFolder.MapPath(_appDataFolder.Combine(folder, fileName));
                break;

            case "geojson":
                o.Stream   = true;
                o.Provider = "geojson";
                o.File     = _slugService.Slugify(part.Title()) + ".geo.json";

                var suppress = new HashSet <string>()
                {
                    Common.BatchValueFieldName, part.MapColorField, part.MapPopUpField
                };
                var coordinates = new HashSet <string>()
                {
                    part.MapLatitudeField, part.MapLongitudeField
                };
                foreach (var entity in process.Entities)
                {
                    foreach (var field in entity.GetAllFields())
                    {
                        if (suppress.Contains(field.Alias))
                        {
                            field.Output   = false;
                            field.Property = false;
                            field.Alias   += "Suppressed";
                        }
                        else if (coordinates.Contains(field.Alias))
                        {
                            field.Property = field.Export == "true";
                        }
                        else
                        {
                            field.Property = field.Property || field.Output && field.Export == "defer" || field.Export == "true";
                        }
                    }
                }

                break;

            case "map":
                o.Stream   = true;
                o.Provider = "geojson";
                o.File     = _slugService.Slugify(part.Title()) + ".geo.json";

                var mapFields = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase)
                {
                    { part.MapColorField, "geojson-color" },
                    { part.MapPopUpField, "geojson-description" },
                    { part.MapLatitudeField, "latitude" },
                    { part.MapLongitudeField, "longitude" },
                    { Common.BatchValueFieldName, Common.BatchValueFieldName }
                };

                ConfineData(process, mapFields);
                break;

            case "json":
                o.Stream   = true;
                o.Provider = "json";
                o.File     = _slugService.Slugify(part.Title()) + ".json";
                break;

            case "calendar":
                o.Stream   = true;
                o.Provider = "json";
                o.File     = _slugService.Slugify(part.Title()) + ".json";
                var calendarFields = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase)
                {
                    { part.CalendarIdField, "id" },
                    { part.CalendarTitleField, "title" },
                    { part.CalendarUrlField, "url" },
                    { part.CalendarClassField, "class" },
                    { part.CalendarStartField, "start" },
                    { part.CalendarEndField, "end" },
                    { Common.BatchValueFieldName, Common.BatchValueFieldName }
                };
                ConfineData(process, calendarFields);
                break;

            case "kml":
                o.Stream   = true;
                o.Provider = "kml";
                o.File     = _slugService.Slugify(part.Title()) + ".kml";
                break;

            default: // csv
                o.Stream        = true;
                o.Provider      = "file";
                o.Delimiter     = ",";
                o.TextQualifier = "\"";
                o.File          = _slugService.Slugify(part.Title()) + ".csv";
                break;
            }

            // common
            foreach (var entity in process.Entities)
            {
                entity.Fields.RemoveAll(f => f.System);

                foreach (var field in entity.GetAllFields())
                {
                    field.T = string.Empty; // because short-hand has already been expanded
                    switch (exportType)
                    {
                    case "map":
                    case "calendar":
                    case "geojson":
                        // already been modified
                        break;

                    default:
                        if (field.Alias == Common.BatchValueFieldName)
                        {
                            field.Output = false;
                        }
                        field.Output = field.Output && field.Export == "defer" || field.Export == "true";
                        break;
                    }
                }
            }
        }