public void year_checked() {
			var ent = new WTEntityResolver();
			var obj2 = ent.Get<WTObject>(2);
			var ctx = new WrapContext { TargetObject = obj2, Period = 11, Year = 2010};
			var wf = load("test\\admin");
			Assert.True(wf.WrapForm("X4.A4",ctx).Context.IsValid);
			Assert.False(wf.WrapForm("X5.A5", ctx).Context.IsValid);
			Assert.False(wf.WrapForm("X5.A5", ctx).Context.YearIsValid);
		}
		public void forperiod_must_match() {
			var ent = new WTEntityResolver();
			var obj1 = ent.Get<WTObject>(1);
			var ctx1 = new WrapContext { TargetObject = obj1, Period = 14 };
			var ctx2 = new WrapContext { TargetObject = obj1, Period = 11 };
			var ctx3 = new WrapContext { TargetObject = obj1, Period = 1 };
			var wf = load("test\\admin");
			Assert.False(wf.WrapForm("X4.A4", ctx1).Context.IsValid);
			Assert.True(wf.WrapForm("X4.A4", ctx2).Context.IsValid);
			Assert.False(wf.WrapForm("X4.A4", ctx3).Context.IsValid);

			Assert.False(wf.WrapForm("X5.A5", ctx1).Context.IsValid);
			Assert.True(wf.WrapForm("X5.A5", ctx2).Context.IsValid);
			Assert.True(wf.WrapForm("X5.A5", ctx3).Context.IsValid);
			
		}
		public UserThemaTree BuildTree(string usr = null, WrapContext context = null) {
			var result = new UserThemaTree();
			result.Usr = usr;
			result.Context = context;
			var groups = new List<utThemaGroup>();
			foreach (var g in Factory.Themas.GetGroups(usr)) {
				var ug = new utThemaGroup();
				ug.Idx = g.EffectiveIndex;
				ug.Code = g.Code;
				ug.Name = g.Name;
				ug.Target = g;
				ug.Tree = result;

				var roots = new List<utThemaRoot>();
				foreach (var rt in g.GroupMembers.Where(x => x.Authorized(usr) && x.Parent == null).OrderBy(x => x.EffectiveIndex)) {
					var root = new utThemaRoot();
					root.Idx = rt.EffectiveIndex;
					root.Code = rt.Code;
					root.Name = rt.Name;
					root.Target = rt;
					root.Usr = usr;
					root.Group = ug;
					var terminals = new List<utTerminal>();

					foreach (var c in rt.Children.Where(x => x.Authorized(usr)).OrderBy(x => x.EffectiveIndex)) {
						var terminal = new utTerminal();
						terminal.Idx = c.EffectiveIndex;
						terminal.Code = c.Code;
						terminal.Name = c.Name;
						terminal.Target = c;
						terminals.Add(terminal);
						terminal.Usr = usr;
						terminal.Parent = root;
					}

					root.Terminals = terminals.ToArray();
					roots.Add(root);
				}

				ug.Roots = roots.ToArray();

				groups.Add(ug);
			}
			result.Groups = groups.ToArray();
			return result;
		}
		public void period_redirect_must_be_applyed()
		{
			var ent = new WTEntityResolver();
			var obj1 = ent.Get<WTObject>(1);
			var obj2 = ent.Get<WTObject>(2); //KVART
			var ctx1 = new WrapContext { TargetObject = obj1, Period = 1 };
			var ctx2 = new WrapContext { TargetObject = obj2, Period = 1 };
			var wf = load("test\\admin");
			var v1 = wf.WrapForm("X5.A5", ctx1).Context;
			var v2 = wf.WrapForm("X5.A5", ctx2).Context;
			Assert.True(v1.IsValid);
			Assert.True(v1.IsChanged);
			Assert.True(v1.PeriodRedirected);
			Assert.AreEqual(11,v1.Period);

			Assert.True(v2.IsValid);
			Assert.True(v2.IsChanged);
			Assert.True(v2.PeriodRedirected);
			Assert.AreEqual(13, v2.Period);
			

		}
Beispiel #5
0
		public IThemaWrapper GetWrap(WrapContext context = null) {
			return _wrap ??
			       (_wrap = new ThemaWrapperFactory(Target.Factory, Usr).WrapThema(Target.Code, context ?? Group.Tree.Context));
		}
		IThemaItemWrapper getitem(string usr = "******",WrapContext context = null) {
			return load(usr).WrapReport("X.A",context);
		}
Beispiel #7
0
		public ThemaWrapper(IThema target, IThemaWrapperFactory factory, WrapContext context) {
			Thema = target;
			Factory = factory;
			Context = context;
		}
		IThemaItemWrapper getitem(string usr = "******",WrapContext context = null) {
			context = context ?? new WrapContext {ObjectId = 1, ObjectGroups = "/G1/KVART/", Year = 2012, Period = 1};
			var result = load(usr).WrapReport("X.A",context);
			this.elements = result.GetAllElements();
			return result;
		}
		public void object_redirected_with_fixedobject() {
			var ent = new WTEntityResolver();
			var obj1 = ent.Get<WTObject>(1);
			var obj2 = ent.Get<WTObject>(2);
			var obj3 = ent.Get<WTObject>(3);
			var wf = load("test\\admin");
			var ctx = new WrapContext { TargetObject = obj1, Period = 11 };
			var v1 = wf.WrapForm("X4.A4.in", ctx);
			ctx = new WrapContext { TargetObject = obj2, Period = 11 };
			var v2 = wf.WrapForm("X4.A4.in", ctx);
			ctx = new WrapContext { TargetObject = obj3, Period = 11 };
			var v3 = wf.WrapForm("X4.A4.in", ctx);
			Assert.True(v1.Context.ObjectRedirected == v2.Context.ObjectRedirected == v3.Context.ObjectRedirected);
			Assert.True((v1.Context.ObjectId == v2.Context.ObjectId) && (v2.Context.ObjectId == v3.Context.ObjectId));
			Assert.True((v1.Context.ObjectGroups == v2.Context.ObjectGroups) && (v2.Context.ObjectGroups == v3.Context.ObjectGroups));
			Assert.True(v1.Context.ObjectRedirected);
			Assert.AreEqual(2,v1.Context.ObjectId);
			Assert.AreEqual("/G1/KVART/",v1.Context.ObjectGroups);
			Assert.True(v1.Context.IsChanged);
			Assert.True(v1.Context.IsValid);
		}
		public void forgroup_checked_well() {
			var ent = new WTEntityResolver();
			var obj1 = ent.Get<WTObject>(1);
			var obj2 = ent.Get<WTObject>(2);
			var obj3 = ent.Get<WTObject>(3);
			var wf = load("test\\admin");
			var ctx = new WrapContext {TargetObject = obj1, Period=11};
			Assert.True(wf.WrapForm("X1.A1",ctx).Context.IsValid);
			Assert.True(wf.WrapForm("X2.A2", ctx).Context.IsValid);
			Assert.False(wf.WrapForm("X3.A3", ctx).Context.IsValid);
			Assert.True(wf.WrapForm("X4.A4", ctx).Context.IsValid);
			Assert.True(wf.WrapForm("X5.A5", ctx).Context.IsValid);

			ctx = new WrapContext { TargetObject = obj2, Period = 11 };
			Assert.True(wf.WrapForm("X1.A1", ctx).Context.IsValid);
			Assert.False(wf.WrapForm("X2.A2", ctx).Context.IsValid);
			Assert.True(wf.WrapForm("X3.A3", ctx).Context.IsValid);
			Assert.True(wf.WrapForm("X4.A4", ctx).Context.IsValid);
			Assert.True(wf.WrapForm("X5.A5", ctx).Context.IsValid);

			ctx = new WrapContext { TargetObject = obj3, Period = 11 };
			Assert.True(wf.WrapForm("X1.A1", ctx).Context.IsValid);
			Assert.False(wf.WrapForm("X2.A2", ctx).Context.IsValid);
			Assert.False(wf.WrapForm("X3.A3", ctx).Context.IsValid);
			Assert.True(wf.WrapForm("X4.A4", ctx).Context.IsValid);
			Assert.True(wf.WrapForm("X5.A5", ctx).Context.IsValid);
		}