private void OnProgress(string cmdId, string args) { if (String.IsNullOrEmpty(args)) { return; } String[] vals = Regex.Split(args, ";"); if (vals == null || vals.Length != 3) { return; } try { CollectPageInformation collectType = (CollectPageInformation)Enum.ToObject(typeof(CollectPageInformation), int.Parse(vals[0])); int prg = int.Parse(vals[1]); int tot = int.Parse(vals[2]); if ((collectType & CollectPageInformation.Screenshots_Small) == CollectPageInformation.Screenshots_Small || (collectType & CollectPageInformation.Screenshots_Full) == CollectPageInformation.Screenshots_Full) { TestEvents.FireProgressEvent(TestEventType.CapturingSegment, prg, tot, null); } else { TestEvents.FireProgressEvent(TestEventType.RenderingSegment, prg, tot, null); } } catch { } }
public Collector(XmlNode x) { String collectorName = x.Attributes["name"].Value; this.CollectType = (CollectPageInformation)Enum.Parse(typeof(CollectPageInformation), collectorName, true); try{ this.IsStandalone = x.Attributes["standalone"].Value.ToLower().Equals("true"); }catch {} this.Collection = x.InnerText; }
public override void Flush() { CollectorsConfig cc = null; Stream configStream = null; try { configStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MySpace.MSFast.Engine.DataCollectors.config"); cc = new CollectorsConfig(configStream); } catch { } finally { try { if (configStream != null) { configStream.Close(); } } catch { } configStream = null; } if (this.CollectionInfoParser.CollectFlags == 0 || cc == null || cc.Collection == null || String.IsNullOrEmpty(cc.Collection.JSMain) || String.IsNullOrEmpty(cc.Collection.Html) || String.IsNullOrEmpty(cc.Collection.JSSetTestID) || String.IsNullOrEmpty(cc.Collection.JSStartCollecting)) { return; } CollectPageInformation cpi = CollectPageInformation.Render; try{ cpi = (CollectPageInformation)Enum.ToObject(typeof(CollectPageInformation), this.CollectionInfoParser.CollectFlags); }catch { } StringBuilder scripts = new StringBuilder(); foreach (CollectorsConfig.Collector cs in cc) { if ((cpi & cs.CollectType) == cs.CollectType) { scripts.Append(cs.Collection); } } if (this.CollectionInfoParser != null && this.Configuration is EngineSuProxyConfiguration) { scripts.Insert(0, String.Format(cc.Collection.JSSetTestID, 0, 0, ((EngineSuProxyConfiguration)this.Configuration).CollectionID, this.CollectionInfoParser.URL, this.CollectionInfoParser.URLEncoded)); scripts.Insert(0, cc.Collection.JSMain); String page = String.Format(cc.Collection.Html, scripts.ToString(), cc.Collection.JSStartCollecting); byte[] b = Encoding.UTF8.GetBytes(page); base.SendHeader(String.Format(responseHeader, b.Length)); base.SendBodyData(b, 0, b.Length); } base.Flush(); }