public static void DbWriterComma(DbDebugItem <string> debug, AbstractDb <string> db) { try { StringLineStream lines = new StringLineStream(debug.OldPath, ',', false); lines.Remove(db); string line; int numOfElements = debug.AbsractDb.Table.AttributeList.Attributes.Count; var v = debug.AbsractDb.Table.AttributeList.Attributes.FirstOrDefault(p => (p.Visibility & VisibleState.Hidden) == VisibleState.Hidden); if (v != null) { numOfElements = debug.AbsractDb.Table.AttributeList.Attributes.IndexOf(v); } foreach (ReadableTuple <string> tuple in db.Table.FastItems.Where(p => !p.Normal).OrderBy(p => p.Key)) { line = string.Join(",", tuple.GetRawElements().Take(numOfElements).Select(p => (p ?? "").ToString()).ToArray()); lines.Write(tuple.Key, line); } lines.WriteFile(debug.FilePath); } catch (Exception err) { debug.ReportException(err); } }
public static void DbConstantsWriter <TKey>(DbDebugItem <TKey> debug, AbstractDb <TKey> db) { try { StringLineStream lines = new StringLineStream(debug.OldPath); lines.Remove(db); string line; foreach (ReadableTuple <TKey> tuple in db.Table.FastItems.Where(p => !p.Normal).OrderBy(p => p.GetKey <TKey>())) { string key = tuple.GetKey <string>(); int item2 = tuple.GetValue <int>(2); if (item2 == 0) { line = string.Join("\t", tuple.GetRawElements().Take(2).Select(p => (p ?? "").ToString()).ToArray()); } else { line = string.Join("\t", tuple.GetRawElements().Take(3).Select(p => (p ?? "").ToString()).ToArray()); } lines.Write(key, line); } lines.WriteFile(debug.FilePath); } catch (Exception err) { debug.ReportException(err); } }
public static void DbUniqueWriter <TKey>(DbDebugItem <TKey> debug, AbstractDb <TKey> db) { try { if (!db.IsModified) { DbDirectCopyWriter(debug, db); return; } StringLineStream lines = new StringLineStream(debug.OldPath); lines.ClearAfterComments(); lines.Remove(db); string line; bool anySkippable = db.AttributeList.Attributes.Any(p => p.IsSkippable); foreach (ReadableTuple <TKey> tuple in db.Table.FastItems.OrderBy(p => p.GetValue <int>(1))) { List <object> elements = tuple.GetRawElements(); if (anySkippable) { foreach (DbAttribute attribute in db.AttributeList.Attributes.Where(p => p.IsSkippable).Reverse()) { if (elements[attribute.Index] == "") { elements.RemoveAt(attribute.Index); } } line = string.Join(",", elements.Skip(1).Select(p => (p ?? "").ToString()).ToArray()); lines.Append(line); } else { line = string.Join(",", tuple.GetRawElements().Skip(1).Select(p => (p ?? "").ToString()).ToArray()); lines.Append(line); } } lines.WriteFile(debug.FilePath); } catch (Exception err) { debug.ReportException(err); } }
public static void Writer(DbDebugItem <string> debug, AbstractDb <string> db) { try { StringLineStream lines = new StringLineStream(debug.OldPath); lines.Remove(db); string line; foreach (ReadableTuple <string> tuple in db.Table.FastItems.Where(p => !p.Normal).OrderBy(p => p.GetValue <int>(1))) { line = string.Join(",", tuple.GetRawElements().Skip(1).Select(p => (p ?? "").ToString()).ToArray()); lines.Write(tuple.Key, line); } lines.WriteFile(debug.FilePath); } catch (Exception err) { debug.ReportException(err); } }