public async Task <IActionResult> Edit(int id, [Bind("Id,Model,PhoneId,Storage,RAM")] Configration configration) { if (id != configration.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(configration); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ConfigrationExists(configration.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(configration)); }
public async Task <IActionResult> Create([Bind("Id,Model,PhoneId,Storage,RAM")] Configration configration) { if (ModelState.IsValid) { _context.Add(configration); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(configration)); }
private static object Configration(Configration opts) { throw new NotImplementedException(); }
private static void Configration(Configration opts, VuberConfig config) { foreach (var item in opts.GetType().GetProperties()) { if (item.GetValue(opts, null) != null && item.PropertyType == typeof(string)) { if (item.Name != "ConnectionString") { Regex folder = new Regex(@"^(?:[a-zA-Z]\:|\\\\[\w\.]+\\[\w.$]+)\\(?:[\w]+\\)*\w([\w.])+$"); // Folder regex c:\sql\working Regex share = new Regex(@"^(\\)(\\[A-Za-z0-9-_]+){2,}(\\?)$"); // Share Folder regex \\fileserver\shared if (folder.Match(item.GetValue(opts, null).ToString()).Success || share.Match(item.GetValue(opts, null).ToString()).Success) { config.GetType().GetProperty(item.Name).SetValue(config, item.GetValue(opts, null).ToString().Replace(@"\", "\\"), null); } else { Console.WriteLine("{0} property is not match folder or shared folder expressions. {1}", item.Name, item.GetValue(opts, null)); } } else { try { using (new SqlConnection(item.GetValue(opts, null).ToString())) { } config.GetType().GetProperty(item.Name).SetValue(config, item.GetValue(opts, null).ToString().Replace(@"\", "\\"), null); } catch (Exception) { Console.WriteLine("Connection string is missing. {0}", item.GetValue(opts, null)); } } } } config.SaveConfigFile(config); if (opts.List) { foreach (PropertyInfo prop in typeof(VuberConfig).GetProperties()) { if (prop.PropertyType == typeof(string)) { Console.WriteLine("{0} Configration is {1}", prop.Name, config.GetType().GetProperty(prop.Name).GetValue(config) ?? "Empty"); } } } if (opts.Test) { string configFile = string.Format(@"{0}\config.json", Environment.CurrentDirectory); if (File.Exists(configFile)) { Console.WriteLine("Connection String {0}", Utils.TestConnection()); Console.WriteLine("Working Directory {0}", Utils.DirectoryExists(config.WorkingDirectory)); Console.WriteLine("Executed Directory {0}", Utils.DirectoryExists(config.ExecutedDirectory)); Console.WriteLine("Rollback Directory {0}", Utils.DirectoryExists(config.RollbackDirectory)); } else { Console.WriteLine("Sometings is wrong to configration.\nPleace use vuber --help config"); } } }
static void Main(string[] args) { Console.WriteLine("C1 Package Development Helper"); Console.WriteLine("______________________________________________"); Console.WriteLine(); var configValidationErrors = Configration.GetValidationErrors(); if (configValidationErrors.Any()) { Console.WriteLine("Configuration file is not complete - please correct these issues:"); Console.WriteLine(); foreach (var item in configValidationErrors) { Console.WriteLine("{0}: {1}", item.Key, item.Value); } Console.WriteLine(); Console.WriteLine("Press any key to exit..."); Console.ReadLine(); } else { bool moveOn = false; Console.Write("Reset C1 site to base image? [Yes / No / Quit]"); while (!moveOn) { var keyPress = Console.ReadKey(); Console.WriteLine(); if (Char.ToLower(keyPress.KeyChar) == 'q') { return; } if (Char.ToLower(keyPress.KeyChar) == 'n') { moveOn = true; } if (Char.ToLower(keyPress.KeyChar) == 'y') { Console.WriteLine("Initializing base image and mirrorring to working C1 Site - this make take a few minutes ..."); C1BaseImageProvider.InitializeBaseImage(); MirrorProcessManager.MirrorBaseToWorkingSite(); CompositeConfigManager.RegisterMockPackageServer(); moveOn = true; } } Console.WriteLine(); Console.WriteLine("Building missing / updated packages..."); try { PackageServerConfigManager.UpdatePackageServerConfig(); } catch (Exception ex) { Console.WriteLine(); Console.WriteLine(ex.Message); Console.WriteLine(); Console.WriteLine("You need to fix the package failing here and rerun this tool. Press any key to exit."); Console.ReadLine(); return; } Console.ForegroundColor = ConsoleColor.Red; WriteEventsToConsole(); Console.WriteLine(); PackageServerProcessManager.Start(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Package Server running at http://localhost:{0}/C1.asmx", Configration.MockPackageServerPort); Console.WriteLine(); try { Console.WriteLine(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Monitoring file changes in repo paths - for installed packages, will sync file updates to website."); Console.ResetColor(); Console.WriteLine("Press any key to exit..."); using (var syncManager = new FileChangeSyncManager()) { syncManager.StartSync(true); var run = true; while (run) { WriteEventsToConsole(); if (Console.KeyAvailable) { run = false; } } } } catch (Exception ex) { Console.WriteLine(); Console.WriteLine(ex); Console.ReadLine(); } finally { PackageServerProcessManager.Stop(); } } }