public ActionResult Getdept() { int deptno = int.Parse(Request.Form["txtdeptno"]); List <EMPDATA> l = DBoperations.Getdept(deptno); return(View("getDeptData", l)); }
/// <summary> /// Remove user from friends. /// </summary> /// <param name="user">user.</param> /// <param name="friendLogin">friend's login.</param> /// <exception cref="ConnectionInterruptedException"></exception> private void RemoveFriend(OnlineUser user, string friendLogin) { int friendId = DBoperations.GetUserId(friendLogin); if (friendId == 0) { return; } if (DBoperations.RemoveFriend(user.Id, friendId)) { // send new data to user one SendFriends(user); OnlineUser friend = GetOnlineUser(friendLogin); // send notification to user two if online if (friend != null) { friend.Client.SendMessage(new UserActionMessage { UserLogin = user.Login, Time = DateTime.Now, Action = UserActions.RemoveFromFriends }); } // write to db else { DBoperations.AddNotification(friendId, user.Id, UserActions.RemoveFromFriends, DateTime.Now); } } }
/// <summary> /// Send conversation to user. /// </summary> /// <param name="user">user.</param> /// <param name="interlocutor">interlocutor of user in conversation.</param> /// <exception cref="ConnectionInterruptedException"></exception> private void SendConversation(OnlineUser user, string interlocutor) { int interlocutorId = DBoperations.GetUserId(interlocutor); if (interlocutorId == 0) { return; } // get replies from db ConversationReply[] replies = DBoperations.GetConversation(user.Id, interlocutorId); if (replies != null) { foreach (var r in replies) { user.Client.SendMessage(new OldReplyMessage { Interlocutor = interlocutor, Author = DBoperations.GetUserLogin(r.user_id), Time = r.time, Text = r.reply }); } } }
/// <summary> /// Accept friendship request. /// </summary> /// <param name="user">user.</param> /// <param name="friendLogin">friend's login.</param> /// <exception cref="ConnectionInterruptedException"></exception> private void AcceptFriendshipRequest(OnlineUser user, string friendLogin) { int friendId = DBoperations.GetUserId(friendLogin); if (friendId == 0) { return; } if (DBoperations.SetFriendship(friendId, user.Id, true)) { // send new data to user one SendIncomeFriendshipRequests(user); SendFriends(user); OnlineUser friend = GetOnlineUser(friendLogin); // send notification to user two if online if (friend != null) { friend.Client.SendMessage(new UserActionMessage { UserLogin = user.Login, Time = DateTime.Now, Action = UserActions.AcceptFriendship }); } // write to db else { DBoperations.AddNotification(friendId, user.Id, UserActions.AcceptFriendship, DateTime.Now); } } }
/// <summary> /// Send array of outcome friendship requests to user. /// </summary> /// <param name="user">user.</param> /// <exception cref="ConnectionInterruptedException"></exception> private void SendOutcomeFriendshipRequests(OnlineUser user) { user.Client.SendMessage(new OutcomeFriendshipRequestsMessage { Logins = DBoperations.GetOutcomeFriendshipRequests(user.Id) }); }
public ActionResult empupdate() { int empno = int.Parse(Request.QueryString["e"]); EMPDATA emp = DBoperations.extractemp(empno); return(View("update", emp)); }
/// <summary> /// Add user to list of online users and start to listen to him. /// </summary> /// <param name="user">user.</param> public void AddUser(OnlineUser user) { if (user != null) { onlineUsers.Add(user); // online notification to friends string[] allFriends = DBoperations.GetFriends(user.Id); string[] online_users = onlineUsers.Select(x => x.Login).ToArray(); string[] onlineFriends = allFriends.Where(x => online_users.Contains(x)).ToArray(); foreach (var login in onlineFriends) { OnlineUser friend = GetOnlineUser(login); friend?.Client.SendMessage(new UserActionMessage { UserLogin = user.Login, Action = UserActions.GoOnline }); } } // listen this user Task.Run(() => UserListener(user)); }
public BestellingController( DBoperations repo, UserManager <AppUser> userManager ) { Repo = repo; _userManager = userManager; }
public ActionResult Index1() { l = DBoperations.emptable(); ViewBag.emplist = l; return(View()); }
public ActionResult radioextract() { //l = DBoperations.emptable(); int empno = Convert.ToInt32(Request.Form["rdb"]); return(View(DBoperations.empemp(empno))); }
public ActionResult showdata() { int deptno = int.Parse(Request.QueryString["d"]); ViewBag.l = list; List <EMPDATA> l = DBoperations.Getdept(deptno); return(View("getDepts", l)); }
public ActionResult del() { int empno = int.Parse(Request.Form["ddlempno"]); ViewBag.res = DBoperations.empno_del(empno); ViewBag.e = DBoperations.delemp(); return(View("deletedata")); }
public ActionResult updatebtn(EMPDATA e) { int empno = int.Parse(Request.Form["EMPNO"]); string s = DBoperations.updatedata(empno, e); ViewBag.msg = s; return(View("update")); }
public ActionResult extractdate() { DateTime start = DateTime.Parse(Request.Form["txtsd"]); DateTime end = DateTime.Parse(Request.Form["txted"]); l = DBoperations.Empdate(start, end); ViewBag.list = l; return(View("DateView")); }
/// <summary> /// Send array of friends to user. /// </summary> /// <param name="user">user.</param> /// <exception cref="ConnectionInterruptedException"></exception> private void SendFriends(OnlineUser user) { string[] allFriends = DBoperations.GetFriends(user.Id); string[] online_users = onlineUsers.Select(x => x.Login).ToArray(); user.Client.SendMessage(new FriendsMessage { OnlineFriends = allFriends.Where(x => online_users.Contains(x)).ToArray(), OfflineFriends = allFriends.Where(x => !online_users.Contains(x)).ToArray() }); }
/// <summary> /// Try to register client. Send response about result. /// </summary> /// <param name="client">client.</param> /// <param name="message">client's message.</param> private void RegisterClient(MpClient client, RegisterRequestMessage message) { Message response; if (string.IsNullOrEmpty(message.Login) || string.IsNullOrEmpty(message.Password) || message.Login.Length > 20 || message.Password.Length > 30) { response = new LoginRegisterResponseMessage { Response = LoginRegisterResponse.Error }; } else { if (DBoperations.Register(message.Login, message.Password)) { log.Info($"Client registered: {message.Login}"); response = new LoginRegisterResponseMessage { Response = LoginRegisterResponse.Success }; } else { response = new LoginRegisterResponseMessage { Response = LoginRegisterResponse.Fail }; } } try { // response to client client.SendMessage(response); } catch (ConnectionInterruptedException e) { log.Error("Connection with client brokes.", e); } // close connection log.Info($"Client disconnected. ip {((IPEndPoint)client.tcpClient.Client.RemoteEndPoint).Address.ToString()}"); try { client.Close(); } catch (ConnectionInterruptedException e) { log.Error(e); } }
protected Boolean DeleteRow(int apid) { DBoperations db = new DBoperations(); Boolean truth = db.DeleteAppointments(apid); if (truth) { return(true); } else { return(false); } }
//This is the event. When the user clicks submit, it will do the following: protected void btnSubmit_Click(object sender, EventArgs e) { string cs = WebConfigurationManager.ConnectionStrings["localConnection"].ConnectionString; SqlConnection con = new SqlConnection(cs); //1.check if email exists. //2. if it does not, insert data into appointment and account table. try { //check if the email already exist, email must be unique as this is the username //retrieving and saving to variables all the information in the form. FirstName = FirstName_Form.Text; LastName = LastName_Form.Text; Major = Major_Form.Text; Email = Email_Form.Text; Phone = Phone_Form.Text; Reason = Reason_Form.Text; Advisor = Advisor_Form.Text; TimeSlot = TimeSlots_Form.Text; string sql = "select count(*) from customer where email = '" + Email + "'"; con.Open(); int count = DBoperations.GetOneInt(sql); if (count != 0) {//email already exisits LblMsg.Text = "The email you entered already exists in the database. Please login to access your account or register with a different email. "; } else { DBoperations.CreateAccount(FirstName, LastName, Major, Email, Phone); StudentId = 1;//insert CreateAccount outparameter in here so that createappointment can work. DBoperations.CreateAppointment(StudentId, Reason, Advisor, Date, TimeSlot, Phone); } } catch (Exception err) { LblMsg.Text = "Cannot submit information now. Please try again later."; } finally //must make sure the connection is properly closed { //the finally block will always run whether there is an error or not con.Close(); } }
//This is the event. When the user clicks submit, it will do the following: protected void btnSubmit_Click(object sender, EventArgs e) { DBoperations DB = new DBoperations(); string username = UserName_Form.Text; string notes = "Tester"; int SID = DB.GetStudentID(username); int ATID = Convert.ToInt32(TimeSlots_Form.SelectedValue); Boolean value = DB.CreateAppointment(ATID, SID, notes); string cs = WebConfigurationManager.ConnectionStrings["localConnection"].ConnectionString; SqlConnection con = new SqlConnection(cs); int APID = 0; try { string selectSQL = "Select APID FROM KBS_APPOINTMENTS WHERE ATID=" + ATID + ";"; SqlCommand com = new SqlCommand(selectSQL, con); string setNonValid = "UPDATE KBS_ADVISOR_TIMES SET Valid=0 WHERE ATID=" + ATID + ";"; SqlCommand edit = new SqlCommand(setNonValid, con); con.Open(); APID = (int)com.ExecuteScalar(); edit.ExecuteNonQuery(); } catch (Exception err) { err.ToString(); } finally { con.Close(); } foreach (ListItem row in Reason_Form.Items) { if (row.Selected == true) { int reasons = Convert.ToInt32(row.Value); DB.MatchReasonsToAppointment(reasons, APID); } } DB = null; }
/// <summary> /// Handle new reply in conversation. /// </summary> /// <param name="user">user.</param> /// <param name="interlocutor">interlocutor.</param> /// <param name="text">text of reply.</param> /// <exception cref="ConnectionInterruptedException"></exception> private void HandleReply(OnlineUser user, string interlocutor, string text) { int interlocutorId = DBoperations.GetUserId(interlocutor); if (interlocutorId == 0) { return; } // time of reply DateTime time = DateTime.Now; if (DBoperations.AddNewReply(user.Id, interlocutorId, text, time)) { // send reply to user one user.Client.SendMessage(new NewReplyMessage { Interlocutor = interlocutor, Author = user.Login, Time = time, Text = text }); // send reply to user two if online OnlineUser friend = GetOnlineUser(interlocutor); if (friend != null) { friend.Client.SendMessage(new NewReplyMessage { Interlocutor = user.Login, Author = user.Login, Time = time, Text = text }); } // write notification to db else { DBoperations.AddNotification(interlocutorId, user.Id, UserActions.MessageSended, DateTime.Now); } } }
protected void GetDate(object sender, EventArgs e) { string date = Hidden.Value.ToString(); string time = Time.SelectedValue.ToString(); DateTime dates = Convert.ToDateTime(date); if (dates > DateTime.Now) { DBoperations DB = new DBoperations(); int temp = int.Parse(advisor.Value); Boolean truth = DB.CreateAdvisorTimes(date, time, temp); GetPrevDates(temp); } else { hold.Text = "This date is unavailable"; } }
/// <summary> /// Send array of all users to user. /// </summary> /// <param name="user">user.</param> /// <exception cref="ConnectionInterruptedException"></exception> private void SendAllUsers(OnlineUser user) { string[] allUsers = DBoperations.GetAllUsers(); string[] incomeRequests = DBoperations.GetIncomeFriendshipRequests(user.Id); string[] outcomeRequests = DBoperations.GetOutcomeFriendshipRequests(user.Id); string[] friends = DBoperations.GetFriends(user.Id); string[] users = allUsers.Where(x => !incomeRequests.Contains(x) & !outcomeRequests.Contains(x) & !friends.Contains(x) & x != user.Login).ToArray(); string[] online_users = onlineUsers.Select(x => x.Login).ToArray(); user.Client.SendMessage(new AllUsersMessage { OnlineUsers = users.Where(x => online_users.Contains(x)).ToArray(), OfflineUsers = users.Where(x => !online_users.Contains(x)).ToArray() }); }
/// <summary> /// Log out user. /// </summary> /// <param name="user">user.</param> private void Logout(OnlineUser user) { log.Info($"Client disconnected. ip {((IPEndPoint)user.Client.tcpClient.Client.RemoteEndPoint).Address.ToString()}"); string[] allFriends = DBoperations.GetFriends(user.Id); string[] online_users = onlineUsers.Select(x => x.Login).ToArray(); string[] onlineFriends = allFriends.Where(x => online_users.Contains(x)).ToArray(); foreach (var login in onlineFriends) { OnlineUser friend = GetOnlineUser(login); friend?.Client.SendMessage(new UserActionMessage { UserLogin = user.Login, Action = UserActions.GoOffline }); } onlineUsers.Remove(user); user.Dispose(); }
public ActionResult radiobtn() { dlist = DBoperations.getDepts(); ViewBag.d = dlist; if (Request.Form["txtsd"] != null && Request.Form["txted"] != null) { DateTime start = DateTime.Parse(Request.Form["txtsd"]); DateTime end = DateTime.Parse(Request.Form["txted"]); l = DBoperations.Empdate(start, end); ViewBag.list = l; } if (Request.Form["ddldeptno"] != null) { int deptno = int.Parse(Request.Form["ddldeptno"]); l = DBoperations.Getdept(deptno); ViewBag.list = l; } return(View("Index")); }
public ActionResult deletedata() { listemp = DBoperations.delemp(); ViewBag.e = listemp; return(View()); }
public ActionResult getDepts() { list = DBoperations.getDepts(); ViewBag.l = list; return(View()); }
public ActionResult Index(EMPDATA e) { ViewBag.msg = DBoperations.InsertEMPDATA(e); return(View()); }
protected void btnNext_Click(object sender, EventArgs e) { StudentInformation.Visible = false; ContactInformation.Visible = true; DBoperations DB = new DBoperations(); string First = FirstName_Form.Text; string Last = LastName_Form.Text; string Email = Email_Form.Text; string UserName = UserName_Form.Text; string Major = Major_Form.SelectedValue; int Maj = Convert.ToInt32(Major); string Phone = Phone_Form.Text; string UID = SUID_Form.Text; Boolean Student = DB.SecureVerifyStudent(UserName); if (Student == false) { DB.CreateStudent(First, Last, Email, UserName, Maj, 1, UID, Phone); } DB = null; //Advisors string cs = WebConfigurationManager.ConnectionStrings["localConnection"].ConnectionString; SqlConnection con = new SqlConnection(cs); try { ListItem newItem = new ListItem(); newItem.Text = "Select Advisor"; newItem.Value = "0"; Advisor_Form.Items.Add(newItem); string selectSQL = "Select AID ,AdvFName, AdvLName From KBS_ADVISORS"; SqlCommand comd = new SqlCommand(selectSQL, con); con.Open(); SqlDataReader reads = comd.ExecuteReader(); while (reads.Read()) { ListItem NewItem = new ListItem(); string first = reads["AdvFName"].ToString(); string last = reads["AdvLName"].ToString(); string full = first + " " + last; NewItem.Text = full; NewItem.Value = reads["AID"].ToString(); Advisor_Form.Items.Add(NewItem); } reads.Close(); con.Close(); } catch (Exception err) { err.ToString(); } finally { con.Close(); } try { string selectSQL = "Select RID, ReaDesc FROM VW_KBS_REASONS"; SqlCommand com = new SqlCommand(selectSQL, con); con.Open(); SqlDataReader reader = com.ExecuteReader(); while (reader.Read()) { ListItem NewItem = new ListItem(); NewItem.Text = reader["ReaDesc"].ToString(); NewItem.Value = reader["RID"].ToString(); Reason_Form.Items.Add(NewItem); } reader.Close(); con.Close(); } catch (Exception err) { err.ToString(); } finally { con.Close(); } }
public DeadlineController(DBoperations repo) { Repo = repo; }
public ActionResult Index() { dlist = DBoperations.getDepts(); ViewBag.d = dlist; return(View()); }