Example #1
0
        public Dictionary <RepGroupKey, EventRepInfo> SumGroupTotals(int k,
                                                                     List <EventRepInfo> list, List <string> keys, List <int> ids)
        {
            var    ret = new Dictionary <RepGroupKey, EventRepInfo>();
            string list_cur = null, key_cur = null;

            for (int i = 0; i < list.Count; i++)
            {
                var ev_cur = list[i];
                list_cur = ev_cur.GetSField(k);
                int pos = keys.BinarySearch(list_cur);
                if (pos >= 0 && pos < keys.Count)
                {
                    pos += 1;
                }
                if (pos < 0)
                {
                    pos = ~pos;
                }
                pos--;
                if (pos == -1)
                {
                    continue;
                }
                EventRepInfo ev_dic = null;
                while (pos >= 0)
                {
                    key_cur = keys[pos];
                    if (!list_cur.StartsWith(key_cur))
                    {
                        break;
                    }
                    var gk = new RepGroupKey(5);
                    gk.Fields[0] = key_cur;
                    if (!ret.TryGetValue(gk, out ev_dic))
                    {
                        ev_dic = new EventRepInfo();
                        ev_dic.FieldSortOrder = ev_cur.FieldSortOrder;
                        ev_dic.SetFieldId(k, ids[pos]);
                        ev_dic.SetSField(k, key_cur);
                        ev_dic.RCat1 = key_cur;
                        ev_dic.SetName1(k);
                        ev_dic.IsTotal = true;
                        ret[gk]        = ev_dic;
                    }
                    ev_dic.Add(ev_cur);

                    pos--;
                }
            }
            return(ret);
        }
Example #2
0
        public EventRepInfo SumTotals(IEnumerable <EventRepInfo> evrs, int k)
        {
            var ret = new EventRepInfo()
            {
                RegNr   = "KOPĀ",
                RCat1   = "KOPĀ",
                Name    = "Kopsumma",
                IsTotal = true
            };

            if (k >= 0)
            {
                ret.SetSField(k, "KOPĀ");
                ret.SetRField(k, "KOPĀ");
            }
            foreach (var evr in evrs)
            {
                ret.Add(evr);
            }
            return(ret);
        }