// 加载mesh动画文件 //Modify by Aoicocoon 2017/12/06 //修改打包士兵数据+动画文件 public override void LoadSoldierAnim(string meshName, string animName, bool IsCache, AssetLoadHook pfun) { if (null == pfun) { return; } string folder = ResourcesPath.GetRelativePath(ResourcesType.ActorSoldierMesh, ResourcesPathMode.AssetBundle); string key = GetKey(folder, meshName + "/" + animName.ToLower()); string path = key + ConstantData.ABEXT; Object obj = FindAssetObj(key); if (null != obj) { pfun.Invoke(obj); } else { ABLoad.LoadAB(path, true, (ab) => { LoadQueue.AddLoadTask(path, animName, typeof(Texture2D), IsCache, IsCache, false, pfun); }); } }
public void ClearEverything() { Table.DeleteIfExists(); LoadQueue.DeleteIfExists(); CrawlQueue.DeleteIfExists(); StopQueue.DeleteIfExists(); }
public void ClearEverything() { SiteDataTable.DeleteIfExists(); LoadQueue.DeleteIfExists(); CrawlQueue.DeleteIfExists(); StopQueue.DeleteIfExists(); AdminStatusTable.DeleteIfExists(); ErrorQueue.DeleteIfExists(); }
public void Load(int i) { if (Loaded.Contains(i)) { return; } Loaded.Add(i); LoadQueue.Enqueue(i); }
private void ProcessXML(string URL) { HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(URL); httpRequest.Timeout = 10000; // 10 secs httpRequest.UserAgent = "Code Sample Web Client"; HttpWebResponse webResponse = (HttpWebResponse)httpRequest.GetResponse(); var stream = new StreamReader(webResponse.GetResponseStream()); XmlDocument xmlDoc = new XmlDocument(); // Create an XML document object xmlDoc.Load(stream); // Get elements XmlNodeList elements = xmlDoc.GetElementsByTagName("sitemap"); if (elements.Count == 0) { elements = xmlDoc.GetElementsByTagName("url"); } for (int i = 0; i < elements.Count; i++) { var link = elements[i].ChildNodes[0].InnerText; bool correctDate = true; if (elements[i].LastChild.InnerText != link) { var date = elements[i].ChildNodes[1].InnerText; correctDate = CheckLinkIsRecent(link, date); } if (CheckLinkDomain(link) && CheckLinkIsCorrectType(link) && CheckIfAllowed(link) && correctDate) { CloudQueueMessage linkMessage = new CloudQueueMessage(link); if (link.EndsWith("xml")) { LoadQueue.AddMessage(linkMessage); } else { CrawlQueue.AddMessage(linkMessage); } } } }
public string StartCrawler() { StopQueue = CloudConfiguration.GetStopQueue(); StateQueue = CloudConfiguration.GetStateQueue(); if (StopQueue.PeekMessage() == null) { LoadQueue = CloudConfiguration.GetLoadingQueue(); CloudQueueMessage startMessage = new CloudQueueMessage("http://www.cnn.com/robots.txt http://www.bleacherreport.com/robots.txt"); LoadQueue.AddMessage(startMessage); CloudQueueMessage state = new CloudQueueMessage("Loading"); } else { StopQueue.DeleteMessage(StopQueue.GetMessage()); } return("start crawler method executed"); }
private void ProcessTxt(string URL) { WebClient client = new WebClient(); string file = client.DownloadString(URL); string[] lines = file.Split('\n'); HashSet <string> links = new HashSet <string> (lines.Where(x => x.ToLower().StartsWith("sitemap:")) .Select(x => x.Substring(x.IndexOf("http")))); foreach (string link in links) { if (CheckLinkDomain(link)) { CloudQueueMessage message = new CloudQueueMessage(link); LoadQueue.AddMessage(message); } } }
// 加载asset接口 private void LoadObj(string ResType, string ABName, string ObjName, Type type, bool IsCacheAsset, bool IsCacheAB, bool IsFreeUnUseABRes, bool async, AssetLoadHook pfun) { string RelativePath = ABLoad.GetRelativePath(ResType, ABName); string key = GetKey(RelativePath, ObjName); UnityEngine.Object obj = FindAssetObj(key); if (obj != null) { if (pfun != null) { pfun(obj); } } else { if (async == false) { ABLoad.LoadAB(RelativePath, IsCacheAB, (ab) => { Object g = LoadObjByAb(ab, ObjName, type, IsCacheAB, IsFreeUnUseABRes); LoadAssetCallBack(g, key, IsCacheAsset, pfun); }); } else { // 异步加载队列 LoadQueue.AddLoadTask(RelativePath, ObjName, type, IsCacheAsset, IsCacheAB, IsFreeUnUseABRes, pfun); } } }
private void CheckFunc(PointOctreeNode <Integer> .OctreeObject octreeObject) { var objectPosition = DataSet[octreeObject.Obj].Position; var distanceCurrent = Vector3.Distance(cachePosition, objectPosition); if (distanceCurrent > NearRadius && distanceCurrent < FarRadius && !Loaded.Contains(octreeObject.Obj)) { Loaded.Add(octreeObject.Obj); lock (LoadQueue) { LoadQueue.Enqueue(octreeObject.Obj); } } else if ((distanceCurrent < NearRadius || distanceCurrent > FarRadius) && Loaded.Contains(octreeObject.Obj)) { Loaded.Remove(octreeObject.Obj); lock (UnloadQueue) { UnloadQueue.Enqueue(octreeObject.Obj); } } }
public string StartCrawler() { StopQueue = CloudConfiguration.GetStopQueue(); CloudQueueMessage stopMessage = StopQueue.GetMessage(); while (stopMessage != null) { StopQueue.DeleteMessage(stopMessage); stopMessage = StopQueue.GetMessage(); } LoadQueue = CloudConfiguration.GetLoadingQueue(); //Add message CloudQueueMessage cnnRobots = new CloudQueueMessage("http://www.cnn.com/robots.txt"); LoadQueue.AddMessage(cnnRobots); CloudQueueMessage bleacherReportRobots = new CloudQueueMessage("http://www.bleacherreport.com/robots.txt"); LoadQueue.AddMessage(bleacherReportRobots); return(LoadQueue.Name + " " + cnnRobots.AsString + " " + bleacherReportRobots.AsString); }
private void FinishTask() { Debug.Log("加载完成!"); LoadQueue.NotifyTaskFinish(this); }
private void Awake() { id = idCounter; idCounter++; LoadQueue.AddLoadToQueue(SpawnObject); }
public override void Run() { Storage = new AzureStorage(); LoadQueue = CloudConfiguration.GetLoadingQueue(); CrawlQueue = CloudConfiguration.GetCrawlingQueue(); StopQueue = CloudConfiguration.GetStopQueue(); SiteDataTable = CloudConfiguration.GetSiteDataTable(); AdminStatusTable = CloudConfiguration.GetAdminStatusTable(); StateQueue = CloudConfiguration.GetStateQueue(); State = "Idle"; CPUCount = new PerformanceCounter("Processor", "% Processor Time", "_Total"); MemCount = new PerformanceCounter("Memory", "Available MBytes"); Status = new AdminStatus(State, (int)CPUCount.NextValue(), (int)MemCount.NextValue()); string[] robots = { "http://www.cnn.com/robots.txt", "http://www.bleacherreport.com/robots.txt" }; Crawler = new WebCrawler(robots, Storage); Thread.Sleep(10000); string url = ""; while (true) { CloudQueueMessage stopMessage = StopQueue.GetMessage(); while (stopMessage == null) { // Get the next message CloudQueueMessage loadMessage = LoadQueue.GetMessage(); State = "Loading"; if (loadMessage != null) { State = "Loading"; url = loadMessage.AsString; if (url.Contains("robots.txt")) { string[] robotLinks = url.Split(null); foreach (string link in robotLinks) { Crawler.ProcessURL(link); } LoadQueue.DeleteMessage(loadMessage); } else { Crawler.ProcessURL(url); } } else if (State.Equals("Loading") || State.Equals("Crawling")) { CloudQueueMessage crawlMessage = CrawlQueue.GetMessage(); // dequeue crawl message if (crawlMessage != null) { State = "Crawling"; url = crawlMessage.AsString; Crawler.ProcessURL(url); CrawlQueue.DeleteMessage(crawlMessage); } } stopMessage = StopQueue.GetMessage(); UpdateDashboard(url); } State = "Idle"; } }