// // GET: /AppConfig/ public ActionResult Config() { var model = new ConfigModel { ServiceHost = WebConfigurationManager.AppSettings["ServiceHost"], Version = WebConfigurationManager.AppSettings["Version"], Env = WebConfigurationManager.AppSettings["Env"] }; return PartialView(model); }
public DeliveryOrderService(ConfigModel configModel) : base(configModel) { }
public static void Reload() { _model = null; }
public static void setConfigModel(ConfigModel config) { DataModel.config = config; }
public ConfigController(IOptions <ConfigModel> settings) { _config = settings.Value; }
public BaseController(IOptions <ConfigModel> options) { this.config = options.Value; }
public TestModel() { ConfigModel = new ConfigModel(); }
public ConfigModel CreateBlob(ConfigModel model) { if (model == null) { throw new HttpRequestWithStatusException("Empty model", new HttpResponseException(HttpStatusCode.BadRequest)); } if (string.IsNullOrWhiteSpace(model.ClientId) || string.IsNullOrWhiteSpace(model.ClientSecret) || string.IsNullOrWhiteSpace(model.TenantId) || string.IsNullOrWhiteSpace(model.Subscription)) { throw new HttpRequestWithStatusException("ClientId/ClientSecret/TenantId/Subscription is empty", new HttpResponseException(HttpStatusCode.BadRequest)); } try { var azure = AzureClient.GetAzure(model.ClientId, model.ClientSecret, model.TenantId, model.Subscription); var resourceGroupName = GetUniqueHash(model.TenantId + model.ClientId + CommonName); model.SelectedRegion = Region.USEast.Name; IResourceGroup resourceGroup; try { resourceGroup = azure.ResourceGroups.GetByName(resourceGroupName); } catch (Exception e) { resourceGroup = ApiHelper.CreateResourceGroup(azure, resourceGroupName, model.SelectedRegion); } model.SelectedDeploymentRg = resourceGroupName; var storageAccountName = GetUniqueHash(model.TenantId + model.ClientId + resourceGroupName + CommonName); model.StorageAccountName = storageAccountName; var storageAccounts = azure.StorageAccounts.ListByResourceGroup(resourceGroupName); IStorageAccount storageAccountInfo; if (storageAccounts != null) { storageAccountInfo = storageAccounts.FirstOrDefault(x => x.Name.Equals(storageAccountName, StringComparison.OrdinalIgnoreCase)); } else { storageAccountInfo = ApiHelper.CreateStorageAccount(azure, resourceGroup.Name, model.SelectedRegion, storageAccountName); } if (storageAccountInfo == null) { throw new HttpRequestWithStatusException("storage account not created", new HttpResponseException(HttpStatusCode.InternalServerError)); } var storageKeys = storageAccountInfo.GetKeys(); string storageConnection = string.Format(StorageConStringFormat, model.StorageAccountName, storageKeys[0].Value); var storageAccount = CloudStorageAccount.Parse(storageConnection); var blockBlob = ApiHelper.CreateBlobContainer(storageAccount); var data = blockBlob.DownloadText(); if (data == null) { var configString = ApiHelper.ConvertConfigObjectToString(model); using (var ms = new MemoryStream()) { LoadStreamWithJson(ms, configString); blockBlob.UploadFromStream(ms); } } else { var azureSettings = JsonConvert.DeserializeObject <AzureSettings>(data); model = ConvertAzureSettingsConfigModel(azureSettings); } var functionAppName = GetUniqueHash(model.ClientId + model.TenantId + model.Subscription + CommonName); var azureFunctions = azure.AppServices.FunctionApps.ListByResourceGroup(resourceGroupName); if (azureFunctions != null && azureFunctions.Count() > 0) { return(model); } if (!DeployAzureFunctions(model, functionAppName, storageConnection, resourceGroupName)) { throw new HttpRequestWithStatusException("Azure Functions are not deployed", new HttpResponseException(HttpStatusCode.InternalServerError)); } return(model); } catch (Exception e) { Console.WriteLine(e); throw; } }
private void Execute() { // if (!ExecuteProperty.Instance.GetStartCommunication) // ExecuteProperty.Instance.SetStartCommunication(); //else // return; JavaScriptSerializer json_serializer = new JavaScriptSerializer(); FileInfo fi = new FileInfo(config.FileConfigJson);//@"C:\Desenvolvimento\MaSF\ContC\extension\ea\ContC.Extension.EA.Service\config.json"); ConfigModel configModel = null; try { String s = File.ReadAllText(fi.FullName); configModel = json_serializer.Deserialize <ConfigModel>(s); DateTime dtm = Convert.ToDateTime(configModel.LastImportDate); DateTime dtnow = dtm.AddHours(2) > DateTime.Now ? DateTime.Now : dtm.AddHours(2); AjustTimer(dtnow); IEnumerable <ReceitaDTO> er = this._receitaService.GetReceita(Convert.ToDateTime(configModel.LastImportDate), dtnow); Thread.Sleep(10); foreach (ReceitaDTO item in er) { String cid = Guid.NewGuid().ToString(); FileInfo fiR = new FileInfo(Path.Combine(config.PathReceitaBag, cid + ".json")); if (!fiR.Directory.Exists) { fiR.Directory.Create(); } ContC.Communication.Model.ReceitaCom rc = new Communication.Model.ReceitaCom(); rc.Descricao = "Communicação Automatica do EasyAssist"; rc.EmpresaId = config.EmpresaId; rc.Valor = item.Valor; rc.DataCadastro = dtnow; rc.CommunicationId = cid; switch (item.TipoReceita) { case 1: rc.TipoReceita = "DINHEIRO"; break; case 4: rc.TipoReceita = "CARTAO"; break; } String sO = json_serializer.Serialize(rc); File.WriteAllText(fiR.FullName, sO); configModel.LastImportDate = dtnow.ToString("dd/MM/yyyy HH:mm:ss"); } configModel.LastImportDate = dtnow.ToString("dd/MM/yyyy HH:mm:ss"); } catch (Exception ex) { Singleton.ExecuteProperty.Instance.EventLog.WriteEntry(ex.Message, System.Diagnostics.EventLogEntryType.Error); } finally { if (configModel != null) { String s = json_serializer.Serialize(configModel); File.Delete(fi.FullName); File.WriteAllText(fi.FullName, s); } } Thread.Sleep(100); // ExecuteProperty.Instance.SetCloseCommunication(); }
/// <summary> /// 从文件中载入游戏配置。 /// </summary> /// <exception cref="FileNotFoundException"></exception> public static ConfigModel LoadConfig() { if (!FileExists()) { throw new FileNotFoundException("未找到游戏配置文件。"); } var config = new ConfigModel(); config.OtherConfigs = File.ReadAllLines(ConfigPath).ToList(); for (int i = 0; i < config.OtherConfigs.Count; i++) { string line = config.OtherConfigs[i].Trim(); config.OtherConfigs[i] = null; // 游戏脚本。 if (line.StartsWith("game-script")) { config.GameScript = line.Split('=')[1]; continue; } // 旧版OP。 if (line.StartsWith("env[legacy_op]")) { config.LegacyOp = Convert.ToBoolean(line.Split('=')[1]); continue; } // 分辨率。 if (line.StartsWith("window-width")) { string str = line.Split('=')[1]; switch (str) { case "1280": config.DisplayResolution = DisplayResolution.x720; break; case "1366": config.DisplayResolution = DisplayResolution.x768; break; case "1440": config.DisplayResolution = DisplayResolution.x810; break; case "1600": config.DisplayResolution = DisplayResolution.x900; break; case "1920": config.DisplayResolution = DisplayResolution.x1080; break; case "2560": config.DisplayResolution = DisplayResolution.x1440; break; default: config.DisplayResolution = DisplayResolution.Custom; config.CustomDisplayResolution = str; break; } continue; } // 显示模式。 if (line.StartsWith("window")) { config.DisplayMode = DisplayMode.Window; continue; } if (line.StartsWith("fullscreen")) { config.DisplayMode = DisplayMode.FullScreen; continue; } // 缩放全屏。 if (line.StartsWith("scale")) { config.Scale = true; continue; } config.OtherConfigs[i] = line; } config.OtherConfigs.RemoveAll(line => line == null); return(config); }
public BuildPathsProcessor(ConfigModel config) { configModel = config; }
/// <summary> /// 保存游戏配置至文件。 /// </summary> public static void SaveConfig(ConfigModel config) { var configStrings = new List <string> { // 游戏脚本 "game-script=" + config.GameScript, // 旧版OP "env[legacy_op]=" + config.LegacyOp.ToString().ToLower() }; // 分辨率 string displayResolution = "window-width="; switch (config.DisplayResolution) { case DisplayResolution.x720: displayResolution += "1280"; break; case DisplayResolution.x768: displayResolution += "1366"; break; case DisplayResolution.x810: displayResolution += "1440"; break; case DisplayResolution.x900: displayResolution += "1600"; break; case DisplayResolution.x1080: displayResolution += "1920"; break; case DisplayResolution.x1440: displayResolution += "2560"; break; case DisplayResolution.Custom: if (string.IsNullOrEmpty(config.CustomDisplayResolution)) { goto default; } else { displayResolution += config.CustomDisplayResolution; } break; default: goto case DisplayResolution.x1080; } configStrings.Add(displayResolution); // 显示模式 switch (config.DisplayMode) { case DisplayMode.Window: configStrings.Add("window"); break; case DisplayMode.FullScreen: configStrings.Add("fullscreen"); break; case DisplayMode.Auto: default: break; } // 缩放全屏 if (config.Scale) { configStrings.Add("scale"); } if (config.OtherConfigs != null) { configStrings.AddRange(config.OtherConfigs); } File.WriteAllLines(ConfigPath, configStrings); }
public Example(ConfigModel configModel, DatabaseHandler dbHandler) { ConfigModel = configModel; DatabaseHandler = dbHandler; }
static void Main(string[] args) { if (File.Exists("config.json")) { try { Config = JsonConvert.DeserializeObject <ConfigModel>(File.ReadAllText(CONFIG_FILE_NAME)); } catch (Exception e) { Console.WriteLine(CONFIG_FILE_NAME + " konnte nicht eingelesen werden\n" + e.ToString()); } } else { var input = ConsoleHelper.AskUserForIPAndPort(); Config = new ConfigModel { IpAddress = input.Item1.ToString(), Port = input.Item2 }; File.WriteAllText(CONFIG_FILE_NAME, JsonConvert.SerializeObject(Config, Formatting.Indented)); Console.WriteLine(CONFIG_FILE_NAME + " angelegt. Bitte anpassen und die Anwendung neu starten."); ConsoleHelper.ExitDialog(); } // check package configuration file if (!File.Exists(PACKET_CONFIG_FILE_NAME)) { Console.WriteLine("Bitte " + PACKET_CONFIG_FILE_NAME + "ins Verzeichnis der Anwendung legen und Anwendung neu starten."); ConsoleHelper.ExitDialog(); } // read package configuration file try { NetworkPacketConfig = JsonConvert.DeserializeObject <List <NetworkPacketModel> >(File.ReadAllText(PACKET_CONFIG_FILE_NAME), new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto }); } catch (Exception e) { Console.WriteLine(); Console.WriteLine(e); Console.WriteLine(PACKET_CONFIG_FILE_NAME + " lässt sich nicht einlesen. Bitte prüfen Sie die Datei und starten die Anwendung neu."); ConsoleHelper.ExitDialog(); } // check for faulted ipaddress if (!IPAddress.TryParse(Config.IpAddress, out IPAddress ip)) { Console.WriteLine($"Format der IP-Adresse in {CONFIG_FILE_NAME} falsch. Bitte anpassen und neustarten"); ConsoleHelper.ExitDialog(); } // try to register for the port try { TcpClient = new TcpClient(Config.IpAddress, Config.Port); StreamReader = new StreamReader(TcpClient.GetStream());; } catch (Exception e) { Console.WriteLine(); Console.WriteLine(e); Console.WriteLine("Fehler beim Registrieren des Listeners. Eine andere Anwendung hört bereits auf Port {0}.", Config.Port); ConsoleHelper.ExitDialog(); } Console.WriteLine("Paket-Empfang gestartet..."); Task.Run(() => { var previousInput = ""; while (true) { try { var message = StreamReader.ReadLine(); if (message != previousInput) { previousInput = message; if (ProcessData(message)) { Console.WriteLine("\nVerarbeitet: \n" + message); } else { previousInput = ""; } } // else // { // Console.WriteLine("\nNur Empfangen (keine Veränderung der Daten): \n" + message); // } } catch (Exception e) { Console.WriteLine(); Console.WriteLine($"Folgender Fehler ist beim Lesen ankommender Pakete von {Config.IpAddress} aufgetreten:"); Console.WriteLine(e); Console.WriteLine(); } } }); if (GetLocalIPAddress() == Config.IpAddress) { SendTestPackets(Config.Port); } // keep app running while (true) { Console.ReadKey(); } }
public ReminderService(DiscordSocketClient client, IUserRepository userContext, ConfigModel config) { _client = client; _userRepository = userContext; _config = config; _timer = new Timer(ReminderCheck, null, TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(5)); }
public ConfigModelService(ILoadConfigService loadConfigService) { this.LoadConfigService = loadConfigService; this.ConfigModel = LoadConfig(); }