public ActionResult UpdateUserInfo(UserModel user) { string userName = Request.Form["username"]; string email = Request.Form["email"]; string mobile = Request.Form["mobile"]; string tel = Request.Form["tel"]; string fax = Request.Form["fax"]; if (userName == "") return JavaScript("alert('请输入用户名!');"); if (email == "") return JavaScript("alert('请输入邮箱!');"); yhgl_users userInfo = new yhgl_users { user_id = user.UserInfo.user_id, user_avatar = GlobalVar.AvatarPath, user_fax = fax, user_email = email, user_mobile = mobile, user_tel = tel, user_name = userName }; ArgsHelp ah = yhglDAO.UpdateUserInfo(userInfo); if (ah.flag) return JavaScript("alert('更新成功!');refresh();"); else return JavaScript("alert('更新失败!" + ah.msg + "');"); }
public ActionResult Verify(UserModel user,FsyhModel fsyh) { string name = Request.Form["username"]; string psw = Request.Form["password"]; string kind = Request.Form["userKind"]; if (kind == "主用户") { var users = (from u in userDB.yhgl_users where u.user_name == name where u.user_psw == psw where u.user_qy == "是" select u).ToList(); if (users.Count != 0) { user.UserInfo = users.First(); return JavaScript("document.location='/Home/Main'"); } return JavaScript("alert('登录失败');"); } else { var fsyhs = (from fs in fsyhDB.yhgl_fsyh where fs.fsyh_name == name select fs).ToList(); if (fsyhs.Count != 0) { fsyh.FsyhInfo = fsyhs.First(); return JavaScript("document.location='/Home/Fsyh'"); } return JavaScript("alert('登录失败')"); } }
public ContentResult UploadAndSave(HttpPostedFileBase fileData, string folder, string bz, string userId) { string result = ""; if (null != fileData) { try { var userModel = new UserModel { UserInfo = (from u in userDB.yhgl_users where u.user_id == Convert.ToInt32(userId) select u).First() }; result = Path.GetFileName(fileData.FileName);//获得文件名 string ext = Path.GetExtension(fileData.FileName);//获得文件扩展名 string saveName = result;//实际保存文件名 string fileUpTime = DateTime.Now.ToString("yyyy-MM-dd") + "-" + fileDAO.GetFileId("文件上传"); fileID = "文件上传-" + fileUpTime; string fileName = fileUpTime + ext; string path = userModel.UserInfo.user_id + "/" + fileUpTime + ext; Save2SQL(fileData, saveName, path, ext, bz, userModel);//保存到数据库 SaveFile(fileData, fileName, ext, userModel);//保存文件 } catch(Exception e) { result = ""; } } return Content(result); }
/// <summary> /// 发送站内信 /// </summary> /// <param name="user"></param> /// <returns></returns> public ActionResult Send(UserModel user) { string[] receivers = Request.Form["rsvID"].Split(','); string content = Request.Form["content"]; string topic = Request.Form["topic"]; try { foreach (var receiver in receivers) { yjgl_znx znx = new yjgl_znx { fs_user_id = user.UserInfo.user_id, js_user_id = Convert.ToInt32(receiver), znx_topic = topic, znx_nr = content, znx_fssj = DateTime.Now.ToString("yyy-MM-dd hh:mm:ss"), znx_isread = "否" }; ArgsHelp ah = znxDAO.SendZnx(znx); if (!ah.flag) throw new Exception(ah.msg); } } catch (Exception e) { return JavaScript("ZnxFailed('" + e.Message + "');"); } return JavaScript("ZnxSuccessed();"); }
public ActionResult Admin(UserModel user) { var friends = (from f in userDB.yhgl_users where f.level_id != 1 select f).ToList(); List<FriendEntity> friendList = new List<FriendEntity>(); foreach (var friend in friends) { FriendEntity friendEntity = new FriendEntity { YhInfo = friend, GroupInfo = new hygl_group { group_id = 0 }, FriendMx = new hygl_friend() }; friendList.Add(friendEntity); } user.FriendMx = friendList; var groups = (from g in friendGroupDB.hygl_group where g.user_id == user.UserInfo.user_id select g).ToList(); user.FriendGroups = groups == null ? new List<hygl_group>() : groups; return View(user); }
public string SearchResult(string searchKind,UserModel user) { string content=Request.Form["Content"]; string HTMLStr = "<p>检索到的文件名称为:</p>"; List<wjgl_files> files = new List<wjgl_files>(); if (searchKind == "全文检索") { var wjnrs = (from c in wjnrDB.wjgl_wjnrjs where c.file_nr.Contains(content) select c.file_id).Distinct().ToList(); foreach (var wjnr in wjnrs) { var file = (from f in filesDB.wjgl_files where f.file_id == wjnr select f).First(); files.Add(file); } } else { files = (from f in filesDB.wjgl_files where (f.file_name.Contains(content) || f.file_bz.Contains(content)) where f.user_id == user.UserInfo.user_id select f).ToList(); } foreach (var file in files) HTMLStr += BulidHTML(file.file_id, file.file_name); HTMLStr += "<p>你可以在左边的文件列表中点击查看。</p>"; return HTMLStr; }
public ActionResult MoveFriend(string groupId, string friendId, UserModel user) { ArgsHelp ah = friendDAO.MoveToNewGroup(groupId, friendId, user.UserInfo.user_id); if (ah.flag) return JavaScript("refresh();"); else return JavaScript("alert('出错!" + ah.msg + "')"); }
public ActionResult AllZnx(UserModel user) { var model = new ZnxModel { ZnxEntities = znxDAO.GetAllZnx(user.UserInfo.user_id) }; return View(model); }
public ActionResult AddNewFriend(UserModel user, string HiddenUId) { try { yhglDAO.AddFriend(user.UserInfo.user_id, Convert.ToInt32(HiddenUId)); return JavaScript("alert('添加好友成功!');"); } catch (Exception e) { return JavaScript("alert('添加好友失败!');"); } }
public ActionResult GxFiles_ToOthers(UserModel user) { var zyhFiles = (from zf in zyhGxFilesDB.gxgl_zyhgx where zf.gx_ly == user.UserInfo.user_id select zf).ToList(); var fsyhFiles = (from ff in fsyhGxFilesDB.gxgl_fsyhgxb where ff.fsyhgx_ly == user.UserInfo.user_id select ff).ToList(); var model = BuildModel(zyhFiles, fsyhFiles); return View(model); }
/// <summary> /// 新增附属用户 /// </summary> /// <param name="user"></param> /// <returns></returns> public ActionResult AddNewFsyh(UserModel user) { string fsyhName = Request.Form["fsyhName"]; try { yhglDAO.AddFsyh(fsyhName, user.UserInfo.user_id); return JavaScript("alert('增加附属用户成功!');refresh();"); } catch (Exception e) { return JavaScript("alert('增加附属用户失败!');"); } }
public ActionResult MoveToFloder(string fileID, string floderName, string higherFloder, UserModel user) { ArgsHelp ah = new ArgsHelp(); string filePath = string.Empty; if (higherFloder == null || higherFloder == "") filePath = user.UserInfo.user_id + "/" + floderName; else filePath = user.UserInfo.user_id + "/" + higherFloder + "/" + floderName; ah = floderDAO.MoveFileToNewFloder(fileID, floderName, filePath, Request.MapPath("/UploadFiles/")); if (ah.flag) return JavaScript("alert('移动成功');refresh();"); else return JavaScript("alert('移动失败');"); }
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { if (bindingContext.Model != null) throw new InvalidOperationException("Cannot update instances"); // Return the cart from Session[] (creating it first if necessary) UserModel user = (UserModel)controllerContext.HttpContext.Session[CartSessionKey]; if (user == null) { user = new UserModel(); controllerContext.HttpContext.Session[CartSessionKey] = user; } return user; }
/// <summary> /// 增加好友分组 /// </summary> /// <param name="user"></param> /// <returns></returns> public ActionResult AddNewGroup(UserModel user) { string groupName = Request.Form["groupName"]; ArgsHelp ah = new ArgsHelp(); try { ah = yhglDAO.AddNewGroup(groupName, user.UserInfo.user_id); if(ah.flag) return JavaScript("alert('增加分组成功!');refresh();"); else return JavaScript("alert('增加分组失败!');"); } catch (Exception e) { return JavaScript("alert('增加分组失败!');"); } }
public ActionResult DelFloder(string floderName, string higherFloder, UserModel user) { ArgsHelp ah = new ArgsHelp(); foreach (var file in user.Files) { if (file.floder_name == floderName) return JavaScript("alert('文件夹内还有文件,无法删除!')"); } string filePath = string.Empty; if (higherFloder == null || higherFloder == "") filePath = Request.MapPath("/UploadFiles/" + user.UserInfo.user_id + "/") + floderName; else filePath = Request.MapPath("/UploadFiles/" + user.UserInfo.user_id + "/") + higherFloder + "/" + floderName; ah = floderDAO.DeleteFloder(floderName, filePath); if (ah.flag) return JavaScript("alert('删除成功');refresh();"); else return JavaScript("alert('删除失败');"); }
public ActionResult SetGx(UserModel user) { List<string> userList = new List<string>(); List<string> fileList = new List<string>(); List<string> fsyhList = new List<string>(); GxEntity gxEntity = new GxEntity(); try { if (Request.Form["filesGx"] == null) { throw new Exception("没有选择要共享的文件!"); } if (Request.Form["usersGx"] == null && Request.Form["fsyhsGx"] == null) { throw new Exception("没有选择要共享的用户!"); } var files = Request.Form["filesGx"]; var users = Request.Form["usersGx"] == null ? string.Empty : Request.Form["usersGx"]; var fsyhs = Request.Form["fsyhsGx"] == null ? string.Empty : Request.Form["fsyhsGx"]; if (users != "") { foreach (var userInfo in users.Split(',')) userList.Add(userInfo); } foreach (var fileInfo in files.Split(',')) fileList.Add(fileInfo); if (fsyhs != "") { foreach (var fsyhInfo in fsyhs.Split(',')) fsyhList.Add(fsyhInfo); } gxEntity.UserList = userList; gxEntity.FileList = fileList; gxEntity.FsyhList = fsyhList; gxglDAO.AddGx(gxEntity, user.UserInfo.user_id); return JavaScript("alert('设置成功!')"); } catch (Exception e) { return JavaScript("alert('" + e.Message + "')"); } }
// // GET: /Floder/ public ActionResult AddFloder(UserModel user) { ArgsHelp ah = new ArgsHelp(); string floderName = Request.Form["floderName"]; string higherFloder = Request.Form["higherFloder"]; if (floderName == "") return JavaScript("alert('请填写文件名')"); string filePath = Request.MapPath("/UploadFiles/" + user.UserInfo.user_id + "/"); if (higherFloder == null || higherFloder == "/") { filePath = Request.MapPath("/UploadFiles/" + user.UserInfo.user_id + "/") + floderName; higherFloder = ""; } else filePath = Request.MapPath("/UploadFiles/" + user.UserInfo.user_id + "/") + higherFloder + "/" + floderName; ah = floderDAO.AddNewFloder(user.UserInfo.user_id, floderName, filePath, higherFloder); if (ah.flag) return JavaScript("alert('添加成功');refresh();"); else return JavaScript("alert('添加失败');"); }
// // GET: /Files/ public ActionResult FileList(UserModel user,string floderName) { List<wjgl_files> files; bool canAddNewFloder = true; bool canDelFloder = true; if (floderName == "默认") { canDelFloder = false; floderName = ""; } if (floderName == "共享") { canAddNewFloder = false; canDelFloder = false; files = new List<wjgl_files>(); foreach (var file in user.ZyhGxFiles) files.Add(file.FileInfo); } else { if (user.Files != null) { files = (from f in user.Files where f.floder_name == (floderName == "" ? null : floderName) select f).ToList(); }else files = new List<wjgl_files>(); } var floderInfo = (from fd in userFloderDB.userfloder where fd.floder_name == floderName select fd).ToList(); var fileListEntity = new FileListEntity { Files = files, CanAddNewFloder = canAddNewFloder, CanDelFolder = canDelFloder, FloderInfo = floderInfo.Count==0 ? new userfloder() : floderInfo.First() }; return View(fileListEntity); }
public ActionResult EmailsView(UserModel user) { var model = new EmailWithFilesModel { YjmxWithFilesEntites = emailglDAO.GetAllEmails(user.UserInfo.user_id) }; return View(model); }
/// <summary> /// 发送邮件 /// </summary> /// <param name="user"></param> /// <returns></returns> public ActionResult Send(UserModel user) { string receiver = Request.Form["receiver"]; string sender = Request.Form["sender"]; string content = Request.Form["content"]; string psw = Request.Form["psw"]; string topic = Request.Form["topic"]; if (!CommonOper.email_hftz(receiver)) return JavaScript("Failed('不正确的邮件格式');"); ArgsHelp ah = SendMail(receiver, user.UserInfo.user_name, receiver, topic, content, psw,user.UserInfo.user_id); if (ah.flag) return JavaScript("Successed();"); else return JavaScript("Failed('" + ah.msg + "');"); }
/// <summary> /// 发送邮件(view) /// </summary> /// <param name="user"></param> /// <returns></returns> public ActionResult Index(UserModel user) { return View(user); }
public ActionResult GxFileList(UserModel user) { var gxFileModel = new GxFilesModel { ZyhGxFiles = user.ZyhGxFiles }; return View(gxFileModel); }
public string FindUsers(string username,UserModel user) { string resultStr = string.Empty; var users = yhglDAO.GetUsersByName(username); if (users.Count == 0) return "<div>没有找到这个用户!</div>"; else { foreach (var u in users) { if (u.user_id == user.UserInfo.user_id) continue; resultStr += BuildResultString(u.user_id.ToString(), u.user_name); } } return "<div>" + resultStr + "</div>"; }
public ActionResult ForwardEmail(string emailId, string receiver,string psw, UserModel user) { FileDAO fileDAO = new FileDAO(); var email = emailglDAO.GetEmailById(emailId); if (!CommonOper.email_hftz(receiver)) return JavaScript("ForwardFailed('错误的邮箱格式');"); foreach (var fileID in email.yj_fj.Split('|')) { if (fileID == "") continue; var file = fileDAO.GetFileByID(fileID); ArgsHelp ah2 = AddAccessoriesNoJs(file.file_path, file.file_name, file.file_id); if (!ah2.flag) return JavaScript("ForwardFailed('附件添加错误:" + ah2.msg + "');"); } ArgsHelp ah = SendMail(user.UserInfo.user_email, user.UserInfo.user_name, receiver, email.yj_zt, email.yj_nr, psw, user.UserInfo.user_id); if (ah.flag) return JavaScript("ForwardSuccessed();"); else return JavaScript("ForwardFailed('" + ah.msg + "');"); }
/// <summary> /// 保存文件原本 /// </summary> /// <param name="postedFile"></param> /// <param name="filepath">文件路径</param> /// <param name="saveName">文件名</param> /// <param name="ext">文件后缀名</param> private void SaveFile(HttpPostedFileBase postedFile, string fileName,string ext,UserModel user) { string filepath = Request.MapPath("/UploadFiles/" + user.UserInfo.user_id + "/"); if (!Directory.Exists(filepath)) { Directory.CreateDirectory(filepath); } try { postedFile.SaveAs(filepath + fileName); Conversion(filepath + fileName, ext); } catch (Exception e) { throw new ApplicationException(e.Message); } }
/// <summary> /// 保存文件到数据库 /// </summary> private void Save2SQL(HttpPostedFileBase postedFile, string fileName,string path, string ext, string bz,UserModel user) { var file = new wjgl_files { file_id = fileID, file_name = fileName, file_path = path, file_scsj = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), file_bz = bz, user_id = user.UserInfo.user_id }; fileDAO.AddNewFile(file); SaveWjnr(fileID, path, ext); }
// // GET: /Upload/ public ActionResult UploadPartial(UserModel user) { return View(user); }
public ActionResult Welcome(UserModel user) { return View(user); }
/// <summary> /// 上传头像 /// </summary> /// <returns></returns> public ActionResult UploadAvatar(UserModel user) { return View(user); }
public ActionResult Main(UserModel user) { if (user.UserInfo.level_id == 1) return RedirectToAction("Admin"); //上传的文件 var file = (from f in filesDB.wjgl_files where f.user_id == user.UserInfo.user_id select f).ToList(); //附属用户 var fsyhs = (from fs in fsyhDB.yhgl_fsyh where fs.user_id == user.UserInfo.user_id select fs).ToList(); //好友(主用户) var friends = (from fr in friendDB.hygl_friend where fr.hy1_id == user.UserInfo.user_id select fr).ToList(); var floders = (from fl in userFloderDB.userfloder where fl.user_id == user.UserInfo.user_id select fl).ToList(); var groups = (from g in friendGroupDB.hygl_group where g.user_id == user.UserInfo.user_id select g).ToList(); user.Files = file.Count == 0 ? new List<wjgl_files>() : file; user.FsyhMx = fsyhs.Count == 0 ? new List<yhgl_fsyh>() : fsyhs; user.UserFloders = floders.Count == 0 ? new List<userfloder>() : floders; user.FriendGroups = groups.Count == 0 ? new List<hygl_group>() : groups; List<FriendEntity> friendList = new List<FriendEntity>(); foreach (var friend in friends) { var userF = (from u in userDB.yhgl_users where u.user_id == friend.hy2_id select u).First(); hygl_group group; if (friend.group_id == null) group = new hygl_group(); else group = (from g in friendGroupDB.hygl_group where g.group_id == friend.group_id select g).First(); FriendEntity friendEntity = new FriendEntity { YhInfo = userF, GroupInfo = group, FriendMx = friend }; friendList.Add(friendEntity); } user.FriendMx = friendList; //可查看的共享文件 var gxFiles = (from gf in zyhGxFilesDB.gxgl_zyhgx where gf.user_id == user.UserInfo.user_id select gf).ToList(); List<ZyhGxFilesEntity> gxFilesEntities = new List<ZyhGxFilesEntity>(); foreach (gxgl_zyhgx zyhgx in gxFiles) { var fileInfo = (from fi in filesDB.wjgl_files where fi.file_id == zyhgx.file_id select fi).First(); var userInfo = (from ui in userDB.yhgl_users where ui.user_id == zyhgx.gx_ly select ui).First(); ZyhGxFilesEntity zyhGxFilesEntity = new ZyhGxFilesEntity { FileInfo = fileInfo, GxyhInfo = userInfo, Gxmx = zyhgx }; gxFilesEntities.Add(zyhGxFilesEntity); } user.ZyhGxFiles = gxFilesEntities; user.ZnxMx = znxDAO.GetAllRsvZnx(user.UserInfo.user_id); return View(user); }