Exemplo n.º 1
0
        public ActionResult picture()
        {
            HttpCookie cookie = StorageHelper.Cookie.GetCookie("User");

            if (cookie != null)
            {
                string           schoolid = StorageHelper.Cookie.GetCookieValue("User", "sguid");//通过cookie获取
                string           uid      = StorageHelper.Cookie.GetCookieValue("User", "uguid");
                List <Role_User> list1    = sharebll.GetUser(schoolid, uid);
                ViewData["list"] = list1;
            }
            else
            {
                Response.Redirect(ConfigHelper.GetConfigString("out"));
            }
            FileOpe       f      = new FileOpe();
            List <FileOp> list   = f.Category("1");
            var           l      = list.GroupBy(s => s.Date.Split(' ')[0]);
            var           result = l.Select(x => new DateFiles
            {
                Date = x.Key,
                List = x.ToList()
            }).OrderByDescending(x => x.Date);

            ViewData["imagelist"] = result.ToList();
            return(View());
        }
Exemplo n.º 2
0
        //还原
        public ActionResult Reduction(string id)
        {
            //HttpCookie cookie = StorageHelper.Cookie.GetCookie("UserInfo");
            Utilities.ConvertJson c = new Utilities.ConvertJson();

            JavaScriptSerializer jss  = new JavaScriptSerializer();
            List <string>        list = jss.Deserialize <List <string> >(id);

            try
            {
                foreach (var item in list)
                {
                    DataTable dt = sharebll.GetRecycleByid(item);
                    //通过cookie获取
                    FileOpe fo    = new FileOpe();
                    bool    isSuc = fo.MoveFile(AppDomain.CurrentDomain.BaseDirectory + "/Recycle/" + StorageHelper.Cookie.GetCookieValue("User", "uguid") + "/" + dt.Rows[0]["jw_virtualname"].ToString(), AppDomain.CurrentDomain.BaseDirectory + dt.Rows[0]["jw_sourcepath"].ToString());
                    sharebll.DelRecycleByid(item);
                    sharebll.UpdateShareFileStatus(new Jw_share_file {
                        Jw_filepath = dt.Rows[0]["jw_sourcepath"].ToString(), Jw_filestatus = 0
                    });
                }
                return(Content(c.ToJson("200", "", "{}")));
            }
            catch (Exception)
            {
                return(Content(c.ToJson("0", "", "{}")));
            }
        }
Exemplo n.º 3
0
        public ActionResult DeleteUp()
        {
            FileOpe.DeleteFolder(AppDomain.CurrentDomain.BaseDirectory + "\\upload");
            Utilities.ConvertJson c = new Utilities.ConvertJson();
            string a = c.ToJson("200", "", "{}");

            return(Content(a));
        }
Exemplo n.º 4
0
        //回收站
        public ActionResult Recycle(string path)
        {
            //HttpCookie cookie = StorageHelper.Cookie.GetCookie("UserInfo");
            Utilities.ConvertJson c    = new Utilities.ConvertJson();
            JavaScriptSerializer  jss  = new JavaScriptSerializer();
            List <string>         list = jss.Deserialize <List <string> >(path);

            try
            {
                foreach (var item in list)
                {
                    Jw_recycle jr = new Jw_recycle();
                    jr.Jw_recycleid  = Guid.NewGuid().ToString("N");
                    jr.Jw_userid     = StorageHelper.Cookie.GetCookieValue("User", "uguid");//通过cookie获取
                    jr.Jw_sourcePath = item;
                    string p = AppDomain.CurrentDomain.BaseDirectory + item;
                    if (System.IO.File.Exists(p))
                    {
                        FileInfo fi = new FileInfo(p);
                        jr.Jw_realName    = fi.Name;
                        jr.Jw_type        = fi.Extension.Substring(1);
                        jr.Jw_size        = global::Commonn.FileOperate.GetFileSize(fi.Length);
                        jr.Jw_virtualName = DateTime.Now.ToString("yyyyMMddhhmmssfffff") + fi.Extension;
                    }
                    if (Directory.Exists(p))
                    {
                        DirectoryInfo di = new DirectoryInfo(p);
                        jr.Jw_realName    = di.Name;
                        jr.Jw_type        = "1";
                        jr.Jw_size        = "--";
                        jr.Jw_virtualName = DateTime.Now.ToString("yyyyMMddhhmmssfffff");
                    }

                    jr.Jw_delTime = DateTime.Now;
                    jr.Jw_delflag = 0;
                    Jw_share_file jsf = new Jw_share_file();
                    if (sharebll.AddMycycle(jr, new Jw_share_file {
                        Jw_filepath = item, Jw_filestatus = 1
                    }) > 0)
                    {
                        FileOpe fo = new FileOpe();
                        string  recycleFilePath = AppDomain.CurrentDomain.BaseDirectory + "/Recycle/" + StorageHelper.Cookie.GetCookieValue("User", "uguid");
                        if (!Directory.Exists(recycleFilePath))
                        {
                            Directory.CreateDirectory(recycleFilePath);
                        }
                        fo.MoveFile(AppDomain.CurrentDomain.BaseDirectory + item, AppDomain.CurrentDomain.BaseDirectory + "/Recycle/" + StorageHelper.Cookie.GetCookieValue("User", "uguid") + "/" + jr.Jw_virtualName);
                    }
                }
                return(Content(c.ToJson("200", "", "{}")));
            }
            catch (Exception ex)
            {
                new DBHelper().Log(ex.ToString());
                return(Content(c.ToJson("0", "", "{}")));
            }
        }
Exemplo n.º 5
0
        //获取分享文件
        public ActionResult GetMyShare(string path, string type, string category, string shareid, string username, string date)
        {
            HttpCookie cookie = StorageHelper.Cookie.GetCookie("User");
            string     userid = StorageHelper.Cookie.GetCookieValue("User", "uguid");//通过cookie获取;//从cookie中取

            Utilities.ConvertJson c = new Utilities.ConvertJson();
            if (string.IsNullOrEmpty(path))
            {
                List <FileOp> list = new List <FileOp>();
                if (string.IsNullOrEmpty(category))
                {
                    list = sharebll.MyShare(userid);
                }
                else
                {
                    list = sharebll.MyReceive(userid);
                }

                string data = JsonConvert.SerializeObject(list);

                string a = c.ToJson("0", "", data, list.Count.ToString());
                return(Content(a));
            }
            else
            {
                FileOpe fo = new FileOpe();

                if (type == "3")
                {
                    //JavaScriptSerializer jss = new JavaScriptSerializer();
                    //List<string> paths = jss.Deserialize<List<string>>(path);
                    List <string> paths = sharebll.GetFilepathByShareid(shareid);
                    List <FileOp> list  = fo.GetFilesByPath(paths, username, date);

                    string data = JsonConvert.SerializeObject(list);

                    string a = c.ToJson("0", "", data, list.Count.ToString());
                    return(Content(a));
                }
                else if (type == "1")
                {
                    List <FileOp> list = fo.GetFileByPath(path, username, date);

                    string data = JsonConvert.SerializeObject(list);

                    string a = c.ToJson("0", "", data, list.Count.ToString());
                    return(Content(a));
                }
                else
                {
                    return(new EmptyResult());
                }
            }
        }
Exemplo n.º 6
0
        public ActionResult NewFile(string path)
        {
            FileOpe f = new FileOpe();

            Utilities.ConvertJson c = new Utilities.ConvertJson();
            if (f.NewFile(path))
            {
                return(Content(c.ToJson("0", "", "{}")));
            }
            return(Content(c.ToJson("250", "", "{}")));
        }
Exemplo n.º 7
0
 //清空
 public ActionResult empty()
 {
     //HttpCookie cookie = StorageHelper.Cookie.GetCookie("UserInfo");
     Utilities.ConvertJson c = new Utilities.ConvertJson();
     if (sharebll.DelRecycleAll(StorageHelper.Cookie.GetCookieValue("User", "uguid")) > 0)
     {
         FileOpe fo = new FileOpe();
         fo.DelFile(AppDomain.CurrentDomain.BaseDirectory + "/recycle/" + StorageHelper.Cookie.GetCookieValue("User", "uguid"));
         return(Content(c.ToJson("200", "", "{}")));
     }
     return(Content(c.ToJson("0", "", "{}")));
 }
Exemplo n.º 8
0
        public ActionResult pageOne(string path, string type, string search, string token)
        {
            HttpCookie cookie = StorageHelper.Cookie.GetCookie("User");

            if (cookie != null)
            {
                string           schoolid = StorageHelper.Cookie.GetCookieValue("User", "sguid");//通过cookie获取
                string           uid      = StorageHelper.Cookie.GetCookieValue("User", "uguid");
                List <Role_User> list1    = sharebll.GetUser(schoolid, uid);
                ViewData["list"] = list1;
            }
            else
            {
                Response.Redirect(ConfigHelper.GetConfigString("out"));
            }
            if (String.IsNullOrEmpty(path))
            {
                path = "/File/" + StorageHelper.Cookie.GetCookieValue("User", "uguid");//通过cookie获取
                //path = "/File/123456";//通过cookie获取
            }
            FileOpe f = new FileOpe();

            f.Token = token;
            List <FileOp> list = f.GetFileName(path);

            ViewBag.filecount = list.Count;
            ViewBag.filepath  = path;
            string[]       paths = path.Replace("//", "/").Split('/');
            List <FileInA> l     = new List <FileInA>();

            for (int i = 3; i < paths.Length; i++)
            {
                FileInA fia = new FileInA();
                string  tp  = "";
                for (int j = 0; j <= i; j++)
                {
                    tp += paths[j] + "/";
                }
                tp          = tp.Substring(0, tp.Length - 1);
                fia.Address = tp;
                fia.Name    = paths[i];
                l.Add(fia);
            }
            ViewBag.remindPath = l;
            ViewBag.type       = type;
            ViewBag.token      = token;
            //DoAspose doAspose = new DoAspose();
            //bool b = doAspose.Excel2Pdf(@"C:\Users\admin\Desktop\ri_usersl0913.xlsx", @"C:\Users\admin\Desktop\aa.pdf", Response);
            return(View());
        }
Exemplo n.º 9
0
        //删除文件
        public ActionResult DelFile(string path)
        {
            Utilities.ConvertJson c = new Utilities.ConvertJson();
            if (string.IsNullOrEmpty(path))
            {
                return(Content(c.ToJson("00000", "请求错误", "{}")));
            }
            FileOpe fo = new FileOpe();

            if (fo.DelFile(AppDomain.CurrentDomain.BaseDirectory + "Download" + path.Split(new string[] { "Download" }, StringSplitOptions.None)[1]))
            {
                return(Content(c.ToJson("200", "", "{}")));
            }
            return(Content(c.ToJson("00000", "请求错误", "{}")));
        }
Exemplo n.º 10
0
        //重命名
        public ActionResult Rename(string orignFile, string newFile)
        {
            Utilities.ConvertJson c = new Utilities.ConvertJson();
            FileOpe fo         = new FileOpe();
            string  nf         = orignFile.Substring(0, orignFile.LastIndexOf('/')) + "/" + newFile;
            string  orignFileP = AppDomain.CurrentDomain.BaseDirectory + orignFile;
            string  newFileP   = AppDomain.CurrentDomain.BaseDirectory + nf;

            if (fo.MoveFile(orignFileP, newFileP))
            {
                sharebll.UpdateShareFilePath(new Jw_share_file {
                    Jw_filepath = orignFile
                }, nf);
                return(Content(c.ToJson("200", "", "{}")));
            }
            return(Content(c.ToJson("0", "当文件已存在时,无法创建该文件", "{}")));
        }
Exemplo n.º 11
0
        public ActionResult GetFile(string path, string type, string search, string start, string end, string ftype, string token, string field, string order)
        {
            HttpCookie cookie = StorageHelper.Cookie.GetCookie("User");

            if (String.IsNullOrEmpty(path))
            {
                path = "/File/" + StorageHelper.Cookie.GetCookieValue("User", "uguid");//通过cookie获取
                //path = "/File/1234567";//通过cookie获取
            }
            FileOpe f = new FileOpe();

            f.Token = token;
            if (string.IsNullOrEmpty(f.Token))
            {
                f.Token = Utilities.Encryption.DESEnCode(StorageHelper.Cookie.GetCookieValue("User", "uguid") + "|" + DateTime.Now.ToFileTimeUtc(), Utilities.Encryption.DESKey);
            }
            List <FileOp> list = null;

            if (!string.IsNullOrEmpty(type))
            {
                list = f.Category(type);
            }
            else if (!string.IsNullOrEmpty(search) || !string.IsNullOrEmpty(start) || !string.IsNullOrEmpty(end) || !string.IsNullOrEmpty(ftype))
            {
                list = f.Search(search, start, end, ftype);
            }
            else
            {
                list = f.GetFileName(path);
            }
            if (!string.IsNullOrEmpty(field))
            {
                string myorder = order == "" ? "asc" : order;
                if (myorder == "asc")
                {
                    if (field == "Size")
                    {
                        list = list.OrderBy((fo) => fo.Ysize).ToList();
                    }
                    if (field == "Name")
                    {
                        list = list.OrderBy((fo) => fo.Name).ToList();
                    }
                    if (field == "Date")
                    {
                        list = list.OrderBy((fo) => fo.Date).ToList();
                    }
                }
                else
                {
                    if (field == "Size")
                    {
                        list = list.OrderByDescending(fo => fo.Ysize).ToList();
                    }
                    if (field == "Name")
                    {
                        list = list.OrderByDescending(fo => fo.Name).ToList();
                    }
                    if (field == "Date")
                    {
                        list = list.OrderByDescending(fo => fo.Date).ToList();
                    }
                }
            }
            string data = JsonConvert.SerializeObject(list);

            Utilities.ConvertJson c = new Utilities.ConvertJson();
            string a = c.ToJson("0", "", data, list.Count.ToString());

            return(Content(a));
        }