/// <summary> /// 获取图纸信息 /// </summary> /// <param name="partNumber">零件编码</param> /// <param name="partVersion">零件版本</param> /// <returns></returns> public async Task <PartDrawingDto> GetPartDrawing(string partNumber, string partVersion) { if (string.IsNullOrWhiteSpace(partNumber)) { throw new ArgumentNullException(nameof(partNumber)); } if (string.IsNullOrWhiteSpace(partVersion)) { throw new ArgumentNullException(nameof(partVersion)); } var sourceList = await this._winchillRepository.GetByPartItem(new GetByPartItemInput { PartNumber = partNumber, PartVersion = partVersion, }); if (sourceList == null || !sourceList.Any()) { return(null); } PartDrawingDto partDrawing = PartDrawingFactory.Create(sourceList).FirstOrDefault(); return(partDrawing); }
/// <summary> /// 获取零件最新版本图纸信息 /// </summary> /// <param name="partNumber">零件编码</param> /// <returns></returns> public async Task <PartDrawingDto> GetPartDrawingLastVersion(string partNumber) { if (string.IsNullOrWhiteSpace(partNumber)) { throw new ArgumentNullException(nameof(partNumber)); } var sourceList = await this._winchillRepository.GetByPartItem(new GetByPartItemInput { PartNumber = partNumber }); if (sourceList == null || !sourceList.Any()) { return(null); } var lastPartVersions = sourceList .GroupBy(pd => pd.PartVersion) .OrderByDescending(g => g.Key) .FirstOrDefault(); PartDrawingDto partDrawing = PartDrawingFactory.Create(lastPartVersions).FirstOrDefault(); return(partDrawing); }
/// <summary> /// 序列化到XML /// </summary> public static string SerializerToXML(PartDrawingDto data) { if (data == null) { throw new ArgumentNullException(nameof(data)); } using (MemoryStream ms = new MemoryStream()) { XmlSerializer xmlser = new XmlSerializer(typeof(PartDrawingDto)); xmlser.Serialize(ms, data); ms.Position = 0; using (StreamReader sr = new StreamReader(ms)) { return(sr.ReadToEnd()); } } }