コード例 #1
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);
        }
コード例 #2
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()
            }
                );
        }
コード例 #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
        public static bool IsEqual(this FreeDocument value, FreeDocument content)
        {
            var ignore = new List <string>()
            {
                "Description", "ScriptPath"
            };

            value.RemoveElements(d => ignore.Contains(d));
            return(FileConnectorXML.GetString(value) == FileConnectorXML.GetString(content));
        }
コード例 #5
0
        public static Project LoadProject(string path)
        {
            if (File.Exists(path) == false)
            {
                throw new Exception("当前工程文件的路径不存在,生成新工程");
            }
            var xml = new FileConnectorXML {
                FileName = path
            };
            var r       = xml.ReadFile().FirstOrDefault();
            var project = new Project();

            if (r != null)
            {
                project.DictDeserialize(r.DictSerialize());
            }
            return(project);
        }
コード例 #6
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);
        }
コード例 #7
0
ファイル: Project.cs プロジェクト: zhangtianhe365/Hawk
        public static async Task <Project> LoadFromUrl(string url)
        {
            var resquest = await WebRequest.Create(url).GetResponseAsync();

            var response      = resquest.GetResponseStream();
            var fileConnector = new FileConnectorXML();
            var proj          = new Project();

            ControlExtended.SafeInvoke(() =>
            {
                var docs = fileConnector.ReadFile(response, url.EndsWith("hproj"), null);
                if (docs.Any() == false)
                {
                    throw new Exception("TODO");
                }
                var first = docs.FirstOrDefault();

                DocumentToProject(first, proj);
            }, LogType.Info, GlobalHelper.Get("key_307"));

            return(proj);
        }
コード例 #8
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
            }
                );
        }