Beispiel #1
0
 public long CommitMovie(
     BaseItem baseInfo,Movie movieInfo, FSM.FileSet fset,string srcIp)
 {
     ShareManDBDataContext context = new ShareManDBDataContext();
     try
     {
         context.Connection.Open();
         context.Transaction = context.Connection.BeginTransaction();
         movieInfo.ID = CommitBase(baseInfo, ref fset,srcIp,context);
         context.Movie.InsertOnSubmit(movieInfo);
         context.SubmitChanges();
         context.Transaction.Commit();
     }
     catch (System.Exception e)
     {
         context.Transaction.Rollback();
         throw e;
     }
     return baseInfo.ID;
 }
Beispiel #2
0
 partial void DeleteBaseItem(BaseItem instance);
Beispiel #3
0
 partial void UpdateBaseItem(BaseItem instance);
Beispiel #4
0
 partial void InsertBaseItem(BaseItem instance);
Beispiel #5
0
        private long CommitBase(BaseItem baseInfo, 
            ref FSM.FileSet fset,string srcIp,ShareManDBDataContext context)
        {
            // 插入基本信息
            baseInfo.Ext4 = fset.File.Length.ToString();
            context.BaseItem.InsertOnSubmit(baseInfo);
            context.SubmitChanges();
            // 插入审核信息
            Audit ad = new Audit
            {
                ID = baseInfo.ID,
                AuditDate = DateTime.Now,
                State = 0
            };
            context.Audit.InsertOnSubmit(ad);

            // 開始創建文件集
            FSM.FileSetMan src = new ShareMan.FSM.FileSetMan();
            QS.Queries qs = new ShareMan.QS.Queries();
            qs.Url ="http://localhost/QS/QueryService.asmx" ;

            // 查詢WebService服務地址
            src.Url = qs.QueryUrl(srcIp, QS.ServiceType.FileSetMan);
            FileSetLink fsSrc = new FileSetLink();
            //在源站点创建文件集
            fsSrc.FileSetID = src.CreateFileSet(fset,false);
            fsSrc.IP = srcIp;
            /*
             * 此处查询当前活动的中转服务器
             *
             * */
            FileSetLink fsInter = new FileSetLink();
            FSM.FileSetMan inter = new ShareMan.FSM.FileSetMan();

            // 在中转服务器上创建文件集信息
            fsInter.IP = qs.QueryActInterSrv();
            inter.Url = qs.QueryUrl(fsInter.IP, QS.ServiceType.FileSetMan);
            fsInter.FileSetID = inter.CreateFileSet(fset,true);
            // 创建文件集进度信息
            CreateProgress(baseInfo,srcIp,fsInter.IP,fsInter.FileSetID,"上传",context);

            // 查询中转服务器上创建的文件集信息,并保存,用于启动传输任务
            fset = inter.QureyFileSet(fsInter.FileSetID);

            // 准备传输文件集
            Trans fsrv = new Trans();
            fsrv.Url = qs.QueryUrl(qs.QueryActInterSrv(), QS.ServiceType.FileService);
            Position pos = new Position();
            pos.ip = srcIp;
            fsrv.Transform(Convert(fset),pos);
            fsrv.Start();
            // 提交更改
            context.FileSetLink.InsertOnSubmit(fsSrc);
            context.FileSetLink.InsertOnSubmit(fsInter);
            context.SubmitChanges();

            // 创建文件链接信息
            ItemLink iLink = new ItemLink();
            iLink.ID = baseInfo.ID;
            iLink.SrcLink = fsSrc.ID;
            iLink.InterLink = fsInter.ID;
            context.ItemLink.InsertOnSubmit(iLink);
            context.SubmitChanges();
            return baseInfo.ID;
        }
Beispiel #6
0
 public void UpdateVidioNews(BaseItem baseInfo,VidioNews vidioInfo)
 {
     ShareManDBDataContext context = new ShareManDBDataContext();
     try
     {
         context.Connection.Open();
         context.Transaction = context.Connection.BeginTransaction();
         UpdateBase(baseInfo, context);
         var vn = from b in context.VidioNews where b.ID == baseInfo.ID select b;
         foreach (VidioNews b in vn)
         {
             b.Context = vidioInfo.Context;
         }
         context.SubmitChanges();
         context.Transaction.Commit();
     }
     catch(Exception e)
     {
         context.Transaction.Rollback();
         throw e;
     }
 }
Beispiel #7
0
 public void UpdateMusic(BaseItem baseInfo,Music musicInfo)
 {
     ShareManDBDataContext context = new ShareManDBDataContext();
     try
     {
         context.Connection.Open();
         context.Transaction = context.Connection.BeginTransaction();
         UpdateBase(baseInfo,context);
         var mu = from b in context.Music where b.ID == baseInfo.ID select b;
         foreach (Music b in mu)
         {
             b.Author= musicInfo.Author;
             b.Singer = musicInfo.Singer;
         }
         context.SubmitChanges();
         context.Transaction.Commit();
     }
     catch
     {
         context.Transaction.Rollback();
     }
 }
Beispiel #8
0
 public void UpdateSoft(BaseItem baseInfo,Software softInfo)
 {
     ShareManDBDataContext context = new ShareManDBDataContext();
     try
     {
         context.Connection.Open();
         context.Transaction = context.Connection.BeginTransaction();
         UpdateBase(baseInfo, context);
         var mv = from b in context.Software where b.ID == baseInfo.ID select b;
         foreach (Software b in mv)
         {
             b.Manufacturer= softInfo.Manufacturer;
             b.Version = softInfo.Version;
         }
         context.SubmitChanges();
         context.Transaction.Commit();
     }
     catch(Exception e)
     {
         context.Transaction.Rollback();
         throw e;
     }
 }
Beispiel #9
0
 public void UpdateMovie(BaseItem baseInfo,Movie movieInfo)
 {
     ShareManDBDataContext context = new ShareManDBDataContext();
     try
     {
         context.Connection.Open();
         context.Transaction = context.Connection.BeginTransaction();
         UpdateBase(baseInfo, context);
         var mv = from b in context.Movie where b.ID == baseInfo.ID select b;
         foreach (Movie b in mv)
         {
             b.Player = movieInfo.Player;
             b.Director = movieInfo.Director;
         }
         context.SubmitChanges();
         context.Transaction.Commit();
     }
     catch(Exception e)
     {
         context.Transaction.Rollback();
         throw e;
     }
 }
Beispiel #10
0
 public void UpdateCartoon(BaseItem baseInfo,Cartoon cartoonInfo)
 {
     ShareManDBDataContext context = new ShareManDBDataContext();
     try
     {
         context.Connection.Open();
         context.Transaction = context.Connection.BeginTransaction();
         UpdateBase(baseInfo, context);
         var mv = from b in context.Cartoon where b.ID == baseInfo.ID select b;
         foreach (Cartoon b in mv)
         {
             b.Author = cartoonInfo.Author;
         }
         context.SubmitChanges();
         context.Transaction.Commit();
     }
     catch(Exception e)
     {
         context.Transaction.Rollback();
         throw e;
     }
 }
Beispiel #11
0
 public void UpdateBase(BaseItem baseInfo, ShareManDBDataContext context)
 {
     var bi = from b in context.BaseItem where b.ID == baseInfo.ID select b;
     foreach (BaseItem baseItem in bi)
     {
         baseItem.Ext1 = baseInfo.Ext1;
         baseItem.Ext2 = baseInfo.Ext2;
         baseItem.Ext3 = baseInfo.Ext3;
         baseItem.Ext4 = baseInfo.Ext4;
         baseItem.Ext5 = baseInfo.Ext5;
         baseItem.Ext6 = baseInfo.Ext6;
         baseItem.Ext7 = baseInfo.Ext7;
         baseItem.Ext8 = baseInfo.Ext8;
         baseItem.PublishType = baseInfo.PublishType;
         baseItem.Brief = baseInfo.Brief;
         baseItem.IssueDate = baseInfo.IssueDate;
     }
     context.SubmitChanges();
 }
Beispiel #12
0
 private void CreateProgress(BaseItem baseInfo, 
                 string srcIp, 
                 string dstIp, 
                 long fsIdOnDst, 
                 string extInfo,
                 ShareManDBDataContext context)
 {
     Progress progress = new Progress();
     progress.DstIp = dstIp;
     progress.SrcIp = srcIp;
     progress.FileSetID = fsIdOnDst;
     progress.CmmitDate = baseInfo.Birth;
     progress.downloaded = 0;
     progress.total = 0;
     //progress.AuditMan = auditMan;
     progress.State = "等待中";
     progress.ItemId = baseInfo.ID;
     progress.Title = baseInfo.Title;
     progress.Owner = baseInfo.Owner;
     switch(baseInfo.Category)
     {
         case 1:
             progress.Category = "电影";
             break;
         case 2:
             progress.Category = "音乐";
             break;
         case 3:
             progress.Category = "软件";
             break;
         case 4:
             progress.Category = "动漫";
             break;
     }
     progress.Ext1 = extInfo;
     context.Progress.InsertOnSubmit(progress);
     context.SubmitChanges();
 }
Beispiel #13
0
 private SB.BaseItem Convert(BaseItem baseItem)
 {
     SB.BaseItem sbbi = new ShareMan.SB.BaseItem
     {
         ID = baseItem.ID,
         IssueDate = baseItem.IssueDate,
         Owner = baseItem.Owner,
         Title = baseItem.Title,
         PublishType = baseItem.PublishType,
         Birth = baseItem.Birth,
         Brief = baseItem.Brief,
         BrowseCount = 0,
         Category = baseItem.Category,
         Ext1 = baseItem.Ext1,
         Ext2 = baseItem.Ext2,
         Ext3 = baseItem.Ext3,
         Ext4 = baseItem.Ext4,
         Ext5 = baseItem.Ext5,
         Ext6 = baseItem.Ext6,
         Ext7 = baseItem.Ext7,
         Ext8 = baseItem.Ext8,
     };
     return sbbi;
 }