/// <summary> /// 加载需要的xml文档信息 /// </summary> /// <param name="Path">xml文档路径</param> private static void LoadXML(string Path) { Context context = Context.GetInstance(); try { ModelGeneralInformation GeneralInfomation = XMLSerializeHelper.DeserializeXML <ModelGeneralInformation>(Path); context.GeneralInformation = GeneralInfomation; } catch (Exception ex) { throw new Exception(ex.Message); } }
public USGSItemActor() { Receive <ProcessUSGSItem>(e => { var item = XMLSerializeHelper.Deserialize <FeedEntry>(e.item.ToString()); var usgs = new FeedDataStructures.USGSItem(); var html = new HtmlDocument(); html.LoadHtml(item.Summary.Text); var orig = html.DocumentNode.SelectNodes("//dd").Select(z => z.InnerText).First(); var dt = DateTimeOffset.Parse(orig.Substring(0, orig.Length - 3)); usgs.id = item.Id.Substring(item.Id.LastIndexOf(":") + 1); usgs.partionKey = usgs.id + ":" + dt.ToString("yyyy-MM-dd"); usgs.published = dt; usgs.updated = DateTimeOffset.Parse(item.Updated); usgs.magnitude = processMag(item.Title); usgs.point = processPoint(item.Point); usgs.elevation = float.Parse(item.Elev) / 1000f; usgs.link = item.Link.Href; usgs.originalXML = e.ToString(); usgs.title = item.Title; usgs.source = e.path.Substring(0, e.path.IndexOf('.')); if (updateIfNew(usgs)) { Program.cdb.UpsertDocument(new CommonDataFormat() { id = Guid.NewGuid().ToString(), partionKey = "usgs", source = "usgs", title = usgs.title, extra = usgs.summary, point = usgs.point, pubDate = usgs.published, sourceId = usgs.id, sourcePk = usgs.partionKey }, "commondata").Wait(); if ((DateTimeOffset.UtcNow - usgs.updated).TotalSeconds > 10) { Sender.Tell(new processRecent(usgs)); } } Sender.Tell(new itemProcessed()); }); }
private void LoadConfiguration(ModelGeneralInformation ModelConfiguration) { try { string CtrlCardPath = XMLFolderPath + ModelConfiguration.ControlCardFileName; ControlCardInfomation = XMLSerializeHelper.DeserializeXML <ControlCards>(CtrlCardPath); context.ControlCard = ControlCardInfomation; string CameraCfgPath = XMLFolderPath + ModelConfiguration.CameraConfigFileName; CameraInfomation = XMLSerializeHelper.DeserializeXML <SlaveServers>(CameraCfgPath); context.SlaveServerConfig = CameraInfomation; string RecipePath = XMLFolderPath + ModelConfiguration.ModelRecipeFileName; Recipes RecipeInfomation = XMLSerializeHelper.DeserializeXML <Recipes>(RecipePath); context.ModuleRecipe = RecipeInfomation.RecipeArray; } catch (Exception ex) { throw new Exception(ex.Message); } }
public CustomModel() { InitializeComponent(); FucModel = XMLSerializeHelper.DeserializeXML <FunctionModules>("./Configurations/ManualModelFunctionConfig.xml"); FunctionCount = FucModel.SingleFunctionModule.Length; }
public WeatherGovItemActor() { Receive <ProcessWeatherItem>(r => { var entry = XMLSerializeHelper.Deserialize <Entry>(r.item.ToString()); Microsoft.Azure.Documents.Spatial.Polygon poly = null; if (!string.IsNullOrWhiteSpace(entry.Polygon)) { var pnts = entry.Polygon.Split(' ', StringSplitOptions.RemoveEmptyEntries); var pos = new List <Position>(); foreach (var p in pnts) { pos.Add(new Position( double.Parse(p.Substring(p.IndexOf(",") + 1)), double.Parse(p.Substring(0, p.IndexOf(","))) )); } var ring = new Microsoft.Azure.Documents.Spatial.LinearRing(pos); poly = new Microsoft.Azure.Documents.Spatial.Polygon(new List <LinearRing>() { ring }); } var item = new WeatherGovItem() { id = entry.Id.Substring(entry.Id.IndexOf("=") + 1), parameter = new VTEC() { valueType = entry.Parameter.ValueName, vtecValue = entry.Parameter.Value }, areaDesc = entry.AreaDesc, category = entry.Category, certainty = entry.Certainty, effective = entry.Effective, eventType = entry.Event, expires = DateTimeOffset.Parse(entry.Expires), geocode = entry.Geocode, link = entry.Link.Href, msgType = entry.MsgType, polygon = poly, published = DateTimeOffset.Parse(entry.Published), severity = entry.Severity, status = entry.Status, summary = entry.Summary, title = entry.Title, updated = DateTimeOffset.Parse(entry.Updated), urgency = entry.Urgency, originalXML = r.item.ToString() }; item.partionKey = item.id; var prior = Program.cdb.GetDocumentQuery <WeatherGovItem>("weathergov") .Where(w => w.id == item.id && w.partionKey == item.id) .Select(w => w.updated) .ToList(); if (Program.forceSave) { prior.Clear(); } // prior.Clear(); if (prior.Any()) { if (prior.First() != item.updated) { // TODO: Message Archiving Program.cdb.UpsertDocument(item, "weathergov").Wait(); Program.cdb.UpsertDocument(new CommonDataFormat() { id = Guid.NewGuid().ToString(), partionKey = "weather", source = "weather", title = item.title, extra = item.summary, point = poly, pubDate = item.updated, expires = item.expires, sourceId = item.id, sourcePk = item.partionKey }, "commondata").Wait(); } } else { Program.cdb.UpsertDocument(item, "weathergov").Wait(); Program.cdb.UpsertDocument(new CommonDataFormat() { id = Guid.NewGuid().ToString(), partionKey = "weather", source = "weather", title = item.title, extra = item.summary, point = poly, pubDate = item.updated, expires = item.expires, sourceId = item.id, sourcePk = item.partionKey }, "commondata").Wait(); } if (item.parameter.vtecValue != "") { bool inactive = (item.parameter.vtecValue.StartsWith("/O.CAN") || item.parameter.vtecValue.StartsWith("/O.EXP")) || item.expires < DateTimeOffset.UtcNow; if (inactive) { Sender.Tell(new processedWeatherGov()); } else { Sender.Tell(new processedWeatherGov() { item = item }); } } else { Sender.Tell(new processedWeatherGov()); } var a = ""; }); }
public SeattlePDItemActor() { Receive <processSPDItem>(r => { var item = XMLSerializeHelper.Deserialize <Item>(r.item.ToString()); var c = new SeattlePDItem() { category = item.Category, creator = item.Creator.Text, description = item.Encoded.Text .Replace("<p>", "") .Replace("</p>", "\r\n") .Replace("’", "'") .Replace("″", "\"") .Replace("…", "…"), link = item.Link, pubDate = DateTimeOffset.Parse(item.PubDate), title = item.Title, id = "seattlewa:" + item.Guid.Text.Substring(item.Guid.Text.IndexOf("=") + 1), originalXML = r.item.ToString() }; c.partionKey = "seattlewa"; var idx = c.description.IndexOf("For additional tips "); if (idx > 0) { c.description = c.description.Substring(0, idx - 1); } var startsHTML = c.description.StartsWith("<"); if (startsHTML) { c.description = c.description.Substring(c.description.IndexOf("\r\n") + 1).Trim(); } var str = c.description.IndexOf("<", 10); if (str > 0) { c.description = c.description.Substring(0, str - 1); } var qry = Program.cdb.GetDocumentQuery <SeattlePDItem>("police") .Where(s => s.id == c.id && c.partionKey == c.id) .Select(s => s.id); var results = qry.ToList(); results.Clear(); if (!results.Any()) { Program.cdb.UpsertDocument(c, "police").Wait(); Program.cdb.UpsertDocument(new { id = "recent", partionKey = "seattlewa", }, "police").Wait(); } Sender.Tell(new itemProcessed() { item = c }); }); }