Exemplo n.º 1
0
        private static void SaveWorkspace(string filename, WorkspaceInfo workspaceInfo)
        {
            var str = UXmlConvert.GetString(workspaceInfo);

            UIO.SaveFile(str, filename);
        }
Exemplo n.º 2
0
        private static WorkspaceInfo CreateWorkspaceInfo(string filename, List <string> newFiles = null, WorkspaceInfo workspaceInfoRef = null)
        {
            var wks = workspaceInfoRef ?? new WorkspaceInfo();

            wks.SaveTime = DateTime.Now;
            var datinfos = new SDatinfos();

            wks.Datinfos = datinfos;

            var dir = Path.GetDirectoryName(filename);

            if (!Directory.Exists(dir))
            {
                return(wks);
            }

            var workspaceDefs = WorkspaceDefinitionFactory.WorkspaceDefs;

            foreach (var workspaceDef in workspaceDefs)
            {
                foreach (var catalogDef in workspaceDef.CatalogDefs)
                {
                    var def = catalogDef as SubProductCatalogDef;
                    if (def == null)
                    {
                        continue;
                    }
                    string[] fnames = GetFiles(dir, def.Identify, def.Pattern);
                    if (fnames == null || fnames.Length == 0)
                    {
                        continue;
                    }

                    foreach (var fname in fnames)
                    {
                        if (newFiles != null && !newFiles.Contains(fname))
                        {
                            continue;
                        }

                        var datinfo = CreateDatinfo(fname, def);
                        if (datinfo != null)
                        {
                            datinfos.AddDatinfo(datinfo);
                        }
                    }
                }
            }

            SaveWorkspace(filename, wks);
            return(wks);
        }