SGGL_SHJ/SGGL/FineUIPro.Web/HJGL/WeldingManage/PipelineListPDMSIn.aspx.cs

1346 lines
62 KiB
C#
Raw Normal View History

2022-09-05 16:36:31 +08:00
using BLL;
2022-10-13 18:52:45 +08:00
using MiniExcelLibs;
2022-09-05 16:36:31 +08:00
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
namespace FineUIPro.Web.HJGL.WeldingManage
{
public partial class PipelineListPDMSIn : PageBase
{
#region
/// <summary>
/// 上传预设的虚拟路径
/// </summary>
private string initPath = Const.ExcelUrl;
/// <summary>
/// 安装组件集合
/// </summary>
public static List<Model.View_HJGL_WeldJoint> PipelineList = new List<Model.View_HJGL_WeldJoint>();
/// <summary>
/// 错误集合
/// </summary>
public static string errorInfos = string.Empty;
/// <summary>
/// 导入数据分类(管线)
/// </summary>
public static string DataClassification = "Pipeline";
public enum ButtonState { Check = 0, Import = 1, Save = 2 }
public static int State;
#endregion
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.hdFileName.Text = string.Empty;
State = (int)ButtonState.Check;
if (PipelineList != null)
{
PipelineList.Clear();
}
errorInfos = string.Empty;
lbVersion.Text = BLL.HJGL_DesignBasisDataImportService.GetNowVersionByUnitWorkId(Request.Params["UnitWorkId"], DataClassification).ToString();
BindGrid2();
}
}
#endregion
void BindGrid2()
{
string strSql = @" select Import.DesignBasisDataImportId
,Import.ProjectId
,Import.UnitWorkId
,(Case Import.ImportType when '0' then ''
when '1' then '' end) as ImportType
,Import.FileName
,Import.FilePath
,Import.DataClassification
,Import.FileType
,Import.FileSize
,Import.FileId
,Import.Version
,Import.Remark
,Import.CreateMan
,Import.CreateDate
, Users.PersonName
from HJGL_DesignBasisDataImport as Import
left join Person_Persons as Users on Users.PersonId=Import.CreateMan
where Import.UnitWorkId=@UnitWorkId and Import.ProjectId=@ProjectId and Import.DataClassification=@DataClassification
order by Import.CreateDate";
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
listStr.Add(new SqlParameter("@UnitWorkId", Request.Params["UnitWorkId"]));
listStr.Add(new SqlParameter("@DataClassification", DataClassification));
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
// 2.获取当前分页数据
//var table = this.GetPagedDataTable(Grid1, tb1);
Grid2.RecordCount = tb.Rows.Count;
tb = GetFilteredTable(Grid2.FilteredData, tb);
var table = this.GetPagedDataTable(Grid2, tb);
Grid2.DataSource = table;
Grid2.DataBind();
2023-11-23 16:50:57 +08:00
drpVersion.DataSource = BLL.HJGL_DesignBasisDataImportService.GetListVersionByUnitWorkId(Request.Params["UnitWorkId"], DataClassification);
2022-09-05 16:36:31 +08:00
drpVersion.DataBind();
}
#region
/// <summary>
/// 审核
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAudit_Click(object sender, EventArgs e)
{
try
{
if (this.fuAttachUrl.HasFile == false)
{
ShowNotify("请您选择Excel文件", MessageBoxIcon.Warning);
return;
}
string IsXls = Path.GetExtension(this.fuAttachUrl.FileName).ToString().Trim().ToLower();
2022-10-13 18:52:45 +08:00
if (IsXls != ".xlsx")
2022-09-05 16:36:31 +08:00
{
ShowNotify("只可以选择Excel文件", MessageBoxIcon.Warning);
return;
}
if (PipelineList != null)
{
PipelineList.Clear();
}
if (!string.IsNullOrEmpty(errorInfos))
{
errorInfos = string.Empty;
}
string rootPath = Server.MapPath("~/");
string initFullPath = rootPath + initPath;
if (!Directory.Exists(initFullPath))
{
Directory.CreateDirectory(initFullPath);
}
this.hdFileName.Text = BLL.Funs.GetNewFileName() + IsXls;
string filePath = initFullPath + this.hdFileName.Text;
this.fuAttachUrl.PostedFile.SaveAs(filePath);
ImportXlsToData(rootPath + initPath + this.hdFileName.Text);
}
catch (Exception ex)
{
2022-12-18 22:40:49 +08:00
Alert alert = new Alert
{
Message = "'" + ex.Message + "'",
Target = Target.Self
};
alert.Show();
2022-09-05 16:36:31 +08:00
}
}
#region Excel提取数据
/// <summary>
/// 从Excel提取数据--》Dataset
/// </summary>
/// <param name="filename">Excel文件路径名</param>
private void ImportXlsToData(string fileName)
{
try
{
var ds = MiniExcel.Query(fileName).ToList();
2023-11-23 16:50:57 +08:00
var columns = MiniExcel.GetColumns(fileName);
var cnt = columns.Count;
var reposedata = AddDatasetToSQL(ds, cnt);
if (reposedata.code == 1)
2022-09-05 16:36:31 +08:00
{
State = (int)ButtonState.Import;
ShowNotify("审核完成请点击导入");
}
else
{
2022-12-18 22:40:49 +08:00
Alert alert = new Alert
{
Message = reposedata.message,
Target = Target.Self
};
alert.Show();
//ShowNotify(reposedata.message);
2022-09-05 16:36:31 +08:00
}
}
catch (Exception exc)
{
2022-12-07 17:19:30 +08:00
ErrLogInfo.WriteLog("焊接基础数据上传失败!", exc);
2022-09-05 16:36:31 +08:00
}
}
2023-07-07 16:19:46 +08:00
#endregion
2023-11-23 16:50:57 +08:00
2023-07-07 16:19:46 +08:00
#region Dataset的数据导入数据库
/// <summary>
/// 将Dataset的数据导入数据库
/// </summary>
/// <param name="pds">数据集</param>
/// <param name="Cols">数据集行数</param>
/// <returns></returns>
private Model.ResponeData AddDatasetToSQL(List<dynamic> pds, int count)
{
Model.ResponeData responeData = new Model.ResponeData();
2023-11-23 16:50:57 +08:00
// string result = string.Empty;
List<string> result = new List<string>();
//pds = BLL.Funs.FilterBlankLines(pds);
if (count < 28)
{
responeData.code = 0;
responeData.message = "导入Excel格式错误Excel只有" + count.ToString().Trim() + "列";
return responeData;
}
if (pds.Count > 0 && pds != null)
{
2023-11-26 17:43:05 +08:00
Model.SGGLDB db = Funs.DB;
var getPipeline = from x in db.View_HJGL_WeldJoint where x.ProjectId == this.CurrUser.LoginProjectId select x;
var getMedium = from x in db.Base_Medium where x.ProjectId == this.CurrUser.LoginProjectId select x;//介质
var getPipeLineClass = from x in db.Base_PipingClass where x.ProjectId == this.CurrUser.LoginProjectId select x;//管道等级
var getDetectionRate = from x in db.Base_DetectionRate select x;//探伤比例
var getDetectionType = from x in db.Base_DetectionType select x;//探伤类型
var getPressurePipingClass = from x in db.Base_PressurePipingClass select x;//压力管道级别
var getTestMedium = from x in db.Base_TestMedium where x.TestType == "1" select x;//压力试验介质
var getLeakMedium = from x in db.Base_TestMedium where x.TestType == "2" select x;//泄露性试验介质
var getPurgeMethod = from x in db.Base_PurgeMethod select x;
var getMaterial = from x in db.Base_Material select x;
var getWeldType = from x in db.Base_WeldType select x;
//var getComponents = from x in Funs.DB.Base_Components where x.ProjeceId == this.CurrUser.LoginProjectId select x;
2023-11-26 17:43:05 +08:00
Model.WBS_UnitWork unitWork = BLL.UnitWorkService.GetUnitWorkByUnitWorkId(Request.Params["UnitWorkId"]);
for (int i = 1; i < pds.Count; i++)
{
Model.View_HJGL_WeldJoint pipeline = new Model.View_HJGL_WeldJoint();
//pipeline.PipelineId = SQLHelper.GetNewID();
2023-11-26 17:43:05 +08:00
if (unitWork != null)
{
pipeline.UnitWorkId = Request.Params["UnitWorkId"];
pipeline.UnitId = unitWork.UnitId;
}
2022-11-18 18:04:38 +08:00
string col0 = pds[i].A;
string pipeLineId = string.Empty;
if (string.IsNullOrEmpty(col0))
{
2023-11-23 16:50:57 +08:00
result.Add("第" + (i + 1).ToString() + "行," + "管线号" + "," + "此项为必填项!" + "|");
}
else
{
pipeline.PipelineCode = col0;
}
2022-11-18 18:04:38 +08:00
pipeline.SingleNumber = pds[i].B;
pipeline.SingleName = pds[i].C;
2022-11-18 18:04:38 +08:00
string col3 = pds[i].D;
if (string.IsNullOrEmpty(col3))
{
2023-10-24 17:38:20 +08:00
result.Add("第" + (i + 1).ToString() + "行," + "介质代号" + "," + "此项为必填项!" + "|");
}
else
{
2023-10-24 17:38:20 +08:00
var Medium = getMedium.FirstOrDefault(x => x.MediumCode == col3);
if (Medium == null)
{
2023-11-23 16:50:57 +08:00
// result += "第" + (i + 1).ToString() + "行," + "该介质不存在!" + "|";
result.Add(col3 + "-该介质不存在!" + "|");
}
else
{
pipeline.MediumId = Medium.MediumId;
pipeline.MediumName = col3;
}
}
2022-11-18 18:04:38 +08:00
string col4 = pds[i].E;
if (string.IsNullOrEmpty(col4))
{
result.Add("第" + (i + 1).ToString() + "行," + "管道等级" + "," + "此项为必填项!" + "|");
}
else
{
var PipeLineClass = getPipeLineClass.FirstOrDefault(x => x.PipingClassCode == col4);
if (PipeLineClass == null)
{
2023-11-23 16:50:57 +08:00
// result += "第" + (i + 1).ToString() + "行," + "该管道等级不存在!" + "|";
result.Add(col4 + "-该管道等级不存在!" + "|");
}
else
{
pipeline.PipingClassId = PipeLineClass.PipingClassId;
pipeline.PipingClassCode = col4;
}
}
2022-11-18 18:04:38 +08:00
string col5 = pds[i].F;
if (!string.IsNullOrEmpty(col5))
{
var DetectionRate = getDetectionRate.FirstOrDefault(x => x.DetectionRateValue.ToString() == col5.Replace("%", "") || x.DetectionRateCode == col5);
if (DetectionRate == null)
{
2023-11-23 16:50:57 +08:00
// result += "第" + (i + 1).ToString() + "行," + "该探伤比例不存在!" + "|";
result.Add(col5 + "-该探伤比例不存在!" + "|");
}
else
{
pipeline.DetectionRateId = DetectionRate.DetectionRateId;
pipeline.DetectionRateCode = col5;
}
}
else
{
result.Add("第" + (i + 1).ToString() + "行," + "探伤比例" + "," + "此项为必填项!" + "|");
}
2022-11-18 18:04:38 +08:00
string col6 = pds[i].G;
if (!string.IsNullOrEmpty(col6))
{
2023-11-23 16:50:57 +08:00
string typeStr = col6.ToString();
var type = getDetectionType.FirstOrDefault(x => x.DetectionTypeCode == typeStr);
if (type == null)
{
2023-11-23 16:50:57 +08:00
//result += "第" + (i + 1).ToString() + "行," + "探伤类型【" + t + "】不存在!" + "|";
result.Add("探伤类型【" + typeStr + "】不存在!" + "|");
}
2023-11-23 16:50:57 +08:00
else
{
2023-11-23 16:50:57 +08:00
pipeline.DetectionType = type.DetectionTypeId;
pipeline.DetectionTypeStr = col6;
}
}
else
{
result.Add("第" + (i + 1).ToString() + "行," + "探伤类型" + "," + "此项为必填项!" + "|");
}
2023-04-16 14:56:34 +08:00
string col7 = Convert.ToString(pds[i].H);
if (!string.IsNullOrEmpty(col7))
{
pipeline.DesignTemperature = col7;
}
2023-04-16 14:56:34 +08:00
string col8 = Convert.ToString(pds[i].I);
if (!string.IsNullOrEmpty(col8))
{
pipeline.DesignPress = col8;
}
2023-04-16 14:56:34 +08:00
string col9 = Convert.ToString(pds[i].J);
if (!string.IsNullOrEmpty(col9))
{
var TestMedium = getTestMedium.FirstOrDefault(x => x.MediumName == col9);
if (TestMedium == null)
{
//result += "第" + (i + 1).ToString() + "行," + "该压力试验介质不存在!" + "|";
result.Add(col9 + "-该压力试验介质不存在!" + "|");
}
else
{
pipeline.TestMedium = TestMedium.TestMediumId;
pipeline.TestMediumName = col9;
}
}
2023-04-16 14:56:34 +08:00
string col10 = Convert.ToString(pds[i].K);
if (!string.IsNullOrEmpty(col10))
{
pipeline.TestPressure = col10;
}
2023-04-16 14:56:34 +08:00
string col11 = Convert.ToString(pds[i].L);
if (!string.IsNullOrEmpty(col11))
{
var PressurePipingClass = getPressurePipingClass.FirstOrDefault(x => x.PressurePipingClassCode == col11);
if (PressurePipingClass == null)
{
2023-11-23 16:50:57 +08:00
// result += "第" + (i + 1).ToString() + "行," + "该压力管道级别不存在!" + "|";
result.Add(col11 + "-该压力管道级别不存在!" + "|");
}
else
{
pipeline.PressurePipingClassId = PressurePipingClass.PressurePipingClassId;
pipeline.PressurePipingClassCode = col11;
}
}
2023-04-16 14:56:34 +08:00
string col12 = Convert.ToString(pds[i].M);
if (!string.IsNullOrEmpty(col12))
{
try
{
var PipeLenth = Funs.GetNewDecimal(col12);
pipeline.PipeLenth = PipeLenth;
}
catch (Exception)
{
result.Add("第" + (i + 1).ToString() + "行," + "管线长度(m)格式输入有误" + "|");
}
}
2023-04-16 14:56:34 +08:00
string col13 = Convert.ToString(pds[i].N);
if (!string.IsNullOrEmpty(col13))
{
var LeakMedium = getLeakMedium.FirstOrDefault(x => x.MediumName == col13);
if (LeakMedium == null)
{
//result += "第" + (i + 1).ToString() + "行," + "该泄露试验介质不存在!" + "|";
result.Add(col13 + "-该泄露试验介质不存在!" + "|");
}
else
{
pipeline.LeakMedium = LeakMedium.TestMediumId;
pipeline.LeakMediumName = col13;
}
}
2023-04-16 14:56:34 +08:00
string col14 = Convert.ToString(pds[i].O);
if (!string.IsNullOrEmpty(col14))
{
pipeline.LeakPressure = col14;
}
2023-04-16 14:56:34 +08:00
string col15 = Convert.ToString(pds[i].P);
if (!string.IsNullOrEmpty(col15))
{
var PurgeMethod = getPurgeMethod.FirstOrDefault(x => x.PurgeMethodCode == col15);
if (PurgeMethod == null)
{
//result += "第" + (i + 1).ToString() + "行," + "该吹洗要求不存在!" + "|";
result.Add(col15 + "-该吹洗要求不存在!" + "|");
}
else
{
pipeline.PCMedium = PurgeMethod.PurgeMethodId;
pipeline.PurgeMethodCode = col15;
}
}
2023-04-16 14:56:34 +08:00
string col16 = Convert.ToString(pds[i].Q);
if (!string.IsNullOrEmpty(col16))
{
pipeline.VacuumPressure = col16;
}
2023-04-16 14:56:34 +08:00
string col17 = Convert.ToString(pds[i].R);
if (!string.IsNullOrEmpty(col17))
{
var material = getMaterial.FirstOrDefault(x => x.MaterialCode == col17);
if (material == null)
{
2023-11-23 16:50:57 +08:00
// result += "第" + (i + 1).ToString() + "行," + "该材质不存在!" + "|";
result.Add(col17 + "-该材质不存在!" + "|");
}
else
{
pipeline.MaterialId = material.MaterialId;
pipeline.PipeMaterialCode = col17;
}
}
2023-11-23 16:50:57 +08:00
pipeline.FlowingSection = Convert.ToString(pds[i].S);
2023-06-13 15:51:41 +08:00
pipeline.Remark = Convert.ToString(pds[i].T);
// 以下是焊口信息
2023-06-13 15:51:41 +08:00
string col19 = Convert.ToString(pds[i].U);
if (string.IsNullOrEmpty(col19))
{
result.Add("第" + (i + 1).ToString() + "行," + "焊口号" + "," + "此项为必填项!" + "|");
}
else
{
//var oldWeldJoint = getPipeline.FirstOrDefault(x => x.PipelineId == pipeLineId && x.WeldJointCode == col19);
//if (oldWeldJoint != null)
//{
// pipeline.WeldJointId = oldWeldJoint.WeldJointId;
//}
//else
//{
// pipeline.WeldJointId = SQLHelper.GetNewID();
//}
pipeline.WeldJointCode = col19;
}
2022-12-23 09:03:32 +08:00
string col20 = "";
2023-11-23 16:50:57 +08:00
if (pds[i].V != null)
2022-12-23 09:03:32 +08:00
{
2023-06-13 15:51:41 +08:00
col20 = pds[i].V.ToString();
2022-12-23 09:03:32 +08:00
}
2023-11-23 16:50:57 +08:00
if (!string.IsNullOrEmpty(col20))
{
var material = getMaterial.FirstOrDefault(x => x.MaterialCode == col20);
if (material == null)
{
2023-11-23 16:50:57 +08:00
// result += "第" + (i + 1).ToString() + "行," + "该材质1不存在" + "|";
result.Add(col20 + "-该材质1不存在" + "|");
}
else
{
pipeline.Material1Id = material.MaterialId;
pipeline.Material1Code = col20;
}
}
else
{
result.Add("第" + (i + 1).ToString() + "行," + "材质1" + "," + "此项为必填项!" + "|");
}
2022-12-23 09:03:32 +08:00
string col21 = "";
2023-11-23 16:50:57 +08:00
if (pds[i].W != null)
2022-12-23 09:03:32 +08:00
{
2023-06-13 15:51:41 +08:00
col21 = pds[i].W.ToString();
2022-12-23 09:03:32 +08:00
}
2023-11-23 16:50:57 +08:00
if (!string.IsNullOrEmpty(col21))
{
var material = getMaterial.FirstOrDefault(x => x.MaterialCode == col21);
if (material == null)
{
//result += "第" + (i + 1).ToString() + "行," + "该材质2不存在" + "|";
result.Add(col21 + "-该材质2不存在" + "|");
}
else
{
pipeline.Material2Id = material.MaterialId;
pipeline.Material2Code = col21;
}
}
else
{
result.Add("第" + (i + 1).ToString() + "行," + "材质2" + "," + "此项为必填项!" + "|");
}
2023-06-13 15:51:41 +08:00
string col22 = Convert.ToString(pds[i].X);
2023-11-23 16:50:57 +08:00
string col27 = "";
if (pds[i].AC != null)
{
2023-11-23 16:50:57 +08:00
col27 = pds[i].AC.ToString();
}
if (rbDiaType.SelectedValue == "1")
{
if (!string.IsNullOrEmpty(col27))
{
try
{
2022-11-18 18:04:38 +08:00
decimal Dia = Convert.ToDecimal(col27.Replace("Φ", ""));
pipeline.Dia = Dia;
//var inch = BLL.Base_DNCompareService.GetSizeByDia(Dia);
//if (inch != null)
//{
// pipeline.Size = inch;
//}
}
catch (Exception)
{
result.Add("第" + (i + 1).ToString() + "行," + "外径格式输入有误" + "|");
}
}
else
{
result.Add("第" + (i + 1).ToString() + "行," + "外径" + "," + "此项为必填项!" + "|");
}
}
else
{
if (!string.IsNullOrEmpty(col22))
{
pipeline.DNDia = col22;
}
else
{
result.Add("第" + (i + 1).ToString() + "行," + "DN公称直径" + "," + "此项为必填项!" + "|");
}
}
2023-06-13 15:51:41 +08:00
var col23 = Convert.ToString(pds[i].Y);
2023-11-23 16:50:57 +08:00
if (col23 != null)
{
try
{
decimal Size = Convert.ToDecimal(col23);
pipeline.Size = Size;
}
catch (Exception)
{
result.Add("第" + (i + 1).ToString() + "行," + "达因格式输入有误" + "|");
}
}
else
{
result.Add("第" + (i + 1).ToString() + "行," + "达因" + "," + "此项为必填项!" + "|");
}
2023-06-13 15:51:41 +08:00
var col24 = Convert.ToString(pds[i].Z);
2023-11-23 16:50:57 +08:00
if (col24 != null)
{
2023-10-25 10:03:27 +08:00
// var Thickness = Convert.ToDecimal(col24);
decimal Thickness = 0;
string thickness = col24.ToString();
if (thickness.Contains("Sch") || thickness.Contains("SCH"))
{
2023-10-25 10:03:27 +08:00
if (rbDiaType.SelectedValue == "1")//外径
{
2023-11-23 16:50:57 +08:00
Thickness = (decimal)BLL.Base_DNCompareService.GetThicknessByDia(pipeline.Dia, thickness);
2023-10-25 10:03:27 +08:00
pipeline.Thickness = Thickness;
}
else //DN直径
{
2023-11-23 16:50:57 +08:00
Thickness = (decimal)BLL.Base_DNCompareService.GetThicknessByDNDia(int.Parse(pipeline.DNDia.Replace("DN", "")), thickness);
2023-10-25 10:03:27 +08:00
pipeline.Thickness = Thickness;
}
}
2023-10-25 10:03:27 +08:00
else
{
2023-10-25 10:03:27 +08:00
try
{
Thickness = Convert.ToDecimal(col24);
pipeline.Thickness = Thickness;
//是否根据壁厚计算达因
//Model.Project_Sys_Set thicknessSet = BLL.Project_SysSetService.GetSysSetBySetId("7", this.CurrUser.LoginProjectId);
//if (thicknessSet != null && thicknessSet.IsAuto == true)
//{
// if (pipeline.Size != null)
// {
// pipeline.Size = Convert.ToDecimal(BLL.WeldJointService.GetSizeByThickness(pipeline.Size, Thickness));
// }
//}
}
catch (Exception)
{
result.Add("第" + (i + 1).ToString() + "行," + "壁厚格式输入有误" + "|");
}
}
2023-11-23 16:50:57 +08:00
}
else
{
result.Add("第" + (i + 1).ToString() + "行," + "壁厚" + "," + "此项为必填项!" + "|");
}
if (rbDiaType.SelectedValue == "1")
{
pipeline.Specification = "Φ" + (pipeline.Dia ?? 0).ToString() + "*" + (pipeline.Thickness ?? 0).ToString();
}
else
{
pipeline.Specification = pipeline.DNDia + "*" + (pipeline.Thickness ?? 0).ToString();
}
2023-06-13 15:51:41 +08:00
string col25 = Convert.ToString(pds[i].AA);
if (!string.IsNullOrEmpty(col25))
{
var weldType = getWeldType.FirstOrDefault(x => x.WeldTypeCode == col25);
if (weldType == null)
{
2023-11-23 16:50:57 +08:00
// result += "第" + (i + 1).ToString() + "行," + "该焊缝类型不存在!" + "|";
result.Add(col25 + "-该焊缝类型不存在!" + "|");
}
else
{
pipeline.WeldTypeId = weldType.WeldTypeId;
pipeline.WeldTypeCode = col25;
if (col25.Contains("B"))
{
if (col6.Contains("RT"))
{
2023-11-26 17:43:05 +08:00
Model.Base_DetectionType rt = getDetectionType.FirstOrDefault(x => x.DetectionTypeCode == "RT");
if (rt != null)
{
pipeline.DetectionTypeId = rt.DetectionTypeId;
}
}
else
{
2023-11-26 17:43:05 +08:00
Model.Base_DetectionType ut = getDetectionType.FirstOrDefault(x => x.DetectionTypeCode == "UT");
if (ut != null)
{
pipeline.DetectionTypeId = ut.DetectionTypeId;
}
}
}
else
{
if (col6.Contains("MT"))
{
2023-11-26 17:43:05 +08:00
Model.Base_DetectionType mt = getDetectionType.FirstOrDefault(x => x.DetectionTypeCode == "MT");
if (mt != null)
{
pipeline.DetectionTypeId = mt.DetectionTypeId;
}
}
else
{
2023-11-26 17:43:05 +08:00
Model.Base_DetectionType pt = getDetectionType.FirstOrDefault(x => x.DetectionTypeCode == "PT");
if (pt != null)
{
pipeline.DetectionTypeId = pt.DetectionTypeId;
}
}
}
}
}
else
{
result.Add("第" + (i + 1).ToString() + "行," + "焊缝类型" + "," + "此项为必填项!" + "|");
}
2023-06-13 15:51:41 +08:00
string col26 = Convert.ToString(pds[i].AB);
if (!string.IsNullOrEmpty(col26))
{
var JointAttribute = BLL.DropListService.HJGL_JointAttribute();
var q = JointAttribute.Where(x => x.Value == col26);
if (q == null)
{
result.Add("第" + (i + 1).ToString() + "行," + "该焊口属性不存在!" + "|");
}
else
{
pipeline.JointAttribute = col26;
}
}
else
{
result.Add("第" + (i + 1).ToString() + "行," + "焊口属性" + "," + "此项为必填项!" + "|");
}
2023-07-07 16:19:46 +08:00
string col28 = Convert.ToString(pds[i].AD);
if (!string.IsNullOrEmpty(col28))
{
if (col28.Trim() == "是")
{
pipeline.IsHotProess = true;
}
}
if (!string.IsNullOrEmpty(pipeline.PipelineCode) && !string.IsNullOrEmpty(pipeline.WeldJointCode))
{
pipeline.ProjectId = this.CurrUser.LoginProjectId;
PipelineList.Add(pipeline);
}
2023-11-23 16:50:57 +08:00
}
if (result.Count > 0)
{
PipelineList.Clear();
// result = result.Substring(0, result.LastIndexOf("|"));
errorInfos = string.Join("|", result.Distinct());
//Alert alert = new Alert();
//alert.Message = result;
//alert.Target = Target.Self;
//alert.Show();
responeData.code = 0;
responeData.message = errorInfos;
}
else
{
errorInfos = string.Empty;
}
}
else
{
responeData.code = 0;
responeData.message = "导入数据为空!";
}
return responeData;
}
2022-09-05 16:36:31 +08:00
#endregion
#endregion
#region
/// <summary>
/// 导入
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnImport_Click(object sender, EventArgs e)
{
if (State != (int)ButtonState.Import)
2022-09-05 16:36:31 +08:00
{
ShowNotify("请先审核");
return;
}
if (string.IsNullOrEmpty(errorInfos))
{
if (!string.IsNullOrEmpty(this.hdFileName.Text))
{
if (PipelineList.Count > 0)
{
this.Grid1.Hidden = false;
this.Grid1.DataSource = PipelineList;
this.Grid1.DataBind();
Grid1.RecordCount = PipelineList.Count;
State = (int)ButtonState.Save;
}
}
else
{
ShowNotify("请先审核要导入的文件!", MessageBoxIcon.Warning);
}
}
else
{
ShowNotify("请先将错误数据修正,再重新导入提交!", MessageBoxIcon.Warning);
}
}
#endregion
#region
/// <summary>
/// 提交
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
if (State != (int)ButtonState.Save)
{
ShowNotify("请先审核/导入");
return;
}
if (string.IsNullOrEmpty(errorInfos))
{
string rootPath = Server.MapPath("~/");
2023-11-23 16:50:57 +08:00
string oldefilePath = rootPath + initPath + this.hdFileName.Text;
2022-09-05 16:36:31 +08:00
string unitworkId = Request.Params["UnitWorkId"];
2023-11-23 16:50:57 +08:00
string filePath = rootPath + Const.DesignBasisDataImportPath + this.hdFileName.Text;
2022-09-05 16:36:31 +08:00
if (oldefilePath != string.Empty && System.IO.File.Exists(oldefilePath))
{
if (!Directory.Exists(rootPath + Const.DesignBasisDataImportPath))
{
Directory.CreateDirectory(rootPath + Const.DesignBasisDataImportPath);
}
2023-11-23 16:50:57 +08:00
File.Move(oldefilePath, filePath);
2022-09-05 16:36:31 +08:00
//System.IO.File.Delete(oldefilePath);//删除上传的XLS文件
}
string FileName = this.fuAttachUrl.FileName;
2023-11-23 16:50:57 +08:00
2022-09-05 16:36:31 +08:00
if (DrpType.SelectedValue == "1")//更新导入
{
BLL.PipelineMatService.DeletePipeLineMatByUnitWorkId(unitworkId);//删除原有管线对应材料
BLL.WeldJointService.DeleteWeldJointByUnitWorkId(unitworkId);////删除原有管线对应焊口
BLL.PipelineService.DeletePipelineByUnitworkId(unitworkId);//删除原有管线
AddView_HJGL_WeldJoint(PipelineList);//导入数据
2023-11-23 16:50:57 +08:00
Model.HJGL_DesignBasisDataImport hJGL_DesignBasisDataImport = new Model.HJGL_DesignBasisDataImport();
hJGL_DesignBasisDataImport.DesignBasisDataImportId = SQLHelper.GetNewID();
2022-09-05 16:36:31 +08:00
hJGL_DesignBasisDataImport.ProjectId = this.CurrUser.LoginProjectId;
hJGL_DesignBasisDataImport.UnitWorkId = unitworkId;
hJGL_DesignBasisDataImport.ImportType = "1";
hJGL_DesignBasisDataImport.DataClassification = DataClassification;
hJGL_DesignBasisDataImport.FileName = FileName;
hJGL_DesignBasisDataImport.FilePath = filePath.Replace(rootPath, "");
hJGL_DesignBasisDataImport.FileType = BLL.HJGL_DesignBasisDataImportService.GetFileType(FileName);
2023-11-23 16:50:57 +08:00
hJGL_DesignBasisDataImport.Version = BLL.HJGL_DesignBasisDataImportService.GetNewVersionByUnitWorkId(unitworkId, DataClassification);
2022-09-05 16:36:31 +08:00
hJGL_DesignBasisDataImport.Remark = txtRemark.Text;
hJGL_DesignBasisDataImport.CreateMan = this.CurrUser.PersonId;
hJGL_DesignBasisDataImport.CreateDate = DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss");
BLL.HJGL_DesignBasisDataImportService.AddHJGL_DesignBasisDataImport(hJGL_DesignBasisDataImport);
BLL.HJGL_DesignBasisDataImportVerSionLogService.UpdateVersion(this.CurrUser.LoginProjectId, unitworkId, (decimal)hJGL_DesignBasisDataImport.Version, DataClassification);
2023-11-23 16:50:57 +08:00
2022-09-05 16:36:31 +08:00
}
else //补充导入
{
AddView_HJGL_WeldJoint(PipelineList);
Model.HJGL_DesignBasisDataImport hJGL_DesignBasisDataImport = new Model.HJGL_DesignBasisDataImport();
hJGL_DesignBasisDataImport.DesignBasisDataImportId = SQLHelper.GetNewID();
hJGL_DesignBasisDataImport.ProjectId = this.CurrUser.LoginProjectId;
hJGL_DesignBasisDataImport.UnitWorkId = unitworkId;
hJGL_DesignBasisDataImport.ImportType = "0";
hJGL_DesignBasisDataImport.DataClassification = DataClassification;
hJGL_DesignBasisDataImport.FileName = FileName;
hJGL_DesignBasisDataImport.FilePath = filePath.Replace(rootPath, ""); ;
hJGL_DesignBasisDataImport.FileType = BLL.HJGL_DesignBasisDataImportService.GetFileType(FileName);
hJGL_DesignBasisDataImport.Version = BLL.HJGL_DesignBasisDataImportService.GetNowVersionByUnitWorkId(unitworkId, DataClassification);
hJGL_DesignBasisDataImport.Remark = txtRemark.Text;
hJGL_DesignBasisDataImport.CreateMan = this.CurrUser.PersonId;
hJGL_DesignBasisDataImport.CreateDate = DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss");
BLL.HJGL_DesignBasisDataImportService.AddHJGL_DesignBasisDataImport(hJGL_DesignBasisDataImport);
BLL.HJGL_DesignBasisDataImportVerSionLogService.UpdateVersion(this.CurrUser.LoginProjectId, unitworkId, (decimal)hJGL_DesignBasisDataImport.Version, DataClassification);
}
ShowNotify("导入成功!", MessageBoxIcon.Success);
2022-11-23 15:38:28 +08:00
PipelineService.RestPipelineAndJoints(this.CurrUser.LoginProjectId);
2022-09-05 16:36:31 +08:00
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
else
{
ShowNotify("请先将错误数据修正,再重新导入提交!", MessageBoxIcon.Warning);
}
}
public void AddView_HJGL_WeldJoint(List<Model.View_HJGL_WeldJoint> PipelineList)
{
string unitworkId = Request.Params["UnitWorkId"];
2022-09-05 16:36:31 +08:00
addPipelines(PipelineList, unitworkId);
addHJGL_WeldJoints(PipelineList, unitworkId);
2022-09-05 16:36:31 +08:00
}
2023-07-07 16:19:46 +08:00
void addPipelines(List<Model.View_HJGL_WeldJoint> PipelineList, string UnitWorkId)
{
// var getPipeline = from x in Funs.DB.View_HJGL_WeldJoint where x.UnitWorkId == UnitWorkId select x;
var pipelines = (from x in PipelineList
select new Model.HJGL_Pipeline
{
PipelineId = x.PipelineId,
ProjectId = this.CurrUser.LoginProjectId,
UnitId = x.UnitId,
UnitWorkId = x.UnitWorkId,
PipelineCode = x.PipelineCode,
SingleName = x.SingleName,
SingleNumber = x.SingleNumber,
MediumId = x.MediumId,
PipingClassId = x.PipingClassId,
DetectionRateId = x.DetectionRateId,
DetectionType = x.DetectionType,
DesignPress = x.DesignPress,
DesignTemperature = x.DesignTemperature,
TestMedium = x.TestMedium,
TestPressure = x.TestPressure,
PressurePipingClassId = x.PressurePipingClassId,
PipeLenth = x.PipeLenth,
LeakMedium = x.LeakMedium,
LeakPressure = x.LeakPressure,
VacuumPressure = x.VacuumPressure,
PCMedium = x.PCMedium,
MaterialId = x.MaterialId,
Remark = x.Remark,
FlowingSection = x.FlowingSection
}).DistinctBy(temp => new
{
temp.PipelineId,
temp.ProjectId,
temp.UnitId,
temp.UnitWorkId,
temp.PipelineCode,
temp.SingleName,
temp.SingleNumber,
temp.MediumId,
temp.PipingClassId,
temp.DetectionRateId,
temp.DetectionType,
temp.DesignPress,
temp.DesignTemperature,
temp.TestMedium,
temp.TestPressure,
temp.PressurePipingClassId,
temp.PipeLenth,
temp.LeakMedium,
temp.LeakPressure,
temp.VacuumPressure,
temp.PCMedium,
temp.MaterialId,
temp.Remark,
temp.FlowingSection
}).ToList();
for (int i = 0; i < pipelines.Count(); i++)
{
Model.HJGL_Pipeline pipeline = new Model.HJGL_Pipeline();
pipeline.PipelineId = pipelines[i].PipelineId;
pipeline.ProjectId = this.CurrUser.LoginProjectId;
pipeline.UnitId = pipelines[i].UnitId;
pipeline.UnitWorkId = pipelines[i].UnitWorkId;
pipeline.PipelineCode = pipelines[i].PipelineCode;
pipeline.SingleName = pipelines[i].SingleName;
pipeline.SingleNumber = pipelines[i].SingleNumber;
pipeline.MediumId = pipelines[i].MediumId;
pipeline.PipingClassId = pipelines[i].PipingClassId;
pipeline.DetectionRateId = pipelines[i].DetectionRateId;
pipeline.DetectionType = pipelines[i].DetectionType;
pipeline.DesignPress = pipelines[i].DesignPress;
pipeline.DesignTemperature = pipelines[i].DesignTemperature;
pipeline.TestMedium = pipelines[i].TestMedium;
pipeline.TestPressure = pipelines[i].TestPressure;
pipeline.PressurePipingClassId = pipelines[i].PressurePipingClassId;
pipeline.PipeLenth = pipelines[i].PipeLenth;
pipeline.LeakMedium = pipelines[i].LeakMedium;
pipeline.LeakPressure = pipelines[i].LeakPressure;
pipeline.VacuumPressure = pipelines[i].VacuumPressure;
pipeline.PCMedium = pipelines[i].PCMedium;
pipeline.MaterialId = pipelines[i].MaterialId;
pipeline.Remark = pipelines[i].Remark;
pipeline.FlowingSection = pipelines[i].FlowingSection;
var isExistPipelineCode = PipelineService.GetPipelineByCode(pipeline.PipelineCode, pipeline.UnitWorkId);
if (isExistPipelineCode != null) // 更新管线
{
pipeline.PipelineId = isExistPipelineCode.PipelineId;
BLL.PipelineService.UpdatePipeline(pipeline);
}
else // 增加管线
{
pipeline.PipelineId = SQLHelper.GetNewID();
BLL.PipelineService.AddPipeline(pipeline);
}
}
}
void addHJGL_WeldJoints(List<Model.View_HJGL_WeldJoint> PipelineList, string UnitWorkId)
{
2023-11-26 17:43:05 +08:00
Model.SGGLDB db = Funs.DB;
var getpipelines = from y in db.HJGL_Pipeline where y.UnitWorkId == UnitWorkId select y;
var allWeldJoints = from x in db.HJGL_WeldJoint
join y in db.HJGL_Pipeline on x.PipelineId equals y.PipelineId
where y.UnitWorkId == UnitWorkId
select x;
2023-07-07 16:19:46 +08:00
List<Model.HJGL_WeldJoint> weldJoints_add = new List<Model.HJGL_WeldJoint>();
var weldJoints = (from x in PipelineList
select new Model.HJGL_WeldJoint
{
WeldJointCode = x.WeldJointCode,
PipelineCode = x.PipelineCode,
Material1Id = x.Material1Id,
Material2Id = x.Material2Id,
Dia = x.Dia,
DNDia = x.DNDia,
Size = x.Size,
Thickness = x.Thickness,
Specification = x.Specification,
WeldTypeId = x.WeldTypeId,
DetectionTypeId = x.DetectionTypeId,
JointAttribute = x.JointAttribute,
ProjectId = this.CurrUser.LoginProjectId,
IsHotProess = x.IsHotProess,
}).DistinctBy(temp => new
{
temp.WeldJointCode,
temp.PipelineCode,
temp.Material1Id,
temp.Material2Id,
temp.Dia,
temp.DNDia,
temp.Size,
temp.Thickness,
temp.Specification,
temp.WeldTypeId,
temp.DetectionTypeId,
temp.JointAttribute,
temp.ProjectId,
temp.IsHotProess
}).ToList();
2023-11-25 12:34:55 +08:00
var pipelineCodes = weldJoints.Select(x => x.PipelineCode).Distinct().ToList();
2023-07-07 16:19:46 +08:00
for (int i = 0; i < weldJoints.Count(); i++)
{
Model.HJGL_WeldJoint weldJoint = new Model.HJGL_WeldJoint();
weldJoint.PipelineId = getpipelines.Where(x => x.PipelineCode == weldJoints[i].PipelineCode).FirstOrDefault().PipelineId;
weldJoint.WeldJointCode = weldJoints[i].WeldJointCode;
weldJoint.PipelineCode = weldJoints[i].PipelineCode;
weldJoint.Material1Id = weldJoints[i].Material1Id;
weldJoint.Material2Id = weldJoints[i].Material2Id;
weldJoint.Dia = weldJoints[i].Dia;
weldJoint.DNDia = weldJoints[i].DNDia;
weldJoint.Size = weldJoints[i].Size;
weldJoint.Thickness = weldJoints[i].Thickness;
weldJoint.Specification = weldJoints[i].Specification;
weldJoint.WeldTypeId = weldJoints[i].WeldTypeId;
weldJoint.DetectionTypeId = weldJoints[i].DetectionTypeId;
weldJoint.JointAttribute = weldJoints[i].JointAttribute;
weldJoint.ProjectId = weldJoints[i].ProjectId;
weldJoint.IsHotProess = weldJoints[i].IsHotProess;
2023-11-26 17:43:05 +08:00
var isExistJot = allWeldJoints.FirstOrDefault(x => x.PipelineId == weldJoint.PipelineId && x.WeldJointCode == weldJoint.WeldJointCode);
2023-07-07 16:19:46 +08:00
if (isExistJot != null) // 更新焊口
{
weldJoint.WeldJointId = isExistJot.WeldJointId;
BLL.WeldJointService.UpdateWeldJoint(weldJoint);
}
else // 增加焊口
{
weldJoint.WeldJointId = SQLHelper.GetNewID();
weldJoints_add.Add(weldJoint);
}
}
2023-11-26 17:43:05 +08:00
//db.SubmitChanges();
2023-07-07 16:19:46 +08:00
if (weldJoints_add.Count > 0)
{
BLL.WeldJointService.AddBulkWeldJoint(weldJoints_add);
}
2023-11-26 17:43:05 +08:00
Model.SGGLDB db2 = Funs.DB;
List<Model.HJGL_WeldJoint> delJoints = new List<Model.HJGL_WeldJoint>();
var allWeldJoints2 = from x in db2.HJGL_WeldJoint
join y in db2.HJGL_Pipeline on x.PipelineId equals y.PipelineId
where y.UnitWorkId == Request.Params["UnitWorkId"]
select x;
foreach (var pipelineCode in pipelineCodes)
{
var pipelineWeldJointCodes = weldJoints.Where(x => x.PipelineCode == pipelineCode).Select(x => x.WeldJointCode).ToList();
var q = allWeldJoints2.Where(x => x.PipelineCode == pipelineCode && !pipelineWeldJointCodes.Contains(x.WeldJointCode)).ToList();
delJoints.AddRange(q);
}
if (delJoints.Count() > 0)
2023-11-25 12:34:55 +08:00
{
2023-12-01 12:11:50 +08:00
try
{
db2.HJGL_WeldJoint.DeleteAllOnSubmit(delJoints);
db2.SubmitChanges();
}
catch (Exception)
{
2023-11-28 10:59:50 +08:00
string weldJointCodes = string.Empty;
foreach (var item in delJoints)
{
weldJointCodes += item.WeldJointCode + ",";
}
Alert.ShowInParent(weldJointCodes, MessageBoxIcon.Warning);
2023-12-01 12:11:50 +08:00
}
2023-11-25 12:34:55 +08:00
}
2023-07-07 16:19:46 +08:00
}
//public void AddView_HJGL_WeldJoint(List<Model.View_HJGL_WeldJoint> PipelineList)
//{
// string unitworkId = Request.Params["UnitWorkId"];
// var getPipeline = from x in Funs.DB.View_HJGL_WeldJoint where x.UnitWorkId== unitworkId select x;
2023-11-26 17:43:05 +08:00
// List<Model.HJGL_WeldJoint> weldJoints_add = new List<Model.HJGL_WeldJoint>();
// for (int i = 0; i < PipelineList.Count(); i++)
// {
// var pipeLineId = string.Empty;
// var WeldJointId = string.Empty;
// Model.HJGL_Pipeline pipeline = new Model.HJGL_Pipeline();
// pipeline.PipelineId = PipelineList[i].PipelineId;
// pipeline.ProjectId = this.CurrUser.LoginProjectId;
// pipeline.UnitId = PipelineList[i].UnitId;
// pipeline.UnitWorkId = PipelineList[i].UnitWorkId;
// pipeline.PipelineCode = PipelineList[i].PipelineCode;
// pipeline.SingleName = PipelineList[i].SingleName;
// pipeline.SingleNumber = PipelineList[i].SingleNumber;
// pipeline.MediumId = PipelineList[i].MediumId;
// pipeline.PipingClassId = PipelineList[i].PipingClassId;
// pipeline.DetectionRateId = PipelineList[i].DetectionRateId;
// pipeline.DetectionType = PipelineList[i].DetectionType;
// pipeline.DesignPress = PipelineList[i].DesignPress;
// pipeline.DesignTemperature = PipelineList[i].DesignTemperature;
// pipeline.TestMedium = PipelineList[i].TestMedium;
// pipeline.TestPressure = PipelineList[i].TestPressure;
// pipeline.PressurePipingClassId = PipelineList[i].PressurePipingClassId;
// pipeline.PipeLenth = PipelineList[i].PipeLenth;
// pipeline.LeakMedium = PipelineList[i].LeakMedium;
// pipeline.LeakPressure = PipelineList[i].LeakPressure;
// pipeline.VacuumPressure = PipelineList[i].VacuumPressure;
// pipeline.PCMedium = PipelineList[i].PCMedium;
// pipeline.MaterialId = PipelineList[i].MaterialId;
// pipeline.Remark = PipelineList[i].Remark;
// var isExistPipelineCode = getPipeline.FirstOrDefault(x => x.PipelineCode == pipeline.PipelineCode && x.UnitWorkId == Request.Params["UnitWorkId"]);
// if (isExistPipelineCode != null) // 更新管线
// {
// pipeLineId = isExistPipelineCode.PipelineId;
// pipeline.PipelineId = isExistPipelineCode.PipelineId;
// BLL.PipelineService.UpdatePipeline(pipeline);
// }
// else // 增加管线
// {
// pipeLineId = SQLHelper.GetNewID();
// pipeline.PipelineId = pipeLineId;
// BLL.PipelineService.AddPipeline(pipeline);
// }
// Model.HJGL_WeldJoint weldJoint = new Model.HJGL_WeldJoint();
// weldJoint.PipelineId = pipeLineId;
// weldJoint.WeldJointCode = PipelineList[i].WeldJointCode;
// weldJoint.PipelineCode = PipelineList[i].PipelineCode;
// weldJoint.Material1Id = PipelineList[i].Material1Id;
// weldJoint.Material2Id = PipelineList[i].Material2Id;
// weldJoint.Dia = PipelineList[i].Dia;
// weldJoint.Size = PipelineList[i].Size;
// weldJoint.Thickness = PipelineList[i].Thickness;
// weldJoint.Specification = PipelineList[i].Specification;
// weldJoint.WeldTypeId = PipelineList[i].WeldTypeId;
// weldJoint.DetectionTypeId = PipelineList[i].DetectionTypeId;
// weldJoint.JointAttribute = PipelineList[i].JointAttribute;
// weldJoint.ProjectId= PipelineList[i].ProjectId;
// var isExistJot = getPipeline.FirstOrDefault(x => x.PipelineId == pipeLineId && x.WeldJointCode == PipelineList[i].WeldJointCode);
// if (isExistJot != null) // 更新焊口
// {
// weldJoint.WeldJointId = isExistJot.WeldJointId;
// BLL.WeldJointService.UpdateWeldJoint(weldJoint);
// }
// else // 增加焊口
// {
// weldJoint.WeldJointId=SQLHelper.GetNewID();
// weldJoints_add.Add(weldJoint);
// //BLL.WeldJointService.AddWeldJoint(weldJoint);
// }
// }
// if (weldJoints_add.Count>0)
// {
// BLL.WeldJointService.AddBulkWeldJoint(weldJoints_add);
// }
//}
#endregion
2022-09-05 16:36:31 +08:00
/// <summary>
/// 恢复版本
/// </summary>
/// <param name="unitworkId"></param>
/// <param name="version"></param>
private void RestoreVersion(string unitworkId, decimal version)
{
var model = BLL.HJGL_DesignBasisDataImportService.GetDataByUnitWorkIdAndVersion(unitworkId, version, DataClassification);
if (model != null && model.Count > 0)
{
foreach (var item in model)
{
string rootPath = Server.MapPath("~/");
// initFullPath = rootPath + initPath;
string filePath = rootPath + item.FilePath;
ImportXlsToData(filePath);
BLL.PipelineMatService.DeletePipeLineMatByUnitWorkId(unitworkId);//删除原有管线对应材料
BLL.WeldJointService.DeleteWeldJointByUnitWorkId(unitworkId);////删除原有管线对应焊口
BLL.PipelineService.DeletePipelineByUnitworkId(unitworkId);//删除原有管线
AddView_HJGL_WeldJoint(PipelineList);//导入数据
PipelineList.Clear();
}
BLL.HJGL_DesignBasisDataImportVerSionLogService.UpdateVersion(this.CurrUser.LoginProjectId, unitworkId, version, DataClassification);
2022-11-23 15:38:28 +08:00
PipelineService.RestPipelineAndJoints(this.CurrUser.LoginProjectId);
2022-09-05 16:36:31 +08:00
ShowNotify("恢复成功!");
}
}
protected void btnRestore_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(drpVersion.SelectedValue))
{
ShowNotify("请选择版本");
}
else
{
PageContext.RegisterStartupScript(Confirm.GetShowReference("确定恢复至该版本吗?", String.Empty, MessageBoxIcon.Question, PageManager1.GetCustomEventReference(false, "Confirm_Restore"), PageManager1.GetCustomEventReference("Confirm_Cancel")));
}
}
#region
/// <summary>
/// 下载模板按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnDownLoad_Click(object sender, EventArgs e)
{
PageContext.RegisterStartupScript(Confirm.GetShowReference("确定下载导入模板吗?", String.Empty, MessageBoxIcon.Question, PageManager1.GetCustomEventReference(false, "Confirm_OK"), PageManager1.GetCustomEventReference("Confirm_Cancel")));
}
/// <summary>
/// 下载导入模板
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void PageManager1_CustomEvent(object sender, CustomEventArgs e)
{
if (e.EventArgument == "Confirm_OK")
{
string rootPath = Server.MapPath("~/");
string uploadfilepath = rootPath + Const.PDMSPipelineTemplateUrl;
string filePath = Const.PDMSPipelineTemplateUrl;
string fileName = Path.GetFileName(filePath);
FileInfo info = new FileInfo(uploadfilepath);
long fileSize = info.Length;
Response.ClearContent();
Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
Response.ContentType = "excel/plain";
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.AddHeader("Content-Length", fileSize.ToString().Trim());
Response.TransmitFile(uploadfilepath, 0, fileSize);
Response.End();
}
else if (e.EventArgument == "Confirm_Restore")
{
var unitworkid = Request.Params["UnitWorkId"];
decimal version = decimal.Parse(drpVersion.SelectedValue);
RestoreVersion(unitworkid, version);
}
}
#endregion
protected string ConvertDetectionType(object detectionType)
{
string detectionName = string.Empty;
if (detectionType != null)
{
string[] types = detectionType.ToString().Split('|');
foreach (string t in types)
{
var type = BLL.Base_DetectionTypeService.GetDetectionTypeByDetectionTypeId(t);
if (type != null)
{
detectionName += type.DetectionTypeCode + ",";
}
}
}
if (detectionName != string.Empty)
{
return detectionName.Substring(0, detectionName.Length - 1);
}
else
{
return "";
}
}
#region
/// <summary>
/// 分页选择下拉改变事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
this.Grid1.DataSource = PipelineList;
this.Grid1.DataBind();
Grid1.RecordCount = PipelineList.Count;
}
#endregion
}
}