Beispiel #1
0
		public static void Write(ProjectManager projects, string path, IdTable ids) {
			foreach ( var p in projects ) {
				if ( p == Project.Empty ) continue;
				var f = new XmlWriter(path + p.Name + ".xml");
				f.Begin(p, ids);
				f.Begin("Assignments");
				var faclist = new FlatAssignmentCollection[p.Assignments.Count];
				lock ( p.Assignments ) p.Assignments.CopyTo(faclist, 0);
				foreach ( var fac in faclist ) {
					f.Begin(fac, ids);
					var falist = new FlatAssignment[fac.Count];
					lock ( fac ) fac.CopyTo(falist, 0);
					foreach ( var fa in falist ) f.Write(fa, ids);
					f.End(fac);
				}
				f.End("Assignments");
				f.Begin("Costs");
				var costlist = new Cost[p.Costs.Count];
				lock ( p.Costs ) p.Costs.CopyTo(costlist, 0);
				foreach ( var c in costlist ) {
					f.Begin(c, ids);
					f.Begin("Options");
					var optionslist = new CostOptions[c.Options.Count];
					lock ( c.Options ) c.Options.CopyTo(optionslist, 0);
					foreach ( var o in optionslist ) f.Write(o, ids);
					f.End("Options");
					f.End(c);
				}
				f.End("Costs");
				f.End(p);
				f.Close();
			}
		}
Beispiel #2
0
		void NotifyIfChanged(Cost c) {
			c.PropertyChanged += (__, p) => NotifyPropertyChanged(p.PropertyName);
			foreach ( var option in c.Options ) {
				option.PropertyChanged += (___, o) => NotifyPropertyChanged(o.PropertyName);
			}
			c.Options.CollectionChanged += (collection, e) => {
                if (e.Action == NotifyCollectionChangedAction.Add)
				    foreach ( CostOptions option in e.NewItems )
					    option.PropertyChanged += (_, arg) => NotifyPropertyChanged(arg.PropertyName);
			};
		}
Beispiel #3
0
		public double CalculateAmount(Cost cost, ResultInfo info, double devisor) {
			switch ( cost.Mode ) {
				case CostMode.Lessee: return cost.Amount * info.Duration / devisor;
				case CostMode.Member: return cost.Amount * info.Members / devisor;
				case CostMode.Flat: return cost.Amount * info.FlatSize / devisor;
				case CostMode.External: 
                    if (info.Lessee != null)
					    return cost.Options.First(o => o.Lessee == info.Lessee).Amount;
                    else if (info == Vacancy)
                        return cost.VacancyAmount;
                    else return 0;
			}
			return 0;
		}
Beispiel #4
0
		public double CalculateDevisor(Cost cost, Dictionary<Lessee, ResultInfo> result, ResultInfo vacancy) {
			switch ( cost.Mode ) {
				case CostMode.Lessee: 
					return cost.Options.Sum(o => o.Affected || o.Exempt ? result[o.Lessee].Duration : 0) 
						+ (cost.AffectsVacancy ? vacancy.Members : 0);
				case CostMode.Member:
					return cost.Options.Sum(o => o.Affected || o.Exempt ? result[o.Lessee].Members : 0) 
						+ (cost.AffectsVacancy ?  vacancy.Members : 0);
				case CostMode.Flat:
					return cost.Options.Sum(o => o.Affected || o.Exempt ? result[o.Lessee].FlatSize : 0) 
						+ (cost.AffectsVacancy ? vacancy.FlatSize : 0);
			}
			return 1;
		}
Beispiel #5
0
		internal CostOptions(Cost host, Lessee appliesTo) {
			cost = host;
			lessee = appliesTo;
		}
Beispiel #6
0
		public Cost CreateCost() {
			Cost c = new Cost();
			foreach ( var ac in Assignments ) {
				foreach ( var a in ac ) {
					c.AddLessee(a.Lessee);
				}
			}
			costs.Add(c);
			return c;
		}