620 lines
28 KiB
C#
620 lines
28 KiB
C#
using Microsoft.Office.Interop.Word;
|
||
using Microsoft.SqlServer.Dts.Runtime;
|
||
using MiniExcelLibs;
|
||
using Model;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Data.SqlClient;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Web.UI.DataVisualization.Charting;
|
||
using System.Web.UI.WebControls;
|
||
using static BLL.PipelineService;
|
||
|
||
namespace BLL
|
||
{
|
||
public static class PipelineService
|
||
{
|
||
/// <summary>
|
||
/// 工厂预制
|
||
/// </summary>
|
||
public const string PipeArea_SHOP="1";
|
||
/// <summary>
|
||
/// 现场安装
|
||
/// </summary>
|
||
public const string PipeArea_FIELD = "2";
|
||
public static List<Model.HJGL_Pipeline> hJGL_Pipelines
|
||
{
|
||
|
||
get;
|
||
set;
|
||
|
||
}
|
||
/// <summary>
|
||
/// 实际日期类型
|
||
/// </summary>
|
||
public enum ActDateType
|
||
{
|
||
/// <summary>
|
||
/// 实际开始日期(预制)
|
||
/// </summary>
|
||
ActDateStart_Shop,
|
||
/// <summary>
|
||
/// 实际完成日期(预制)
|
||
/// </summary>
|
||
ActDateEnd_Shop ,
|
||
/// <summary>
|
||
/// 实际开始日期(安装)
|
||
/// </summary>
|
||
ActDateStart_FIELD ,
|
||
/// <summary>
|
||
/// 实际完成日期(安装)
|
||
/// </summary>
|
||
ActDateEnd_FIELD ,
|
||
}
|
||
public static ListItem[] GetPipeArea()
|
||
{
|
||
ListItem[] list = new ListItem[2];
|
||
list[0] = new ListItem("工厂预制", PipeArea_SHOP);
|
||
list[1] = new ListItem("现场安装", PipeArea_FIELD);
|
||
return list;
|
||
}
|
||
public static void RestPipelineAndJoints(string projectid )
|
||
{
|
||
PipelineService.hJGL_Pipelines = PipelineService.GetPipelinesByProjectId(projectid);
|
||
WeldJointService.hJGL_WeldJoints = WeldJointService.GetWeldJointByProjectid(projectid);
|
||
}
|
||
/// <summary>
|
||
/// 根据管线ID获取管线信息
|
||
/// </summary>
|
||
/// <param name="pipelineName"></param>
|
||
/// <returns></returns>
|
||
public static Model.HJGL_Pipeline GetPipelineByPipelineId(string pipelineId)
|
||
{
|
||
return Funs.DB.HJGL_Pipeline.FirstOrDefault(e => e.PipelineId == pipelineId);
|
||
}
|
||
public static void GetStateByPipelineId(string pipelineId)
|
||
{
|
||
var mdoel = GetPipelineByPipelineId(pipelineId);
|
||
var PlanStartDate = mdoel.PlanStartDate;
|
||
var PlanEndDate = mdoel.PlanEndDate;
|
||
var ActStartDate = new DateTime?();
|
||
var ActEndDate = new DateTime?();
|
||
if (!string .IsNullOrEmpty(GetDateByPipelineId(pipelineId, ActDateType.ActDateStart_FIELD)))
|
||
{
|
||
ActStartDate = Convert.ToDateTime(GetDateByPipelineId(pipelineId, ActDateType.ActDateStart_FIELD));
|
||
}
|
||
if (!string.IsNullOrEmpty(GetDateByPipelineId(pipelineId, ActDateType.ActDateEnd_FIELD)))
|
||
{
|
||
ActEndDate = Convert.ToDateTime(GetDateByPipelineId(pipelineId, ActDateType.ActDateEnd_FIELD));
|
||
}
|
||
if (ActStartDate==null&&DateTime.Compare(DateTime.Now,PlanStartDate.Value)<0)
|
||
{
|
||
mdoel.State = 0;
|
||
}
|
||
else if(ActStartDate == null && DateTime.Compare(DateTime.Now, PlanStartDate.Value) > 0)
|
||
{
|
||
mdoel.State = 1;
|
||
}
|
||
else if (ActStartDate!=null && DateTime.Compare(ActStartDate.Value, PlanStartDate.Value)<0 && ActEndDate==null)
|
||
{
|
||
mdoel.State = 2;
|
||
}
|
||
else if (ActStartDate != null && DateTime.Compare(ActStartDate.Value, PlanStartDate.Value) > 0 && ActEndDate == null)
|
||
{
|
||
mdoel.State = 3;
|
||
}
|
||
else if (ActEndDate != null)
|
||
{
|
||
mdoel.State = 4;
|
||
}
|
||
UpdatePipeline(mdoel);
|
||
}
|
||
|
||
public static string GetDateByPipelineId(object pipelineId, ActDateType actDateType)
|
||
{
|
||
string result ="";
|
||
string _pipelineId = pipelineId.ToString();
|
||
string ActDateStart_Shop = "";
|
||
string ActDateEnd_Shop = "";
|
||
string ActDateStart_FIELD = "";
|
||
string ActDateEnd_FIELD = "";
|
||
|
||
var pipemodel = GetPipelineByPipelineId(_pipelineId);
|
||
var joints = BLL.WeldJointService.GetWeldJointsByPipelineId(_pipelineId);
|
||
int joint_Shop_count = joints.Where(x => x.JointAttribute == "预制口").Count();
|
||
int joint_Field_count = joints.Where(x => x.JointAttribute == "安装口").Count();
|
||
var TaskJoints = (from x in Funs.DB.View_HJGL_WeldingTask where x.ProjectId == pipemodel.ProjectId && x.PipelineCode == pipemodel.PipelineCode
|
||
select x).ToList();
|
||
var TaskJoints_Shop = TaskJoints.Where(x => x.JointAttribute == "预制口").ToList();
|
||
var TaskJoints_Field= TaskJoints.Where(x => x.JointAttribute == "安装口").ToList();
|
||
if (TaskJoints_Shop.Count>0)
|
||
{
|
||
ActDateStart_Shop = TaskJoints_Shop.OrderBy(x => x.TaskDate).First().TaskDate.Value.ToShortDateString();
|
||
}
|
||
if (joint_Shop_count== TaskJoints_Shop.Count&& joint_Shop_count>0)
|
||
{
|
||
ActDateEnd_Shop = TaskJoints_Shop.OrderByDescending(x => x.TaskDate).First().TaskDate.Value.Date.ToShortDateString();
|
||
}
|
||
if (TaskJoints_Field.Count > 0)
|
||
{
|
||
ActDateStart_FIELD = TaskJoints_Field.OrderBy(x => x.TaskDate).First().TaskDate.Value.Date.ToShortDateString();
|
||
}
|
||
if (joint_Field_count == TaskJoints_Field.Count && joint_Field_count > 0)
|
||
{
|
||
ActDateEnd_FIELD = TaskJoints_Field.OrderByDescending(x => x.TaskDate).First().TaskDate.Value.Date.ToShortDateString();
|
||
}
|
||
switch (actDateType)
|
||
{
|
||
case ActDateType.ActDateStart_Shop:
|
||
result = ActDateStart_Shop;
|
||
break;
|
||
case ActDateType.ActDateEnd_Shop:
|
||
result = ActDateEnd_Shop;
|
||
break;
|
||
case ActDateType.ActDateStart_FIELD:
|
||
result = ActDateStart_FIELD;
|
||
break;
|
||
case ActDateType.ActDateEnd_FIELD:
|
||
result = ActDateEnd_FIELD;
|
||
break;
|
||
}
|
||
return result;
|
||
|
||
}
|
||
public static Model.HJGL_Pipeline GetPipelineByPipelineCode(string pipelineCode)
|
||
{
|
||
return Funs.DB.HJGL_Pipeline.FirstOrDefault(e => e.PipelineCode == pipelineCode);
|
||
}
|
||
public static List<HJGL_Pipeline> GetView_HJGL_Pipelines(HJGL_Pipeline model)
|
||
{
|
||
var db = Funs.DB;
|
||
var pipelineList =( from x in Funs.DB.HJGL_Pipeline
|
||
where
|
||
(string.IsNullOrEmpty(model.ProjectId) || x.ProjectId.Contains(model.ProjectId))
|
||
&& (string.IsNullOrEmpty(model.UnitWorkId) || x.UnitWorkId.Contains(model.UnitWorkId))
|
||
&& (string.IsNullOrEmpty(model.PipelineCode) || x.PipelineCode.Contains(model.PipelineCode))
|
||
&& (string.IsNullOrEmpty(model.SingleName) || x.SingleName.Contains(model.SingleName))
|
||
&& (string.IsNullOrEmpty(model.DesignPress) || x.DesignPress.Contains(model.DesignPress))
|
||
/* && (string.IsNullOrEmpty(model.MaterialCode) || x.MaterialCode.Contains(model.MaterialCode))*/
|
||
select x).ToList();
|
||
if (model.IsFinished!=null)
|
||
{
|
||
if (model.IsFinished==true)
|
||
{
|
||
pipelineList= pipelineList.Where(x => x.IsFinished == true).ToList();
|
||
}
|
||
else
|
||
{
|
||
pipelineList = pipelineList.Where(x => x.IsFinished == false||x.IsFinished==null).ToList();
|
||
|
||
}
|
||
|
||
}
|
||
return pipelineList;
|
||
}
|
||
/// <summary>
|
||
/// 根据unitworkId获取所有管线
|
||
/// </summary>
|
||
/// <param name="unitworkId"></param>
|
||
/// <returns></returns>
|
||
public static List<Model.HJGL_Pipeline> GetPipelinesByUnitWordId(string unitworkId)
|
||
{
|
||
|
||
var q = Funs.DB.HJGL_Pipeline.Where(e => e.UnitWorkId == unitworkId).ToList();
|
||
return q;
|
||
}
|
||
/// <summary>
|
||
/// 根据项目获取所有管线
|
||
/// </summary>
|
||
/// <param name="ProjectId"></param>
|
||
/// <returns></returns>
|
||
public static List<Model.HJGL_Pipeline> GetPipelinesByProjectId(string ProjectId)
|
||
{
|
||
|
||
var q = Funs.DB.HJGL_Pipeline.Where(e => e.ProjectId == ProjectId).ToList();
|
||
return q;
|
||
}
|
||
/// <summary>
|
||
/// 根据管线ID获取管线信息
|
||
/// </summary>
|
||
/// <param name="pipelineName"></param>
|
||
/// <returns></returns>
|
||
public static Model.View_HJGL_Pipeline GetViewPipelineByPipelineId(string pipelineId)
|
||
{
|
||
return Funs.DB.View_HJGL_Pipeline.FirstOrDefault(e => e.PipelineId == pipelineId);
|
||
}
|
||
/// <summary>
|
||
/// 下载预制口管线导入模板
|
||
/// </summary>
|
||
/// <param name="projectid"></param>
|
||
/// <param name="unitworkid"></param>
|
||
public static void DownPipeArea_SHOPFile(string projectid,string unitworkid)
|
||
{
|
||
string templatePath = Funs.RootPath + @"File\Excel\DataOut\WeldingPlanDataOut_SHOP.xlsx";
|
||
string path = Funs.RootPath + @"File\Excel\DataOut\WeldingPlanDataOut_SHOP.xlsx";
|
||
path = path.Replace(".xlsx", string.Format("{0:yyyy-MM-dd-HH-mm}", DateTime.Now) + ".xlsx");
|
||
|
||
string strSql = @"select line.PipelineId+'&'+com.PipelineComponentId as ID
|
||
,line.PipelineId
|
||
,line.PipelineCode
|
||
,line.ProjectId
|
||
,line.UnitWorkId
|
||
,line.UnitId
|
||
,line.SingleNumber
|
||
,line.PipingClassId
|
||
,line.MediumId
|
||
,line.DetectionRateId
|
||
,line.DetectionType
|
||
,line.TestPressure
|
||
,line.TestMedium
|
||
,line.Remark
|
||
,line.PressurePipingClassId
|
||
,line.PipeLenth
|
||
,line.DesignPress
|
||
,line.DesignTemperature
|
||
,line.PCtype
|
||
,line.LeakPressure
|
||
,line.LeakMedium
|
||
,line.VacuumPressure
|
||
,line.PCMedium
|
||
,line.MaterialId
|
||
,line.SingleName
|
||
,line.PipeArea
|
||
,line.WBSId
|
||
,line.PlanStartDate
|
||
,line.PlanEndDate
|
||
,line.ActStartDate
|
||
,line.ActEndDate
|
||
,line.IsFinished
|
||
,line.FlowingSection
|
||
,com.PipelineComponentId
|
||
,com.PreUnit
|
||
,com.PipelineComponentCode
|
||
,com.BoxNumber
|
||
,com.AssembleUnit
|
||
,com.PipeLineMatId
|
||
,com.QRCode
|
||
,com.State
|
||
,com.PlanStartDate as PlanStartDate_SHOP
|
||
,com.PlanEndDate as PlanEndDate_SHOP
|
||
,com.ActStartDate as ActStartDate_SHOP
|
||
,com.ActEndDate as ActEndDate_SHOP
|
||
,unit.UnitWorkName
|
||
from HJGL_Pipeline line
|
||
left join HJGL_Pipeline_Component com on line.PipelineId=com.PipelineId
|
||
left join WBS_UnitWork unit on line.UnitWorkId=unit.UnitWorkId
|
||
WHERE line.ProjectId= @ProjectId and line.PipeArea='1' ";
|
||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||
listStr.Add(new SqlParameter("@ProjectId", projectid));
|
||
if (!string.IsNullOrEmpty(unitworkid) && unitworkid != "2")
|
||
{
|
||
strSql += " AND line.UnitWorkId =@UnitWorkId";
|
||
listStr.Add(new SqlParameter("@UnitWorkId", unitworkid));
|
||
}
|
||
|
||
SqlParameter[] parameter = listStr.ToArray();
|
||
System.Data.DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||
tb.TableName = "Data";
|
||
var value = new Dictionary<string, object>()
|
||
{
|
||
["Data"] = tb,
|
||
};
|
||
MiniExcel.SaveAsByTemplate(path, templatePath, value);
|
||
HJGL_DataImportService.DownFile(path.Replace(Funs.RootPath,"") , "焊接施工计划(预制).xlsx");
|
||
File.Delete(path);
|
||
}
|
||
/// <summary>
|
||
/// 下载安装口管线导入模板
|
||
/// </summary>
|
||
/// <param name="projectid"></param>
|
||
/// <param name="unitworkid"></param>
|
||
public static void DownPipeArea_FIELDFile(string projectid, string unitworkid)
|
||
{
|
||
string templatePath = Funs.RootPath + @"File\Excel\DataOut\WeldingPlanDataOut2.xlsx";
|
||
string path = Funs.RootPath + @"File\Excel\DataOut\WeldingPlanDataOut2.xlsx";
|
||
path = path.Replace(".xlsx", string.Format("{0:yyyy-MM-dd-HH-mm}", DateTime.Now) + ".xlsx");
|
||
|
||
string strSql = @"select line.PipelineId as ID
|
||
,line.PipelineId
|
||
,line.PipelineCode
|
||
,line.ProjectId
|
||
,line.UnitWorkId
|
||
,line.UnitId
|
||
,line.SingleNumber
|
||
,line.PipingClassId
|
||
,line.MediumId
|
||
,line.DetectionRateId
|
||
,line.DetectionType
|
||
,line.TestPressure
|
||
,line.TestMedium
|
||
,line.Remark
|
||
,line.PressurePipingClassId
|
||
,line.PipeLenth
|
||
,line.DesignPress
|
||
,line.DesignTemperature
|
||
,line.PCtype
|
||
,line.LeakPressure
|
||
,line.LeakMedium
|
||
,line.VacuumPressure
|
||
,line.PCMedium
|
||
,line.MaterialId
|
||
,line.SingleName
|
||
,line.PipeArea
|
||
,line.WBSId
|
||
,line.PlanStartDate
|
||
,line.PlanEndDate
|
||
,line.ActStartDate
|
||
,line.ActEndDate
|
||
,line.IsFinished
|
||
,line.FlowingSection
|
||
,unit.UnitWorkName
|
||
from HJGL_Pipeline line
|
||
left join WBS_UnitWork unit on line.UnitWorkId=unit.UnitWorkId
|
||
WHERE line.ProjectId= @ProjectId ";
|
||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||
listStr.Add(new SqlParameter("@ProjectId", projectid));
|
||
if (!string.IsNullOrEmpty(unitworkid) && unitworkid != "2")
|
||
{
|
||
strSql += " AND line.UnitWorkId =@UnitWorkId";
|
||
listStr.Add(new SqlParameter("@UnitWorkId", unitworkid));
|
||
}
|
||
|
||
SqlParameter[] parameter = listStr.ToArray();
|
||
System.Data.DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||
tb.TableName = "Data";
|
||
var value = new Dictionary<string, object>()
|
||
{
|
||
["Data"] = tb,
|
||
};
|
||
MiniExcel.SaveAsByTemplate(path, templatePath, value);
|
||
HJGL_DataImportService.DownFile(path.Replace(Funs.RootPath, ""), "焊接施工计划(安装).xlsx");
|
||
File.Delete(path);
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据管线Code获取管线信息
|
||
/// </summary>
|
||
/// <param name="isoNo"></param>
|
||
/// <returns></returns>
|
||
public static bool IsExistPipelineCode(string pipelineCode, string workAreaId, string PipelineId)
|
||
{
|
||
Model.SGGLDB db = Funs.DB;
|
||
Model.HJGL_Pipeline q = null;
|
||
if (!string.IsNullOrEmpty(PipelineId))
|
||
{
|
||
q = Funs.DB.HJGL_Pipeline.FirstOrDefault(x => x.PipelineCode == pipelineCode && x.UnitWorkId == workAreaId && x.PipelineId != PipelineId);
|
||
}
|
||
else
|
||
{
|
||
q = Funs.DB.HJGL_Pipeline.FirstOrDefault(x => x.PipelineCode == pipelineCode && x.UnitWorkId == workAreaId);
|
||
}
|
||
|
||
if (q != null)
|
||
{
|
||
return true;
|
||
}
|
||
else
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
|
||
public static bool IsExistPipelineCode(string pipelineCode, string unitWorkId)
|
||
{
|
||
Model.SGGLDB db = Funs.DB;
|
||
Model.HJGL_Pipeline q = null;
|
||
q = Funs.DB.HJGL_Pipeline.FirstOrDefault(x => x.PipelineCode == pipelineCode && x.UnitWorkId == unitWorkId);
|
||
if (q != null)
|
||
{
|
||
return true;
|
||
}
|
||
else
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
public static HJGL_Pipeline GetPipelineByCode(string pipelineCode, string unitWorkId)
|
||
{
|
||
Model.SGGLDB db = Funs.DB;
|
||
Model.HJGL_Pipeline q = null;
|
||
q = Funs.DB.HJGL_Pipeline.FirstOrDefault(x => x.PipelineCode == pipelineCode && x.UnitWorkId == unitWorkId);
|
||
return q;
|
||
}
|
||
|
||
public static void AddPipeline(Model.HJGL_Pipeline pipeline)
|
||
{
|
||
Model.SGGLDB db = Funs.DB;
|
||
Model.HJGL_Pipeline newPipeline = new Model.HJGL_Pipeline();
|
||
newPipeline.PipelineId = pipeline.PipelineId;
|
||
newPipeline.ProjectId = pipeline.ProjectId;
|
||
//newPipeline.InstallationId = pipeline.InstallationId;
|
||
newPipeline.UnitId = pipeline.UnitId;
|
||
newPipeline.UnitWorkId = pipeline.UnitWorkId;
|
||
newPipeline.PipelineCode = pipeline.PipelineCode;
|
||
newPipeline.SingleName = pipeline.SingleName;
|
||
newPipeline.SingleNumber = pipeline.SingleNumber;
|
||
newPipeline.PipingClassId = pipeline.PipingClassId;
|
||
newPipeline.MediumId = pipeline.MediumId;
|
||
newPipeline.DetectionRateId = pipeline.DetectionRateId;
|
||
newPipeline.DetectionType = pipeline.DetectionType;
|
||
newPipeline.DesignPress = pipeline.DesignPress;
|
||
newPipeline.DesignTemperature = pipeline.DesignTemperature;
|
||
newPipeline.TestPressure = pipeline.TestPressure;
|
||
newPipeline.TestMedium = pipeline.TestMedium;
|
||
newPipeline.PipeLenth = pipeline.PipeLenth;
|
||
newPipeline.PressurePipingClassId = pipeline.PressurePipingClassId;
|
||
newPipeline.Remark = pipeline.Remark;
|
||
newPipeline.LeakPressure = pipeline.LeakPressure;
|
||
newPipeline.LeakMedium = pipeline.LeakMedium;
|
||
newPipeline.VacuumPressure = pipeline.VacuumPressure;
|
||
newPipeline.PCMedium = pipeline.PCMedium;
|
||
newPipeline.PCtype = pipeline.PCtype;
|
||
newPipeline.MaterialId = pipeline.MaterialId;
|
||
newPipeline.State = pipeline.State;
|
||
newPipeline.FlowingSection=pipeline.FlowingSection;
|
||
db.HJGL_Pipeline.InsertOnSubmit(newPipeline);
|
||
db.SubmitChanges();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 修改作业管线
|
||
/// </summary>
|
||
/// <param name="pipeline"></param>
|
||
public static void UpdatePipeline(Model.HJGL_Pipeline pipeline)
|
||
{
|
||
Model.SGGLDB db = Funs.DB;
|
||
Model.HJGL_Pipeline newPipeline = db.HJGL_Pipeline.FirstOrDefault(e => e.PipelineId == pipeline.PipelineId);
|
||
if (newPipeline != null)
|
||
{
|
||
//newPipeline.InstallationId = pipeline.InstallationId;
|
||
newPipeline.UnitId = pipeline.UnitId;
|
||
newPipeline.UnitWorkId = pipeline.UnitWorkId;
|
||
newPipeline.PipelineCode = pipeline.PipelineCode;
|
||
newPipeline.SingleName = pipeline.SingleName;
|
||
newPipeline.SingleNumber = pipeline.SingleNumber;
|
||
newPipeline.PipingClassId = pipeline.PipingClassId;
|
||
newPipeline.MediumId = pipeline.MediumId;
|
||
newPipeline.DetectionRateId = pipeline.DetectionRateId;
|
||
newPipeline.DetectionType = pipeline.DetectionType;
|
||
newPipeline.DesignPress = pipeline.DesignPress;
|
||
newPipeline.DesignTemperature = pipeline.DesignTemperature;
|
||
newPipeline.TestPressure = pipeline.TestPressure;
|
||
newPipeline.TestMedium = pipeline.TestMedium;
|
||
newPipeline.PipeLenth = pipeline.PipeLenth;
|
||
newPipeline.PressurePipingClassId = pipeline.PressurePipingClassId;
|
||
newPipeline.LeakPressure = pipeline.LeakPressure;
|
||
newPipeline.LeakMedium = pipeline.LeakMedium;
|
||
newPipeline.VacuumPressure = pipeline.VacuumPressure;
|
||
newPipeline.PCMedium = pipeline.PCMedium;
|
||
newPipeline.PCtype = pipeline.PCtype;
|
||
newPipeline.Remark = pipeline.Remark;
|
||
newPipeline.MaterialId = pipeline.MaterialId;
|
||
newPipeline.IsFinished = pipeline.IsFinished;
|
||
newPipeline.PlanStartDate = pipeline.PlanStartDate;
|
||
newPipeline.PlanEndDate = pipeline.PlanEndDate;
|
||
newPipeline.ActStartDate = pipeline.ActStartDate;
|
||
newPipeline.ActEndDate = pipeline.ActEndDate;
|
||
newPipeline.WBSId = pipeline.WBSId;
|
||
newPipeline.State = pipeline.State;
|
||
newPipeline.FlowingSection = pipeline.FlowingSection;
|
||
|
||
try
|
||
{
|
||
db.SubmitChanges(System.Data.Linq.ConflictMode.ContinueOnConflict);
|
||
}
|
||
catch (System.Data.Linq.ChangeConflictException ex)
|
||
{
|
||
foreach (System.Data.Linq.ObjectChangeConflict occ in db.ChangeConflicts)
|
||
{
|
||
// 使用Linq缓存中实体对象的值,覆盖当前数据库中的值
|
||
occ.Resolve(System.Data.Linq.RefreshMode.KeepCurrentValues);
|
||
}
|
||
// 这个地方要注意,Catch方法中,我们前面只是指明了怎样来解决冲突,这个地方还需要再次提交更新,这样的话,值 //才会提交到数据库。
|
||
db.SubmitChanges();
|
||
}
|
||
}
|
||
}
|
||
|
||
// 管线划分
|
||
public static void UpdatePipelineArea(string pipelineId, string pipelineArea)
|
||
{
|
||
Model.SGGLDB db = Funs.DB;
|
||
Model.HJGL_Pipeline newPipeline = db.HJGL_Pipeline.FirstOrDefault(e => e.PipelineId == pipelineId);
|
||
if (newPipeline != null)
|
||
{
|
||
newPipeline.PipeArea = pipelineArea;
|
||
db.SubmitChanges();
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 更新管线是否完成
|
||
/// </summary>
|
||
/// <param name="pipelineId"></param>
|
||
/// <param name="finishDate"></param>
|
||
/// <param name="isFinish"></param>
|
||
public static void UpdatePipelinePlan(string pipelineId, string wbsId, DateTime? planStartDate, DateTime? planEndDate, DateTime? actStartDate, DateTime? actEndDate, bool? isFinish)
|
||
{
|
||
Model.SGGLDB db = Funs.DB;
|
||
Model.HJGL_Pipeline newPipeline = db.HJGL_Pipeline.FirstOrDefault(e => e.PipelineId == pipelineId);
|
||
if (newPipeline != null)
|
||
{
|
||
newPipeline.IsFinished = isFinish;
|
||
newPipeline.PlanStartDate = planStartDate;
|
||
newPipeline.PlanEndDate = planEndDate;
|
||
newPipeline.ActStartDate = actStartDate;
|
||
newPipeline.ActEndDate = actEndDate;
|
||
newPipeline.WBSId = wbsId;
|
||
db.SubmitChanges();
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据作业管线Id删除一个作业管线信息
|
||
/// </summary>
|
||
/// <param name="pipelineId"></param>
|
||
public static void DeletePipeline(string pipelineId)
|
||
{
|
||
Model.SGGLDB db = Funs.DB;
|
||
Model.HJGL_Pipeline pipeline = db.HJGL_Pipeline.FirstOrDefault(e => e.PipelineId == pipelineId);
|
||
//var jot = db.HJGL_Pipeline.Where(e => e.PipelineId == pipelineId);
|
||
if (pipeline != null)
|
||
{
|
||
//db.HJGL_Pipeline.DeleteAllOnSubmit(jot);
|
||
db.HJGL_Pipeline.DeleteOnSubmit(pipeline);
|
||
db.SubmitChanges();
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 根据unitworkId删除一个作业管线信息
|
||
/// </summary>
|
||
/// <param name="pipelineId"></param>
|
||
public static void DeletePipelineByUnitworkId(string unitworkId)
|
||
{
|
||
Model.SGGLDB db = Funs.DB;
|
||
var pipeline = db.HJGL_Pipeline.Where(e => e.UnitWorkId == unitworkId);
|
||
if (pipeline != null)
|
||
{
|
||
//db.HJGL_Pipeline.DeleteAllOnSubmit(jot);
|
||
db.HJGL_Pipeline.DeleteAllOnSubmit(pipeline);
|
||
db.SubmitChanges();
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 获取管线名称项
|
||
/// </summary>
|
||
/// <param name="projectId">项目Id</param>
|
||
/// <returns></returns>
|
||
public static ListItem[] GetPipelineList(string unitWorkId)
|
||
{
|
||
List<Model.HJGL_Pipeline> q = (from x in Funs.DB.HJGL_Pipeline where x.UnitWorkId == unitWorkId orderby x.PipelineCode select x).ToList();
|
||
ListItem[] item = new ListItem[q.Count()];
|
||
for (int i = 0; i < q.Count(); i++)
|
||
{
|
||
item[i] = new ListItem(q[i].PipelineCode, q[i].PipelineId.ToString());
|
||
}
|
||
return item;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 管线下拉框
|
||
/// </summary>
|
||
/// <param name="dropName">下拉框名字</param>
|
||
/// <param name="isShowPlease">是否显示请选择</param>
|
||
public static void InitPipelineDownList(FineUIPro.DropDownList dropName, string unitWorkId, bool isShowPlease)
|
||
{
|
||
dropName.DataValueField = "Value";
|
||
dropName.DataTextField = "Text";
|
||
dropName.DataSource = GetPipelineList(unitWorkId);
|
||
dropName.DataBind();
|
||
if (isShowPlease)
|
||
{
|
||
Funs.FineUIPleaseSelect(dropName);
|
||
}
|
||
}
|
||
}
|
||
}
|