コード例 #1
0
 public bool checkduplicate(IList <DocumentsGroupe> list, DocumentsGroupe group)
 {
     foreach (DocumentsGroupe g in list)
     {
         if (list.Count == 0)
         {
             return(true);
         }
         if (g.title.Equals(group.title))
         {
             return(false);
         }
     }
     return(true);
 }
コード例 #2
0
        public void InitGroups(string tri)
        {
            list = new List <DocumentsGroupe>();
            if (documents == null || documents.Count == 0)
            {
                return;
            }

            if (tri.Equals("Date de  Document"))
            {
                DocumentsGroupe group = null;
                dateDocs = new List <DocumentsGroupe>();
                DateTime date = DateTime.MinValue;
                foreach (Document d in documents.OrderByDescending(doc => doc.date))
                {
                    if (d.date != date)
                    {
                        date = d.date;
                        date.AddMonths(1);
                        group = new DocumentsGroupe(date.ToString("MM/dd/yyyy"));

                        if (!checkduplicate(dateDocs, group))
                        {
                            continue;
                        }

                        foreach (Document docs in documents)
                        {
                            if (d.date == docs.date)
                            {
                                group.Add(docs);
                            }
                        }
                        dateDocs.Add(group);
                    }
                }
                list = new List <DocumentsGroupe>();
                list = dateDocs;
            }
            if (tri.Equals("Professionnel de santé"))
            {
                DocumentsGroupe group = null;
                drDocs = new List <DocumentsGroupe>();
                string dr = string.Empty;
                foreach (Document d in documents)
                {
                    if (!d.dr.Equals(dr))
                    {
                        dr    = d.dr;
                        group = new DocumentsGroupe(dr);

                        if (!checkduplicate(drDocs, group))
                        {
                            continue;
                        }

                        foreach (Document docs in documents)
                        {
                            if (d.dr.Equals(docs.dr))
                            {
                                group.Add(docs);
                            }
                        }
                        drDocs.Add(group);
                    }
                }
                list = new List <DocumentsGroupe>();
                list = drDocs;
            }
            if (tri.Equals("Type de document"))
            {
                DocumentsGroupe group = null;
                typeDocs = new List <DocumentsGroupe>();
                string type = string.Empty;
                foreach (Document d in documents)
                {
                    if (!d.type.Equals(type))
                    {
                        type  = d.type;
                        group = new DocumentsGroupe(type);
                        if (!checkduplicate(typeDocs, group))
                        {
                            continue;
                        }
                        foreach (Document docs in documents)
                        {
                            if (d.type.Equals(docs.type))
                            {
                                group.Add(docs);
                            }
                        }
                        typeDocs.Add(group);
                    }
                }
                list = new List <DocumentsGroupe>();
                list = typeDocs;
            }
            if (tri.Equals("Structure de santé"))
            {
                DocumentsGroupe group = null;
                hsDocs = new List <DocumentsGroupe>();
                string str = string.Empty;
                foreach (Document d in documents)
                {
                    if (!d.HStructure.Equals(str))
                    {
                        str   = d.HStructure;
                        group = new DocumentsGroupe(str);
                        if (!checkduplicate(hsDocs, group))
                        {
                            continue;
                        }
                        foreach (Document docs in documents)
                        {
                            if (d.HStructure.Equals(docs.HStructure))
                            {
                                group.Add(docs);
                            }
                        }
                        hsDocs.Add(group);
                    }
                }
                list = new List <DocumentsGroupe>();
                list = hsDocs;
            }
        }