Пример #1
0
 public UploadService(ILogger <UploadService> logger, IAmazonS3 amazonS3Client, TransferUtility transferUtility, IOptions <ConfigKeys> config)
 {
     _logger          = logger;
     _amazonS3Client  = amazonS3Client;
     _transferUtility = transferUtility;
     _config          = config.Value;
 }
Пример #2
0
 public static string GetName(this ConfigKeys val)
 {
     DescriptionAttribute[] attributes = (DescriptionAttribute[])val
                                         .GetType()
                                         .GetField(val.ToString())
                                         .GetCustomAttributes(typeof(DescriptionAttribute), false);
     return(attributes.Length > 0 ? attributes[0].Description : string.Empty);
 }
Пример #3
0
 public static string GetSection(this ConfigKeys val)
 {
     Section[] attributes = (Section[])val
                            .GetType()
                            .GetField(val.ToString())
                            .GetCustomAttributes(typeof(Section), false);
     return(attributes.Length > 0 ? attributes[0].Name : null);
 }
Пример #4
0
 private void FillConfigKeys()
 {
     ConfigKey = null;
     AsUI(_ => ConfigKeys.Swap(UploaderConfigFile.GetKeys()));
     if (ConfigKeys.Any())
     {
         ConfigKey = ConfigKeys[0];
     }
 }
Пример #5
0
 public static string Read(ConfigKeys property)
 {
     try
     {
         return ConfigurationManager.AppSettings[property.ToString()];
     }
     catch (Exception)
     {
         return null;
     }
 }
Пример #6
0
 public static string Read(ConfigKeys property)
 {
     try
     {
         return(ConfigurationManager.AppSettings[property.ToString()]);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Пример #7
0
        /// <summary>
        /// 设置一个配置项,值不在合法范围内抛出异常
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        public void Set(ConfigKeys key, double value)
        {
            ConfigItem item = this.GetItem(key);

            if (!IsValueValid(key, value))
            {
                throw new ConfigManagerException(String.Format("[ConfigManager.Set] New value {0} is not in valid range({1}~{2})", value, item.minValue, item.maxValue));
            }

            item.value = value;
        }
Пример #8
0
 public T GetValue <T>(ConfigKeys key)
 {
     try
     {
         return((T)Convert.ChangeType(GetValue(key), typeof(T)));
     }
     catch (Exception ex)
     {
         //if (SystemMode == "Debug") throw;
         return(default(T));
     }
 }
Пример #9
0
        /// <summary>
        /// 按key获取一个配置项
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        private ConfigItem GetItem(ConfigKeys key)
        {
            ConfigItem item;

            if (configItems.TryGetValue(key, out item))
            {
                return(item);
            }
            else
            {
                throw new ConfigManagerException("[ConfigManager.GetItem] Cannot find config with key: " + key.ToString());
            }
        }
Пример #10
0
        /// <summary>
        /// 检查值范围
        /// </summary>
        /// <param name="key"></param>
        /// <param name="valueToCheck"></param>
        /// <returns></returns>
        public bool IsValueValid(ConfigKeys key, double valueToCheck)
        {
            ConfigItem item = GetItem(key);

            if (valueToCheck < item.minValue || valueToCheck > item.maxValue)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
		public static bool GetBool(ConfigKeys key) {
			bool value;
			switch (key) {
				case ConfigKeys.ForceSSL:
					value = GetBoolForKey("ForceSSL");
					break;
				case ConfigKeys.ForceHttp:
					value = GetBoolForKey("ForceHTTP");
					break;
				case ConfigKeys.BypassLocalization:
					value = GetBoolForKey("BypassLocalization");
					break;
				default:
					throw new InvalidOperationException("Unknown bool configuration key.");
			}
			return value;
		}
		public static string GetString(ConfigKeys key) {
			string value;
			switch (key) {
				case ConfigKeys.RecaptchaPrivateKey:
					value = ConfigurationManager.AppSettings["RecaptchaPrivateKey"];
					break;
				case ConfigKeys.RecaptchaPublicKey:
					value = ConfigurationManager.AppSettings["RecaptchaPublicKey"];
					break;
				case ConfigKeys.CustomUrlProviderName:
					value = ConfigurationManager.AppSettings["CustomUrlProviderName"];
					break;
				default:
					throw new InvalidOperationException("Unknown string configuration key.");
			}
			return value;
		}
Пример #13
0
        static void Main(string[] args)
        {
            GerarListaKeys();

            Configuracao = null;
            print_msg("Lendo configuracoes...");
            if (File.Exists("Config.json"))
            {
                Configuracao = JsonConvert.DeserializeObject <ConfigKeys>(File.ReadAllText("Config.json"));
            }
            else
            {
                Configuracao = ConfigKeys.Padrao();
            }

            if (Configuracao == null)
            {
                Configuracao = ConfigKeys.Padrao();
            }

            File.WriteAllText("Config.json", JsonConvert.SerializeObject(Configuracao));
            print_msg("Iniciando buscando processos do ");
            print_mark("AIKA");


            if (!BuscarProcesso(out ProcJogo))
            {
                print_error("Janela do jogo nao foi encontrada.");
                Console.ReadLine();
                return;
            }

            print_info(string.Format("Janela {0} encontrada [0x{1}] ModuloBase: [0x{2}] ModuloTamanho:[0x{3}]", ProcJogo.MainWindowTitle, ProcJogo.MainWindowHandle.ToInt32().ToString("X"), ProcJogo.MainModule.BaseAddress.ToString("X"), ProcJogo.MainModule.ModuleMemorySize.ToString("X")));

            print_info(string.Format("Pressione {0} para iniciar ou {1} para parar.", Configuracao.IniciarBot.ToString(), Configuracao.IniciarBot.ToString()));
            Iniciar();

            tTecla = new Thread(KeyStatus);
            tTecla.Start();

            //Rotina para reparar uns bugs..;
            new Thread(RotinaSeguranca).Start();
            while (true)
            {
            }
        }
Пример #14
0
        public ActionResult Index(ContactViewModel model)
        {
            SetSelectList();
            ViewData["Selected"] = "ContactUs";
            if (ModelState.IsValid)
            {
                EmailMessage _mail = new EmailMessage();
                _mail.SMTPSettings = (SmtpSection)ConfigKeys.GetConfigSection("system.net/mailSettings/smtp");

                if (model.Type == ContactUsTypes.General)
                {
                    _mail.To      = ConfigKeys.GetConfigValue("GeneralEmail");
                    _mail.Subject = "General Inquires";
                }
                else if (model.Type == ContactUsTypes.Sponsorship)
                {
                    _mail.To      = ConfigKeys.GetConfigValue("SponsorshipEmail");
                    _mail.Subject = "Sponsorship Inquires";
                }
                _mail.From            = model.Email;
                _mail.FromDisplayName = model.Name;
                _mail.MessageBody     = model.Comment;


                if (_emailService.Send(_mail))
                {
                    ViewData["Message"] = "Thanks!";
                }
                else
                {
                    ViewData["Message"] = "Sorry your message could not be sent please try again!";
                }
            }
            else
            {
                ModelState.AddModelError("", "Please enter all the required fields.");
            }

            return(View("Index", model));
        }
Пример #15
0
        /// <summary>
        /// Fonction d'obtention d'un chemin tiré du App.config
        /// </summary>
        /// <param name="key">Clé</param>
        /// <returns>Chemin associé</returns>
        public static string GetPath(ConfigKeys key)
        {
            string res;

            switch (key)
            {
            case ConfigKeys.IMG:
                res = System.Configuration.ConfigurationManager.AppSettings["imgDirectoryPath"];
                break;

            case ConfigKeys.PLAYERS:
                res = System.Configuration.ConfigurationManager.AppSettings["playerDirectory"];
                break;

            case ConfigKeys.DECK_COLOR:
                res = System.Configuration.ConfigurationManager.AppSettings["deckColorsDirectory"];
                break;

            case ConfigKeys.DECKS:
                res = System.Configuration.ConfigurationManager.AppSettings["decksDirectory"];
                break;

            case ConfigKeys.DUELS:
                res = System.Configuration.ConfigurationManager.AppSettings["duelsDirectory"];
                break;

            case ConfigKeys.CARDS:
                res = System.Configuration.ConfigurationManager.AppSettings["cardsDirectory"];
                break;

            default:
                res = "";
                break;
            }

            return(res);
        }
Пример #16
0
 /// <summary>
 /// 获取一个配置项的值
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public double Get(ConfigKeys key)
 {
     return(this.GetItem(key).value);
 }
Пример #17
0
 /// <summary>
 /// 检查一套配置的完整性
 /// 若配置已经完整,true
 /// </summary>
 /// <param name="config"></param>
 /// <param name="missingKey"></param>
 /// <returns></returns>
 private static bool CheckIntegrety(Dictionary <ConfigKeys, ConfigItem> config, out ConfigKeys missingKey)
 {
     foreach (ConfigKeys configKey in Enum.GetValues(typeof(ConfigKeys)))
     {
         if (config[configKey].value == ConfigItem.UNSET_VALUE)
         {
             Debug.WriteLine("[ConfigManager.CheckIntegrety]Missing key: " + configKey.ToString());
             missingKey = configKey;
             return(false);
         }
     }
     missingKey = 0;
     return(true);
 }
Пример #18
0
 public static void Set(ConfigKeys key, String value)
 {
     File.Write(key.GetName(), value, key.GetSection());
 }
Пример #19
0
        public static string GetValue(ConfigKeys key)
        {
            var path = ConfigurationManager.AppSettings[key.ToString()];

            return(path);
        }
Пример #20
0
 public string GetReadableName(ConfigKeys key)
 {
     return(this.GetItem(key).readableName);
 }
Пример #21
0
        public static String Read(ConfigKeys key)
        {
            String value = ConfigurationManager.AppSettings[Enum.GetName(key.GetType(), key)];

            return((!String.IsNullOrEmpty(value)) ? value.Trim() : String.Empty);
        }
Пример #22
0
 public double GetMaxValue(ConfigKeys key)
 {
     return(this.GetItem(key).maxValue);
 }
Пример #23
0
 public string GetValue(ConfigKeys key)
 {
     return(GetValue(key.ToString()));
 }
Пример #24
0
    /// <summary>
    /// Displays info label, if any module is disabled
    /// </summary>
    private bool DisplayErrorText()
    {
        GlobalObjects = ";" + GlobalObjects + ";";
        SiteObjects   = ";" + SiteObjects + ";";

        bool keyDisabled    = false;
        bool isAnyKeySite   = false;
        bool settingChecked = false;
        bool showSite       = false;
        bool showGlobal     = false;

        // Check config keys - stronger
        if (!String.IsNullOrEmpty(ConfigKeys))
        {
            var keys = ConfigKeys.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string key in keys)
            {
                if (!ValidationHelper.GetBoolean(SettingsHelper.AppSettings[key], false))
                {
                    if (!AtLeastOne)
                    {
                        settingChecked = false;
                        break;
                    }
                }
                else
                {
                    settingChecked = true;
                }
            }
        }

        // Check settings
        if (!settingChecked && !String.IsNullOrEmpty(SettingsKeys))
        {
            int i = 0;

            var keys = SettingsKeys.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string key in keys)
            {
                String objectKey    = ";" + key + ";";
                bool   globalObject = GlobalObjects.Contains(objectKey);
                bool   siteObject   = SiteObjects.Contains(objectKey);
                String siteKeyName  = SiteName + "." + key;
                String keyName      = (SiteOrGlobal || globalObject || KeyScope == DisabledModuleScope.Global) ? key : siteKeyName;

                // If module disabled
                if (!SettingsKeyInfoProvider.GetBoolValue(keyName) || (siteObject && !SettingsKeyInfoProvider.GetBoolValue(siteKeyName)))
                {
                    // For site or global settings check site setting separately
                    if (SiteOrGlobal && SettingsKeyInfoProvider.GetBoolValue(siteKeyName))
                    {
                        settingChecked = true;
                        i++;
                        continue;
                    }

                    // If at least one is checked, info error is set later
                    if (!AtLeastOne)
                    {
                        // If setting is global - hide site button
                        var ski = SettingsKeyInfoProvider.GetSettingsKeyInfo(key);
                        if ((ski != null) && (!ski.KeyIsGlobal))
                        {
                            isAnyKeySite = true;
                        }

                        // Get text (either from collection of text or from single text property)
                        String text = (InfoTexts.Count != 0 && InfoTexts.Count > i) ? InfoTexts[i] : InfoText;

                        if (String.IsNullOrEmpty(text) && (ski != null))
                        {
                            text = GenerateInfoText(ski);
                        }

                        if (lblText.Text != "")
                        {
                            lblText.Text += " ";
                        }

                        // Add new text to label
                        lblText.Text += text;

                        // Add this key to collection of disabled keys

                        // Make this info label visible
                        keyDisabled = !String.IsNullOrEmpty(text);

                        if (!siteObject && !globalObject)
                        {
                            showSite   = (KeyScope != DisabledModuleScope.Global);
                            showGlobal = (KeyScope != DisabledModuleScope.Site);
                        }
                        else
                        {
                            showSite   |= siteObject;
                            showGlobal |= globalObject;
                        }
                    }
                }
                else
                {
                    settingChecked = true;
                }

                i++;
            }
        }

        // If atleastone is set, check if any setting is checked. If no, display warning message
        if (AtLeastOne && !settingChecked)
        {
            keyDisabled  = true;
            lblText.Text = InfoText;
        }

        // If parent panel is set, show(hide) it
        if (ParentPanel != null)
        {
            ParentPanel.Visible = keyDisabled;
        }

        // Show/hide this control if module disabled
        Visible = keyDisabled;

        // Show site button only if any key is site
        btnSite.Visible = isAnyKeySite;

        // Set result to property
        SettingsEnabled = !keyDisabled;

        btnSite.Visible   &= showSite;
        btnGlobal.Visible &= showGlobal;

        return(!keyDisabled);
    }
Пример #25
0
 public static String Get(ConfigKeys key)
 {
     return(File.KeyExists(key.GetName(), key.GetSection()) ? File.Read(key.GetName() ?? string.Empty, key.GetSection()) : string.Empty);
 }