Exemplo n.º 1
0
 public void Audit(long id, int rst,string reson, string audiMan)
 {
     ShareManDBDataContext context = new ShareManDBDataContext();
     try
     {
         context.Connection.Open();
         context.Transaction = context.Connection.BeginTransaction();
         var tmp = from a in context.Audit where a.ID == id select a;
         foreach (Audit au in tmp)
         {
             if(!string.IsNullOrEmpty(reson))
                 au.Reason = reson;
             au.State = rst;
             if(!string.IsNullOrEmpty(audiMan))
                 au.AuditOwner = audiMan;
             au.AuditDate = DateTime.Now;
         }
         context.SubmitChanges();
         context.Transaction.Commit();
     }
     catch (System.Exception e)
     {
         context.Transaction.Rollback();
         throw e;
     }
 }
Exemplo n.º 2
0
        public void CleanInfos(long id, ShareManDBDataContext context)
        {
            Audit tmp = context.Audit.First(c => c.ID == id);
            context.Audit.DeleteOnSubmit(tmp);

            var tmp3 = context.BaseItem.First(c => c.ID == id);
            context.BaseItem.DeleteOnSubmit(tmp3);
        }
Exemplo n.º 3
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;
 }
Exemplo n.º 4
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;
     }
 }
Exemplo n.º 5
0
 public void UpdateFileSet(long id, FSM.FileSet fs,string srcIp)
 {
     QS.Queries qs = new QS.Queries();
     // 停止中转服务器文件传输
     StopTrans(qs.QueryActInterSrv());
     // 删除中转服务器上相关文件
     //DeleteFiles(fs.ID,qs.QueryActInterSrv());
     // 清除服务器上的文件集信息
     ShareManDBDataContext context = new ShareManDBDataContext();
     try
     {
         context.Connection.Open();
         context.Transaction = context.Connection.BeginTransaction();
         DeleteFileSet(id,context);
         FSM.FileSet tmp = CreateFileSet(id, fs, srcIp, context);
         TransFileSet("",srcIp,tmp);
     }
     catch (System.Exception e)
     {
         context.Transaction.Rollback();
         throw e;
     }
 }
Exemplo n.º 6
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;
     }
 }
Exemplo n.º 7
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();
 }
Exemplo n.º 8
0
        public FSM.FileSet CreateFileSet(long id, FSM.FileSet fset, string srcIp,ShareManDBDataContext context)
        {
            // 開始創建文件集
            FSM.FileSetMan fsm = new ShareMan.FSM.FileSetMan();
            QS.Queries qs = new ShareMan.QS.Queries();
            //            qs.Url = "http://localhost/QS/QueryService.asmx";

            // 查詢WebService服務地址
            fsm.Url = qs.QueryUrl(srcIp, QS.ServiceType.FileSetMan);
            FileSetLink fsSrc = new FileSetLink();

            //在源站点创建文件集
            fsSrc.FileSetID = fsm.CreateFileSet(fset, true);
            fsSrc.IP = srcIp;

            FileSetLink fsInter = new FileSetLink();
            // 在中转服务器上创建文件集信息
            fsm.Url = qs.QueryUrl("", QS.ServiceType.InterServer);
            fsInter.FileSetID = fsm.CreateFileSet(fset,true);
            // 查询中转服务器上创建的文件集信息,并保存,用于启动传输任务
            return fsm.QureyFileSet(fsInter.FileSetID);
            //fsInter.IP = "";
        }
Exemplo n.º 9
0
 private void Audit(long id, int rst)
 {
     ShareManDBDataContext context = new ShareManDBDataContext();
     try
     {
         context.Connection.Open();
         context.Transaction = context.Connection.BeginTransaction();
         var tmp = from a in context.Audit where a.ID == id select a;
         foreach (Audit au in tmp)
         {
             au.State = rst;
             au.AuditDate = DateTime.Now;
         }
         context.SubmitChanges();
         context.Transaction.Commit();
     }
     catch (System.Exception e)
     {
         context.Transaction.Rollback();
         throw e;
     }
 }
Exemplo n.º 10
0
 public FSM.FileSet QueryFileSetOnSrc(long id)
 {
     ShareManDBDataContext context = new ShareManDBDataContext();
     var itemLink = from i in context.ItemLink where i.ID == id select i;
     foreach (ItemLink il in itemLink)
     {
         var fsl = from f in context.FileSetLink where f.ID == il.SrcLink select f;
         foreach (FileSetLink sl in fsl)
         {
             FSM.FileSetMan fsm = new ShareMan.FSM.FileSetMan();
             QS.Queries qs = new ShareMan.QS.Queries();
             fsm.Url = qs.QueryUrl(sl.IP, QS.ServiceType.FileSetMan);
             return fsm.QureyFileSet(sl.FileSetID);
         }
     }
     return null;
 }
Exemplo n.º 11
0
        public void PublishVidioNews(long id,string [] dst)
        {
            ShareManDBDataContext context = new ShareManDBDataContext();
            try
            {
                context.Connection.Open();
                context.Transaction = context.Connection.BeginTransaction();
                // 查找相关文件链接
                ItemLink il = context.ItemLink.First(c => c.ID == id);
                FileSetLink fsl = context.FileSetLink.First(c => c.ID == il.InterLink);
                // 查询文件集信息
                FSM.FileSetMan fsm = new ShareMan.FSM.FileSetMan();
                QS.Queries qs = new ShareMan.QS.Queries();
                // 中转服务器ip
                string actIp = qs.QueryActInterSrv();

                fsm.Url = qs.QueryUrl(qs.QueryActInterSrv(), QS.ServiceType.FileSetMan);
                FSM.FileSet fs = fsm.QureyFileSet(fsl.FileSetID);
                // 发布
                foreach (string subCode in dst)
                {
                    string ip = qs.QuerySrvIp(subCode);
                    fsm.Url = qs.QueryUrl(ip, QS.ServiceType.FileSetMan);
                    long fsid = fsm.CreateFileSet(fs, true);
                    FSM.FileSet tmpFs = fsm.QureyFileSet(fsid);

                    // 查询基本信息
                    BaseItem baseItem = context.BaseItem.First(c => c.ID == id);
                    // 查询电影信息
                    VidioNews vnInfo = context.VidioNews.First(c => c.ID == id);

                    PublishType pubType = context.PublishType.First(c => c.ID == baseItem.PublishType);
                    SB.ShareBrowse sb = new SB.ShareBrowse();
                    string url = qs.QueryUrl(ip, QS.ServiceType.ShareBrowse);
                    sb.Url = url;
                    sb.PublishVidioNews(this.Convert(baseItem), this.Convert(vnInfo), this.Convert(pubType), fsid);
                    CreateProgress(baseItem, actIp, ip, fsid, "发布", context);
                    TransFileSet(actIp, ip, tmpFs);
                    Distribute trbut = new Distribute
                    {
                        SubCode = subCode,
                        ItemID = id
                    };
                    context.Distribute.InsertOnSubmit(trbut);
                    context.SubmitChanges();
                    Audit(id, 2);
                    context.Transaction.Commit();
                }
            }
            catch (System.Exception e)
            {
                context.Transaction.Rollback();
                throw e;
            }
        }
Exemplo n.º 12
0
        public void PublishSoft(long id, string[] dst)
        {
            ShareManDBDataContext context = new ShareManDBDataContext();
            // 查找相关文件链接
            ItemLink il  = context.ItemLink.First(c => c.ID == id);

            FileSetLink fsl = context.FileSetLink.First(c => c.ID == il.InterLink);
            // 查询文件集信息
            FSM.FileSetMan fsm = new ShareMan.FSM.FileSetMan();
            QS.Queries qs = new ShareMan.QS.Queries();

            string actIp = qs.QueryActInterSrv();
            fsm.Url = qs.QueryUrl(qs.QueryActInterSrv(),QS.ServiceType.FileSetMan);
            FSM.FileSet fs = fsm.QureyFileSet(fsl.FileSetID);

            // 发布
            foreach (string subCode in dst)
            {
                string ip = qs.QuerySrvIp(subCode);
                fsm.Url = qs.QueryUrl(ip, QS.ServiceType.FileSetMan);
                long fsid = fsm.CreateFileSet(fs,true);
                FSM.FileSet tmpFs = fsm.QureyFileSet(fsid);

                // 查询基本信息
                BaseItem baseItem = context.BaseItem.First(c => c.ID == id);
                // 查询电影信息
                Software softInfo = context.Software.First(c => c.ID == id);
                PublishType pubType = context.PublishType.First(c => c.ID == baseItem.PublishType);

                SB.ShareBrowse sb = new SB.ShareBrowse();
                //sb.Url = "http://localhost/SB/ShareBrowse.asmx";
                string url = qs.QueryUrl(ip,QS.ServiceType.ShareBrowse);
                sb.Url = url;
                sb.PublishSoft(this.Convert(baseItem), this.Convert(softInfo), this.Convert(pubType),fsid);
                CreateProgress(baseItem, actIp, ip, fsid, "发布", context);
                TransFileSet(qs.QueryActInterSrv(), ip,tmpFs);
                Distribute trbut = new Distribute
                {
                    SubCode = subCode,
                    ItemID = id
                };
                context.Distribute.InsertOnSubmit(trbut);
                context.SubmitChanges();
                Audit(id, 2);
            }
        }
Exemplo n.º 13
0
        public void PublishMusic(long id,string [] dst)
        {
            ShareManDBDataContext context = new ShareManDBDataContext();
            // 查找相关文件链接
            //var link = from l in context.ItemLink where l.ID == id select l;
            ItemLink il  = context.ItemLink.First(c => c.ID == id);
            if (il == null)
            {
                throw new ArgumentException("il is null" + id.ToString());
            }
            //var fslink = from f in context.FileSetLink where f.ID == il.SrcLink select f;
            FileSetLink fsl = context.FileSetLink.First(c => c.ID == il.InterLink);
            if (fsl == null)
            {
                throw new ArgumentException("fsl is null" + il.SrcLink.ToString());
            }
            // 查询文件集信息
            FSM.FileSetMan fsm = new ShareMan.FSM.FileSetMan();
            QS.Queries qs = new ShareMan.QS.Queries();

            string actIp = qs.QueryActInterSrv();

            fsm.Url = qs.QueryUrl(qs.QueryActInterSrv(),QS.ServiceType.FileSetMan);
            FSM.FileSet fs = fsm.QureyFileSet(fsl.FileSetID);
            if(fs == null)
            {
                throw new ArgumentException("fs is null"+fsl.FileSetID.ToString());
            }

            // 发布
            foreach (string subCode in dst)
            {
                string ip = qs.QuerySrvIp(subCode);
                fsm.Url = qs.QueryUrl(ip, QS.ServiceType.FileSetMan);
                long fsid = fsm.CreateFileSet(fs,true);
                FSM.FileSet tmpFs = fsm.QureyFileSet(fsid);

                // 查询基本信息
                BaseItem baseItem = context.BaseItem.First(c => c.ID == id);
                // 查询电影信息
                Music musicInfo = context.Music.First(c => c.ID == id);
                PublishType pubType = context.PublishType.First(c => c.ID == baseItem.PublishType);

                SB.ShareBrowse sb = new SB.ShareBrowse();
                string url = qs.QueryUrl(ip,QS.ServiceType.ShareBrowse);
                sb.Url = url;
                sb.PublishMusic(this.Convert(baseItem), this.Convert(musicInfo), this.Convert(pubType),fsid);
                CreateProgress(baseItem, actIp, ip, fsid, "发布", context);
                TransFileSet(qs.QueryActInterSrv(), ip,tmpFs);
                Distribute trbut = new Distribute
                {
                    SubCode = subCode,
                    ItemID = id
                };
                context.Distribute.InsertOnSubmit(trbut);
                context.SubmitChanges();
                Audit(id, 2);
            }
        }
Exemplo n.º 14
0
 public void DeleteFileSet(long id, ShareManDBDataContext context)
 {
     FSM.FileSetMan fsm = new ShareMan.FSM.FileSetMan();
     QS.Queries qs = new QS.Queries();
     var il = from l in context.ItemLink where l.ID == id select l;
     foreach (ItemLink it in il)
     {
         long[] ids = {it.InterLink, it.SrcLink};
         var flink = from f in context.FileSetLink where ids.Contains(f.ID)  select f;
         foreach (FileSetLink fl in flink)
         {
             fsm.Url = qs.QueryUrl(fl.IP, QS.ServiceType.FileSetMan);
             // 先清除文件
             DeleteFiles(fl.FileSetID, fl.IP);
             // 在清除数据
             fsm.DeleteFileSet(fl.FileSetID);
             context.FileSetLink.DeleteOnSubmit(fl);
         }
         context.ItemLink.DeleteOnSubmit(it);
     }
 }
Exemplo n.º 15
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();
     }
 }
Exemplo n.º 16
0
 public void RemoveBase(long id, ShareManDBDataContext context)
 {
     QS.Queries qs = new QS.Queries();
     // 停止中转服务器文件传输
     StopTrans(qs.QueryActInterSrv());
     // 删除中转服务器上相关文件
     //DeleteFiles(,qs.QueryActInterSrv());
     // 清除服务器上的文件集信息
     DeleteFileSet(id,context);
     // 清楚已经发布的数据
     RemovePublish(id, context);
     // 清除其他相关信息
     CleanInfos(id, context);
 }
Exemplo n.º 17
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;
     }
 }
Exemplo n.º 18
0
 public void RemovePublish(long id, ShareManDBDataContext context)
 {
     SB.ShareBrowse sb = new ShareMan.SB.ShareBrowse();
     QS.Queries qs = new ShareMan.QS.Queries();
     var subSite = from p in context.Distribute where p.ItemID == id select p;
     foreach (Distribute d in subSite)
     {
         // 查询发布站点IP
         var sub = context.T_SubSection.First(c => c.subCode == d.SubCode);
         sb.Url = qs.QueryUrl(sub.serverIp, QS.ServiceType.ShareBrowse);
         sb.RemovePublish(id);
     }
 }
Exemplo n.º 19
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;
     }
 }
Exemplo n.º 20
0
 public void RemoveVidioNews(long id)
 {
     ShareManDBDataContext context = new ShareManDBDataContext();
     try
     {
         context.Connection.Open();
         context.Transaction = context.Connection.BeginTransaction();
         RemoveBase(id, context);
         var tmp1 = context.VidioNews.First(c => c.ID == id);
         context.VidioNews.DeleteOnSubmit(tmp1);
         context.SubmitChanges();
         context.Transaction.Commit();
     }
     catch(Exception e)
     {
         context.Transaction.Rollback();
         throw e;
     }
 }
Exemplo n.º 21
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;
        }
Exemplo n.º 22
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();
 }