private void GetProjectInfo() { try { if (string.IsNullOrEmpty(DocCentralPath)) { return; } try { const string regPattern = @"\\([0-9]{2}[\.|\-][0-9]{4,5}[\.|\-][0-9]{2})(.*?)\\"; 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 (Exception ex) { Log.AppendLog(LogMessageType.EXCEPTION, ex.Message); } if (string.IsNullOrEmpty(ProjectNumber)) { var paths = DocCentralPath.Split('\\'); //Find E-BIM or E-CAD and get preceding values for (var i = 0; i < paths.Length; i++) { if (!prefixes.Contains(paths[i])) { continue; } ProjectName = paths[i - 1]; break; } ProjectNumber = "00.00000.00"; } var regServer = new Regex(@"^\\\\group\\hok\\(.+?(?=\\))|^\\\\(.{2,3})-\d{2}svr(\.group\.hok\.com)?\\", RegexOptions.IgnoreCase); var regMatch = regServer.Match(DocCentralPath); if (regMatch.Success) { FileLocation = string.IsNullOrEmpty(regMatch.Groups[1].Value) ? regMatch.Groups[2].Value : regMatch.Groups[1].Value; } } catch (Exception ex) { Log.AppendLog(LogMessageType.EXCEPTION, ex.Message); } }
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); }
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 } }