コード例 #1
0
        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()
            }
                );
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
ファイル: Project.cs プロジェクト: zhangtianhe365/Hawk
        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);
        }
コード例 #5
0
ファイル: Project.cs プロジェクト: zhangtianhe365/Hawk
        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
            }
                );
        }