private void makecv_GLmonlist(List <GL_mon_item> GL_list, int Type) { List <KeyValuePair <string, int> > kvplist_aanmaak = new List <KeyValuePair <string, int> >(); List <KeyValuePair <string, int> > kvplist_dub1 = new List <KeyValuePair <string, int> >(); foreach (GL_mon_item subGL in GL_list) { if (subGL.HandelingNummer == 27) { foreach (KeyValuePair <string, int> kvp in subGL.GebruikersCntr) { kvplist_aanmaak.Add(kvp); } } else if (subGL.HandelingNummer == 6) { foreach (KeyValuePair <string, int> kvp in subGL.GebruikersCntr) { kvplist_dub1.Add(kvp); } } } List <KeyValuePair <string, int> > nwnkvplist = new List <KeyValuePair <string, int> >(); foreach (KeyValuePair <string, int> kvvp in kvplist_aanmaak) { foreach (KeyValuePair <string, int> kkvp in kvplist_dub1) { if (kvvp.Key == kkvp.Key) { nwnkvplist.Add(new KeyValuePair <string, int>(kvvp.Key, kvvp.Value - kkvp.Value)); } } } //GL_list.Add(new GL_mon_item(){ HandelingNummer = 30, GebruikersCntr = nwnkvplist, H_Type = Type, GroepNaam = "Nieuwe invoer", Naam = "Dubbele invoerlijst niet getoont", SortOrder = 1}); List <GL_mon_item> GL_sorted_list = new List <GL_mon_item>(); var x = from g in GL_list orderby g.SortOrder ascending, g.GroepNaam ascending select g; foreach (var a in x) { GL_sorted_list.Add(a); } DataTable DT = new DataTable(); DataColumn C_hnaam = new DataColumn("HandelingNaam", typeof(string)); DT.Columns.Add(C_hnaam); DataColumn C_hnr = new DataColumn("HandelingNr", typeof(int)); DT.Columns.Add(C_hnr); int max_g_col = GL_sorted_list.Max(GL_mon_item => GL_mon_item.GebruikersCntr.Count); GL_mon_item GL_I = GL_sorted_list.Find(GL_mon_item => GL_mon_item.GebruikersCntr.Count == max_g_col); for (int i = 0; i < max_g_col; i++) { if (!DT.Columns.Contains(GL_I.GebruikersCntr.ElementAt(i).Key)) { DataColumn dc = new DataColumn(GL_I.GebruikersCntr.ElementAt(i).Key, typeof(int)); DT.Columns.Add(dc); } } DataColumn C_cat = new DataColumn("Groep", typeof(string)); DT.Columns.Add(C_cat); DataColumn C_volgorde = new DataColumn("Volgorde", typeof(int)); DT.Columns.Add(C_volgorde); foreach (GL_mon_item GLMI in GL_sorted_list) { DataRow DR = DT.NewRow(); DR[0] = GLMI.Naam; DR["HandelingNr"] = GLMI.HandelingNummer; foreach (KeyValuePair <string, int> KVP in GLMI.GebruikersCntr) { if (DT.Columns[KVP.Key] != null) { DR[KVP.Key] = KVP.Value; } } DR["Groep"] = GLMI.GroepNaam; DR["Volgorde"] = GLMI.SortOrder; DT.Rows.Add(DR); } //// voeg samen if (Type == 0) { DT = voegsamen_algemeen(DT); } DataContext = DT; ICollectionView view = CollectionViewSource.GetDefaultView(DT); view.GroupDescriptions.Clear(); view.GroupDescriptions.Add(new PropertyGroupDescription("Groep")); view.SortDescriptions.Clear(); view.SortDescriptions.Add(new SortDescription("Groep", ListSortDirection.Ascending)); view.Refresh(); }
private void HM2GL(List <HM_item> h_list, int Type) { List <int> nwn = new List <int>() { 2, 3, 4 }; var aangemaakt = new List <HM_item>(); if (Type > 0) { aangemaakt = (from q in Handelingen_DataContext.log_handeling_gebruikers where nwn.Contains((int)q.handeling_nr) && q.timestamp >= date_forFilter && q.record_type == Type group q by new { q.gebruiker, q.log_id } into g select new HM_item { gebruiker = g.Key.gebruiker, handeling_nr = 27, Order = 0, r_type = Type, _count = g.Select(x => x.log_id).Count() }).ToList <HM_item>(); } else { aangemaakt = (from q in Handelingen_DataContext.log_handeling_gebruikers where nwn.Contains((int)q.handeling_nr) && q.timestamp >= date_forFilter group q by new { q.gebruiker, q.log_id } into g select new HM_item { gebruiker = g.Key.gebruiker, handeling_nr = 27, Order = 0, r_type = Type, _count = g.Select(x => x.log_id).Count() }).ToList <HM_item>(); } foreach (var aanm_HMI in aangemaakt) { h_list.Add(aanm_HMI); } List <GL_mon_item> G_list = new List <GL_mon_item>(); string handelingnaam = String.Empty; string categorienaam = String.Empty; int volgorde_nr = 0; foreach (HM_item HI in h_list) { if (G_list.Exists(GL_mon_item => GL_mon_item.HandelingNummer == HI.handeling_nr && (GL_mon_item.H_Type == HI.r_type || Type == 0))) { GL_mon_item GI = G_list.Find(GL_mon_item => GL_mon_item.HandelingNummer == HI.handeling_nr); bool bestaat = false; Stack <KeyValuePair <string, int> > kvp_kill_stack = new Stack <KeyValuePair <string, int> >(); Stack <KeyValuePair <string, int> > kvp_new_stack = new Stack <KeyValuePair <string, int> >(); foreach (KeyValuePair <string, int> kvp in GI.GebruikersCntr) { if (kvp.Key == HI.gebruiker) { bestaat = true; int neem_mee = kvp.Value; kvp_kill_stack.Push(kvp); kvp_new_stack.Push(new KeyValuePair <string, int>(HI.gebruiker, HI._count + neem_mee)); } } if (!bestaat) { GI.GebruikersCntr.Add(new KeyValuePair <string, int>(HI.gebruiker, HI._count)); } else { while (kvp_kill_stack.Count > 0) { GI.GebruikersCntr.Remove(kvp_kill_stack.Pop()); } while (kvp_new_stack.Count > 0) { GI.GebruikersCntr.Add(kvp_new_stack.Pop()); } } } else { var x_handelingnaam = (from h in Handelingen_DataContext.gebruikers_handelingens where h.handeling_nr == HI.handeling_nr select new { h.handeling_omschrijving }); foreach (var x in x_handelingnaam) { handelingnaam = x.handeling_omschrijving; } var x_categorienaam = (from c in Handelingen_DataContext.gebruikers_handelingens where c.handeling_nr == HI.handeling_nr select new { c.Categorie }); foreach (var x in x_categorienaam) { categorienaam = x.Categorie; } if (categorienaam.ToLower() == "view") { if (HI.r_type == 1 || HI.handeling_nr == 3) { categorienaam += " Project"; } else if (HI.r_type == 3 || HI.handeling_nr == 4) { categorienaam += " Contact"; } } var x_volgorde_nr = (from s in Handelingen_DataContext.gebruikers_handelingens where s.handeling_nr == HI.handeling_nr select new { s.Sort_order }); foreach (var x in x_volgorde_nr) { volgorde_nr = (int)x.Sort_order; } G_list.Add(new GL_mon_item() { HandelingNummer = HI.handeling_nr, Naam = handelingnaam, GroepNaam = categorienaam, SortOrder = volgorde_nr, GebruikersCntr = new List <KeyValuePair <string, int> >(), H_Type = HI.r_type }); GL_mon_item GI = G_list.Find(GL_mon_item => GL_mon_item.HandelingNummer == HI.handeling_nr); bool bestaat = false; Stack <KeyValuePair <string, int> > kvp_kill_stack = new Stack <KeyValuePair <string, int> >(); Stack <KeyValuePair <string, int> > kvp_new_stack = new Stack <KeyValuePair <string, int> >(); foreach (KeyValuePair <string, int> kvp in GI.GebruikersCntr) { if (kvp.Key == HI.gebruiker) { bestaat = true; int neem_mee = kvp.Value; kvp_kill_stack.Push(kvp); kvp_new_stack.Push(new KeyValuePair <string, int>(HI.gebruiker, HI._count + neem_mee)); } } if (!bestaat) { GI.GebruikersCntr.Add(new KeyValuePair <string, int>(HI.gebruiker, HI._count)); } else { while (kvp_kill_stack.Count > 0) { GI.GebruikersCntr.Remove(kvp_kill_stack.Pop()); } while (kvp_new_stack.Count > 0) { GI.GebruikersCntr.Add(kvp_new_stack.Pop()); } } } } makecv_GLmonlist(G_list, Type); }