protected override void ExecuteTask() { PropertyTask Property = new PropertyTask(this.PropertyName, this.TextValue.Value, this.ReadOnly, this.Dynamic, this.Overwrite); Property.Parent = this.Parent; Property.Project = this.Project; Property.Execute(); }
private void LoadFile(FilterChain filterChain) { string content = null; try { content = FileUtils.ReadFile(File.FullName, filterChain, Encoding); } catch (IOException ex) { throw new BuildException("The properties file could not be read.", Location, ex); } PropertyDictionary properties = Project.Properties; PropertyTask propertyTask = new PropertyTask(); propertyTask.Parent = this; propertyTask.Project = Project; using (StringReader sr = new StringReader(content)) { string line = sr.ReadLine(); int current_line = 0; while (line != null) { current_line++; // skip empty lines and comments if (String.IsNullOrEmpty(line) || line.StartsWith("#")) { line = sr.ReadLine(); continue; } int equals_pos = line.IndexOf('='); if (equals_pos == -1) { throw new BuildException(string.Format(CultureInfo.InvariantCulture, "Invalid property defined on line {0}.", current_line), Location); } string name = line.Substring(0, equals_pos).Trim(); string value = line.Substring(equals_pos + 1, line.Length - equals_pos - 1).Trim(); string expandedValue = properties.ExpandProperties(value, Location); propertyTask.PropertyName = name; propertyTask.Value = expandedValue; propertyTask.Execute(); line = sr.ReadLine(); } } }
public PropertyTask GetPropertyTask(int id) { PropertyTask propertyTask = db.PropertyTasks.Include("Crews").FirstOrDefault(p => p.Id == id); if (propertyTask == null) { return(null); } return(propertyTask); }
public bool UpdatePropertyTask(PropertyTask propertyTask) { var existingTask = db.PropertyTasks.Include("Crews").FirstOrDefault(p => p.Id == propertyTask.Id); if (propertyTask.EventTaskListId == 0) { propertyTask.EventTaskListId = null; if (existingTask != null && existingTask.EventTaskList != null && existingTask.EventTaskList.PropertyTasks.Count() <= 1) { db.EventTaskLists.Remove(existingTask.EventTaskList); } } if (existingTask != null) { existingTask.Description = propertyTask.Description; existingTask.EstimatedDuration = propertyTask.EstimatedDuration; existingTask.EventTaskListId = propertyTask.EventTaskListId; existingTask.IsFreeService = propertyTask.IsFreeService; existingTask.Location = propertyTask.Location; existingTask.Notes = propertyTask.Notes; existingTask.EventTaskListId = propertyTask.EventTaskListId; List <Crew> crews = new List <Crew>(); foreach (Crew cr in propertyTask.Crews) { crews.Add(db.Crews.Single(c => c.Id == cr.Id)); } existingTask.Crews = new List <Crew>(); db.SaveChanges(); existingTask.Crews = crews; } else { db.PropertyTasks.Add(propertyTask); } db.SaveChanges(); return(true); }
/// <summary> /// Reads the list of global properties specified in the NAnt configuration /// file. /// </summary> /// <param name="propertyNodes">An <see cref="XmlNodeList" /> representing global properties.</param> private void ProcessGlobalProperties(XmlNodeList propertyNodes) { //deals with xml info from the config file, not build document. foreach (XmlNode propertyNode in propertyNodes) { //skip special elements like comments, pis, text, etc. if (!(propertyNode.NodeType == XmlNodeType.Element)) { continue; } // initialize task PropertyTask propertyTask = new PropertyTask(); propertyTask.Parent = propertyTask.Project = Project; propertyTask.NamespaceManager = NamespaceManager; propertyTask.InitializeTaskConfiguration(); // configure using xml node propertyTask.Initialize(propertyNode); // execute task propertyTask.Execute(); } }
public override void Update(float deltaTime, Camera cam) { base.Update(deltaTime, cam); CurrFlow = 0.0f; currPowerConsumption = powerConsumption; if (item.CurrentHull == null) { return; } if (voltage < minVoltage) { powerDownTimer += deltaTime; running = false; if ((powerUpTask == null || powerUpTask.IsFinished) && powerDownTimer > 5.0f) { powerUpTask = new PropertyTask(item, IsRunning, 50.0f, "Turn on the oxygen generator"); } return; } else { powerDownTimer = 0.0f; } ApplyStatusEffects(ActionType.OnActive, deltaTime, null); running = true; CurrFlow = Math.Min(voltage, 1.0f) * generatedAmount * 100.0f; //item.CurrentHull.Oxygen += CurrFlow * deltaTime; UpdateVents(CurrFlow); voltage -= deltaTime; }
private PropertyTask<ReadOnlyCollectionShortcut<SavedListConfigViewModel>> EnsureConfigsTask() { if (_configsTask != null) return _configsTask; return _configsTask = new PropertyTask<ReadOnlyCollectionShortcut<SavedListConfigViewModel>>( notifier: () => { OnPropertyChanged("Configs"); OnPropertyChanged("ConfigsAsync"); }, createTask: () => { var ctx = ViewModelFactory.CreateNewContext(); var qryTask = ctx.GetQuery<SavedListConfiguration>() .Where(i => i.Type.ExportGuid == Parent.DataType.ExportGuid) // Parent.DataType might be from FrozenContext .Where(i => i.Owner == null || i.Owner.ID == this.CurrentPrincipal.ID) .ToListAsync(); var result = new ZbTask<ReadOnlyCollectionShortcut<SavedListConfigViewModel>>(qryTask); result .OnResult(t => { t.Result = new ReadOnlyCollectionShortcut<SavedListConfigViewModel>(); foreach (var cfg in qryTask.Result) { var obj = cfg.Configuration.FromXmlString<SavedListConfigurationList>(); foreach (var item in obj.Configs) { t.Result.Rw.Add(ViewModelFactory.CreateViewModel<SavedListConfigViewModel.Factory>().Invoke(DataContext, this, item, cfg.Owner != null)); } } }) .Finally(() => ctx.Dispose()); return result; }, set: null); }
private PropertyTask<IEnumerable<CalendarItemViewModel>> EnsureNextEventsTask() { if (_NextEventsTask != null) return _NextEventsTask; return _NextEventsTask = new PropertyTask<IEnumerable<CalendarItemViewModel>>( notifier: () => { OnPropertyChanged("NextEvents"); OnPropertyChanged("NextEventsAsync"); }, createTask: () => { var now = DateTime.Now; var tomorrow = now.Date.AddDays(2).AddSeconds(-1); // I know.... :-( var fetchCalendar = FetchCalendar(); var fetchTaskFactory = new ZbTask<ZbTask<IEnumerable<EventViewModel>>>(fetchCalendar) .OnResult(t => { _fetchCache.SetCalendars(fetchCalendar.Result); t.Result = _fetchCache.FetchEventsAsync(now, tomorrow); }); return new ZbFutureTask<IEnumerable<EventViewModel>, IEnumerable<CalendarItemViewModel>>(fetchTaskFactory) .OnResult(t => { t.Result = fetchTaskFactory .Result .Result .SelectMany(e => e.CreateCalendarItemViewModels(now, tomorrow)) .OrderBy(i => i.From.Date) .ThenByDescending(i => i.IsAllDay) .ThenBy(i => i.From.TimeOfDay) .ToList(); }); }, set: (IEnumerable<CalendarItemViewModel> value) => { throw new NotImplementedException(); }); }
protected override void ExecuteTask() { XmlDocument xml = new XmlDocument(); using (XmlTextReader reader = new XmlTextReader(_propertiesFile)) xml.Load(reader); XmlNodeList properties = xml.GetElementsByTagName("property"); int counter = 0; foreach (XmlNode property in properties) { string name = string.Empty, value = string.Empty; bool readOnly = false, dynamic = false, overwrite = true; if (property.Attributes["name"] != null) { name = string.IsNullOrEmpty(property.Attributes["name"].Value) ? string.Empty : property.Attributes["name"].Value; } if (property.Attributes["value"] != null) { value = string.IsNullOrEmpty(property.Attributes["value"].Value) ? string.Empty : property.Attributes["value"].Value; } if (property.Attributes["readonly"] != null) { readOnly = string.IsNullOrEmpty(property.Attributes["readonly"].Value) ? false : GetBooleanValue(property.Attributes["readonly"].Value, false); } if (property.Attributes["dynamic"] != null) { dynamic = string.IsNullOrEmpty(property.Attributes["dynamic"].Value) ? false : GetBooleanValue(property.Attributes["dynamic"].Value, false); } if (property.Attributes["overwrite"] != null) { overwrite = string.IsNullOrEmpty(property.Attributes["overwrite"].Value) ? true : GetBooleanValue(property.Attributes["overwrite"].Value, true); } if (property.Attributes["projects"] != null && !string.IsNullOrEmpty(property.Attributes["projects"].Value)) { string[] projects = property.Attributes["projects"].Value.Split( new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); bool propertyBelongsToProject = Array.Exists(projects, delegate(string project) { return((project == Project.ProjectName) || (project.ToLowerInvariant() == "all")); }); if (propertyBelongsToProject) { PropertyTask task = new PropertyTask(); task.Project = Project; task.NamespaceManager = NamespaceManager; task.PropertyName = name; task.Value = value; task.ReadOnly = readOnly; task.Dynamic = dynamic; task.Overwrite = overwrite; task.Execute(); counter += 1; } } else { PropertyTask task = new PropertyTask(); task.Project = Project; task.NamespaceManager = NamespaceManager; task.PropertyName = name; task.Value = value; task.ReadOnly = readOnly; task.Dynamic = dynamic; task.Overwrite = overwrite; task.Execute(); counter += 1; } } Log(Level.Info, INFO_MSG, counter, _propertiesFile); }
public override void Update(float deltaTime, Camera cam) { if (GameMain.Server != null && nextServerLogWriteTime != null) { if (Timing.TotalTime >= (float)nextServerLogWriteTime) { GameServer.Log(lastUser + " adjusted reactor settings: " + "Temperature: " + (int)temperature + ", Fission rate: " + (int)fissionRate + ", Cooling rate: " + (int)coolingRate + ", Cooling rate: " + coolingRate + ", Shutdown temp: " + shutDownTemp + (autoTemp ? ", Autotemp ON" : ", Autotemp OFF"), ServerLog.MessageType.ItemInteraction); nextServerLogWriteTime = null; lastServerLogWriteTime = (float)Timing.TotalTime; } } ApplyStatusEffects(ActionType.OnActive, deltaTime, null); fissionRate = Math.Min(fissionRate, AvailableFuel); float heat = 80 * fissionRate * (AvailableFuel / 2000.0f); float heatDissipation = 50 * coolingRate + Math.Max(ExtraCooling, 5.0f); float deltaTemp = (((heat - heatDissipation) * 5) - temperature) / 10000.0f; Temperature = temperature + deltaTemp; if (temperature > fireTemp && temperature - deltaTemp < fireTemp) { #if CLIENT Vector2 baseVel = Rand.Vector(300.0f); for (int i = 0; i < 10; i++) { var particle = GameMain.ParticleManager.CreateParticle("spark", item.WorldPosition, baseVel + Rand.Vector(100.0f), 0.0f, item.CurrentHull); if (particle != null) { particle.Size *= Rand.Range(0.5f, 1.0f); } } #endif new FireSource(item.WorldPosition); } if (temperature > meltDownTemp) { MeltDown(); return; } else if (temperature == 0.0f) { if (powerUpTask == null || powerUpTask.IsFinished) { powerUpTask = new PropertyTask(item, IsRunning, 50.0f, "Power up the reactor"); } } load = 0.0f; List <Connection> connections = item.Connections; if (connections != null && connections.Count > 0) { foreach (Connection connection in connections) { if (!connection.IsPower) { continue; } foreach (Connection recipient in connection.Recipients) { Item it = recipient.Item as Item; if (it == null) { continue; } PowerTransfer pt = it.GetComponent <PowerTransfer>(); if (pt == null) { continue; } load = Math.Max(load, pt.PowerLoad); } } } //item.Condition -= temperature * deltaTime * 0.00005f; if (temperature > shutDownTemp) { CoolingRate += 0.5f; FissionRate -= 0.5f; } else if (autoTemp) { //take deltaTemp into account to slow down the change in temperature when getting closer to the desired value float target = temperature + deltaTemp * 100.0f; //-1.0f in order to gradually turn down both rates when the target temperature is reached FissionRate += (MathHelper.Clamp(load - target, -10.0f, 10.0f) - 1.0f) * deltaTime; CoolingRate += (MathHelper.Clamp(target - load, -5.0f, 5.0f) - 1.0f) * deltaTime; } //the power generated by the reactor is equal to the temperature currPowerConsumption = -temperature * powerPerTemp; if (item.CurrentHull != null) { //the sound can be heard from 20 000 display units away when running at full power item.CurrentHull.SoundRange = Math.Max(temperature * 2, item.CurrentHull.AiTarget.SoundRange); } #if CLIENT UpdateGraph(deltaTime); #endif ExtraCooling = 0.0f; AvailableFuel = 0.0f; item.SendSignal(0, ((int)temperature).ToString(), "temperature_out", null); sendUpdateTimer = Math.Max(sendUpdateTimer - deltaTime, 0.0f); if (unsentChanges && sendUpdateTimer <= 0.0f) { if (GameMain.Server != null) { item.CreateServerEvent(this); } #if CLIENT else if (GameMain.Client != null) { item.CreateClientEvent(this); } #endif sendUpdateTimer = NetworkUpdateInterval; unsentChanges = false; } }
public static TTarget MapTo <TTarget>(this PropertyTask source) where TTarget : PropertyTaskViewModel { return(Mapper.Map <PropertyTask, TTarget>(source)); }
private void CreateProperties(String name, XmlNodeList nodes) { foreach (XmlNode Child in nodes) { if (this.NeedToProcessChildren(Child.ChildNodes)) { String NewName = Child.LocalName; if (!String.IsNullOrEmpty(name)) { NewName = String.Format("{0}.{1}", name, Child.LocalName); } this.CreateProperties(NewName, Child.ChildNodes); } else if (!String.IsNullOrEmpty(Child.InnerText)) { String value = Child.InnerText.Trim(); AttributeList Attributes = new AttributeList(Child.Attributes); Boolean NoTrim = this.GetAttributeValue("notrim", Attributes); if (NoTrim) { value = Child.InnerText; } Boolean @readonly = this.GetAttributeValue("readonly", Attributes); Boolean dynamic = this.GetAttributeValue("dynamic", Attributes); Boolean overwrite = this.GetAttributeValue("overwrite", Attributes); String NewName = Child.LocalName; if (!String.IsNullOrEmpty(name)) { NewName = String.Format("{0}.{1}", name, Child.LocalName); } PropertyTask Property = new PropertyTask(NewName, value, @readonly, dynamic, overwrite); Property.Parent = this.Parent; Property.Project = this.Project; Property.Execute(); } else if (Child.Attributes.Count > 0) { AttributeList Attributes = new AttributeList(Child.Attributes); if (Attributes.Contains("value")) { String value = Attributes["value"].InnerText; Boolean @readonly = this.GetAttributeValue("readonly", Attributes); Boolean dynamic = this.GetAttributeValue("dynamic", Attributes); Boolean overwrite = this.GetAttributeValue("overwrite", Attributes); String NewName = Child.LocalName; if (!String.IsNullOrEmpty(name)) { NewName = String.Format("{0}.{1}", name, Child.LocalName); } PropertyTask Property = new PropertyTask(NewName, value, @readonly, dynamic, overwrite); Property.Parent = this.Parent; Property.Project = this.Project; Property.Execute(); } } } }