Exemplo n.º 1
0
 /// <summary>
 /// 好友分组
 /// </summary>
 /// <param name="groupName"></param>
 /// <param name="userId"></param>
 /// <returns></returns>
 public ArgsHelp AddNewGroup(string groupName,int userId)
 {
     ArgsHelp ah = new ArgsHelp();
     try
     {
         var group = new hygl_group
         {
             group_name = groupName,
             user_id = userId,
             group_cjsj = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")
         };
         friendGroupDB.hygl_group.InsertOnSubmit(group);
         friendGroupDB.SubmitChanges();
     }
     catch (Exception e)
     {
         ah.flag = false;
         ah.msg = e.Message;
     }
     return ah;
 }
        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);
        }
 partial void Deletehygl_group(hygl_group instance);
 partial void Updatehygl_group(hygl_group instance);
 partial void Inserthygl_group(hygl_group instance);