using Aspose.Words.Rendering; using BLL; using BLL.Common; using Model; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; using System.Text; using System.Transactions; using UglyToad.PdfPig; using UglyToad.PdfPig.Content; using UglyToad.PdfPig.Writer; namespace FineUIPro.Web.HJGL.DataIn { public partial class DrawingRecognitionContent : PageBase { internal const string MaterialSessionSuffix = ":DrawingRecognitionMaterials"; internal const string PipeLengthSessionSuffix = ":DrawingRecognitionPipeLengths"; public string URL { get { return (string)ViewState["URL"]; } set { ViewState["URL"] = value; } } public string fileUrl { get { return (string)ViewState["fileUrl"]; } set { ViewState["fileUrl"] = value; } } private string RecognitionDataKey { get { return (string)ViewState["RecognitionDataKey"]; } set { ViewState["RecognitionDataKey"] = value; } } private string MaterialSessionKey { get { return RecognitionDataKey + MaterialSessionSuffix; } } private string PipeLengthSessionKey { get { return RecognitionDataKey + PipeLengthSessionSuffix; } } private List MaterialEntities { get { return Session[MaterialSessionKey] as List; } set { Session[MaterialSessionKey] = value; } } private List PipeLengthEntities { get { return Session[PipeLengthSessionKey] as List; } set { Session[PipeLengthSessionKey] = value; } } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { UnitWorkService.InitUnitWorkDownList(drpUnitWork, this.CurrUser.LoginProjectId, true); RecognitionDataKey = Guid.NewGuid().ToString("N"); if (!string.IsNullOrEmpty(Request.Params["fileUrl"])) { URL = Funs.SGGLUrl + Request.Params["fileUrl"].Replace("\\", "/"); string rootPath = Server.MapPath("~/"); fileUrl = rootPath + Request.Params["fileUrl"]; // 加载PDF文档 if (!File.Exists(fileUrl)) { return; } } } } protected void btnSave_Click(object sender, EventArgs e) { DrawingRecognitionResult recognitionResult; List materialEntities; List pipeLengthEntities; Dictionary pipelinesByCode; if(drpUnitWork.SelectedValue == null|| drpUnitWork.SelectedValue==Const._Null) { Alert.ShowInTop("请选择单位工程", MessageBoxIcon.Warning); return; } try { recognitionResult = DeserializeRecognitionResult(); materialEntities = MaterialEntities; pipeLengthEntities = PipeLengthEntities; if (materialEntities == null || pipeLengthEntities == null) { throw new InvalidOperationException("实体数据已失效,请重新审核识别结果"); } // DrawingInfo 以原始页码关联 C3 管线号,并同步当前项目的管线基础信息。 pipelinesByCode = UpsertPipelinesFromDrawingInfo(recognitionResult); Funs.DB.SubmitChanges(); } catch (Exception ex) { Alert.ShowInTop("识别数据校验或管线保存失败:" + ex.Message, MessageBoxIcon.Warning); return; } Grid1.Hidden = true; Grid2.Hidden = true; contentPanel1.Hidden = false; string rootPath = Server.MapPath("~/"); // PDF 原始页与管线号的关系来自 C3,实体中的 pipe_page_no 保存的是 C1,不能替代原始页码。 Dictionary> dic = recognitionResult.OtherRegions .Where(x => x.Page.HasValue && string.Equals(x.RegionCode, "C3", StringComparison.OrdinalIgnoreCase) && !string.IsNullOrWhiteSpace(x.Text)) .GroupBy(x => x.Text.Trim(), StringComparer.OrdinalIgnoreCase) .ToDictionary( group => group.Key, group => group.Select(x => x.Page.Value).Distinct().ToList(), StringComparer.OrdinalIgnoreCase); using (var pdf = PdfDocument.Open(fileUrl)) { for (int i = 0; i < pdf.NumberOfPages; i++) { var page = pdf.GetPage(i + 1); var rotation = page.Rotation; string outputPath = ""; string isono = ""; foreach (string key in dic.Keys) { if (dic[key].IndexOf(i + 1) >= 0) { isono = key; outputPath = $"{rootPath}/File/PDF/Pipe/" + key; if (!Directory.Exists(outputPath)) { Directory.CreateDirectory(outputPath); } string fileName = key; var pipePageRegion = recognitionResult.OtherRegions.FirstOrDefault(x => x.Page == i + 1 && string.Equals(x.RegionCode, "C1", StringComparison.OrdinalIgnoreCase)); if (pipePageRegion != null) { if (!string.IsNullOrWhiteSpace(pipePageRegion.Text)) { fileName = pipePageRegion.Text.Trim(); } } outputPath = $"{outputPath}/" + fileName + DateTime.Now.ToString("yyyyMMddHHmm")+(i + 1) + ".pdf"; } } if (string.IsNullOrEmpty(outputPath)) { continue; } using (var writer = new PdfDocumentBuilder()) { PdfPageBuilder newPage = null; if (rotation.Value != 0 && rotation.Value != 180) { newPage = writer.AddPage(page.Height, page.Width); } else { newPage = writer.AddPage(page.Width, page.Height); } newPage.CopyFrom(page); // 3. 关键:清除旋转标记 + 反向旋转内容(修正视觉方向) // 清除 /Rotate 标记 newPage.SetRotation(new PageRotationDegrees(rotation.Value)); var newPdf = writer.Build(); File.WriteAllBytes(outputPath, newPdf); if (pipelinesByCode.TryGetValue(isono, out var isoInfo)) { //保存文件到附件 var attatch = AttachFileService.GetAttachFileByToKeyId(isoInfo.PipelineId); if (attatch != null) { UploadFileService.SaveAttachUrl(UploadFileService.GetSourceByAttachUrl(outputPath.Replace(rootPath, ""), 10, attatch.AttachSource), attatch.AttachUrl+","+ outputPath.Replace(rootPath, ""), Const.HJGL_PipelineMenuId, isoInfo.PipelineId); } else { UploadFileService.SaveAttachUrl(UploadFileService.GetSourceByAttachUrl(outputPath.Replace(rootPath, ""), 10, null), outputPath.Replace(rootPath, ""), Const.HJGL_PipelineMenuId, isoInfo.PipelineId); } } } } } ReplaceRecognitionDetails(materialEntities, pipeLengthEntities); List tw_InputDataIns = new List(); foreach (var item in materialEntities) { var model = new Tw_InputDataIn() { MaterialCode = item.Code, MaterialUnit = item.Unit!=null? item.Unit.Contains("M") ? "米" : "个":null, MaterialDef = item.Description, MaterialSpec = item.Spec, }; if(!tw_InputDataIns.Contains(model)) tw_InputDataIns.Add(model); } MaterialCodeLibService.AddListByDraw(tw_InputDataIns); Session.Remove(MaterialSessionKey); Session.Remove(PipeLengthSessionKey); btnSave.Hidden = true; ShowNotify("管线、材料表和管段长度表保存成功!", MessageBoxIcon.Success); } /// /// 按管线号和管线页码替换本次识别范围内的材料及管长数据。 /// private static void ReplaceRecognitionDetails( List materialEntities, List pipeLengthEntities) { var recognitionPages = materialEntities .Select(x => new { PipeNo = x.Pipe_no, PipePageNo = x.Pipe_page_no }) .Concat(pipeLengthEntities.Select(x => new { PipeNo = x.Pipe_no, PipePageNo = x.Pipe_page_no })) .ToList(); if (recognitionPages.Any(x => string.IsNullOrWhiteSpace(x.PipeNo) || !x.PipePageNo.HasValue)) { throw new InvalidOperationException("材料或管长数据存在缺少管线号、管线页码的记录"); } if (recognitionPages.Count == 0) { return; } // 两类识别结果共用替换范围,确保某页本次未识别到其中一类数据时也能清理旧记录。 var pageNumbersByPipeNo = recognitionPages .GroupBy(x => x.PipeNo.Trim(), StringComparer.OrdinalIgnoreCase) .ToDictionary( group => group.Key, group => new HashSet(group.Select(x => x.PipePageNo.Value)), StringComparer.OrdinalIgnoreCase); var pipeNumbers = pageNumbersByPipeNo.Keys.ToList(); var oldMaterials = Funs.DB.HJGL_DrawingRecognition_Material .Where(x => pipeNumbers.Contains(x.Pipe_no)) .ToList() .Where(x => IsRecognitionPage(pageNumbersByPipeNo, x.Pipe_no, x.Pipe_page_no)) .ToList(); var oldPipeLengths = Funs.DB.HJGL_DrawingRecognition_PipeLengths .Where(x => pipeNumbers.Contains(x.Pipe_no)) .ToList() .Where(x => IsRecognitionPage(pageNumbersByPipeNo, x.Pipe_no, x.Pipe_page_no)) .ToList(); using (var scope = new TransactionScope()) { Funs.DB.HJGL_DrawingRecognition_Material.DeleteAllOnSubmit(oldMaterials); Funs.DB.HJGL_DrawingRecognition_PipeLengths.DeleteAllOnSubmit(oldPipeLengths); Funs.DB.SubmitChanges(); Funs.DB.HJGL_DrawingRecognition_Material.InsertAllOnSubmit(materialEntities); Funs.DB.HJGL_DrawingRecognition_PipeLengths.InsertAllOnSubmit(pipeLengthEntities); Funs.DB.SubmitChanges(); scope.Complete(); } } private static bool IsRecognitionPage( Dictionary> pageNumbersByPipeNo, string pipeNo, int? pipePageNo) { return !string.IsNullOrWhiteSpace(pipeNo) && pipePageNo.HasValue && pageNumbersByPipeNo.TryGetValue(pipeNo.Trim(), out var pageNumbers) && pageNumbers.Contains(pipePageNo.Value); } public static string HeaderCorrespondence(string uploadUrl, string data, string method, string contenttype) { // 5. 创建HTTP请求 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uploadUrl); request.Method = string.IsNullOrEmpty(method) ? "GET" : method; request.ContentType = string.IsNullOrEmpty(contenttype) ? "application/json;charset=utf-8" : contenttype; if (uploadUrl.IndexOf("https") >= 0) { request.ProtocolVersion = HttpVersion.Version10; } if (!string.IsNullOrEmpty(data)) { Stream RequestStream = request.GetRequestStream(); byte[] bytes = Encoding.UTF8.GetBytes(data); RequestStream.Write(bytes, 0, bytes.Length); RequestStream.Close(); } HttpWebResponse response = null; Stream ResponseStream = null; StreamReader StreamReader = null; try { response = (HttpWebResponse)request.GetResponse(); ResponseStream = response.GetResponseStream(); StreamReader = new StreamReader(ResponseStream, Encoding.GetEncoding("utf-8")); string re = StreamReader.ReadToEnd(); StreamReader.Close(); ResponseStream.Close(); return re; } catch (WebException ex) { response = (HttpWebResponse)ex.Response; ResponseStream = response.GetResponseStream(); StreamReader = new StreamReader(ResponseStream, Encoding.GetEncoding("utf-8")); string re = StreamReader.ReadToEnd(); return re; } finally { if (StreamReader != null) { StreamReader.Close(); } if (ResponseStream != null) { ResponseStream.Close(); } if (response != null) { response.Close(); } } } protected void btnAudit_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(resultdata.Value)) { try { var recognitionResult = DeserializeRecognitionResult(); var pageRegions = BuildPageRegionMap(recognitionResult.OtherRegions); MaterialEntities = MapMaterialEntities(recognitionResult.MaterialRows, pageRegions); PipeLengthEntities = MapPipeLengthEntities(recognitionResult.PipeLengthRows, pageRegions); } catch (Exception ex) { Alert.ShowInTop("识别结果解析失败:" + ex.Message, MessageBoxIcon.Warning); return; } Grid1.Hidden = false; Grid2.Hidden = false; contentPanel1.Hidden = true; btnAudit.Hidden = true; btnSave.Hidden = false; BindGrids(); } } private DrawingRecognitionResult DeserializeRecognitionResult() { if (string.IsNullOrWhiteSpace(resultdata.Value)) { throw new InvalidOperationException("识别结果为空"); } var recognitionResult = JsonConvert.DeserializeObject(resultdata.Value); if (recognitionResult == null) { throw new InvalidOperationException("识别结果格式不正确"); } recognitionResult.MaterialRows = recognitionResult.MaterialRows ?? new List(); recognitionResult.PipeLengthRows = recognitionResult.PipeLengthRows ?? new List(); recognitionResult.OtherRegions = recognitionResult.OtherRegions ?? new List(); recognitionResult.DrawingInfo = recognitionResult.DrawingInfo ?? new List(); return recognitionResult; } /// /// 构建原始页码与识别区域的映射,供 C1、C3 等区域统一取值。 /// private static Dictionary> BuildPageRegionMap( IEnumerable otherRegions) { // 同一页以 region_code 区分 C1 管线页码和 C3 管线号,避免依赖区域返回顺序。 return otherRegions .Where(x => x != null && x.Page.HasValue && !string.IsNullOrWhiteSpace(x.RegionCode)) .GroupBy(x => x.Page.Value) .ToDictionary( pageGroup => pageGroup.Key, pageGroup => pageGroup .GroupBy(x => x.RegionCode.Trim(), StringComparer.OrdinalIgnoreCase) .ToDictionary( regionGroup => regionGroup.Key, regionGroup => regionGroup.Select(x => x.Text).FirstOrDefault(), StringComparer.OrdinalIgnoreCase)); } private static string GetPageRegionValueOrDefault( Dictionary> pageRegions, int? pageNo, string regionCode) { if (!pageNo.HasValue || !pageRegions.TryGetValue(pageNo.Value, out var regions) || !regions.TryGetValue(regionCode, out var value) || string.IsNullOrWhiteSpace(value)) { return null; } return value.Trim(); } private static string GetRequiredPageRegionValue( Dictionary> pageRegions, int? pageNo, string regionCode) { if (!pageNo.HasValue) { throw new InvalidOperationException("存在缺少 page_no 的识别数据"); } string value = GetPageRegionValueOrDefault(pageRegions, pageNo, regionCode); if (string.IsNullOrEmpty(value)) { throw new InvalidOperationException(string.Format("第 {0} 页未识别到区域 {1}", pageNo.Value, regionCode)); } return value; } /// /// 获取 C1 中的管线页码,并校验其必须为整数。 /// private static int GetRequiredPipePageNo( Dictionary> pageRegions, int? sourcePageNo) { string pipePageNoText = GetRequiredPageRegionValue(pageRegions, sourcePageNo, "C1"); if (!int.TryParse(pipePageNoText, out var pipePageNo)) { throw new InvalidOperationException(string.Format("第 {0} 页区域 C1 的值“{1}”不是有效整数", sourcePageNo, pipePageNoText)); } return pipePageNo; } /// /// 根据识别数据的原始页码获取 C3 管线号。 /// private static string GetPipelineCodeByPageNo( Dictionary> pageRegions, int? pageNo) { // 管线号统一通过原始页码匹配 C3,避免各类识别数据重复实现映射逻辑。 return GetRequiredPageRegionValue(pageRegions, pageNo, "C3"); } /// /// 将材料识别结果映射为待保存的材料实体。 /// private static List MapMaterialEntities( IEnumerable materialRows, Dictionary> pageRegions) { return materialRows.Select(row => new HJGL_DrawingRecognition_Material { Id = SQLHelper.GetNewID(), Pipe_no = GetPipelineCodeByPageNo(pageRegions, row.PageNo), Pipe_page_no = GetRequiredPipePageNo(pageRegions, row.PageNo), Seq_no = GetNullableInt(row.SeqNo), Category = row.Category, Description = row.Description, Spec = row.Spec, Code = row.Code, Qty = row.Qty, Unit = row.Unit, Material = row.Material, Drawing_number = row.DrawingNumber, Remark = row.Remark }).ToList(); } /// /// 将管段长度识别结果映射为待保存的管段长度实体。 /// private static List MapPipeLengthEntities( IEnumerable pipeLengthRows, Dictionary> pageRegions) { return pipeLengthRows.Select(row => new HJGL_DrawingRecognition_PipeLengths { Id = SQLHelper.GetNewID(), Pipe_no = GetPipelineCodeByPageNo(pageRegions, row.PageNo), Pipe_page_no = GetRequiredPipePageNo(pageRegions, row.PageNo), Group_index = row.GroupIndex, Pos_no = row.PosNo, Length_mm = row.LengthMm, Dn = row.Dn }).ToList(); } private static int? GetNullableInt(object value) { return int.TryParse(Convert.ToString(value), out var number) ? number : (int?)null; } /// /// 按当前项目和管线号新增或更新管线,仅同步 DrawingInfo 中识别到的字段。 /// private Dictionary UpsertPipelinesFromDrawingInfo( DrawingRecognitionResult recognitionResult) { var pageRegions = BuildPageRegionMap(recognitionResult.OtherRegions); var pipelineDrawingData = BuildPipelineDrawingData(recognitionResult.DrawingInfo, pageRegions); if (pipelineDrawingData.Count == 0) { throw new InvalidOperationException("未从区域 C3 识别到管线号"); } var pipelineCodes = pipelineDrawingData.Keys.ToList(); var existingPipelines = Funs.DB.HJGL_Pipeline .Where(x => x.ProjectId == CurrUser.LoginProjectId && pipelineCodes.Contains(x.PipelineCode)) .ToList(); var duplicatePipeline = existingPipelines .GroupBy(x => x.PipelineCode, StringComparer.OrdinalIgnoreCase) .FirstOrDefault(group => group.Count() > 1); if (duplicatePipeline != null) { throw new InvalidOperationException("当前项目存在重复管线号:" + duplicatePipeline.Key); } var pipelinesByCode = existingPipelines.ToDictionary( x => x.PipelineCode, StringComparer.OrdinalIgnoreCase); // HJGL_Pipeline 保存 PipingClassId,识别到的等级编码必须先按当前项目批量转换。 var pipingClassCodes = pipelineDrawingData.Values .Select(x => x.PipingClassCode) .Where(x => !string.IsNullOrWhiteSpace(x)) .Distinct(StringComparer.OrdinalIgnoreCase) .ToList(); var pipingClasses = Funs.DB.Base_PipingClass .Where(x => x.ProjectId == CurrUser.LoginProjectId && pipingClassCodes.Contains(x.PipingClassCode)) .ToList() .GroupBy(x => x.PipingClassCode, StringComparer.OrdinalIgnoreCase) .ToDictionary(group => group.Key, group => group.First(), StringComparer.OrdinalIgnoreCase); var missingPipingClassCodes = pipingClassCodes .Where(code => !pipingClasses.ContainsKey(code)) .ToList(); if (missingPipingClassCodes.Count > 0) { throw new InvalidOperationException( "当前项目不存在以下管道等级:" + string.Join("、", missingPipingClassCodes)); } foreach (var item in pipelineDrawingData) { if (!pipelinesByCode.TryGetValue(item.Key, out var pipeline)) { pipeline = new HJGL_Pipeline { PipelineId = SQLHelper.GetNewID(), ProjectId = CurrUser.LoginProjectId, PipelineCode = item.Key, UnitWorkId= drpUnitWork.SelectedValue }; Funs.DB.HJGL_Pipeline.InsertOnSubmit(pipeline); pipelinesByCode.Add(item.Key, pipeline); } // 识别结果为空时保留已有值,避免不完整识别覆盖管线原数据。 if (!string.IsNullOrWhiteSpace(item.Value.PipingClassCode)) { pipeline.PipingClassId = pipingClasses[item.Value.PipingClassCode].PipingClassId; } if (!string.IsNullOrWhiteSpace(item.Value.DesignPress)) { pipeline.DesignPress = item.Value.DesignPress; } if (!string.IsNullOrWhiteSpace(item.Value.DesignTemperature)) { pipeline.DesignTemperature = item.Value.DesignTemperature; } if (item.Value.DesignIsHotProess.HasValue) { pipeline.DesignIsHotProess = item.Value.DesignIsHotProess; } } return pipelinesByCode; } /// /// 按页码取得管线号后聚合 DrawingInfo,同一管线跨页数据合并处理。 /// private static Dictionary BuildPipelineDrawingData( IEnumerable drawingInfo, Dictionary> pageRegions) { // 同一管线可能对应多个 PDF 页,按 C3 管线号分组后统一校验和取值。 var pipelineGroups = drawingInfo .Where(x => x != null) .GroupBy( x => GetPipelineCodeByPageNo(pageRegions, x.PageNo), StringComparer.OrdinalIgnoreCase); var result = new Dictionary(StringComparer.OrdinalIgnoreCase); foreach (var pipelineGroup in pipelineGroups) { string pwht = GetUniqueDrawingFieldValue( pipelineGroup, pipelineGroup.Key, "PWHT"); result.Add(pipelineGroup.Key, new PipelineDrawingData { PipingClassCode = GetUniqueDrawingFieldValue( pipelineGroup, pipelineGroup.Key, "Piping class"), DesignPress = GetUniqueDrawingFieldValue( pipelineGroup, pipelineGroup.Key, "Design pressure, MPag"), DesignTemperature = GetUniqueDrawingFieldValue( pipelineGroup, pipelineGroup.Key, "Design temperature", true), DesignIsHotProess = string.IsNullOrWhiteSpace(pwht) ? (bool?)null : ParsePwht(pwht, pipelineGroup.Key) }); } return result; } /// /// 获取管线字段的唯一非空值;跨页识别值不一致时阻止保存。 /// private static string GetUniqueDrawingFieldValue( IEnumerable rows, string pipelineCode, string fieldName, bool startsWith = false) { var values = rows .Where(x => !string.IsNullOrWhiteSpace(x.FieldName) && (startsWith ? x.FieldName.Trim().StartsWith(fieldName, StringComparison.OrdinalIgnoreCase) : string.Equals(x.FieldName.Trim(), fieldName, StringComparison.OrdinalIgnoreCase))) .Select(x => x.FieldValue == null ? null : x.FieldValue.Trim()) .Where(x => !string.IsNullOrWhiteSpace(x)) .Distinct(StringComparer.OrdinalIgnoreCase) .ToList(); if (values.Count > 1) { throw new InvalidOperationException(string.Format( "管线“{0}”的字段“{1}”识别值不一致:{2}", pipelineCode, fieldName, string.Join("、", values))); } return values.FirstOrDefault(); } /// /// 将识别结果中的 PWHT Yes/No 标记转换为是否需要焊后热处理。 /// private static bool ParsePwht(string value, string pipelineCode) { string normalizedValue = value.Trim(); if (normalizedValue.IndexOf("(Yes)", StringComparison.OrdinalIgnoreCase) >= 0 || string.Equals(normalizedValue, "Yes", StringComparison.OrdinalIgnoreCase) || string.Equals(normalizedValue, "Y", StringComparison.OrdinalIgnoreCase) || string.Equals(normalizedValue, "1", StringComparison.OrdinalIgnoreCase) || string.Equals(normalizedValue, "是", StringComparison.OrdinalIgnoreCase) || string.Equals(normalizedValue, "True", StringComparison.OrdinalIgnoreCase)) { return true; } if (normalizedValue.IndexOf("(No)", StringComparison.OrdinalIgnoreCase) >= 0 || string.Equals(normalizedValue, "No", StringComparison.OrdinalIgnoreCase) || string.Equals(normalizedValue, "N", StringComparison.OrdinalIgnoreCase) || string.Equals(normalizedValue, "0", StringComparison.OrdinalIgnoreCase) || string.Equals(normalizedValue, "否", StringComparison.OrdinalIgnoreCase) || string.Equals(normalizedValue, "False", StringComparison.OrdinalIgnoreCase)) { return false; } throw new InvalidOperationException(string.Format( "管线“{0}”的 PWHT 值“{1}”无法识别为是或否", pipelineCode, value)); } private sealed class PipelineDrawingData { public string PipingClassCode { get; set; } public string DesignPress { get; set; } public string DesignTemperature { get; set; } public bool? DesignIsHotProess { get; set; } } private void BindGrids() { Grid1.DataSource = MaterialEntities ?? new List(); Grid1.DataBind(); Grid2.DataSource = PipeLengthEntities ?? new List(); Grid2.DataBind(); } #region 双击事件 /// /// Grid行双击事件 /// /// /// protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning); return; } if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.HJGL_DataInMenuId, Const.BtnAdd)) { if (MaterialEntities == null) { Alert.ShowInTop("实体数据已失效,请重新审核识别结果!", MessageBoxIcon.Warning); return; } string editUrl = string.Format( "DrawingRecognitionContentEdit.aspx?Index={0}&DataKey={1}", Grid1.SelectedRowIndex, RecognitionDataKey); PageContext.RegisterStartupScript( Window1.GetSaveStateReference(hdIds.ClientID) + Window1.GetShowReference(editUrl)); } else { ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); } } #endregion protected void Window1_Close(object sender, WindowCloseEventArgs e) { BindGrids(); } } }