private async void runHttpFireTask(IEnumerable <CellMonitor> changedList) { ResponseData <string> res = null; HttpFireTask fireTask = null; foreach (var change in changedList) { fireTask = change.FireTask; if (fireTask == null) { continue; } if (string.IsNullOrWhiteSpace(fireTask.Url)) { continue; } string info = $"FireTask [{change.PrimaryKeyValue}] [{change.ColumnName}]"; try { debugMsg("Try to run " + info); if (fireTask.TypeOfPost) { res = await requester.branchRequest(this, NetRequestProvider.HttpPost, fireTask.Url, fireTask.Data); } else { res = await requester.branchRequest(this, NetRequestProvider.HttpGet, fireTask.Url, fireTask.Data); } debugMsg(info + " complete."); } catch (AggregateException e) { debugMsg(info + " error : " + e.Message); } catch (WebException e) { if (e.Response == null) { debugMsg("FireTask Responese NULL."); } else { HttpWebResponse response = null; if ((response = (e.Response as HttpWebResponse)) != null) { debugMsg("FireTask WebException : " + response.StatusCode); response.Dispose(); } } } } }
public void AddMonitorFromFile(string filePath) { using (System.IO.Stream stream = System.IO.File.Open(filePath, System.IO.FileMode.Open)) { var doc = new System.Xml.XmlDocument(); doc.Load(stream); var rootNodeList = doc.SelectSingleNode("cellmonitors").ChildNodes; foreach (System.Xml.XmlNode childNode in rootNodeList) { if (childNode.Name == "cellmonitor") { string primary = string.Empty; string columnIndexValue = string.Empty; foreach (System.Xml.XmlAttribute attribute in childNode.Attributes) { switch (attribute.Name) { case "primaryKeyValue": primary = attribute.Value; break; case "columnIndex": columnIndexValue = attribute.Value; break; } } if (string.IsNullOrEmpty(primary) || string.IsNullOrEmpty(columnIndexValue)) { continue; } int columnIndex = -1; if (int.TryParse(columnIndexValue, out columnIndex)) { if (columnIndex < 0) { continue; } HttpFireTask fireTask = null; if (childNode.ChildNodes.Count > 0) { string url = string.Empty; string data = string.Empty; string typeofpost = string.Empty; foreach (System.Xml.XmlAttribute attribute in childNode.ChildNodes[0].Attributes) { switch (attribute.Name) { case "url": url = attribute.Value; break; case "data": data = attribute.Value; break; case "typeofpost": typeofpost = attribute.Value; break; } } if (!string.IsNullOrWhiteSpace(typeofpost)) { bool isPost = false; if (bool.TryParse(typeofpost, out isPost)) { fireTask = new HttpFireTask() { Url = url, Data = data, TypeOfPost = isPost }; } else { continue; } } } this.AddToMonitoring(primary, columnIndex).FireTask = fireTask; } } } } }