Esempio n. 1
0
        public EeqgPeopleScale GetScaleData()
        {
            List <string> ls = new List <string>();

            foreach (var item in Items)
            {
                ls.Add(item.Value);
            }
            if (setValue != null)
            {
                setValue.ValueList = ls;
                return(setValue);
            }
            else
            {
                var value = new EeqgPeopleScale();
                value.ID         = ID;
                value.CreatTime  = CreatTime;
                value.Num        = Num;
                value.ScaleType  = ScaleType;
                value.EeqgPeople = null;
                value.ValueList  = ls;
                return(value);
            }
        }
Esempio n. 2
0
        public void SetScaleData(EeqgPeopleScale values)
        {
            setValue       = values;
            this.ID        = values.ID;
            this.CreatTime = values.CreatTime;
            this.Num       = values.Num;

            for (int i = 0; i < values.ValueList.Count; i++)
            {
                Items[i].Value = values.ValueList[i];
            }
        }
Esempio n. 3
0
        public static EeqgPeopleScaleResult Build(EeqgPeopleScaleType type, EeqgPeopleScale values = null, EeqgPeople people = null)
        {
            var valueIsNull = values == null;

            if (!valueIsNull)
            {
                if (type.Name != values.ScaleType)
                {
                    throw (new Exception("传入的量表类型和量表值不一致"));
                }
                if (type.Items.Count != values.ValueList.Count)
                {
                    throw (new Exception("传入的量表类型和量表值数目不一致"));
                }
            }


            var m = new EeqgPeopleScaleResult();

            m.ScaleType = type.Name;
            m.Version   = type.Version;
            m.Introduce = type.Introduce;


            m.People = people;

            m.Items = new List <EeqgPeopleScaleResultItem>();


            var getItem = new Func <EeqgPeopleScaleTypeItem, string, EeqgPeopleScaleResultItem>((t, v) => {
                var item     = new EeqgPeopleScaleResultItem();
                item.Title   = t.Title;
                item.Index   = t.Index;
                item.Group   = t.Group;
                item.Default = t.Default;
                item.Option  = t.Option;
                item.Value   = v;
                return(item);
            });

            if (!type.GroupMode)
            {
                for (int i = 0; i < type.Items.Count; i++)
                {
                    m.Items.Add(getItem(type.Items[i], type.Items[i].Default));
                }
            }
            else
            {
                var gs      = type.Items.GroupBy(x => x.Group);
                var nullgrp = gs.Where(x => x.Key == null);
                var gts     = gs.Where(x => x.Key != null).OrderBy(x => x.Key.Index);
                var numitem = 0;
                foreach (var g in gts)
                {
                    foreach (var item in g)
                    {
                        m.Items.Add(getItem(item, item.Default));
                        numitem++;
                    }
                }
                if (nullgrp.Count() > 0)
                {
                    var g = nullgrp.First();
                    foreach (var item in g)
                    {
                        m.Items.Add(getItem(item, item.Default));
                        numitem++;
                    }
                }
            }
            if (!valueIsNull)
            {
                m.SetScaleData(values);
            }

            return(m);
        }