示例#1
0
        public long GetFileSize()
        {
            long fileSize = 0;

            try
            {
                if (DocCentralPath.StartsWith("C:", StringComparison.OrdinalIgnoreCase))
                {
                    return(fileSize);
                }

                if (!string.IsNullOrEmpty(DocLocalPath))
                {
                    var fileInfo = new FileInfo(DocLocalPath);
                    fileSize = fileInfo.Length / 1024;
                }
            }
            catch
            {
                fileSize = 0;
            }
            return(fileSize);
        }
示例#2
0
        private void DoSetup()
        {
            _prefixes.Add("E-CAD", "E-CAD");
            _prefixes.Add("E-BIM", "E-BIM");
            _prefixes.Add("REVIT", "REVIT");
            _prefixes.Add("E-Design", "E-Design");

            // Get ProjectName and ProjectNumber
            if (!string.IsNullOrEmpty(DocCentralPath))
            {
                try
                {
                    const string regPattern = @"[\\|/](\d{2}\.\d{5}\.\d{2})\s+(.+?(?=[\\|/]))";
                    var          regex      = new Regex(regPattern, RegexOptions.IgnoreCase);
                    var          match      = regex.Match(DocCentralPath);
                    if (match.Success)
                    {
                        ProjectNumber = match.Groups[1].Value;
                        ProjectName   = match.Groups[2].Value;
                    }
                }
                catch
                {
                    // ignored
                }

                if (string.IsNullOrEmpty(ProjectNumber))
                {
                    ProjectName = GetProjectName(DocCentralPath);
                    const string projectNumberRegPattern = @"\d{2}\.\d{5}\.\d{2}";
                    var          regex = new Regex(projectNumberRegPattern);
                    var          match = regex.Match(Doc.ProjectInformation.Number);
                    if (match.Success)
                    {
                        ProjectNumber = match.Value;
                    }
                    else
                    {
                        ProjectNumber = "00.00000.00";
                    }

                    if (DocCentralPath.StartsWith(@"\\GROUP\HOK", StringComparison.OrdinalIgnoreCase) ||
                        DocCentralPath.StartsWith("RSN://", StringComparison.OrdinalIgnoreCase) ||
                        DocCentralPath.StartsWith("BIM 360://", StringComparison.OrdinalIgnoreCase))
                    {
                        IsRecordable = true;
                    }
                    else
                    {
                        IsRecordable = false;
                    }
                }
            }

            //Get Project Location: Longitude, Latitude
            try
            {
                var projectLocation = Doc.ActiveProjectLocation;
#if RELEASE2015 || RELEASE2016 || RELEASE2017 || RELEASE2018
                var site = projectLocation.SiteLocation;
#else
                var site = projectLocation.GetSiteLocation();
#endif
                const double angleRatio = Math.PI / 180;
                ProjectLatitude  = site.Latitude / angleRatio;
                ProjectLongitude = site.Longitude / angleRatio;
            }
            catch
            {
                // ignored
            }

            //Get File Location
            try
            {
                FileLocation      = GetFileLocation(DocCentralPath);
                LocalFileLocation = GetFileLocation(DocLocalPath);
            }
            catch
            {
                // ignored
            }

            //Get Version Number
            try
            {
                VersionNumber = Doc.Application.VersionNumber;
            }
            catch
            {
                // ignored
            }
        }