public async Task <IActionResult> PutPermanence([FromRoute] Guid id, [FromBody] Permanence permanence) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != permanence.Id) { return(BadRequest()); } _db.Entry(permanence).State = EntityState.Modified; try { await _db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PermanenceExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostPermanence([FromForm] Permanence permanence, string DebutHours, string DebutMinutes, string FinHours, string FinMinutes) { permanence.Debut = new TimeSpan(Int32.Parse(DebutHours), Int32.Parse(DebutMinutes), 0); permanence.Fin = new TimeSpan(Int32.Parse(FinHours), Int32.Parse(FinMinutes), 0); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _db.Permences.Add(permanence); try { await _db.SaveChangesAsync(); } catch (DbUpdateException) { if (PermanenceExists(permanence.Id)) { return(new StatusCodeResult(StatusCodes.Status409Conflict)); } else { throw; } } List <Permanence> l_permanence = await _db.Permences.Include(x => x.Clocher).Where(x => x.ClocherId == permanence.ClocherId).ToListAsync(); ViewBag.roles = await FindRole(l_permanence[0].Clocher.ParoisseId); return(PartialView("_indexPermanence", l_permanence)); }
public RendezVousViewModel(INavigationService navigationService = null) { _navigationService = navigationService; _permanence = new Permanence(); getAllPerma(); rdv = new RendezVous(); }
public PageAdminViewModel(INavigationService navigationService = null) { _navigationService = navigationService; _problem = new ObservableCollection <RendezVous>(); _permanence = new Permanence(); getAllPerma(); }
public MainPageViewModel(INavigationService navigationService = null) { _navigationService = navigationService; dataAccess = new DataAccess(); _faq = new ObservableCollection <FAQ>(); getAllFAQ(); _permanence = new Permanence(); getAllPerma(); }
public EntityPreset(Type creation_type, Vector2 position, Guid entityID, int frame, Permanence permanence = Permanence.GRID_LOCAL, string type = "", int linkid = -1) { Type = creation_type; Position = position; EntityID = entityID; Frame = frame; Permanence = permanence; TypeValue = type; LinkID = linkid; }
public EntityPreset(Type creation_type, Vector2 position, Guid entityID, int frame, Permanence permanence = Permanence.GRID_LOCAL, string type = "", bool alive = true) { Type = creation_type; Position = position; EntityID = entityID; Frame = frame; Permanence = permanence; TypeValue = type; Alive = alive; }
public Animation(Permanence permanence, Color color, Point location, int flag) { this.permanence = permanence; this.color = color; this.location = location; this.age = 0; if (permanence == Permanence.PERMANENT) { generateBitmap(flag); } }
/// <summary> /// Guaranteed to return an instance of the specified type. Will cache and manage instances already instantiated. /// </summary> public IFlow Request(Type instanceType, Multiplicity multiplicity, Permanence permanence) { //We only want to allow a single instance of the type, so just get one if there's already one created. //Unfortunately, this will not respect the flow's "busy" state. Hey -- don't look at me like that. That's what you get for using singletons. if (multiplicity == Multiplicity.Singleton && MaybeGetFirstInstance(instanceType, out var instance)) { return(instance); } //Otherwise, try to get the first non-busy instance of the type if (MaybeGetFirstNonBusyInstance(instanceType, out instance)) { return(instance); } //Else we have to create a new one instance = (IFlow)Activator.CreateInstance(instanceType); instance.Initialize(Guid.NewGuid(), _ResolverCache); //The stuff here is just bookkeeping, so no need to hold up the requesting thread. Task.Run(() => { //First, clear any instances that have expired. //Of course, they might expire at any point -- this is just to keep space down. ClearExpiredInstances(instanceType); //Either hold on to the object ourselves, or only keep a weak reference, depending on the flow metadata Func <IFlow> accessor; if (permanence == Permanence.Keep) { accessor = () => instance; } else { //Closures are AWESOME. var weakReference = new WeakReference <IFlow>(instance); accessor = () => { weakReference.TryGetTarget(out var maybeInstance); return(maybeInstance); }; } CacheAdd(instanceType, accessor); }); return(instance); }
public async void getAllPerma() { if (CheckNet()) { List <Permanence> lstPerma = await dataAccess.getAllPerma(); DateTime dateAjd = DateTime.Today; foreach (var item in lstPerma) { DateTime td = Convert.ToDateTime(item.datePerma); if (td > dateAjd && _permanence.heureDebutPerma == 0) { _permanence = item; } } } }
public PermanenceAttribute(Permanence permanence) { Permanence = permanence; }
private static void ReadEntities(string xml) { var type_lookup = (from t in Assembly.GetExecutingAssembly().GetTypes() where t.IsDefined(typeof(NamedEntity), false) group new { type = t, check = t.GetCustomAttribute <NamedEntity>() } by t.GetCustomAttribute <NamedEntity>().GetName(t) ).ToDictionary(t => t.Key, t => t.ToList()); HashSet <string> missing = new HashSet <string>(); XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); XmlNode root = doc.FirstChild; List <DoorMapPair> doors = new List <DoorMapPair>(); if (root.HasChildNodes) { for (int i = 0; i < root.ChildNodes.Count; i++) { var map = root.ChildNodes[i]; string mapName = map.Attributes.GetNamedItem("name").Value; if (!_entities.ContainsKey(mapName)) { _entities.Add(mapName, new List <EntityPreset>()); } List <EntityPreset> presets = _entities[mapName]; foreach (XmlNode child in map.ChildNodes) { if (!type_lookup.ContainsKey(child.Name)) { if (!missing.Contains(child.Name)) { DebugLogger.AddWarning($"Missing Entity {child.Name}!"); missing.Add(child.Name); } continue; } if (int.TryParse(child.Attributes.GetNamedItem("x").Value, out int x) && int.TryParse(child.Attributes.GetNamedItem("y").Value, out int y) && Guid.TryParse(child.Attributes.GetNamedItem("guid").Value, out Guid id) && int.TryParse(child.Attributes.GetNamedItem("frame").Value, out int frame)) { Permanence p = Permanence.GRID_LOCAL; if (child.Attributes.GetNamedItem("p") != null) { p = (Permanence)int.Parse(child.Attributes.GetNamedItem("p").Value); } string type = ""; if (child.Attributes.GetNamedItem("type") != null) { type = child.Attributes.GetNamedItem("type").Value; } bool alive = true; if (child.Attributes.GetNamedItem("alive") != null) { alive = bool.Parse(child.Attributes.GetNamedItem("alive").Value); } var matching = type_lookup[child.Name].FindAll(t => t.check.Matches(frame, type)).ToList(); if (matching.Count == 0) { string missing_entity = $"{child.Name}-{frame}-'{type}'"; if (!missing.Contains(missing_entity)) { missing.Add(missing_entity); DebugLogger.AddWarning($"Missing Entity {missing_entity}!"); } } else if (matching.Count > 1) { DebugLogger.AddWarning($"Conflict at {child.Name}-{frame}-'{type}': " + String.Join(", ", matching.Select(t => t.type.Name))); } else { EntityPreset preset = new EntityPreset(matching[0].type, new Vector2(x, y), id, frame, p, type, alive); presets.Add(preset); if (child.Name == "Door") { DoorMapPair newDoor = new DoorMapPair(preset, mapName); if (doors.Any(d => d.Door.Frame == preset.Frame)) { DoorMapPair doorOne = doors.First(d => d.Door.Frame == preset.Frame); _doorPairs.Add(preset.Frame, new DoorPair(doorOne, newDoor)); doors.Remove(doorOne); DebugLogger.AddInfo($"DOOR PAIR {preset.Frame}\n{doorOne.Door.Position.X} {doorOne.Door.Position.Y} {doorOne.Map}\n{newDoor.Door.Position.X} {newDoor.Door.Position.Y} {newDoor.Map}"); } else { doors.Add(newDoor); } } } } } } } }