public static CTrace FilledTrace(ref Random rand, CLog log) { CTrace trace = new CTrace(); int count = rand.Next(5, 15); for (int i = 0; i < count; i++) { trace.Add(GenerateEvent(log, ref rand)); } return trace; }
/// <summary> /// Создает клона данной трассы /// </summary> public object Clone() { CTrace trace = new CTrace(); trace.Name = Name; foreach (CEvent evt in this.Events) trace.Add(evt); foreach (string key in _Bool_Parameters.Keys) trace[key] = this[key]; foreach (string key in _Int_Parameters.Keys) trace[key] = this[key]; foreach (string key in _Double_Parameters.Keys) trace[key] = this[key]; foreach (string key in _Text_Parameters.Keys) trace[key] = this[key]; return trace; }
// Открывает XES в класс Log private static void open_xml_to_class(XmlDocument doc, out CLog log, out List<XmlNode> trash) { int ErrorCount = 0; DateTimeOffset? date = null; XmlNodeList listoftraces = doc.DocumentElement.ChildNodes; XmlNodeList listofevents; XmlNodeList listofnames; CultureInfo a = new CultureInfo(CultureInfo.CurrentCulture.Name); a.NumberFormat.NumberDecimalSeparator = "."; log = new CLog(); trash = new List<XmlNode>(); foreach (XmlNode trace in listoftraces) { if (trace.Name == "trace") { CTrace tr = new CTrace(); listofevents = trace.ChildNodes; foreach (XmlNode node in listofevents) { switch (node.Name) { case "string": if (node.Attributes[0].Value == "concept:name") tr.Name = node.Attributes[1].Value; else tr.Text_Parameters.Add(node.Attributes[0].Value, node.Attributes[1].Value); break; case "int": try { tr.Int_Parameters.Add(node.Attributes[0].Value, int.Parse(node.Attributes[1].Value)); //TODO Это } catch { ErrorCount++; } break; case "float": try { tr.Double_Parameters.Add(node.Attributes[0].Value, double.Parse(node.Attributes[1].Value)); } catch { ErrorCount++; } break; case "boolean": try { tr.Bool_Parameters.Add(node.Attributes[0].Value, bool.Parse(node.Attributes[1].Value)); } catch { ErrorCount++; } break; case "event": CEvent ev = new CEvent(log); listofnames = node.ChildNodes; foreach (XmlNode name in listofnames) switch (name.Name) { case "date": DateTimeOffset dat = new DateTimeOffset(); DateTimeOffset.TryParse(name.Attributes[1].Value, out dat); date = dat; ev.Date = date; break; case "string": if (name.Attributes[0].Value != "concept:name") ev.Text_Parameters.Add(name.Attributes[0].Value, name.Attributes[1].Value); else ev.Name = name.Attributes[1].Value; break; case "int": try { ev.Int_Parameters.Add(name.Attributes[0].Value, int.Parse(name.Attributes[1].Value)); } catch { ErrorCount++; } break; case "float": try { ev.Double_Parameters.Add(name.Attributes[0].Value, double.Parse(name.Attributes[1].Value, a)); } catch { ErrorCount++; } //TODO Создать логгирующую ошибки системы break; case "boolean": try { ev.Bool_Parameters.Add(name.Attributes[0].Value, bool.Parse(name.Attributes[1].Value)); } catch { ErrorCount++; } break; } tr.Add(ev); break; } } log.Add(tr); } else trash.Add(trace); } listofevents = null; listofnames = null; listoftraces = null; if ((ErrorCountEvent != null) && (ErrorCount > 0)) ErrorCountEvent(ErrorCount); }