Esempio n. 1
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", "", "{}")));
            }
        }
Esempio n. 2
0
        public int AddRecycle(Jw_recycle jr)
        {
            string sql = _cb.InsertModel <Jw_recycle>(jr);

            return(db.ExecuteNonQuery(sql));
        }
Esempio n. 3
0
 public int AddMycycle(Jw_recycle jr, Jw_share_file jsf)
 {
     UpdateShareFileStatus(jsf);
     return(ins.AddRecycle(jr));
 }