public void get_contributions_in_location(object arg, DoWorkEventArgs e) { naturenet_dataclassDataContext db = new naturenet_dataclassDataContext(); var result1 = from c in db.Collection_Contribution_Mappings where (c.Contribution.location_id == (int)e.Argument) && (c.Collection.activity_id != 1) select c.Contribution; //var result1 = from c in db.Contributions // where c.location_id == (int)e.Argument // select c; if (result1 == null) { e.Result = (object)(new List<collection_item>()); return; } List<Contribution> medias = result1.ToList<Contribution>(); List<collection_item> loaded_items = new List<collection_item>(); loading_progress lp0 = new loading_progress(); lp0.current_progress = 0; lp0.total = medias.Count; lp0.loaded_items = loaded_items; worker.ReportProgress(0, lp0); List<collection_item> items = new List<collection_item>(); for (int counter = 0; counter < medias.Count; counter++) { collection_item ci = create_collection_item_from_contribution(medias[counter]); items.Add(ci); loaded_items.Add(ci); loading_progress lp = new loading_progress(); lp.current_progress = counter + 1; lp.total = medias.Count; lp.loaded_items = loaded_items; worker.ReportProgress(counter + 1, lp); } e.Result = (object)items; }
public void get_all_contributions(object arg, DoWorkEventArgs e) { naturenet_dataclassDataContext db = new naturenet_dataclassDataContext(); var result1 = from c in db.Collection_Contribution_Mappings where (c.Collection.User.name == (string)e.Argument) && (c.Collection.activity_id != 1) select c.Contribution; if (result1 == null) { e.Result = (object)(new List<collection_item>()); return; } //List<int> contribution_ids = result1.ToList<int>(); //var result2 = from m in db.Contributions // where contribution_ids.Contains(m.id) // select m; List<Contribution> medias = result1.ToList<Contribution>(); List<collection_item> loaded_items = new List<collection_item>(); loading_progress lp0 = new loading_progress(); lp0.current_progress = 0; lp0.total = medias.Count; lp0.loaded_items = loaded_items; worker.ReportProgress(0, lp0); // download the image if there is no image // create thumbnail if there is no thumbnail List<collection_item> items = new List<collection_item>(); for (int counter = 0; counter < medias.Count; counter++) { collection_item ci = create_collection_item_from_contribution(medias[counter]); items.Add(ci); loaded_items.Add(ci); loading_progress lp = new loading_progress(); lp.current_progress = counter + 1; lp.total = medias.Count; lp.loaded_items = loaded_items; worker.ReportProgress(counter + 1, lp); } e.Result = (object)items; }