コード例 #1
0
        public static string GetUploadUrl(HttpRequest request, string localPath, long idObject, string type)
        {
            var uploadPath = OrganizationManager.GetOrgUploadPath(request);

            if (localPath != null && localPath != "")
            {
                return(uploadPath + "/" + localPath);
            }

            var staticPath = OrganizationManager.GetOrgPrivateStaticPath(request);

            return($"{staticPath}/{type}/default1.png");
        }
コード例 #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc()
            .AddJsonOptions(opt =>
            {
                opt.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;
            });

            services.AddCors();

            var appSection = Configuration.GetSection("App");
            var appConfig  = new Config();

            services.Configure <Config>(appSection);
            appSection.Bind(appConfig);

            var dbSection = Configuration.GetSection("db");

            services.Configure <PostgresqlConfig>(dbSection);

            //var dbConfig = new PostgresqlConfig();
            //dbSection.Bind(dbConfig);

            services.Configure <CorsConfig>(Configuration.GetSection("cors"));
            //services.Configure<Organization>(Configuration.GetSection("organization"));

            ConfigureAuth(services);

            // Disk storage
            var diskStorageSection = Configuration.GetSection("storage.disk");
            var diskStorageConfig  = new DiskStorageProviderConfig();

            diskStorageSection.Bind(diskStorageConfig);

            services.Configure <DiskStorageProviderConfig>(diskStorageSection);
            services.AddSingleton(typeof(IStorageProvider), new DiskStorageProvider(diskStorageConfig));

            services.AddSingleton(typeof(NotificationManager), new NotificationManager(appConfig));

            OrganizationManager.Initialize(OrganizationManager.LoadOrganizationsFromFile("organizations.json"));
        }
コード例 #3
0
        public bool SendEmail(HttpRequest httpRequest, string toAddress, string subject, string textContent, string htmlContent)
        {
            if (httpRequest == null)
            {
                throw new ArgumentNullException("httpRequest");
            }
            if (toAddress == null)
            {
                throw new ArgumentNullException("toAddress");
            }
            if (subject == null)
            {
                throw new ArgumentNullException("subject");
            }

            var cfg        = OrganizationManager.GetConfigForRequest(httpRequest);
            var mailgunCfg = cfg.MailgunConfiguration;

            if (mailgunCfg == null)
            {
                throw new Exception("Error.EmailNotconfigured");
            }

            var result = SendEmail(mailgunCfg, toAddress, subject, textContent, htmlContent);

            if (result == null)
            {
                return(true);                 // ignore empty config
            }
            if (!result.IsSuccessful)
            {
                Log.Error(result.Content);
            }

            return(result.IsSuccessful);
        }