Exemplo n.º 1
0
 static void WriteRevitInfo(RevitFileInfo revitFileInfo, string logFilePath)
 {
     using (System.IO.StreamWriter file = new System.IO.StreamWriter(logFilePath, true))
     {
         try
         {
             file.WriteLine(revitFileInfo.ToCSV());
         }
         catch (Exception ex)
         {
             WriteError("Error writing to the CSV file: " + logFilePath + " - " + ex.Message, logFilePath);
         }
     }
 }
Exemplo n.º 2
0
        public static RevitFileInfo GetRevitFileInfo(string path)
        {
            try
            {
                RevitFileInfo rfi = new RevitFileInfo();
                rfi.FileName = path;

                if (!DesignFile.Info.BasicFileInfo.StructuredStorageUtils.IsFileStucturedStorage(path))
                {
                    throw new NotSupportedException(
                              "File is not a structured storage file");
                }

                var rawData = DesignFile.Info.BasicFileInfo.GetRawBasicFileInfo(path);

                var rawString = System.Text.Encoding.Unicode
                                .GetString(rawData);

                var fileInfoData = rawString.Split(
                    new string[] { "\0", "\r\n" },
                    StringSplitOptions.RemoveEmptyEntries);

                foreach (var info in fileInfoData)
                {
                    rfi.RawData += info;
                    if (info.Contains("sharing:"))
                    {
                        int i = info.IndexOf("sharing: ") + 9;
                        rfi.IsCentral = (info.Substring(i, info.Length - i) == "Central");
                    }
                    ;
                    if (info.Contains("Central Model Path"))
                    {
                        rfi.CentralFileName = info.Substring(19);
                    }
                    ;
                    if (info.Contains("Revit Build:"))
                    {
                        rfi.Version = info.Substring(13);
                    }
                    ;
                }

                rawString = System.Text.Encoding.BigEndianUnicode
                            .GetString(rawData);

                fileInfoData = rawString.Split(
                    new string[] { "\0", "\r\n" },
                    StringSplitOptions.RemoveEmptyEntries);

                foreach (var info in fileInfoData)
                {
                    rfi.RawData += info;
                    if (info.Contains("sharing:"))
                    {
                        int i = info.IndexOf("sharing: ") + 9;
                        rfi.IsCentral = (info.Substring(i, info.Length - i) == "Central");
                    }
                    ;
                    if (info.Contains("Central Model Path"))
                    {
                        rfi.CentralFileName = info.Substring(19);
                    }
                    ;
                    if (info.Contains("Revit Build:"))
                    {
                        rfi.Version = info.Substring(13);
                    }
                    ;
                }

                rfi.Links = GetLinks(rfi.FileName);

                return(rfi);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }