Beispiel #1
0
        public void LoadDeDupConfigsByType(LoadConfigType type = LoadConfigType.ALL)
        {
            try
            {
                using (ConnectionFactory connectionFactory = new ConnectionFactory(connectionString))
                {
                    switch (type)
                    {
                    case LoadConfigType.PLAN:
                        addonPlans = connectionFactory.DbConnection.Query <PlanInfos>("SELECT * FROM \"dedup-settings\".\"planinfos\";").ToList();
                        break;

                    case LoadConfigType.CONFIGVARS:
                        var configvars = connectionFactory.DbConnection.Query <dynamic>("SELECT * FROM \"dedup-settings\".\"configvars\";").FirstOrDefault();
                        SetConfigvars(configvars);
                        break;

                    default:
                        var queryResult = connectionFactory.DbConnection.QueryMultiple("SELECT * FROM \"dedup-settings\".\"configvars\";SELECT * FROM \"dedup-settings\".\"planinfos\";");
                        if (queryResult != null)
                        {
                            SetConfigvars(queryResult.Read <dynamic>().FirstOrDefault());
                            addonPlans = queryResult.Read <PlanInfos>().ToList();
                        }
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: {0}", ex.Message);
                throw;
            }
        }
Beispiel #2
0
        public async Task <JsonResult> RefreshConfigsByType(LoadConfigType type = LoadConfigType.ALL)
        {
            try
            {
                Console.WriteLine("RefreshConfigsByType starts");
                await ConfigVars.Instance.LoadDeDupConfigsByTypeAsync(type);

                Console.WriteLine("RefreshConfigsByType ended");
                return(Json(new { message = $"{type.ToString()} has been refreshed" }));
            }
            catch (Exception ex)
            {
                Console.WriteLine("ERROR: {0}", ex.Message);
            }
            return(Json(new { message = $"{type.ToString()} has not refreshed" }));
        }