public ScanCoreDto GetScanCore(long projectId) { var cores = new Dictionary <string, string> { { "sharp-use", "C#" }, { "java-use", "Java" }, { "php-use", "PHP" }, { "fingerprint-use", "Fingerprint" }, { "pm-use", "Pattern Matching" }, { "config-use", "Configurations" }, { "blackbox-use", "Blackbox" } }; var active = cores.Where( pair => { var setting = _settingsHelper.Get(SettingOwnerDto.Project, projectId, pair.Key); if (setting == null) { return(false); } var value = Convert.ToBoolean(setting.Value); return(value); }).ToList(); return(new ScanCoreDto { Key = string.Join(", ", active.Select(pair => pair.Key)), DisplayName = string.Join(", ", active.Select(pair => pair.Value)) }); }
public async Task <IActionResult> Detail(string id) { var album = await _context.Albums .Include(a => a.Images) .SingleAsync(a => a.Id == id); if (album == null) { return(NotFound()); } if (!await HasPermissionTo(album)) { return(Forbid()); } album.Images = album.Images.OrderByDescending(i => i.UploadTimeUtc).ToList(); return(View(new DetailViewModel { Album = album, StatusMessage = StatusMessage, UploadViewModel = new UploadViewModel { TinifyEnabled = bool.Parse(await _settingsHelper.Get(Settings.EnableTinifyCompress)) } })); }
public async Task <IActionResult> Index() { return(View(new BasicSettingViewModel { ImageCacheTime = TimeSpan.Parse(await _settingsHelper.Get(Settings.ImageCacheTime)), DisableUserRegistration = bool.Parse(await _settingsHelper.Get(Settings.DisableUserRegistration)), StatusMessage = StatusMessage })); }
protected override void OnViewLoaded(object view) { ServiceInvoicePreviewView v = GetView() as ServiceInvoicePreviewView; string basePath = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); string reportPath = basePath + @"\" + _settings.Get("reportPath").Replace("/", "\\").Trim(); if (_invoiceModel != null) { v.SetInvoiceModel(_invoiceModel, reportPath, _settings.Get("noHpToko"), _settings.Get("alamatToko")); } base.OnViewLoaded(view); }
public ImageController( ApplicationDbContext context, IAwsHelper awsHelper, ISettingsHelper settingsHelper, UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager ) { _context = context; _awsHelper = awsHelper; _settingsHelper = settingsHelper; _userManager = userManager; _signInManager = signInManager; _bucketName = _settingsHelper.Get(Settings.S3BucketName).GetAwaiter().GetResult(); _imageCacheTime = TimeSpan.Parse(_settingsHelper.Get(Settings.ImageCacheTime).GetAwaiter().GetResult()); }
public async Task SendSMS(SMSMessage message) { var settings = (await _settingsHelper.Get()).Global.Clickatell; if (settings == null || settings.ApiKey == null || settings.ApiUrl == null) { throw new Exception("Clickatell not set up"); } var request = GetRequestFromMessage(message, settings); await SendMessage(request, settings); }
private async Task <User> AutoLogin(LoginResult result, HttpContext context) { if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { result.Error = "Automatic login is only supported on Windows"; return(null); } if (!(context.User.Identity is WindowsIdentity) || ((WindowsIdentity)context.User.Identity).IsAnonymous) { throw new UnauthorizedAccessException("Unauthorized"); // triggers NTLM auth in browser } ; var winUser = (WindowsIdentity)context.User.Identity; var authenticationGroup = (await _settingsHelper.Get()).Global.AuthenticationGroup; if (string.IsNullOrEmpty(authenticationGroup)) { result.Error = "Authentication group not set up"; return(null); } var groupNames = winUser.Groups.Select(x => x.Translate(typeof(NTAccount)).Value); if (!groupNames.Any(x => x.Substring(x.IndexOf(@"\") + 1) == authenticationGroup)) { result.Error = $"You are not part of the '{authenticationGroup}' group"; return(null); } var username = Regex.Replace(winUser.Name, ".*\\\\(.*)", "$1", RegexOptions.None); var user = await _users.GetAll().FirstOrDefaultAsync(x => x.Username == username); if (user == null) { user = new User { Username = username, IsWindowsUser = true }; _users.Add(user); await _users.SaveChangesAsync(); } else if (!user.IsWindowsUser) { result.Error = $"User {user.Username} exists but is not a windows user"; return(null); } result.Success = true; return(user); }
public AccountController( UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, IEmailSender emailSender, ILogger <AccountController> logger, ISettingsHelper settingsHelper ) { _userManager = userManager; _signInManager = signInManager; _emailSender = emailSender; _logger = logger; _registrationDisabled = bool.Parse( settingsHelper.Get(Data.Settings.DisableUserRegistration).GetAwaiter().GetResult() ); }
protected override async Task SendNotification(NotificationType type, string message, string failedAfter = null) { var settings = (await _settingsHelper.Get()).Global.Email; if (settings == null || string.IsNullOrEmpty(settings.From) || string.IsNullOrEmpty(settings.Server) || settings.Port == null) { throw new Exception("Email not set up"); } var emailIDs = _notification.GetOptions <Options>().EmailAddresses; var emailAddresses = _settings.Contacts.Where(x => emailIDs.Contains(x.ID)).Select(x => x.Value); var subject = $"SystemChecker - {_check.Name}: {_result.Status.Name.ToString()} (Type: {_result.Status.Type.Name})"; var from = settings.From; _logger.Info($"Sending email notification from {from} to {string.Join(", ", emailAddresses.ToArray())} with subject {subject}: {message}"); _logger.Info($"Using SMTP server {settings.Server}:{settings.Port} with {(string.IsNullOrEmpty(settings.Username) ? "no username" : $" username {settings.Username}")} and {(settings.TLS ? "with" : "without")} TLS");
private async Task <SlackClient> GetClient() { if (_client != null) { return(_client); } var settings = await _settingsHelper.Get(); var token = settings.Global.SlackToken; if (string.IsNullOrEmpty(token)) { throw new Exception("Slack token not setup"); } _client = new SlackClient(token); return(_client); }
public AlbumController( ApplicationDbContext context, UserManager <ApplicationUser> userManager, ISettingsHelper settingsHelper, IAwsHelper awsHelper, SignInManager <ApplicationUser> signInManager, ILogger <AlbumController> logger ) { _context = context; _userManager = userManager; _awsHelper = awsHelper; _settingsHelper = settingsHelper; _signInManager = signInManager; _logger = logger; _bucketName = _settingsHelper.Get(Settings.S3BucketName).GetAwaiter().GetResult(); }
private void InitializeClient() { var jsonFormatter = HttpClientDefaults.MediaTypeFormatters.OfType <JsonMediaTypeFormatter>().FirstOrDefault(); jsonFormatter.SerializerSettings = new JsonSerializerSettings { Converters = new List <JsonConverter> { new CustomDateTimeConverter() }, }; string api = _settings.Get("apiUrl"); _apiClient = new HttpClient { BaseAddress = new Uri(api), }; _apiClient.DefaultRequestHeaders.Accept.Clear(); _apiClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); }
public async Task <AmazonS3Client> GetS3Client() { // TODO: Remove or implement proxy setting after development #if DEBUG Amazon.AWSConfigs.ProxyConfig.Host = "http://127.0.0.1"; Amazon.AWSConfigs.ProxyConfig.Port = 1082; #endif var store = new SharedCredentialsFile(); var activeAwsProfileName = await _settingsHelper.Get(Settings.AwsActiveProfile); if (string.IsNullOrEmpty(activeAwsProfileName)) { throw new Exception("No active aws profile was set."); } store.TryGetProfile(activeAwsProfileName, out var profile); AmazonS3Client s3 = new AmazonS3Client(new BasicAWSCredentials( profile.Options.AccessKey, profile.Options.SecretKey ), profile.Region); return(s3); }
public async Task <CheckerSettings> GetSettingsAsync() { return(await _settingsHelper.Get()); }
public async Task <ISettings> GetSettings() { return(await _settingsHelper.Get()); }