private string get_feedback_info(SFeedback f) { string r = f.id + "," + f.account.id + "," + f.kind.ToLower() + "," + f.content + "," + f.target.model.ToLower() + "," + f.target.id + "," + f.parent_id + "," + f.created_at + "," + f.modified_at; return(r); }
private void ProcessInsertFeedback(int feedback_id) { TableTopDataClassesDataContext db = Configurations.GetTableTopDB(); var feedbacks = from f in db.Feedbacks where f.id == feedback_id select f; if (feedbacks.Count() == 1) { Feedback fb = feedbacks.Single <Feedback>(); SFeedback result = null; if (fb.object_type == "nature_net.Contribution") // feedback on contribution (note) { var contributions = from c in db.Contributions where c.id == fb.object_id select c; if (contributions.Count() == 1) { Contribution cn = contributions.Single <Contribution>(); if (fb.parent_id == 0) { if (fb.type_id == 1) // comment on contribution { result = server_api.CreateFeedback("comment", "note", cn.technical_info, fb.User.name, fb.note, "0"); } if (fb.type_id == 2) // like on contribution (currently design idea) { result = server_api.CreateFeedback("like", "note", cn.technical_info, "default", fb.note, "0"); } } else { var fbs = from f in db.Feedbacks where f.id == fb.parent_id select f; if (fbs.Count() == 1) { Feedback parent = fbs.Single <Feedback>(); if (fb.type_id == 1) { result = server_api.CreateFeedback("comment", "note", cn.technical_info, fb.User.name, fb.note, parent.technical_info); } } } } } if (fb.object_type == "nature_net.User") // feedback on user (account) { var users = from u in db.Users where u.id == fb.object_id select u; if (users.Count() == 1) { User us = users.Single <User>(); int account_id = find_account(us.name); if (account_id != -1) { if (fb.parent_id == 0) { if (fb.type_id == 1) // comment on user { result = server_api.CreateFeedback("comment", "account", account_id.ToString(), fb.User.name, fb.note, "0"); } } else { var fbs = from f in db.Feedbacks where f.id == fb.parent_id select f; if (fbs.Count() == 1) { Feedback parent = fbs.Single <Feedback>(); if (fb.type_id == 1) { result = server_api.CreateFeedback("comment", "account", account_id.ToString(), fb.User.name, fb.note, parent.technical_info); } } } } } } if (fb.object_type == "nature_net.Activity") // feedback on activity (context) { var activities = from a in db.Activities where a.id == fb.object_id select a; if (activities.Count() == 1) { Activity ac = activities.Single <Activity>(); int context_id = find_activity(ac.name); if (context_id != -1) { if (fb.parent_id == 0) { if (fb.type_id == 1) // comment on activity { result = server_api.CreateFeedback("comment", "context", context_id.ToString(), fb.User.name, fb.note, "0"); } } else { var fbs = from f in db.Feedbacks where f.id == fb.parent_id select f; if (fbs.Count() == 1) { Feedback parent = fbs.Single <Feedback>(); if (fb.type_id == 1) { result = server_api.CreateFeedback("comment", "context", context_id.ToString(), fb.User.name, fb.note, parent.technical_info); } } } } } } if (fb.object_type == "nature_net.Location") // feedback on location (context) { var locations = from l in db.Locations where l.id == fb.object_id select l; if (locations.Count() == 1) { Location lc = locations.Single <Location>(); int context_id = find_location(lc.id.ToString()); if (context_id != -1) { if (fb.parent_id == 0) { if (fb.type_id == 1) //comment on location { result = server_api.CreateFeedback("comment", "context", context_id.ToString(), fb.User.name, fb.note, "0"); } } else { var fbs = from f in db.Feedbacks where f.id == fb.parent_id select f; if (fbs.Count() == 1) { Feedback parent = fbs.Single <Feedback>(); if (fb.type_id == 1) { result = server_api.CreateFeedback("comment", "context", context_id.ToString(), fb.User.name, fb.note, parent.technical_info); } } } } } } if (result != null) { fb.technical_info = result.id.ToString(); db.SubmitChanges(); } if (RESTService.Last_Exception != null) { this.errors.Add(RESTService.Last_Exception); } } }