Exemplo n.º 1
0
        private static void SaveFile()
        {
            var root = new XElement("Generals");

            foreach (var actionCash in Generals)
            {
                root.Add(GeneralType.ToXElement(actionCash));
            }

            File.WriteAllText(Path, new XDocument(root).ToString());
        }
Exemplo n.º 2
0
        public static void Add(GeneralType general)
        {
            Generals.Add(general);

            if (!File.Exists(Path))
            {
                SaveFile();
            }

            var document = XDocument.Load(Path);

            document.GetXElement("Generals").Add(GeneralType.ToXElement(general));
            File.WriteAllText(Path, document.ToString());

            if (SyncData.IsConnect)
            {
                using (var connection = ConnectionFactory.CreateConnection())
                    connection.Execute(InsertQuery, general);
            }
        }