Ejemplo n.º 1
0
 public static ZDbConfig ReadCurrent(ASVersion version)
 {
     try
     {
         var config = new ZDbConfig
         {
             Version = version,
             Name    = "Current config for AS" + version.ToString(),
         };
         if (Utils.IsRevit(version))
         {
             config.Name = "Current config for RVT" + Utils.RevitVersion(version).ToString();
         }
         if (!Utils.IsRevit(version))
         {
             config.SupportDirIsLink = NativeMethods.IsSymbolicLink(config.PathBuilder.SupportPath);
             config.SupportDirLink   = NativeMethods.NormalizePath(NativeMethods.GetFinalPathName(config.PathBuilder.SupportPath));
         }
         config.DataSources = ReadDataSourcesFromXml(version);
         return(config);
     }
     catch (Win32Exception)
     {
         return(null);
     }
 }
Ejemplo n.º 2
0
        public static bool Compare(ZDbConfig a, ZDbConfig b, bool withName = false)
        {
            if (Utils.IsRevit(a.Version) || Utils.IsRevit(a.Version))
            {
                Console.WriteLine("test");
            }
            if (a == null || b == null)
            {
                return(false);
            }
            //Data sourcy
            if (a.DataSources.Count != b.DataSources.Count)
            {
                log.Debug("Nie zgadza się liczba datasourcow");
                return(false);
            }
            for (int i = 0; i < a.DataSources.Count; i++)
            {
                var ads = a.DataSources[i];
                var bds = b.DataSources[i];
                if (!DbDataSource.Compare(ads, bds))
                {
                    log.Debug(string.Format("Datasourcy w poz {0} nie zgadzaja się", i));
                    return(false);
                }
            }
            if (!Utils.IsRevit(a.Version) || !Utils.IsRevit(b.Version))
            {
                if (a.SupportDirIsLink != b.SupportDirIsLink)
                {
                    log.Debug("Nie zgadza się supportdirislink");
                    return(false);
                }

                if (a.SupportDirLink != b.SupportDirLink)
                {
                    log.Debug("Nie zgadza się supportdirlink");
                    return(false);
                }
            }

            if (withName)
            {
                if (a.Name != b.Name)
                {
                    log.Debug("Nie zgadza się name");
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 3
0
        public static List <ZConfigEntry> GetEntries(string dirpath, ASVersion version)
        {
            var    files = Directory.GetFiles(dirpath);
            string pattern;
            string verstr;

            if ((int)version < 3000)
            {
                verstr  = "AS" + ((int)version).ToString();
                pattern = "(?<asversion>" + verstr + ")_(?<name>[A-Za-z_-]+).config.json$";
            }
            else
            {
                verstr  = "RVT" + ((int)version - 90000).ToString();
                pattern = "(?<asversion>" + verstr + ")_(?<name>[A-Za-z_-]+).config.json$";
            }

            var result = new List <ZConfigEntry>();

            foreach (var filename in files)
            {
                var match = Regex.Match(filename, pattern);
                if (match.Success)
                {
                    var          jsonstr = File.ReadAllText(filename);
                    ZConfigEntry entry   = new ZConfigEntry
                    {
                        Version  = version,
                        FileName = filename,
                        Name     = Path.GetFileNameWithoutExtension(filename),
                        Config   = ZDbConfig.Deserialize(jsonstr)
                    };
                    result.Add(entry);
                }
            }

            return(result);
        }