SuperPowerfulFactory Factoria = new SuperPowerfulFactory();//no implementada en esta versión #endregion #region constructures public SuperPowersfulService(ISuperPowerRepository superPowerRepository, IVillianRepository villianRepository, IHeroRepository heroReposiory) { _superPowerRepository = superPowerRepository; _villianRepository = villianRepository; _heroReposiory = heroReposiory; _flagVillian = ConfigApp.GetFlagForVillian(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.AddTransient <IJurosService, JurosService>(); var configApp = new ConfigApp(); Configuration.Bind("ConfigApp", configApp); services.AddSingleton(configApp); services.AddSwaggerGen(s => { s.SwaggerDoc("calcsoftdoc", new Info { Title = "Calculadora Juros - Teste Softplan", Description = "Está API e um exemplo de implemntação de uma calculadora de juros, " + "que serve como teste de implementação em .net para Softplan", Version = "v1", Contact = new Contact { Name = "Paulo Henrique Sousa da Silva", Email = "*****@*****.**", Url = "https://github.com/pauloofmeta" } }); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); app.UseHsts(); } ConfigApp.SetAppSetting(Configuration.GetSection("SqlContext")); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); ServiceLocator.Instance = app.ApplicationServices; }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.AddTransient <IJurosService, JurosService>(); var configApp = new ConfigApp(); Configuration.Bind("ConfigApp", configApp); services.AddSingleton(configApp); services.AddSwaggerGen(s => { s.SwaggerDoc("DesafioSoftPlandoc", new Info { Title = "Desafio para Calcular Juros - Softplan", Description = "Está API simula a implementação de uma calculadora de juros, " + "que serve para calcular o valot utilizando .net para Teste Softplan", Version = "v1", Contact = new Contact { Name = "Herbert Barbosa Junior", Email = "*****@*****.**", Url = "https://github.com/herbertbarbosajr" } }); }); }
private void LoadContent() { if (this.MasterRemoteContent == null) { if (ConfigApp.ProductionBuild || ConfigApp.IsStableBuild()) { try { string json = IOUtil.LoadFromPersistentStorage("cached_master_remote_content.json"); this.MasterRemoteContent = JsonUtils.Deserialize <Service.MasterRemoteContent>(json, true); this.Log("Loaded cached content"); } catch (Exception) { this.Log("No cached content"); } } if ((this.MasterRemoteContent == null) || (this.MasterRemoteContent.ContentVersion < ConfigApp.ProductionBuildDefaultRemoteContentVersion)) { try { this.MasterRemoteContent = ConfigApp.LoadDefaultMasterRemoteContent(); } catch (Exception exception) { UnityEngine.Debug.LogError("Error deserializing default MasterRemoteContent\n Exception: " + exception); this.MasterRemoteContent = new Service.MasterRemoteContent(); } this.Log("Using default content"); this.SaveContent(); } } }
public ActionResult DeleteConfirmed(int id) { ConfigApp configApp = db.ConfigApp.Find(id); db.ConfigApp.Remove(configApp); db.SaveChanges(); return(RedirectToAction("Index")); }
public override void Configure(Container container) { ConfigApp.AppHost(this, db); this.PreRequestFilters.Add((req, res) => { res.UseBufferedStream = true; }); }
public ActionResult Edit([Bind(Include = "IdConfigApp,NameApp,AccountPOP3,PortPOP3,AccountSMTP,PortSMTP,account,PasswordAccount")] ConfigApp configApp) { if (ModelState.IsValid) { db.Entry(configApp).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(configApp)); }
public ActionResult Create([Bind(Include = "IdConfigApp,NameApp,AccountPOP3,PortPOP3,AccountSMTP,PortSMTP,account,PasswordAccount")] ConfigApp configApp) { if (ModelState.IsValid) { db.ConfigApp.Add(configApp); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(configApp)); }
private static void RegisterConfigApp(ServiceCollection serviceCollection) { serviceCollection.AddSingleton <ConfigApp>(x => { var configApp = new ConfigApp(); //package Microsoft.Extensions.Configuration.Binder x.GetService <IConfigurationRoot>().Bind(configApp); return(configApp); } ); }
private static void CreateFile(string path) { var configApp = new ConfigApp { Theme = ConfigHelper.Theme, Printer = ConfigHelper.Printer, AccentColor = ConfigHelper.AccentColor, IsPrinterActivated = ConfigHelper.IsPrinterActivated }; configApp.WriteJson(path); }
public static async Task SaveConfig(ConfigApp config) { try { var configFile = await StaticContent.LocalFolder.GetFileAsync("ConfigApp.json"); var configString = JsonConvert.SerializeObject(config); await FileIO.WriteTextAsync(configFile, configString); }catch (Exception e) { await ContentDialogService.Show(new ExceptionDialog("Не удалось сохранить настройки приложения", "Возможно, файл занят другим приложением, если ошибка будет повторятся, переустановите приложение", e)); } }
// GET: ConfigApp/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ConfigApp configApp = db.ConfigApp.Find(id); if (configApp == null) { return(HttpNotFound()); } return(View(configApp)); }
public static ConfigApp StartUp() { var environmentName = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "staging"; var builder = new ConfigurationBuilder() .SetBasePath(AppContext.BaseDirectory) .AddJsonFile($"appsettings.{environmentName}.json", optional: false, reloadOnChange: true) .AddEnvironmentVariables(); var configuration = new ConfigApp(); ConfigurationBinder.Bind(builder.Build(), configuration); configuration.Environment = environmentName; return(configuration); }
public static void LoadCompanyInfo() { //Company ConfigCompany.CompanyName = "Hanzla Traders"; ConfigCompany.CompanyAddress = "Baldia Road Bahawalnagar"; ConfigCompany.CompanyContact = "03004070110"; //DataBase ConfigStrings.SQLITE_DB_PATH = "E:\\smsdb.dat"; ConfigStrings.CONNECTION_STRING = @"Data Source=" + ConfigStrings.SQLITE_DB_PATH + ";Version=3;New=true;Compress=True;"; //Application ConfigApp.MESSAGE_DISPLAY_DURATION = 3000; ConfigApp.INSERT_MESSAGE = "Records Inserted"; ConfigApp.UPDATE_MESSAGE = "Records Updated"; ConfigApp.DELETE_MESSAGE = "Records Deleted"; ConfigApp.SEARCH_MODE_ID_MESSAGE = "By ID"; ConfigApp.SEARCH_MODE_TEXT_MESSAGE = "By Name"; ConfigApp.NOT_VALID_FORM_MESSAGE = "Please Fill Form Properly!"; ConfigApp.setDisplayArea(); ConfigApp.DATETIME_FORMATE = "yyyy-MM-dd hh:mm:ss tt"; ConfigApp.SHOW_DATETIME_FORMATE = "yyyy-MM-dd hh:mm:ss tt"; ConfigApp.DATETIME_EXPIRY_FORMATE = "yyyy-MM-dd"; ConfigApp.MIN_DATETIME = DateTime.Now; ConfigApp.SALES_TEX_PERCENTAGE = 0; ConfigApp.LENGTH_INVALID_MESSAGE = "Maximum Exceded"; ConfigApp.NUMBER_INVALID_MESSAGE = "Invalid Number"; ConfigApp.EMAIL_INVALID_MESSAGE = "Invalid Email"; ConfigApp.CURRENCCY_INVALID_MESSAGE = "Invalid Currency"; ConfigApp.STOCK_EXPIRY_MIN_Y = 1; ConfigApp.STOCK_EXPIRY_MIN_M = 1; ConfigApp.STOCK_EXPIRY_MIN_D = 2; ConfigApp.CUSTOMER_EXPIRY_MIN_Y = 0; ConfigApp.CUSTOMER_EXPIRY_MIN_M = 1; ConfigApp.CUSTOMER_EXPIRY_MIN_D = 0; //MODES CONFIG.DISCOUNT_MODE_GVD = "GVD"; CONFIG.DISCOUNT_MODE_NILL = "NILL"; CONFIG.DISCOUNT_MODE_PP = "PP"; CONFIG.DISCOUNT_MODE_RP = "RP"; CONFIG.DISCOUNT_MODE_TP = "TP"; CONFIG.TAX_MODE_GVD = "GVD"; CONFIG.TAX_MODE_NILL = "NILL"; CONFIG.TAX_MODE_PP = "PP"; CONFIG.TAX_MODE_RP = "RP"; CONFIG.TAX_MODE_TP = "TP"; }
public static IWebHostBuilder UseCustomLoggerProvider(this IWebHostBuilder builder) { ConfigApp configApp = new ConfigApp(); long _FileSizeLimitBytes = configApp.TamanoMaximoLog * 1024 * 1024; string _FileLogName = configApp.RutaArchivoLog; Log.Logger = new LoggerConfiguration() .WriteTo.File(_FileLogName, rollOnFileSizeLimit: true, fileSizeLimitBytes: _FileSizeLimitBytes, retainedFileCountLimit: 2, buffered: false, outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message}{NewLine}{Exception}") .CreateLogger(); builder.UseSerilog(); return(builder); }
private void PLCSettingsForm_Load(object sender, EventArgs e) { try { _configApp = DeserializeXML(_nlog); AutoConnectCheckBox.Checked = _configApp.AutoConnectionDataBase; IpTextBox.Text = _configApp.IpAddress; PortTextBox.Text = Convert.ToString(_configApp.PortAddress); CycleTextBox.Text = Convert.ToString(_configApp.CheckTime); } catch (Exception err) { _nlog.Error(err.Message); MessageBox.Show("Не удалось прочитать настройки подключения", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { } }
public ActionResult DeleteItem(int id) { var deleted = ""; try { ConfigApp capp = db.ConfigApp.Find(id); db.ConfigApp.Remove(capp); db.SaveChanges(); deleted = "true"; } catch (Exception) { deleted = "false"; } return(Json(new { success = true, deleted }, JsonRequestBehavior.AllowGet)); }
public MainForm(ConfigApp configApp, PgSQLConnectionSettings connectSettings, Logger nlog) { InitializeComponent(); _configApp = configApp; _connectSettings = connectSettings; _nlog = nlog; ErrorPLCLabel.Text = ""; ErrorSQLLabel.Text = ""; _timer = new Timer(); if (_configApp.CheckTime == 0 || _configApp.CheckTime <= 10) { _timer.Interval = 30000; } else { _timer.Interval = _configApp.CheckTime * 1000; } _timer.Tick += _timer_Tick; _timer.Start(); }
static void Main(string[] args) { Console.WriteLine(); string ConfigFolder = Directory.GetCurrentDirectory().Substring(0, Directory.GetCurrentDirectory().Length - 23); ConfigFolder += @"\Configuration\appsettings.txt"; string configDeserialize = File.ReadAllText(ConfigFolder); JsonSerializerSettings setting = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All }; ConfigApp appSettings = JsonConvert.DeserializeObject <ConfigApp>(configDeserialize, setting); if (args.Length > 0) { foreach (ICommand command in appSettings.CommandList) { if (args.Length == 2 && command.Name != "-h") { command.Run(appSettings, args[1]); } else if (args.Length == 1) { command.Run(appSettings, args[0]); } } string json = JsonConvert.SerializeObject(appSettings, setting); File.WriteAllText(ConfigFolder, json); if (args.Length == 1) { return; } } ManagementInfo.Run(appSettings); Console.WriteLine(); //DrawImageConsole.Draw(); }
public static void Run(ConfigApp config) { so = new WindowsSystem(); List <string> listaCores = new List <string>(); listaCores.AddRange(config.ListOfColors); if (listaCores.Contains(config.ForegroundColor)) { Console.ForegroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), NormalizeColorString(config.ForegroundColor)); } so.UserName = Environment.UserName; if (Environment.Is64BitOperatingSystem) { so.OSType = "OS_Arch: 64-Bit"; } else { so.OSType = "OS_Arch 32-Bit"; } so.Hd = HardDiskInfo.getHd(); so.Host = "Host: " + Environment.MachineName; so.RamMaximum = HardwareInfo.getTotalRam(); so.RamConsumed = HardwareInfo.getUsageRam(); so.Resolution = ResolutionInfo.getResolution(); so.SystemNome = OSInfo.GetName(); so.CPUInfo = HardwareInfo.getCPU(); so.GPUInfo = HardwareInfo.getGPU(); so.PCManufacturer = OSInfo.GetManufacturer(); so.Build = OSInfo.GetBuild(); so.Uptime = "Uptime: " + OSInfo.GetUptime(); Console.Write(so); ConsoleWorker.WriteAll(so.ArrayTheProprierties()); Console.ForegroundColor = ConsoleColor.White; }
private void CloseButton_Click(object sender, EventArgs e) { DialogResult dialog = MessageBox.Show("Вы действительно хотите сохранить изменения в подключении к ПЛК?", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); if (dialog == DialogResult.OK) { try { var config = new ConfigApp() { AutoConnectionDataBase = AutoConnectCheckBox.Checked, IpAddress = IpTextBox.Text, PortAddress = Convert.ToInt16(PortTextBox.Text), CheckTime = Convert.ToInt16(CycleTextBox.Text) }; var xmlSer = new XmlSerializer(typeof(ConfigApp)); using (var stream = new FileStream(XML_CONFIG_APP_FILE_NAME, FileMode.Create)) { xmlSer.Serialize(stream, config); } this.Close(); MessageBox.Show("Перезапустите приложения для инициализации подключения к ПЛК", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception err) { _nlog.Error(err.Message); MessageBox.Show("Не удалось сохранить изменения. Проверьте ввод данных и повторите попытку.", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } } if (dialog == DialogResult.Cancel) { this.Close(); } }
public OAuthService() { var _configService = new ConfigAppService(); _configData = _configService.GetConfigurationForApp(ConfigurationManager.AppSettings["AppName"].ToString()); }
protected override void OnModelCreating(ModelBuilder modelBuilder) { //creacion de las configuraciones por default ConfigApp config = new ConfigApp() { Id = 1, AppName = "Gallos", Prefijo = "Local", }; // creación del usuario default string password = "******"; var data = Encoding.ASCII.GetBytes(password); var md5 = new MD5CryptoServiceProvider(); var md5data = md5.ComputeHash(data); var hashedPassword = new ASCIIEncoding(); AppUser user = new AppUser() { Id = 1, UserName = "******", Password = hashedPassword.GetString(md5data) }; //lista de parentezcos List <Parentezco> parentezcos = new List <Parentezco>() { new Parentezco { Id = 1, Nombre = "Semental" }, new Parentezco { Id = 2, Nombre = "Gallina" }, new Parentezco { Id = 3, Nombre = "Cría" } }; List <EtapaGallos> etapaGallos = new List <EtapaGallos>() { new EtapaGallos { Id = 1, Nombre = "Con la Mamá", IdParentezco = 3 }, }; List <EstatusVenta> estatusVentas = new List <EstatusVenta>() { new EstatusVenta { Id = 1, Nombre = "Finalizada" }, new EstatusVenta { Id = 2, Nombre = "En Proceso" }, new EstatusVenta { Id = 3, Nombre = "Cancelada" } }; modelBuilder.Entity <ConfigApp>().HasData(config); modelBuilder.Entity <AppUser>().HasData(user); modelBuilder.Entity <Parentezco>().HasData(parentezcos); modelBuilder.Entity <EtapaGallos>().HasData(etapaGallos); modelBuilder.Entity <EstatusVenta>().HasData(estatusVentas); }
public AboutController(ConfigApp configApp) { _configApp = configApp; }
public OmronPLCDataService(ConfigApp appSettings) { _configApp = appSettings ?? throw new ArgumentNullException(nameof(appSettings)); }
public void Run(ConfigApp appSettings, string color) { appSettings.ForegroundColor = color; }
private async void Button_Click(object sender, RoutedEventArgs e) { ProgressRing.IsActive = true; Start.Text = "Music X выполняет первичную настройку. Пожалуйста, подождите..."; ButtonStart.Visibility = Visibility.Collapsed; //создание папки с плейлистами. var localpath = ApplicationData.Current.LocalFolder; if (await localpath.TryGetItemAsync("Playlists") == null) { var pathPlaylists = await localpath.CreateFolderAsync("Playlists"); StaticContent.PlaylistsFolder = pathPlaylists; var filePlaylistId1 = await pathPlaylists.CreateFileAsync("Id1.json"); var filePlaylistId2 = await pathPlaylists.CreateFileAsync("Id2.json"); var playlistLastPlay = new Models.PlaylistFile() { Artist = "Music X", Cover = "ms-appx:///Assets/Images/latest.png", Id = 1, Name = "Слушали недавно", IsLocal = true, TracksFiles = new List <AudioFile>() }; var playlistFavorite = new Models.PlaylistFile() { Artist = "Music X", Cover = "ms-appx:///Assets/Images/favorites.png", Id = 2, Name = "Избранное", IsLocal = true, TracksFiles = new List <AudioFile>() }; var jsonPlaylistId1 = JsonConvert.SerializeObject(playlistLastPlay); var jsonPlaylistId2 = JsonConvert.SerializeObject(playlistFavorite); await FileIO.WriteTextAsync(filePlaylistId1, jsonPlaylistId1); await FileIO.WriteTextAsync(filePlaylistId2, jsonPlaylistId2); } if (await localpath.TryGetItemAsync("Covers") == null) { StaticContent.CoversFolder = await localpath.CreateFolderAsync("Covers"); } if (await localpath.TryGetItemAsync("MusicCollection.json") == null) { var musicFile = await localpath.CreateFileAsync("MusicCollection.json"); var musicString = JsonConvert.SerializeObject(new MusicCollection() { Music = new List <AudioFile>(), DateLastUpdate = "none" }); await FileIO.WriteTextAsync(musicFile, musicString); } if (await localpath.TryGetItemAsync("LastPlay.json") == null) { var lastFile = await localpath.CreateFileAsync("LastPlay.json"); var audio = new AudioFile() { Artist = "", Cover = "ms-appx:///Assets/Images/placeholder.png", DurationMinutes = "00:00", DurationSeconds = 0, Id = -2, InternalId = -2, OwnerId = -2, PlaylistId = 1, SourceString = "ms-appx:///Assets/Audio/song.mp3", Source = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/Audio/song.mp3")), Title = "Сейчас ничего не воспроизводится" }; var lastplayModel = new LastPlay() { Playlist = null, Track = audio, Volume = 1.0f, }; var jsonLastFile = JsonConvert.SerializeObject(lastplayModel); await FileIO.WriteTextAsync(lastFile, jsonLastFile); } if (await localpath.TryGetItemAsync("ConfigApp.json") == null) { var configFile = await localpath.CreateFileAsync("ConfigApp.json"); var config = new ConfigApp() { FindInDocumentsLibrary = false, FindInMusicLibrary = true, ThemeApp = 0, StreamMusic = true }; var configString = JsonConvert.SerializeObject(config); await FileIO.WriteTextAsync(configFile, configString); StaticContent.Config = config; } var settings = ApplicationData.Current.LocalSettings; settings.Values["themeApp"] = 0; await LikedArtistsService.CreateLikedArtstsFile(); await MusicFilesService.GetMusicLocal(true); var rootFrame = (Frame)Window.Current.Content; rootFrame.Navigate(typeof(Views.MainFrameView), null); }
public PLCSettingsForm(Logger nlog, ConfigApp configApp) { InitializeComponent(); _nlog = nlog ?? throw new ArgumentNullException(nameof(nlog)); _configApp = configApp ?? throw new ArgumentNullException(nameof(configApp)); }
public override void Configure(Container container) { ConfigApp.AppHost(this, db); }