Beispiel #1
0
        /// <summary>
        /// 创建新的 Fold 对象。
        /// </summary>
        /// <param name="id">Id 属性的初始值。</param>
        /// <param name="userId">UserId 属性的初始值。</param>
        public static Fold CreateFold(global::System.Int32 id, global::System.Int32 userId)
        {
            Fold fold = new Fold();

            fold.Id     = id;
            fold.UserId = userId;
            return(fold);
        }
Beispiel #2
0
 /// <summary>
 /// 增加一个fold
 /// </summary>
 /// <param name="fold"></param>
 /// <returns></returns>
 public int addFold(Fold fold)
 {
     using (FoldDBEntities ef = new FoldDBEntities())
     {
         ef.Fold.AddObject(fold);
         int resuit = ef.SaveChanges();
         if (resuit > 0)
         {
             return(fold.Id);
         }
         else
         {
             return(0);
         }
     }
 }
Beispiel #3
0
        protected void btnUP_Click(object sender, EventArgs e)
        {
            string fileName = "";
            string savePath = "/UserFold/";

            if (this.fileUP.HasFile)
            {
                HttpPostedFile file = this.fileUP.PostedFile;
                fileName = file.FileName;
                string extension = Path.GetExtension(fileName).ToLower();
                if (extension == ".jpg" || extension == ".gif" || extension == ".doc" || extension == ".docx")
                {
                    if (!Directory.Exists(Server.MapPath(savePath)))
                    {
                        Directory.CreateDirectory(Server.MapPath(savePath));
                    }
                    if (File.Exists(Server.MapPath(savePath + fileName)))
                    {
                        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('已经存在相同的文件')</script>");
                        return;
                    }
                    this.fileUP.SaveAs(Server.MapPath(savePath + fileName));
                }

                try
                {///第一次插入数据
                    Fold modelFold = new Fold();
                    modelFold.Depth = 0;
                    //modelFold.FatherId //第一层fatherId没有值
                    modelFold.FoldName = savePath;
                    modelFold.UserId   = 1;
                    int id = bs.addFold(modelFold);
                    if (id > 0)
                    {
                        file modelfile = new file();
                        modelfile.fileName = fileName;
                        modelfile.filePath = savePath + fileName;
                        modelfile.FoldId   = id;
                        bs.addFile(modelfile);
                    }
                } catch (Exception ex)
                {
                }
            }
        }
Beispiel #4
0
 /// <summary>
 /// 用于向 Fold EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToFold(Fold fold)
 {
     base.AddObject("Fold", fold);
 }