public static string Login(string ut, string usr, string pwd, string rd, string nn) { ebridgeEntities _db = new ebridgeEntities(); HttpContext.Current.Session.Clear(); JavaScriptSerializer serial = new JavaScriptSerializer(); if (ut == "participant") { if (_db.PARTICIPANT.Any(p => p.ID == usr && p.PASSWORD == pwd)) { HttpContext.Current.Session["PARTICIPANT_ID"]=usr; HttpContext.Current.Session["SCHOOL"]=Helper.FindSchool(usr); HttpContext.Current.Session["DESIGNATED_COUNSELOR"]=Utility.GetStatus(usr, "COUNSELOR"); } else return serial.Serialize(new Dictionary<string, string>() { { "message", "no match" } }); } else if (ut == "counselor") { COUNSELOR _c = _db.COUNSELOR.First(c=>c.USERNAME==usr && c.PASSWORD==pwd); if (_c != null) { HttpContext.Current.Session["COUNSELOR_ID"] = _c.ID; HttpContext.Current.Session["SCHOOL"]=Helper.FindSchool(_c.SITE); } else return serial.Serialize(new Dictionary<string, string>() { { "message", "no match" } }); } if (rd.Contains("login_alt.aspx")) rd = "list_alt.aspx"; return serial.Serialize(new Dictionary<string, string>() { { "redirect", rd }, { "message", "success" } }); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SchoolInfo = Session["SCHOOL"] as Dictionary<string, string>; if (SchoolInfo == null) { Response.Redirect("login.aspx?id=aiBcAmVnQs"); return; } string SchoolCode = SchoolInfo["code"]; ebridgeEntities _db = new ebridgeEntities(); IQueryable<RESOURCE_LINK> rs_lk = _db.RESOURCE_LINK.Where(rl => rl.ACTIVE == "True" && rl.SITE_ID == SchoolCode).OrderBy(rl1 => rl1.RANK); if (displayColumns != null && displayColumns == 1) { Repeater1.DataSource= new List<List<RESOURCE_LINK>>{rs_lk.ToList()}; Repeater1.DataBind(); return; } int rs_length = rs_lk.Count(); List<RESOURCE_LINK> rs_lk1 = rs_lk.Take(rs_length / 2).ToList(); List<RESOURCE_LINK> rs_lk2 = rs_lk.ToList(); rs_lk2.RemoveRange(0, rs_length / 2); Repeater1.DataSource = new List<List<RESOURCE_LINK>>{ rs_lk1, rs_lk2 }; Repeater1.DataBind(); } }
public static string SendEmail(string prt, string sbj, string msg){ ebridgeEntities _db = new ebridgeEntities(); JavaScriptSerializer serial = new JavaScriptSerializer(); Dictionary<string, string> SchoolInfo = HttpContext.Current.Session["SCHOOL"] as Dictionary<string, string>; string CounselorId = HttpContext.Current.Session["COUNSELOR_ID"] as string; if (SchoolInfo == null) { HttpContext.Current.Session.Clear(); return "redirect"; } // log activity PARTICIPANT _p = _db.PARTICIPANT.First(p=>p.ID==prt); if (_p != null) { string EmailToAddress = _p.EMAIL; Utility.SendPHPMail(EmailToAddress, SchoolInfo["email"], "The eBridge Team", sbj, msg); Utility.LogActivity(SchoolInfo["code"] + "_" + CounselorId, "EMAIL SENT", "to participant: " + _p.ID); return "success"; } else { return "no match"; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ebridgeEntities _db = new ebridgeEntities(); IQueryable<SCREENING_RESPONSE> resp = _db.SCREENING_RESPONSE.Where(sr => sr.PARTICIPANT_ID == ParticipantId); var pg = resp.Join(_db.PAGE_REF, r => r.QUESTION_CODE, p => p.value, (r, p) => new { Response = r, Page = p }).ToList(); List<PAGE_REF> survey_pages = new List<PAGE_REF>(); foreach (var p in pg) { //should be as many questions as there are responses separated by pipes string[] responses = p.Response.RESPONSE.Split('|'); PAGE_REF page_ref = p.Page; IOrderedEnumerable<QUESTION_REF> questions = page_ref.QUESTION_REF.OrderBy(q => q.qid); int cnt = 0; foreach (QUESTION_REF quest in questions) { string response = ""; if (cnt < responses.Length) response = responses[cnt]; quest.setChosenResponses(response, ref _db); cnt++; } page_ref.OrderedQuestions = questions; survey_pages.Add(page_ref); } Repeater1.DataSource = survey_pages; Repeater1.DataBind(); } }
public void deleteLink(int RID) { ebridgeEntities _db = new ebridgeEntities(); RESOURCE_LINK r = _db.RESOURCE_LINK.SingleOrDefault(link => link.RID==RID); if (r != null) { _db.RESOURCE_LINK.Remove(r); _db.SaveChanges(); } else { throw new ApplicationException("Can't find the link"); } }
public static string ParticipantLookup(string prtid) { ebridgeEntities _db = new ebridgeEntities(); JavaScriptSerializer serial = new JavaScriptSerializer(); Dictionary<string, string> SchoolInfo = HttpContext.Current.Session["SCHOOL"] as Dictionary<string, string>; string CounselorId = HttpContext.Current.Session["COUNSELOR_ID"] as string; if (SchoolInfo == null) { HttpContext.Current.Session.Clear(); return "invalid login"; } else { PARTICIPANT _p = _db.PARTICIPANT.First(p=>p.ID==prtid); if (_p != null) return serial.Serialize(new Dictionary<string, string>(){ {"name_first" , _p.NAME_FIRST}, {"gender", _p.GENDER } }); else return "failure"; } }
public void updateLink(int RID, string URL_TEXT, string URL, string ADDTL_TEXT, string ACTIVE, int Rank) { ebridgeEntities _db = new ebridgeEntities(); RESOURCE_LINK r = _db.RESOURCE_LINK.SingleOrDefault(link => link.RID == RID); if (r != null) { r.URL_TEXT=URL_TEXT; r.ADDTL_TEXT=ADDTL_TEXT; r.URL=URL; r.RANK=Rank; r.DATE_TIME=DateTime.Now; _db.SaveChanges(); } else { throw new ApplicationException("Can't find the link"); } }
protected void getThreadMessages() { if (ParticipantId == null) return; ebridgeEntities _db = new ebridgeEntities(); PARTICIPANT Part = _db.PARTICIPANT.SingleOrDefault<PARTICIPANT>(p=>p.ID==ParticipantId); IQueryable<MESSAGE_ALT> Msgs = _db.MESSAGE_ALT.Where<MESSAGE_ALT>(m => m.FROM_ID == ParticipantId || m.TO_ID == ParticipantId).OrderByDescending(m => m.DATE_TIME); if (Msgs == null || Part == null) return; foreach (MESSAGE_ALT m in Msgs) m.setPosition(); ShowResources1.DisplayColumns = 1; FormView1.DataSource=new List<PARTICIPANT>{Part}; FormView1.DataBind(); Repeater2.DataSource = Msgs.ToList<MESSAGE_ALT>(); Repeater2.DataBind(); }
protected void SendMessage(object sender, EventArgs e) { string DialogBody = CKEditor1.Text.Trim(); if (String.IsNullOrEmpty(DialogBody)) return; ebridgeEntities _db = new ebridgeEntities(); MESSAGE_ALT newMessage = new MESSAGE_ALT(); newMessage.MESSAGE_BODY = HttpUtility.HtmlEncode(DialogBody); newMessage.DATE_TIME = DateTime.Now; if (UserType == "participant") { newMessage.FROM_ID = ParticipantId; } else if (UserType == "counselor") { newMessage.TO_ID = ParticipantId; } _db.MESSAGE_ALT.Add(newMessage); _db.SaveChanges(); getThreadMessages(); }
public void createLink(string URL_TEXT, string URL, string Addtl_Text, int Rank ) { ebridgeEntities _db = new ebridgeEntities(); _db.RESOURCE_LINK.Add( new RESOURCE_LINK { URL_TEXT=URL_TEXT, URL=URL, ADDTL_TEXT=ADDTL_TEXT, RANK=Rank, DATE_TIME=DateTime.Now, SITE_ID="s", CREATED_BY="C001", ACTIVE="True"}); _db.SaveChanges(); }
public List<RESOURCE_LINK> getAllLinks() { ebridgeEntities _db = new ebridgeEntities(); return _db.RESOURCE_LINK.ToList<RESOURCE_LINK>(); }
public void setChosenResponses(string rstring, ref ebridgeEntities _db) { string page_title = this.PAGE_REF.value; IQueryable<RESPONSE_REF> r_ref = _db.RESPONSE_REF; List<string> responses = rstring.Split(',').ToList(); IEnumerable<RESPONSE_REF> Chosen = this.RESPONSE_X_QUESTION.Join(r_ref, rxq=>rxq.rid, r=>r.rid, (rxq, r) => r).Where( r=> responseHasReference(ref responses, ref r)); this.ChosenResponses=Chosen.ToList(); string _dsp = ""; if (ChosenResponses != null) { foreach (RESPONSE_REF c in ChosenResponses) { _dsp += string.Format("<li>{0} : {1} </li>", new string[2]{c.value, c.content} ); } } if (responses.Count != 0) { foreach (string r in responses) { if (r == ".") _dsp += string.Format("<li>{0} : {1} </li>", new string[2]{r, "No Response"} ); else _dsp += string.Format("<li>{0} : {1} </li>", new string[2]{"Other", r} ); } } if (string.IsNullOrEmpty(_dsp)) this.DisplayResponses=""; else this.DisplayResponses = string.Format("<ul>{0}</ul>" , _dsp); }
public static string setHours(string[] hours) { JavaScriptSerializer serial = new JavaScriptSerializer(); string CounselorId= HttpContext.Current.Session["COUNSELOR_ID"] as string; Dictionary<string, string> SchoolInfo = HttpContext.Current.Session["SCHOOL"] as Dictionary<string, string>; if (string.IsNullOrEmpty(CounselorId) || SchoolInfo == null) return "failure"; string _tmp = ""; foreach (string v in hours) { _tmp += v + '|'; } _tmp = _tmp.Substring(0, _tmp.Length - 1); ebridgeEntities _db = new ebridgeEntities(); _db.SITE.Add(new SITE{ DATE_TIME= DateTime.Now, ID=SchoolInfo["code"], HOURS=_tmp}); _db.SaveChanges(); return "success"; }
protected void Page_Load(object sender, EventArgs e) { Utility.LogActivity("counselor", "PARTICIPANT LIST PAGE VISITED", Request.UserHostAddress + "|" + Request.UserAgent); SchoolInfo = Session["SCHOOL"] as Dictionary<string, string>; CounselorId = Session["COUNSELOR_ID"] as string; _db = new ebridgeEntities(); if (SchoolInfo == null || string.IsNullOrEmpty(CounselorId)) { Session.Clear(); Response.Redirect(String.Format("login_alt.aspx?p=counselor")); return; } UserType="counselor"; getNavigation(RepeaterNav, "counselor"); getStats(SchoolInfo["code"]); getDialogs(SchoolInfo["code"]); RepeaterHours.DataSource= getHours(ref _db, ref SchoolInfo); RepeaterHours.DataBind(); }
protected List<WeekdayHours> getHours(ref ebridgeEntities _db, ref Dictionary<string, string> SchoolInfo) { if (_db == null && SchoolInfo == null) return null; _db = new ebridgeEntities(); string[] DayKey = new string[6] { "Title", "Mon", "Tue", "Wed", "Thur", "Fri" }; string _code = SchoolInfo["code"] as string; SITE _site = _db.SITE.Where(s => s.ID == _code).OrderByDescending(s1 => s1.SID).First(); string[] _hours = _db.SITE.First(s => s.SID == _site.SID).HOURS.Split('|'); List<WeekdayHours> _list = new List<WeekdayHours>(); for (int i = 0; i < _hours.Length; i++) { _list.Add(new WeekdayHours { Hour = _hours[i], Weekday = DayKey[i], Rank = i }); } return _list; }