Exemplo n.º 1
0
 public int CommitFileSet(long id)
 {
     FileSetManDBDataContext context = new FileSetManDBDataContext();
     var fsets = from fs in context.FileSet where fs.ID == id select fs;
     foreach (FileSet fset in fsets)
     {
         fset.Ready = true;
     }
     context.SubmitChanges();
     ShareManDBDataContext sm = new ShareManDBDataContext();
     var tmp = from pro in sm.Progress where pro.FileSetID == id select pro;
     foreach (Progress pro in tmp)
     {
         pro.State = "已完成";
         pro.FinishDate = DateTime.Now;
     }
     sm.SubmitChanges();
     return 0;
 }
Exemplo n.º 2
0
 public long CreateFileSet(FileSet fset, bool needProgress)
 {
     FileSetManDBDataContext context = new FileSetManDBDataContext();
     context.FileSet.InsertOnSubmit(fset);
     context.SubmitChanges();
     /*
     if (needProgress)
     {
         ShareManDBDataContext sm = new ShareManDBDataContext();
         Progress p = new Progress();
         p.downloaded = 0;
         p.total = 0;
         p.FileSetID = fset.ID;
         p.State = "等待中";
         IPHostEntry ipHost = Dns.Resolve(Dns.GetHostName());
         IPAddress ipAddr = ipHost.AddressList[0];
         p.ServerIp = ipAddr.ToString();
         sm.Progress.InsertOnSubmit(p);
         sm.SubmitChanges();
     }
      * */
     return fset.ID;
 }
Exemplo n.º 3
0
        public void DeleteFileSet(long id)
        {
            FileSetManDBDataContext context = new FileSetManDBDataContext();
            var files = from f in context.File where f.FileSetID == id select f;
            foreach (File f in files)
            {
                context.File.DeleteOnSubmit(f);
            }
            var fsets = from fs in context.FileSet where fs.ID == id select fs;
            foreach (FileSet fset in fsets)
            {
                context.FileSet.DeleteOnSubmit(fset);
            }
            context.SubmitChanges();

            ShareManDBDataContext sm = new ShareManDBDataContext();
            var tmp = from pro in sm.Progress where pro.FileSetID == id select pro;
            foreach (Progress pro in tmp)
            {
                sm.Progress.DeleteOnSubmit(pro);
            }
            sm.SubmitChanges();
            return;
        }
Exemplo n.º 4
0
 public FileSet QureyFileSet(long id)
 {
     FileSetManDBDataContext context = new FileSetManDBDataContext();
     var fsets = from fs in context.FileSet where fs.ID == id select fs;
     foreach (FileSet fset in fsets)
     {
         return fset;
     }
     throw new Exception("无此文件集");
 }