private void loadData(string path) { try { Print("loading . . ."); IOData d = IsCompressed(path) ? IOHandler.ReadFromXmlGZIPFile <IOData>(path) : IOHandler.ReadFromXmlFile <IOData>(path); associationRules = d.Rules; clusters = SerializableClusterOfUsers.Convert(d.Clusters); extractedUsers = d.Users; foreach (var u in extractedUsers) { foreach (var s in u.Sessions) { s.User = u; foreach (var r in s.Requests) { r.Session = s; } } } var v = new Dictionary <string, char>(); for (int i = 0; i < d.itemKeys.Count; i++) { v.Add(d.itemKeys[i], d.itemValues[i]); } Session._items = v; Session.BuildReverseItemsOfTransactions(); Print("done"); Print(); Print("users count = " + extractedUsers.Count.ToString("N0")); Print("clusters count = " + clusters.Count()); Print("rules count = " + associationRules.Count()); bulidMarkov(); } catch (Exception ex) { Print("Error : "); Print(ex.Message); } }
private void saveData(string path) { Print("saving . . ."); try { var data = new IOData() { Rules = associationRules == null ? new List <Rule>() : new List <Rule>(associationRules), Clusters = clusters == null ? new List <SerializableClusterOfUsers>() : SerializableClusterOfUsers.Convert(clusters), Users = extractedUsers == null ? new List <User>() : extractedUsers, itemKeys = Session._items == null ? new List <string>() : Session._items.Keys.ToList(), itemValues = Session._items == null ? new List <char>() : Session._items.Values.ToList(), }; if (IsCompressed(path)) { IOHandler.WriteToXmlGZIPFile <IOData>(path, data); } else { IOHandler.WriteToXmlFile <IOData>(path, data); } Print("done"); } catch (Exception ex) { Print("Error : "); Print(ex.Message); } }