Ejemplo n.º 1
0
        //获取公告通知
        public ActionResult GetNotice()
        {
            int userID = LoginUser.ID;
            var temp   = ShareFileOrNoticeService.LoadEntities(x => x.ID > 0).DefaultIfEmpty().ToList();
            List <ShareFileOrNotice> sfon = new List <ShareFileOrNotice>();

            if (temp[0] != null)
            {
                foreach (var a in temp)
                {
                    if (a.TypeID == 2)
                    {
                        if (a.ShareUser == userID)
                        {
                            sfon.Add(a);
                            continue;
                        }
                        else
                        {
                            Array ay = (a.ShareToUser).Split(',');
                            foreach (var b in ay)
                            {
                                if (b.Equals(""))
                                {
                                    continue;
                                }
                                else
                                {
                                    int c = Convert.ToInt32(b);
                                    if (c == userID)
                                    {
                                        sfon.Add(a);
                                        break;
                                    }
                                    else
                                    {
                                        continue;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        continue;
                    }
                }
                var Rtmp = from d in sfon
                           select new
                {
                    ID           = d.ID,
                    TypeID       = d.ShareType.Name,
                    NoticeText   = d.BeiZhu,
                    UpNoticeTime = d.UploadFileTime,
                    NoticeUser   = d.UserInfo.PerSonName
                };
                return(Json(Rtmp, JsonRequestBehavior.AllowGet));
            }
            return(Json(null, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        //获取通知全部内容
        public ActionResult GetNoticeAllText()
        {
            int    id     = Convert.ToInt32(Request["id"]);
            var    temp   = ShareFileOrNoticeService.LoadEntities(x => x.ID == id).FirstOrDefault();
            string beizhu = temp.BeiZhu;

            return(Json(beizhu, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
        //获取文件下载路径
        public ActionResult GetFileUrl()
        {
            var id     = Convert.ToInt32(Request["id"]);
            var temp   = ShareFileOrNoticeService.LoadEntities(x => x.ID == id).FirstOrDefault();
            var url    = temp.FileURL;
            var beizhu = temp.BeiZhu;

            return(Json(new { ret = url, sbeizhu = beizhu }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 4
0
        public ActionResult getNewFileInfo()
        {
            var      temp = ShareFileOrNoticeService.LoadEntities(x => x.ShareUser == LoginUser.ID).DefaultIfEmpty().OrderByDescending(x => x.UploadFileTime).ToList();
            STUBuMen sm   = new STUBuMen();

            sm.ID   = temp[0].ID;
            sm.Name = temp[0].ShareToUser;
            return(Json(sm, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 5
0
        //补充上传共享文件
        public ActionResult AddUploadFile()
        {
            var sfid  = Convert.ToInt64(Request["sfid"]);
            var sfurl = Request["sfurl"];
            var temp  = ShareFileOrNoticeService.LoadEntities(x => x.ID == sfid).FirstOrDefault();

            if (temp != null)
            {
                temp.FileURL += "," + sfurl;
            }
            ShareFileOrNoticeService.EditEntity(temp);
            return(Json(new { ret = "ok" }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 6
0
        //获取用户模板
        public ActionResult GetModels()
        {
            var uid  = LoginUser.ID;
            var temp = ShareFileOrNoticeService.LoadEntities(x => x.ShareUser == uid && (x.ModelList != null || x.ModelList != "")).DefaultIfEmpty().ToList();

            if (temp[0] == null)
            {
                return(Json(new { ret = "no" }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { ret = "ok" }, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 7
0
        //删除共享文件
        public ActionResult DelShareFile()
        {
            var uid  = LoginUser.ID;
            var id   = Convert.ToInt32(Request["id"]);
            var temp = ShareFileOrNoticeService.LoadEntities(x => x.ID == id).FirstOrDefault();

            if (temp == null)
            {
                return(Json(new { msg = "数据库中无要修改的信息!" }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                if (temp.ShareUser == uid)
                {
                    if (ShareFileOrNoticeService.DeleteEntity(temp))
                    {
                        int type = temp.TypeID;
                        if (type == 1)
                        {
                            string[] str  = temp.FileURL.Split(',');
                            var      list = str.ToList();
                            if (list != null)
                            {
                                foreach (var a in list)
                                {
                                    if (a != "")
                                    {
                                        if (Directory.Exists(Path.GetDirectoryName(Request.MapPath(a))))
                                        {
                                            System.IO.File.Delete(Request.MapPath(a));
                                        }
                                    }
                                }
                            }
                        }
                        return(Json(new { ret = "ok" }, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        return(Json(new { msg = "操作错误,没有删除成功!" }, JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    return(Json(new { msg = "操作错误,你没有权限删除此信息!" }, JsonRequestBehavior.AllowGet));
                }
            }
        }
Ejemplo n.º 8
0
        //查询是否有权补充文件
        public ActionResult GetCanOrCant()
        {
            var id   = Convert.ToInt64(Request["id"]);
            var temp = ShareFileOrNoticeService.LoadEntities(x => x.ID == id).FirstOrDefault();

            if (temp != null)
            {
                if (temp.ShareUser != LoginUser.ID)
                {
                    return(Json(new { ret = "no" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { ret = "ok" }, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 9
0
        //获取共享文件
        public ActionResult GetShareFile()
        {
            int userID    = LoginUser.ID;
            var temp      = ShareFileOrNoticeService.LoadEntities(x => x.ID > 0).DefaultIfEmpty().ToList();
            int pageIndex = Request["page"] != null?int.Parse(Request["page"]) : 1;

            int pageSize = Request["rows"] != null?int.Parse(Request["rows"]) : 25;

            int TotalCount = 0;
            List <ShareFileOrNotice> sfon = new List <ShareFileOrNotice>();

            if (temp[0] != null)
            {
                #region MyRegion
                foreach (var a in temp)
                {
                    if (a.TypeID == 1)
                    {
                        if (a.ShareUser == userID)
                        {
                            sfon.Add(a);
                            continue;
                        }
                        else
                        {
                            Array ay = (a.ShareToUser).Split(',');
                            foreach (var b in ay)
                            {
                                if (b.Equals(""))
                                {
                                    continue;
                                }
                                else
                                {
                                    int c = Convert.ToInt32(b);
                                    if (c == userID)
                                    {
                                        sfon.Add(a);
                                        break;
                                    }
                                    else
                                    {
                                        continue;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        continue;
                    }
                }
                #endregion

                var iemsfon = sfon.OrderByDescending <ShareFileOrNotice, DateTime?>(u => u.UploadFileTime).Skip <ShareFileOrNotice>((pageIndex - 1) * pageSize).Take <ShareFileOrNotice>(pageSize);
                sfon = iemsfon.ToList();
                List <Sfob> rtsfob = new List <Sfob>();
                foreach (var Sf in sfon)
                {
                    Sfob s = new Sfob();
                    s.ID             = Sf.ID;
                    s.ShareType      = Sf.ShareType;
                    s.FileType       = Sf.FileType;
                    s.BeiZhu         = Sf.BeiZhu;
                    s.FileURL        = Sf.FileURL;
                    s.UploadFileTime = Sf.UploadFileTime;
                    s.UserInfo       = Sf.UserInfo;
                    s.ShareToUser    = Sf.ShareToUser;

                    string eyy   = Sf.ShareToUser;
                    var    usp   = eyy.Split(',');
                    string lname = string.Empty;
                    foreach (var u in usp)
                    {
                        if (u.Length <= 0)
                        {
                            continue;
                        }
                        int uid = Convert.ToInt32(u);
                        lname = lname + UserInfoService.LoadEntities(x => x.ID == uid).FirstOrDefault().PerSonName + ",";
                    }
                    s.alluserinfo = lname;
                    rtsfob.Add(s);
                }

                var Rtmp = from d in rtsfob
                           select new
                {
                    ID             = d.ID,
                    TypeID         = d.ShareType.Name,
                    FileTypeID     = d.FileType.FileTypeCHNName,
                    BeiZhu         = d.BeiZhu,
                    FileURL        = d.FileURL,
                    UploadFileTime = d.UploadFileTime,
                    ShareUser      = d.UserInfo.PerSonName,
                    Sunv           = d.ShareToUser,
                    alluserinfo    = d.alluserinfo,
                    AddFile        = d.UserInfo.ID,
                    shareuserid    = LoginUser.ID
                };


                return(Json(new { rows = Rtmp, total = TotalCount }, JsonRequestBehavior.AllowGet));
            }
            return(Json(null, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 10
0
        //获取当前用户所有模型
        public ActionResult GetAllModel()
        {
            var            uid  = LoginUser.ID;
            var            temp = ShareFileOrNoticeService.LoadEntities(x => x.ShareUser == uid && x.TypeID == 1).DefaultIfEmpty().ToList();
            List <ModelSF> list = new List <ModelSF>();

            if (temp.Count != 0 && temp[0] != null)
            {
                foreach (var a in temp)
                {
                    if (list.Count != 0)
                    {
                        int g = 0;
                        if (a == null || a.ModelList == "")
                        {
                            continue;
                        }
                        for (int i = 0; i < list.Count; i++)
                        {
                            if (list[i] == null)
                            {
                                continue;
                            }
                            if (a.ModelList == list[i].StrID)
                            {
                                g = 1;
                            }
                        }
                        if (g == 1)
                        {
                            continue;
                        }
                        ModelSF msf = new ModelSF();
                        msf.StrID = a.ModelList;
                        var str  = (a.ModelList).Split(',');
                        var strs = "";
                        foreach (var c in str)
                        {
                            if (c == "")
                            {
                                continue;
                            }
                            var b1 = Convert.ToInt32(c);
                            var u  = UserInfoService.LoadEntities(x => x.ID == b1).FirstOrDefault();
                            strs = strs + u.PerSonName + ",";
                        }
                        msf.StrName = strs;
                        list.Add(msf);
                    }
                    else
                    {
                        if (a == null || a.ModelList == "")
                        {
                            continue;
                        }
                        ModelSF msf = new ModelSF();
                        msf.StrID = a.ModelList;
                        var str  = (a.ModelList).Split(',');
                        var strs = "";
                        foreach (var b in str)
                        {
                            if (b == "")
                            {
                                continue;
                            }
                            var b1 = Convert.ToInt32(b);
                            var u  = UserInfoService.LoadEntities(x => x.ID == b1).FirstOrDefault();
                            strs = strs + u.PerSonName + ",";
                        }
                        msf.StrName = strs;
                        list.Add(msf);
                    }
                }
                return(Json(list, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }
        }