public async Task <IActionResult> Edit(int id, [Bind("Id,TagNumber,AssetTypeId,Manufacturer,Model,Description,SerialNumber")] Asset asset) { if (id != asset.Id) { return(NotFound()); } if (ModelState.IsValid) { try { AssetManager.Update(asset); } catch (DbUpdateConcurrencyException) { if (!AssetExists(asset.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["AssetTypeId"] = new SelectList(AssetTypeManager.GetAll(), "Id", "Name", asset.AssetTypeId); return(View(asset)); }
public ActionResult Edit(AssetModel assetModel) { try { // create new Asset object from AssetModel var asset = new Asset { Id = assetModel.Id, TagNumber = assetModel.TagNumber, AssetTypeId = assetModel.AssetTypeId, Manufacturer = assetModel.Manufacturer, Model = assetModel.Model, Description = assetModel.Description, SerialNumber = assetModel.SerialNumber }; // Pass in new Asset object to AssetManager to update in database AssetManager.Update(asset); return(RedirectToAction("Index")); } catch { // return if action failed return(View()); } }
/// <summary> /// Main update loop, the majority of both the engine's and the game's logic are processed here. /// </summary> /// <param name="gameTime">Helper class containing timing methods.</param> protected sealed override void Update(GameTime gameTime) { DevelopmentTests(); if (!Config.Initialized) { throw new InvalidOperationException("Config was not initialized!"); } AssetManager.Update(Time.DeltaTime); Config.Update(); GameTime = gameTime; foreach (Action action in GameLoop.Loop.Values) { action.Invoke(); } OnUpdate(gameTime); Editor?.OnUpdate(GraphicsDeviceManager.GraphicsDevice, gameTime); if (gcFrame) { GC.Collect(); gcFrame = false; } EngineUtility.TransformHierarchyDirty = false; }
/// <summary> /// Updates the asset. /// </summary> /// <param name="asset">The asset.</param> /// <returns></returns> public void UpdateAsset(AssetViewModel assetViewModel) { try { Asset asset = AssetViewModelFactory.CreateFromViewModelModel(assetViewModel, ObjectMapper); AssetManager.Update(asset); } catch (Exception ex) { ExceptionManager.HandleException(ex, PolicyNameType.ExceptionReplacing); } }
public IActionResult Edit(Asset asset) { try { //call the OwnerManager to EDIT AssetManager.Update(asset); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
private void Update() { if (mAssetManager == null) { this.Init(); } if (mClearNewCollectionName) { mNewCollectionName = ""; mClearNewCollectionName = false; } if (mAssetManager != null) { mAssetManager.Update(); } }
internal void UpdateBase(float time, float deltaTime) { AssetManager.Update(); foreach (var system in _gameSystems) { system.EarlyUpdate(time, deltaTime); } Update(time, deltaTime); foreach (var system in _gameSystems) { system.LateUpdate(time, deltaTime); } }
private void uxOk_Click(object sender, EventArgs e) { if (Asset == null) { // doing an insert Asset = new Asset(); SetAsset(); AssetManager.Add(Asset); } else { // doing an update SetAsset(); AssetManager.Update(Asset); } Close(); }
internal void UpdateBase(float time, float deltaTime) { AssetManager.Update(); EarlyUpdateDispatcher.ProcessActionQueue(); foreach (var system in _gameSystems) { system.EarlyUpdate(time, deltaTime); } Update(time, deltaTime); foreach (var system in _gameSystems) { system.LateUpdate(time, deltaTime); } }
public IActionResult Edit(Asset asset) { try { AssetManager.Update(asset); //Attempt to update the asset. return(RedirectToAction("Index")); //Attempt to redirect. } catch { //If update fails, reinitialize the page and DropDownList. var assetTypes = AssetTypeManager.GetAllAssetTypes(); ViewBag.AssetTypes = assetTypes; //Re-select the asset that the user was trying to edit. var currentAsset = AssetManager.Find(asset.Id); return(View(currentAsset)); } }
// Update is called once per frame void Update() { AssetManager.Update(); }
protected override void Update(GameTime gameTime) { if (DoExit) { Exit(); } if (!IsActive) { assets.Update(true); return; } if (input.keyboard.Down(Microsoft.Xna.Framework.Input.Keys.LeftControl) && input.keyboard.Pressed(Microsoft.Xna.Framework.Input.Keys.F)) { windowManager.Fullscreen = !windowManager.Fullscreen; } if (input.keyboard.Pressed(Microsoft.Xna.Framework.Input.Keys.S)) { StateSave(); } if (input.keyboard.Pressed(Microsoft.Xna.Framework.Input.Keys.L)) { StateLoad(); } if (Scene != null) { if (world != null) { drawSystem.OnUnload(); for (int i = 0; i < systems.Length; i++) { systems[i].OnUnload(); } } world?.Dispose(); world = new World(); drawSystem.Reset(); for (int i = 0; i < systems.Length; i++) { systems[i].Reset(); } Scene.Load(); Scene = null; drawSystem.OnLoad(); for (int i = 0; i < systems.Length; i++) { systems[i].OnLoad(); } GC.Collect(); } input.Update(); for (int i = 0; i < systems.Length; i++) { systems[i].Update(); } windowManager.Update(); assets.Update(); base.Update(gameTime); if (RemovedEntities.Count > 0) { for (int i = 0; i < RemovedEntities.Count; i++) { RemovedEntities[i].Dispose(); RemovedEntities[i] = default; } } }
public void UpdateAsset(string title, string filename, long contentid, int languageId, byte[] filestream, ContentMetaData[] potentialMeta) { try { assetManager = new AssetManager(); assetManager.ContentLanguage = languageId; if (string.IsNullOrEmpty(userauthHeader.AuthenticationToken)) throw new SoapException("User not logged in", SoapException.ClientFaultCode); this.ImpersonateUser(userauthHeader.AuthenticationToken, assetManager.RequestInformation); ContentAssetData contentassetdata = assetManager.GetItem(contentid, true); if (contentassetdata == null) throw new SoapException("Error Updating Asset", SoapException.ClientFaultCode); contentassetdata.Title = title; contentassetdata.File = filestream; contentassetdata.AssetData.FileName = filename; contentassetdata.LanguageId = languageId; contentassetdata.MetaData = potentialMeta; assetManager.Update(contentassetdata); } catch (Exception ex) { throw new SoapException("Error updating an asset:" + ex.Message, SoapException.ClientFaultCode); } }
public string GetAssetContentQuickLink(string filename, string title, int languageid, long contentid, long folderid, byte[] filestream) { if (string.IsNullOrEmpty(userauthHeader.AuthenticationToken)) throw new SoapException("User not logged in", SoapException.ClientFaultCode); assetManager = new AssetManager(); assetManager.ContentLanguage = languageid; this.ImpersonateUser(userauthHeader.AuthenticationToken, assetManager.RequestInformation); if (contentid > 0) { ContentAssetData contentassetdata = assetManager.GetItem(contentid, true); if (contentassetdata == null) throw new SoapException("Error Updating Asset", SoapException.ClientFaultCode); contentassetdata.Title = title; contentassetdata.File = filestream; contentassetdata.AssetData.FileName = filename; contentassetdata.LanguageId = languageid; return assetManager.GetItem((assetManager.Update(contentassetdata).Id)).Quicklink; } else { ContentAssetData contentassetdata = new ContentAssetData() { FolderId = folderid, Title = title, File = filestream, LanguageId = languageid, AssetData = new AssetData { FileName = filename } }; return assetManager.GetItem((assetManager.Add(contentassetdata).Id)).Quicklink; } }
protected override int Invoke(string[] args) { if (_assets) { new AssetManager().UpdateAll(); } var mgr = new PackageManager(); var pkgs = new HashSet <LocalPackage>(); if (args.Length != 0) { foreach (var name in args) { if (!mgr.LocalPackages.TryGetValue(name, out var pkg)) { if (mgr.Registry.ContainsKey(name)) { _log.Error("Package {0} is not installed", name); } else { _log.Error("Package {0} does not exist", name); } return(1); } pkgs.Add(pkg); } } else { foreach (var pkg in mgr.LocalPackages.Values) { pkgs.Add(pkg); } } var updating = new HashSet <(LocalPackage, Package)>(); foreach (var pkg in pkgs) { if (mgr.Registry.TryGetValue(pkg.Name, out var latest)) { if (pkg.Version < latest.Version) { updating.Add((pkg, latest)); } else { _log.Info("Package {0} is up to date", pkg.Name, pkg.Version, latest.Version); } } else { _log.Warning("Package {0} does not exist in the registry; skipping", pkg.Name); } } var installing = new HashSet <Package>(); void AddDependencies(Package package) { foreach (var name in package.Dependencies) { if (mgr.Registry.TryGetValue(name, out var dep) && installing.Add(dep)) { AddDependencies(dep); } } } foreach (var pkg in updating.Select(x => x.Item2)) { installing.Add(pkg); AddDependencies(pkg); } var existing = mgr.Registry.Values.Where(x => mgr.LocalPackages.ContainsKey(x.Name)).ToHashSet(); installing.ExceptWith(existing); if (installing.Any()) { _log.Basic("Package dependencies to be installed:"); _log.Basic(string.Empty); foreach (var pkg in installing) { _log.Basic(" {0}", pkg.Name); } _log.Basic(string.Empty); } foreach (var pkg in installing) { var finfo = new FileInfo(pkg.Path); var dinfo = new DirectoryInfo(pkg.Path); if (!finfo.Exists && !dinfo.Exists) { continue; } _log.Error("Package path {0} exists already", pkg.Path); return(1); } var changing = new HashSet <Package>(); changing.AddRange(updating.Select(x => x.Item2)); changing.AddRange(installing); foreach (var pkg in changing) { foreach (var name in pkg.Conflicts) { if (updating.Any(x => x.Item2.Name == name)) { const string format = "Package {0} conflicts with to-be-updated package {1}{2}"; if (!_force) { _log.Error(format, pkg.Name, name, string.Empty); return(1); } _log.Warning(format, pkg.Name, name, "; ignoring"); } if (installing.Any(x => x.Name == name)) { const string format = "Package {0} conflicts with to-be-installed package {1}{2}"; if (!_force) { _log.Error(format, pkg.Name, name, string.Empty); return(1); } _log.Warning(format, pkg.Name, name, "; ignoring"); } } } var count = 0; if (installing.Any()) { foreach (var pkg in installing) { _log.Info("Installing package {0}...", pkg.Name); mgr.Install(pkg); count++; } _log.Basic("Installed {0} dependency packages", count); } count = 0; foreach (var(local, latest) in updating) { _log.Info("Updating package {0}...", local.Name); mgr.Update(local, latest); count++; } _log.Basic("Updated {0} packages", count); if (!_assets) { var assets = new AssetManager(); foreach (var kind in updating.SelectMany(x => x.Item2.Assets).Distinct()) { assets.Update(kind); } } return(0); }
protected override int Invoke(string[] args) { if (args.Length == 0) { Console.Error.WriteLine("Expected at least 1 argument"); return(1); } var mgr = new PackageManager(); var installing = new HashSet <Package>(); foreach (var name in args) { if (!mgr.Registry.TryGetValue(name, out var pkg)) { _log.Error("Package {0} does not exist", name); return(1); } installing.Add(pkg); } void AddDependencies(Package package) { foreach (var name in package.Dependencies) { if (mgr.Registry.TryGetValue(name, out var dep) && installing.Add(dep)) { AddDependencies(dep); } } } foreach (var pkg in installing.ToArray()) { AddDependencies(pkg); } _log.Basic("Packages to be installed:"); _log.Basic(string.Empty); foreach (var pkg in installing.ToArray()) { var installed = mgr.LocalPackages.ContainsKey(pkg.Name); if (installed) { installing.Remove(pkg); } var status = installed ? " (already installed; skipping)" : string.Empty; _log.Basic(" {0}{1}", pkg.Name, status); } _log.Basic(string.Empty); foreach (var pkg in installing) { var finfo = new FileInfo(pkg.Path); var dinfo = new DirectoryInfo(pkg.Path); if (!finfo.Exists && !dinfo.Exists) { continue; } _log.Error("Package path {0} exists already", pkg.Path); return(1); } foreach (var pkg in installing) { foreach (var name in pkg.Conflicts) { if (mgr.LocalPackages.ContainsKey(name)) { const string format = "Package {0} conflicts with already-installed package {1}{2}"; if (!_force) { _log.Error(format, pkg.Name, name, string.Empty); return(1); } _log.Warning(format, pkg.Name, name, "; ignoring"); } if (installing.Any(x => x.Name == name)) { const string format = "Package {0} conflicts with to-be-installed package {1}{2}"; if (!_force) { _log.Error(format, pkg.Name, name, string.Empty); return(1); } _log.Warning(format, pkg.Name, name, "; ignoring"); } } } var count = 0; foreach (var pkg in installing) { _log.Info("Installing package {0}...", pkg.Name); mgr.Install(pkg); count++; } _log.Basic("Installed {0} packages", count); var kinds = installing.SelectMany(x => x.Assets).Distinct(); if (kinds.Any()) { var assets = new AssetManager(); foreach (var kind in kinds) { assets.Update(kind); } } return(0); }