private void LoadConfigFromDb()
 {
     AccessKey        = SettingRepository.Get <string>("AWSKey");
     SecretKey        = SettingRepository.Get <string>("AWSSecret");
     bucketName       = SettingRepository.Get <string>("AWSBucketName");
     DefaultImagePath = SettingRepository.Get <string>("AWSDefaultImageURL");
 }
Beispiel #2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Store.CreateDatabase();

            SettingRepository settingRepository = new SettingRepository();

            Store.settings = settingRepository.GetAll();

            string isProtected = Store.settings.Where(s => s.Key == Store.SETTING_IS_PROTECTED).Single().Value;

            if (isProtected == "True")
            {
                Store.userName = Store.settings.Where(s => s.Key == Store.SETTING_USER_NAME).Single().Value;
                Store.password = Store.settings.Where(s => s.Key == Store.SETTING_PASSWORD).Single().Value;

                Application.Run(new LoginUI());
            }
            else
            {
                Application.Run(new MainUI());
            }
        }
Beispiel #3
0
 public UnitOfWork(bbuContext context)
 {
     _context             = context;
     Addresses            = new AddressRepository(_context);
     AppUsers             = new AppUserRepository(_context);
     Banks                = new BankRepository(_context);
     BankAccounts         = new BankAccountRepository(_context);
     Cemeteries           = new CemeteryRepository(_context);
     Credentials          = new CredentialsRepository(_context);
     Deceaseds            = new DeceasedRepository(_context);
     Doctors              = new DoctorRepository(_context);
     Employees            = new EmployeeRepository(_context);
     Files                = new FileRepository(_context);
     Funerals             = new FuneralRepository(_context);
     FuneralDocuments     = new FuneralDocumentRepository(_context);
     Genders              = new GenderRepository(_context);
     HomeAffairsOffices   = new HomeAffairsOfficeRepository(_context);
     HomeAffairsOfficers  = new HomeAffairsOfficerRepository(_context);
     Hospitals            = new HospitalRepository(_context);
     Informants           = new InformantRepository(_context);
     Members              = new MemberRepository(_context);
     Months               = new MonthRepository(_context);
     Mortuaries           = new MortuaryRepository(_context);
     NextOfKins           = new NextOfKinRepository(_context);
     NumberConfigurations = new NumberConfigurationRepository(_context);
     Payments             = new PaymentRepository(_context);
     PaymentPeriods       = new PaymentPeriodRepository(_context);
     People               = new PersonRepository(_context);
     PurchaseItems        = new PurchaseItemRepository(_context);
     Settings             = new SettingRepository(_context);
     States               = new StateRepository(_context);
     Suppliers            = new SupplierRepository(_context);
     Tasks                = new TaskRepository(_context);
     Years                = new YearRepository(_context);
 }
Beispiel #4
0
 public CommentController(FujiyBlogDatabase db, SettingRepository settings, ICompositeViewEngine viewEngine, IEmailSender emailSender)
 {
     this.db          = db;
     this.settings    = settings;
     this.viewEngine  = viewEngine;
     this.emailSender = emailSender;
 }
        public void LoginHPIDTest_ReturnsFault()
        {
            SettingRepository.SetSettingsRepositoryData(new List <AdmSettings>()
            {
                new AdmSettings {
                    ParamName = "HPIDEnabled", StringValue = "true"
                }
            });

            RESTAPIProfileController api = new RESTAPIProfileController();
            RESTAPILoginCredentials  req = new RESTAPILoginCredentials()
            {
                UserName = "",
                Password = "",
                CallerId = "",
                Platform = "",
                Locale   = ""
            };
            GetProfileResponse profileRes = new GetProfileResponse()
            {
                ErrorList = new HashSet <Fault>()
                {
                    new Fault("Profile", "", "")
                }
            };

            hpidMock.Setup(x => x.GetCustomerProfileByTestLogin(It.IsAny <UserAuthenticationInterchange>(), It.IsAny <bool>(), It.IsAny <APIMethods>())).Returns(profileRes);
            RESTAPILoginResponse response = api.Login(req);

            Assert.IsTrue(response.ErrorList.Count == 1);
            Assert.AreEqual(response.ErrorList.First().Origin, "Profile");
        }
Beispiel #6
0
        public static SelectList GetSelectList_Setting(object sValue, string Code, string NullOrNameEmpty)
        {
            var selectListItems = new List <SelectListItem>();
            SettingRepository settingRepository = new SettingRepository(new Domain.ErpDbContext());

            if (NullOrNameEmpty != null)
            {
                SelectListItem itemEmpty = new SelectListItem();
                itemEmpty.Text  = NullOrNameEmpty;
                itemEmpty.Value = null;
                selectListItems.Add(itemEmpty);
            }
            try
            {
                var q = settingRepository.GetAll().Where(x => x.Code == Code).OrderBy(item => item.Id);
                foreach (var i in q)
                {
                    SelectListItem item = new SelectListItem();
                    item.Text  = i.Note;
                    item.Value = i.Key.ToString();
                    selectListItems.Add(item);
                }
            }
            catch { }

            var selectList = new SelectList(selectListItems, "Value", "Text", sValue);

            return(selectList);
        }
 public FeedGenerator(FeedRepository feedRepository, SettingRepository settings, IHttpContextAccessor contextAccessor, IUrlHelperFactory urlHelperFactory, IActionContextAccessor actionContextAccesor)
 {
     this.feedRepository  = feedRepository;
     this.settings        = settings;
     this.contextAccessor = contextAccessor;
     this.urlHelper       = urlHelperFactory.GetUrlHelper(actionContextAccesor.ActionContext);
 }
Beispiel #8
0
        public SettingUI()
        {
            accountRepository = new AccountRepository();
            settingRepository = new SettingRepository();

            InitializeComponent();
        }
Beispiel #9
0
        public void TestSettingRepository1()
        {
            var cat = new SettingRepository(new StoreContext(ConnectionString));
            var m   = cat.GetStoreSettingsByType(9, "", "blogs");

            Console.WriteLine(m.Count);
        }
Beispiel #10
0
        private static int loadCounter(string name)
        {
            int retryCounter;

            try
            {
                if (SettingRepository.IsSettingRepositoryLoaded)
                {
                    retryCounter = SettingRepository.Get <int>(name);
                    if (retryCounter <= 0)
                    {
                        retryCounter = defaultCounter;
                    }
                    SetIsLoadedFlag(name);
                }
                else
                {
                    return(defaultCounter);
                }
            }
            catch
            {
                retryCounter = defaultCounter;
            }
            return(retryCounter);
        }
        public void GatewaySyncState_SettingWasSaveWithoutValue_ShouldReturnSameValue()
        {
            // .: Setup
            var settingsRepository     = new SettingRepository(_dbContext);
            var gatewaySyncSettingsDao = new GatewaySyncStateSettingsDao(settingsRepository);
            var settingService         = new SettingsService(gatewaySyncSettingsDao);

            var expectedDate = 1601000400;
            var testState    = new GatewayUploadState()
            {
                CreationDateOfLastUploadedKey = expectedDate
            };

            // .: Act
            settingService.SaveGatewaySyncState(testState);
            var syncState = settingService.GetGatewayUploadState();

            // .: Validate
            syncState.Should()
            .NotBeNull()
            .And.IsSameOrEqualTo(testState);

            syncState.CreationDateOfLastUploadedKey.Should()
            .Be(expectedDate);
        }
Beispiel #12
0
        public async Task Update_ReturnsUpdatedSettings()
        {
            string settingsJson = File.ReadAllText(TestConfiguration.MockDataFolderPath + @"Settings.json");
            var    settings     = JsonConvert.DeserializeObject <List <Setting> >(settingsJson);

            string userSettingsJson = File.ReadAllText(TestConfiguration.MockDataFolderPath + @"UserSettings.json");
            var    userSetting      = JsonConvert.DeserializeObject <List <UserSetting> >(userSettingsJson).First(s => s.User.Id == TESTING_USER_ID);

            string settingName  = Setting.SettingOptions.ShowBalance.ToString();
            string settingValue = false.ToString().ToLower();

            var newUserSetting = new UserSetting
            {
                Id    = userSetting.Id,
                Name  = userSetting.Name,
                Value = settingValue
            };

            UserSettingRepository.Setup(s => s.GetByName(newUserSetting.Name)).Returns(userSetting);

            UserSettingRepository.Setup(s => s.Update(userSetting)).ReturnsAsync(userSetting);

            SettingRepository.Setup(s => s.GetByKey(settingName)).Returns(settings.First(c => c.Name == settingName));


            var resultUserSetting = await UserSettingService.Update(newUserSetting);


            Assert.NotNull(resultUserSetting);
            Assert.NotNull(resultUserSetting.User);
            Assert.NotNull(resultUserSetting.Setting);
            Assert.Equal(TESTING_USER_ID, resultUserSetting.User.Id);
            Assert.Equal(settingName, resultUserSetting.Setting.Name);
            Assert.Equal(settingValue, resultUserSetting.Value);
        }
        public FormCreateUserFields()
        {
            InitializeComponent();
            metroGridTables.AutoGenerateColumns = false;
            metroTabControl1.SelectedIndex      = 0;

            FillServerTypes();
            FormatFiedType();
            FormatFieldSubType();
            metroTabPageCreateUserField.Hide();

            _tableRepository           = new Infra.SAPTableRepository(DataConnection.Instance);
            _connectionParamRepository = new Infra.ConnectionParamRepository(DataConnection.Instance);
            _settingRepository         = new SettingRepository(DataConnection.Instance);
            _connectinoParam           = _connectionParamRepository.GetConnectionParam();
            _SAPFieldRepository        = new SAPFieldRepository(_company);
            if (_connectinoParam == null)
            {
                _connectinoParam = new ConnectionParam();
            }
            metroComboBoxLanguage.SelectedValueChanged += MetroComboBoxLanguage_SelectedValueChanged;
            metroGridTables.CellMouseClick             += MetroGridTables_CellMouseClick;
            SetSetting();
            FillControls();

            metroToolTip2.SetToolTip(metroLinkContact, "*****@*****.**");
        }
Beispiel #14
0
        private async Task SetCacheItemsAsync(
            string providerName,
            string providerKey,
            string currentName,
            SettingCacheItem currentCacheItem)
        {
            var settingDefinitions = SettingDefinitionManager.GetAll();
            var settingsDictionary = (await SettingRepository.GetListAsync(providerName, providerKey))
                                     .ToDictionary(s => s.Name, s => s.Value);

            var cacheItems = new List <KeyValuePair <string, SettingCacheItem> >();

            foreach (var settingDefinition in settingDefinitions)
            {
                var settingValue = settingsDictionary.GetOrDefault(settingDefinition.Name);

                cacheItems.Add(
                    new KeyValuePair <string, SettingCacheItem>(
                        CalculateCacheKey(settingDefinition.Name, providerName, providerKey),
                        new SettingCacheItem(settingValue)
                        )
                    );

                if (settingDefinition.Name == currentName)
                {
                    currentCacheItem.Value = settingValue;
                }
            }

            await Cache.SetManyAsync(cacheItems, considerUow : true);
        }
Beispiel #15
0
 public FeedGenerator(SettingRepository settingRepository, FeedRepository feedRepository, LinkGenerator linkGenerator, IHttpContextAccessor contextAccessor)
 {
     this.settingRepository = settingRepository;
     this.feedRepository    = feedRepository;
     this.linkGenerator     = linkGenerator;
     this.contextAccessor   = contextAccessor;
 }
Beispiel #16
0
        public async Task <APIGatewayProxyResponse> GetUserSettingAsync(APIGatewayProxyRequest request, ILambdaContext context)
        {
            string username = null;

            if (request.PathParameters.ContainsKey("username"))
            {
                username = request.PathParameters["username"].ToString();
            }

            if (!string.IsNullOrEmpty(username))
            {
                var repo    = new SettingRepository(_tableName);
                var setting = await repo.RetrieveUserSetting(username);

                if (setting != null)
                {
                    return(new APIGatewayProxyResponse
                    {
                        StatusCode = (int)HttpStatusCode.OK,
                        Body = JsonConvert.SerializeObject(setting),
                        Headers = _responseHeader
                    });
                }
            }

            return(new APIGatewayProxyResponse
            {
                StatusCode = (int)HttpStatusCode.NotFound
            });
        }
Beispiel #17
0
 static CustomerUtils()
 {
     // read once from web.config
     SettingRepository.TryGet <int>("supportLocationsCallRefreshCount", out supportLocationsCallRefreshCount);
     SupportLocationsCacheData = new ConcurrentQueue <string>();
     // SettingRepository.TryGet<bool>("SynchronizeIsaacOnGetProfile", out SynchronizeIsaacOnGetProfile);
 }
Beispiel #18
0
    private async Task <List <KeyValuePair <string, SettingCacheItem> > > SetCacheItemsAsync(
        string providerName,
        string providerKey,
        List <string> notCacheKeys)
    {
        var settingDefinitions = SettingDefinitionManager.GetAll().Where(x => notCacheKeys.Any(k => GetSettingNameFormCacheKeyOrNull(k) == x.Name));

        var settingsDictionary = (await SettingRepository.GetListAsync(notCacheKeys.Select(GetSettingNameFormCacheKeyOrNull).ToArray(), providerName, providerKey))
                                 .ToDictionary(s => s.Name, s => s.Value);

        var cacheItems = new List <KeyValuePair <string, SettingCacheItem> >();

        foreach (var settingDefinition in settingDefinitions)
        {
            var settingValue = settingsDictionary.GetOrDefault(settingDefinition.Name);
            cacheItems.Add(
                new KeyValuePair <string, SettingCacheItem>(
                    CalculateCacheKey(settingDefinition.Name, providerName, providerKey),
                    new SettingCacheItem(settingValue)
                    )
                );
        }

        await Cache.SetManyAsync(cacheItems, considerUow : true);

        return(cacheItems);
    }
        public override void OnAuthorization(HttpActionContext actionContext)
        {
            base.OnAuthorization(actionContext);
            ResponseBase r          = new ResponseBase();
            var          Controller = actionContext.ControllerContext.Controller as Controllers.RESTAPIControllerBase;

            try
            {
                UserAuthentication auth = new UserAuthentication();
                DatabaseWrapper.databaseOperation(r, (context, query) => { auth = query.GetHPPToken(context, Controller.UserID, Controller.CallerId); }, readOnly: true);
                int maxSessionTime = SettingRepository.Get <int>("MaxSessionTimeMinutes", 60);

                if (auth.CreatedDate != null || auth.CreatedDate.AddMinutes(maxSessionTime) < DateTime.UtcNow)
                {
                    this.ExecuteLogout(actionContext, r, Controller);
                    return;
                }
                if (r.ErrorList.Count == 0)
                {
                    IsAuthorized(actionContext);
                }
                return;
            }
            catch (Exception)
            {
                this.ExecuteLogout(actionContext, r, Controller);
            }
        }
        public RESTAPILoginResponse Login(RESTAPILoginCredentials req)
        {
            GetProfileResponse            response           = new GetProfileResponse();
            UserAuthenticationInterchange hppAuthInterchange = new UserAuthenticationInterchange()
            {
                UserName          = req.UserName,
                Password          = req.Password,
                CallerId          = req.CallerId,
                Token             = null,
                LanguageCode      = req.LanguageCode,
                CountryCode       = req.CountryCode,
                UseCaseGroup      = req.ClientViewer,
                Platform          = req.Platform,
                ClientApplication = UserAuthenticationInterchange.MapPlatformToClientApplication(req.Platform)
            };

            if (SettingRepository.Get <bool>("TESTLoginEnabled", true))
            {
                response = HPIDUtils.GetCustomerProfileByTestLogin(hppAuthInterchange, false, APIMethods.None);
            }
            else
            {
                if (SettingRepository.Get <bool>("HPIDEnabled", true))
                {
                    response = HPIDUtils.GetCustomerProfileByLogin(hppAuthInterchange, false, APIMethods.None);
                }
                //else
                //{
                //    response = customerUtils.GetCustomerProfile(hppAuthInterchange, false);
                //}
            }

            RESTAPILoginResponse loginResponse = new RESTAPILoginResponse();

            if (response.ErrorList.Count == 0)
            {
                loginResponse.UserID       = response.Credentials.UserID;
                loginResponse.SessionToken = response.Credentials.SessionToken;
                loginResponse.CallerId     = response.Credentials.CallerId;

                loginResponse.Roles        = response.Credentials.Roles;
                loginResponse.Locale       = response.CustomerProfileObject.Locale;
                loginResponse.FirstName    = response.CustomerProfileObject.FirstName;
                loginResponse.LastName     = response.CustomerProfileObject.LastName;
                loginResponse.Emailaddress = response.CustomerProfileObject.EmailAddress;

                if (response.LoginDate.HasValue)
                {
                    //loginResponse.TimeOut = DateTimeFormatUtils.GetIso8601String(response.LoginDate.Value.AddMinutes(SettingRepository.Get<int>("MaxSessionTimeMinutes", 2)));
                }
                loginResponse.Status = Enum.GetName(typeof(ResponseStatusType), ResponseStatusType.Success);
            }
            else
            {
                loginResponse.ErrorList = response.ErrorList;
                loginResponse.Status    = Enum.GetName(typeof(ResponseStatusType), ResponseStatusType.Failure);
            }
            return(loginResponse);
        }
Beispiel #21
0
        public void TestInitialize()
        {
            _context    = new DbTestContext(Settings.Default.MainConnectionString);
            _fixture    = new Fixture();
            _serializer = new Serializer();

            _repository = new SettingRepository(new SqlProcedureExecutor(Settings.Default.MainConnectionString), _serializer);
        }
Beispiel #22
0
		public void TestInitialize()
		{
			_context = new DbTestContext(Settings.Default.MainConnectionString);
			_fixture = new Fixture();
			_serializer = new Serializer();

			_repository = new SettingRepository(new SqlProcedureExecutor(Settings.Default.MainConnectionString), _serializer);
		}
        //
        // GET: /Settings/Delete/5

        public ActionResult DeleteStoreSettings(int storeId = 0, int settingId = 0)
        {
            Setting setting = SettingRepository.GetSingle(settingId);

            SettingRepository.Delete(setting);
            SettingRepository.SaveSetting();
            return(RedirectToAction("Settings", new { storeId = setting.StoreId }));
        }
Beispiel #24
0
        public async Task GetListAsync()
        {
            var settings = await SettingRepository.GetListAsync(GlobalSettingValueProvider.ProviderName, null);

            settings.Any().ShouldBeTrue();
            settings.ShouldContain(s => s.Name == "MySetting1" && s.Value == "42");
            settings.ShouldContain(s => s.Name == "MySetting2" && s.Value == "default-store-value");
        }
Beispiel #25
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            this.Suspending += OnSuspending;
            var setting = new SettingRepository();

            AppGlobal.Init(setting);
        }
Beispiel #26
0
        public ActionResult DeleteConfirmed(int id)
        {
            Setting setting = SettingRepository.GetSingle(id);

            SettingRepository.Delete(setting);
            SettingRepository.Save();
            return(RedirectToAction("Index"));
        }
Beispiel #27
0
        public void Create(Setting setting)
        {
            var settingKey = new PartionKeyRowKeyPair(setting.Category, setting.Config);

            var settingRepository  = new SettingRepository(_tableEntityOperation);
            var settingTableEntity = new SettingTableEntity(settingKey, setting.Value);

            settingRepository.Create(settingTableEntity);
        }
        public ActionResult SaveSettingValue(int id = 0, string value = "")
        {
            var s = SettingRepository.GetSingle(id);

            s.SettingValue = value;
            SettingRepository.Edit(s);
            SettingRepository.Save();
            return(Content(value));
        }
Beispiel #29
0
 protected void Application_BeginRequest(object sender, EventArgs e)
 {
     this.Response.Headers["X-Content-Type-Options"] = "nosniff";
     ResourcesReloadEnabled = SettingRepository.Get <string>("ResourcesReloadEnabled");
     if (!string.IsNullOrEmpty(ResourcesReloadEnabled) && ResourcesReloadEnabled.Equals("true"))
     {
         DbRes.ClearResources();
     }
 }
Beispiel #30
0
        public async Task DeleteAsync(string name, string providerName, string providerKey)
        {
            var setting = await SettingRepository.FindAsync(name, providerName, providerKey).ConfigureAwait(false);

            if (setting != null)
            {
                await SettingRepository.DeleteAsync(setting).ConfigureAwait(false);
            }
        }
Beispiel #31
0
        public RESTAPILoginResponse Authenticate(RESTAPIAuthCredentials req)
        {
            UserAuthenticationInterchange hppAuthInterchange = new UserAuthenticationInterchange()
            {
                CallerId     = req.CallerId,
                LanguageCode = req.LanguageCode,
                CountryCode  = req.CountryCode,
                Platform     = req.Platform,
                ClientId     = req.ClientId,
                UserId       = req.UserId
            };

            SetClientAppInfo(req.Platform, hppAuthInterchange);

            GetProfileResponse response = new GetProfileResponse();

            if (SettingRepository.Get <bool>("TESTLoginEnabled", true))
            {
                //response = HPIDUtils.GetCustomerProfileByTestLogin(hppAuthInterchange, false, APIMethods.None);
                response = HPIDUtils.GetCustomerProfileByDefaultUserLogin(response, hppAuthInterchange, false, APIMethods.None);
            }
            else
            {
                response = AuthUtils.GetCustomerProfileByAuthentication(hppAuthInterchange, false, req.AccessCode, req.RedirectUrl, APIMethods.POSTAuthenticate, req.ClientId);
            }

            RESTAPILoginResponse loginResponse = new RESTAPILoginResponse();

            if (response.ErrorList.Count == 0)
            {
                loginResponse.UserID       = response.Credentials.UserID;
                loginResponse.SessionToken = response.Credentials.SessionToken;
                loginResponse.CallerId     = response.Credentials.CallerId;
                loginResponse.Roles        = response.Credentials.Roles;
                loginResponse.Locale       = response.CustomerProfileObject.Locale;
                loginResponse.FirstName    = response.CustomerProfileObject.FirstName;
                loginResponse.LastName     = response.CustomerProfileObject.LastName;
                loginResponse.Emailaddress = response.CustomerProfileObject.EmailAddress;
                loginResponse.Status       = Enum.GetName(typeof(ResponseStatusType), ResponseStatusType.Success);

                //if (string.IsNullOrEmpty(req.DeviceToken))
                //{
                //    loginResponse.ErrorList.Add(Faults.EmptyOrNullDevicetoken);
                //}
                if (response.LoginDate.HasValue)
                {
                    //loginResponse.TimeOut = DateTimeFormatUtils.GetIso8601String(response.LoginDate.Value.AddMinutes(SettingRepository.Get<int>("MaxSessionTimeMinutes", 60)));
                }
            }
            else
            {
                loginResponse.Status    = Enum.GetName(typeof(ResponseStatusType), ResponseStatusType.Failure);
                loginResponse.ErrorList = response.ErrorList;
            }

            return(loginResponse);
        }
Beispiel #32
0
		private static void RunEuroCourseJob(string connectionString)
		{
			var serializer = new Serializer();
			var executor = new SqlProcedureExecutor(connectionString);
			var settings = new SettingRepository(executor, serializer);
			var httpClient = new HttpClient();
			var emailMessageRepository = new EmailMessageRepository(executor);
			var mailSender = new DbMailSender(PartitionIdForOtherMails, emailMessageRepository, serializer);
			var courseSource = new CourseSourceFailPolicy(
				new CourseSourceRetryPolicy(
					new CourseSource(httpClient),
					CourseSourceAttempts,
					JobsLogger,
					CourseSourceRetryPolicyPeriod),
				mailSender,
				EmailsHelper.DefaultFrom,
				EmailsHelper.SupportEmail);

			new EuroCourseJob(settings, courseSource, serializer, PreviousRunEuroCourseJobRubTime).Work();
		}