public void EditPackData(TriData dat, String fieldname, String value) { if (!DataService.checkOutModified(tablename, lines)) { int index = GetPackIndexByName(fieldname); data[dat][index] = value; DataService.resetData(tablename, this); } }
public void RemovePackData(TriData dat) { if (!DataService.checkOutModified(tablename, lines)) { data.Remove(dat); int keyid = dat.a; keys[keyid]--; if (keys[keyid] == 0) { keys.Remove(keyid); } DataService.resetData(tablename, this); } }
public void AddPackData(List <String> item) { if (!DataService.checkOutModified(tablename, lines)) { TriData dat = new TriData(int.Parse(item[0]), int.Parse(item[1]), int.Parse(item[2])); data.Add(dat, item); int keyid = int.Parse(item[0]); if (keys.ContainsKey(keyid)) { keys[keyid]++; } else { keys.Add(keyid, 1); } DataService.resetData(tablename, this); } }
public void ImportPackData(String path, bool doClear) { if (!DataService.checkOutModified(tablename, lines)) { if (doClear) { data.Clear(); keys.Clear(); } StreamReader sr = new StreamReader(path, Encoding.Default); string line; int result; while ((line = sr.ReadLine()) != null) { string[] infos = line.Split(','); if (!int.TryParse(infos[0], out result)) { continue; } int keyid = int.Parse(infos[0]); TriData dat = new TriData(int.Parse(infos[0]), int.Parse(infos[1]), int.Parse(infos[2])); data.Add(dat, new List <string>(infos)); if (keys.ContainsKey(keyid)) { keys[keyid]++; } else { keys.Add(keyid, 1); } } DataService.resetData(tablename, this); sr.Close(); } }
public static TriDataPack GetAllTriData(string tableName) { TriDataPack pack = new TriDataPack(tableName); pack.lines.Clear(); StreamReader sr = new StreamReader(datapath + "/" + tableName + ".cfg", Encoding.UTF8); string line = ""; bool inHeader = false; bool inData = false; while ((line = sr.ReadLine()) != null) { pack.lines.Add(line); if (line == "[header]") { inHeader = true; inData = false; } else if (line == "[data]") { inHeader = false; inData = true; } else if (inHeader) { string[] items = line.Split('\t'); if (items.Length >= 3) { pack.headers.Add(items[0]); pack.dataTypes.Add(items[1]); pack.dataSizes.Add(int.Parse(items[2])); } if (items.Length >= 4) { pack.comment.Add(items[3]); } else { pack.comment.Add(""); } } else if (inData) { string[] items = line.Split('\t'); List <string> strList = items.ToList(); int keyid = int.Parse(items[0]); TriData dat = new TriData(int.Parse(items[0]), int.Parse(items[1]), int.Parse(items[2])); pack.data.Add(dat, new List <string>(items)); if (pack.keys.ContainsKey(keyid)) { pack.keys[keyid]++; } else { pack.keys.Add(keyid, 1); } } } sr.Close(); return(pack); }