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; }
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; }
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; } }
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); } }
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); } }
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 = ""; }