public void get_all_users(object arg, DoWorkEventArgs e)
 {
     e.Result = (object)(new List<user_item>());
     try
     {
         naturenet_dataclassDataContext db = new naturenet_dataclassDataContext();
         var r = from u in db.Users
                 where u.id != 0
                 orderby u.name
                 select u;
         if (r == null)
         {
             e.Result = (object)(new List<user_item>());
             return;
         }
         List<user_item> users = new List<user_item>();
         foreach (User u in r)
         {
             user_item i = new user_item();
             ImageSource src = new BitmapImage(new Uri(configurations.GetAbsoluteAvatarPath() + u.avatar));
             src.Freeze();
             i.img = src;
             i.user = u;
             users.Add(i);
         }
         e.Result = (object)users;
     }
     catch (Exception ex)
     {
         log.WriteErrorLog(ex);
     }
 }
 public List<user_item> get_all_users()
 {
     try
     {
         naturenet_dataclassDataContext db = new naturenet_dataclassDataContext();
         var r = from u in db.Users
                 where u.id != 0
                 orderby u.name
                 select u;
         if (r == null)
         {
             return new List<user_item>();
         }
         List<user_item> users = new List<user_item>();
         foreach (User u in r)
         {
             var n1 = from m in db.Collection_Contribution_Mappings
                      where m.Collection.user_id == u.id
                      orderby m.Contribution.date descending
                      select m.Contribution.date;
             //var n2 = from f in db.Feedbacks
             //         where f.user_id == u.id
             //         orderby f.date descending
             //         select f.date;
             List<DateTime> n2 = null;
             int cnt = 0;
             if (n1 != null)
                 cnt = n1.Count();
             if (n2 != null)
                 cnt = cnt + n2.Count();
             user_item i = new user_item();
             ImageSource src = new BitmapImage(new Uri(configurations.GetAbsoluteAvatarPath() + u.avatar));
             src.Freeze();
             i.img = src;
             i.user = u;
             i.count = cnt;
             i.has_date = false;
             if (n1 != null)
             {
                 if (n1.Count() > 0)
                 {
                     i.last_date = n1.First();
                     i.has_date = true;
                 }
             }
             if (n2 != null)
             {
                 if (n2.Count() > 0)
                 {
                     if (i.has_date)
                     {
                         if (i.last_date.CompareTo(n2.First()) < 0)
                             i.last_date = n2.First();
                     }
                     else
                     {
                         i.last_date = n2.First();
                         i.has_date = true;
                     }
                 }
             }
             users.Add(i);
         }
         return users;
     }
     catch (Exception ex)
     {
         log.WriteErrorLog(ex);
         return new List<user_item>();
     }
 }