public void Save() { var connector = new FileConnectorXML(); if (SavePath != null && File.Exists(SavePath)) { connector.FileName = SavePath; } else { var result = connector.CheckFilePath(FileOperate.Save); if (result == false) { return; } SavePath = connector.FileName; } connector.WriteAll( new List <IFreeDocument> { DictSerialize() } ); }
public static Project Load(string path = null) { var connector = new FileConnectorXML(); connector.FileName = path; if (connector.FileName == null) { var result = connector.CheckFilePath(FileOperate.Read); if (result == false) { return(null); } } var proj = connector.ReadFile().FirstOrDefault(); if (proj == null) { return(null); } var proj2 = new Project(); proj.DictCopyTo(proj2); proj2.SavePath = connector.FileName; return(proj2); }
public static Project Load(string path = null) { var connector = new FileConnectorXML(); connector.FileName = path; if (connector.FileName == null) { var result = connector.CheckFilePath(FileOperate.Read); if (result == false) { return(null); } } else { if (!File.Exists(connector.FileName)) { XLogSys.Print.Error($"文件{connector.FileName}不存在"); return(null); } } var proj = connector.ReadFile().FirstOrDefault(); if (proj == null) { return(null); } var proj2 = new Project(); proj.DictCopyTo(proj2); proj2.SavePath = connector.FileName; return(proj2); }
public static Project Load(string path = null) { var connector = new FileConnectorXML(); connector.FileName = path; if (connector.FileName == null) { var result = connector.CheckFilePath(FileOperate.Read); if (result == false) { return(null); } } else { if (!File.Exists(connector.FileName)) { XLogSys.Print.Error(string.Format(GlobalHelper.Get("key_334"), connector.FileName)); return(null); } } var ext = Path.GetExtension(connector.FileName); if (ext != null && ext.Contains("hproj")) { connector.IsZip = true; } var projfile = connector.ReadFile().FirstOrDefault(); if (projfile == null) { return(null); } var proj = new Project(); DocumentToProject(projfile, proj); proj.SavePath = connector.FileName; return(proj); }
public void Save(IEnumerable <DataCollection> collections = null) { var connector = new FileConnectorXML(); if (SavePath != null && File.Exists(SavePath)) { connector.FileName = SavePath; } else { var result = connector.CheckFilePath(FileOperate.Save); if (result == false) { return; } SavePath = connector.FileName; } var ext = Path.GetExtension(SavePath); if (ext != null && ext.Contains("hproj")) { connector.IsZip = true; } var dict = DictSerialize(); if (collections != null) { dict["DataCollections"] = new FreeDocument { Children = collections.Where(d => d.Count < 100000).Select(d => d.DictSerialize()).ToList() } } ; connector.WriteAll( new List <IFreeDocument> { dict } ); }