namespace FineUIPro.Web
{
using System;
using System.Configuration;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using System.IO;
using System.Net;
using System.Text;
using System.Threading;
using System.Web;
using BLL;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
public class Global : System.Web.HttpApplication
{
///
/// 自动启用插件标志文件路径
///
private static string applicationActiveFlagFilePhysicalPath = String.Empty;
protected void Application_Start(object sender, EventArgs e)
{
Application["OnlineUserCount"] = 0;
try
{
Funs.RootPath = Server.MapPath("~/");
// 日志文件所在目录
ErrLogInfo.DefaultErrLogFullPath = Server.MapPath("~/ErrLog.txt");
Funs.ConnString = ConfigurationManager.AppSettings["ConnectionString"];
Funs.SystemName = ConfigurationManager.AppSettings["SystemName"];
Funs.ADomainUrl = ConfigurationManager.AppSettings["ADomainUrl"];
Funs.APPUrl = ConfigurationManager.AppSettings["APPUrl"];
Funs.SystemCode = ConfigurationManager.AppSettings["SystemCode"];
Funs.HJGLUrl = ConfigurationManager.AppSettings["HJGLUrl"];
}
catch (Exception ex)
{
ErrLogInfo.WriteLog(ex);
AppDomain.Unload(AppDomain.CurrentDomain);
}
// 开启线程
System.Threading.Thread LoadServiceData = new System.Threading.Thread(new System.Threading.ThreadStart(WelderIsSync));
LoadServiceData.Start();
}
private void WelderIsSync()
{
//定义一个定时器,并开启和配置相关属性
System.Timers.Timer Wtimer = new System.Timers.Timer();
//执行任务的周期 ,20分钟
Wtimer.Interval = 1000 * 60 * 60;
Wtimer.Enabled = true;
Wtimer.Start();
Wtimer.Elapsed += new System.Timers.ElapsedEventHandler(Wtimer_Elapsed);
}
void Wtimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
// 得到 hour minute second 如果等于某个值就开始执行某个程序。
int intHour = e.SignalTime.Hour;
int intMinute = e.SignalTime.Minute;
// 要执行的代码
var welders = from x in Funs.DB.OAM_User where (x.IsSync == null || x.IsSync == false) && x.MID_Code != null && x.MID_Code != string.Empty select x;
var quas = from x in Funs.DB.OAM_UesrQualified where (x.IsSync == null || x.IsSync == false) && (x.IsDelete == false || x.IsDelete == null) select x;
var units = (from x in Funs.DB.OAM_User where !x.MID_Unit.Contains("-") select x.MID_Unit).Distinct().ToList();
var allUnits = from x in Funs.DB.Base_Unit select x;
foreach (var unit in units)
{
if (!allUnits.Any(x => x.UnitId == unit || x.UnitName == unit))
{
Model.Base_Unit u = new Model.Base_Unit();
u.UnitId = SQLHelper.GetNewID();
u.UnitName = unit;
u.IsMain = true;
u.IsSubUnit = false;
BLL.Base_UnitService.AddUnit(u);
}
}
foreach (var q in welders)
{
var s = from x in Funs.DB.HJGL_BS_Welder where x.IdentityCard == q.MID_IdentityCard select x;
var u = BLL.Base_UnitService.GetUnit2(q.MID_Unit);
if (u != null)
{
Model.HJGL_BS_Welder newWelder = new Model.HJGL_BS_Welder();
newWelder.WED_Code = q.MID_Code;
newWelder.WED_Name = q.MID_Name;
newWelder.WED_Unit = u.UnitId;
newWelder.WED_Sex = q.MID_Sex;
newWelder.IdentityCard = q.MID_IdentityCard;
newWelder.WED_WorkCode = q.MID_WordCode;
newWelder.WED_IfOnGuard = q.MID_IfOnGuard;
newWelder.WED_Remark = q.MID_Remark;
newWelder.MaxHanTiao = q.MID_HanTiao;
newWelder.MaxWeldingWire = q.MID_WeldingWire;
newWelder.IsOAM = true;
if (s.Count() > 0)
{
newWelder.WED_ID = s.First().WED_ID;
BLL.HJGL_PersonManageService.UpdateBSWelder(newWelder);
}
else
{
BLL.HJGL_PersonManageService.AddBSWelder(newWelder);
}
// 回写表OAM_User
string identityCard = q.MID_IdentityCard;
bool isSync = true;
BLL.HJGL_WelderQualifiedProjectService.UpdateOAWelder(identityCard, isSync);
}
}
//更新单位变更情况
var allWelders = from x in Funs.DB.OAM_User select x;
foreach (var q in allWelders)
{
var u = BLL.Base_UnitService.GetUnit2(q.MID_Unit);
var w = BLL.HJGL_PersonManageService.GetWelderByIdentityCard(q.MID_IdentityCard);
if (u != null && w != null)
{
w.WED_Unit = u.UnitId;
w.WED_IfOnGuard = q.IsUsed;
BLL.HJGL_PersonManageService.UpdateBSWelder(w);
}
}
foreach (var q in quas)
{
var s = from x in Funs.DB.HJGL_BS_Welder where x.WED_Code == q.MIDWelder_Code select x;
if (s.Count() > 0)
{
if (!string.IsNullOrEmpty(q.MIDWelder_QualifiedProjectCode))
{
if (q.MIDWelder_QualifiedProjectCode.Contains("+"))
{
string[] codes = q.MIDWelder_QualifiedProjectCode.Split('+');
foreach (string c in codes)
{
var oldCode = from x in Funs.DB.HJGL_BS_WelderQualifiedProject where x.WED_ID == s.First().WED_ID && x.QualifiedProjectCode == c && x.LimitDate.Value.Date == q.MIDWelder_LimitDate.Value.Date select x;
if (oldCode.Count() == 0)
{
Model.HJGL_BS_WelderQualifiedProject welderQualifiedProject = new Model.HJGL_BS_WelderQualifiedProject();
welderQualifiedProject.WelderQualifiedProjectId = SQLHelper.GetNewID(typeof(Model.HJGL_BS_WelderQualifiedProject));
welderQualifiedProject.WED_ID = s.First().WED_ID;
welderQualifiedProject.QualifiedProjectCode = c;
welderQualifiedProject.LimitDate = q.MIDWelder_LimitDate;
welderQualifiedProject.IsSteelStru = q.MIDWelder_sfxgjgbl;
welderQualifiedProject.IsDemoteUse = q.MIDWelder_jjsybl;
welderQualifiedProject.DemoteUseSteelType = q.MIDWelder_jjsy;
BLL.HJGL_WelderQualifiedProjectService.AddWelderQualifiedProject(welderQualifiedProject);
}
else
{
string welderQualifiedProjectId = oldCode.First().WelderQualifiedProjectId;
DateTime? limitDate = q.MIDWelder_LimitDate;
BLL.HJGL_WelderQualifiedProjectService.UpdateWelderQualifiedLimitDate(welderQualifiedProjectId, limitDate, q.MIDWelder_sfxgjgbl, q.MIDWelder_jjsybl, q.MIDWelder_jjsy);
}
}
}
else
{
var oldCode = from x in Funs.DB.HJGL_BS_WelderQualifiedProject where x.WED_ID == s.First().WED_ID && x.QualifiedProjectCode == q.MIDWelder_QualifiedProjectCode && x.LimitDate.Value.Date == q.MIDWelder_LimitDate.Value.Date select x;
if (oldCode.Count() == 0)
{
Model.HJGL_BS_WelderQualifiedProject welderQualifiedProject = new Model.HJGL_BS_WelderQualifiedProject();
welderQualifiedProject.WelderQualifiedProjectId = SQLHelper.GetNewID(typeof(Model.HJGL_BS_WelderQualifiedProject));
welderQualifiedProject.WED_ID = s.First().WED_ID;
welderQualifiedProject.QualifiedProjectCode = q.MIDWelder_QualifiedProjectCode;
welderQualifiedProject.LimitDate = q.MIDWelder_LimitDate;
welderQualifiedProject.IsSteelStru = q.MIDWelder_sfxgjgbl;
welderQualifiedProject.IsDemoteUse = q.MIDWelder_jjsybl;
welderQualifiedProject.DemoteUseSteelType = q.MIDWelder_jjsy;
BLL.HJGL_WelderQualifiedProjectService.AddWelderQualifiedProject(welderQualifiedProject);
}
else
{
string welderQualifiedProjectId = oldCode.First().WelderQualifiedProjectId;
DateTime? limitDate = q.MIDWelder_LimitDate;
BLL.HJGL_WelderQualifiedProjectService.UpdateWelderQualifiedLimitDate(welderQualifiedProjectId, limitDate, q.MIDWelder_sfxgjgbl, q.MIDWelder_jjsybl, q.MIDWelder_jjsy);
}
}
// 回写表OAM_UesrQualified
long welder_ID = q.MIDWelder_ID;
bool isSync = true;
BLL.HJGL_WelderQualifiedProjectService.UpdateOAWelderQue(welder_ID, isSync);
}
}
}
//更新资质删除情况
var allDeleteQuas = from x in Funs.DB.OAM_UesrQualified where x.IsDelete == true select x;
var allWelders2 = from x in Funs.DB.HJGL_BS_Welder select x;
foreach (var q in allDeleteQuas)
{
var s = allWelders2.FirstOrDefault(x => x.WED_Code == q.MIDWelder_Code);
if (s != null)
{
if (!string.IsNullOrEmpty(q.MIDWelder_QualifiedProjectCode))
{
if (q.MIDWelder_QualifiedProjectCode.Contains("+"))
{
string[] codes = q.MIDWelder_QualifiedProjectCode.Split('+');
foreach (string c in codes)
{
var oldCode = (from x in Funs.DB.HJGL_BS_WelderQualifiedProject where x.WED_ID == s.WED_ID && x.QualifiedProjectCode == c && x.LimitDate.Value.Date == q.MIDWelder_LimitDate.Value.Date select x).FirstOrDefault();
if (oldCode != null)
{
BLL.HJGL_WelderQualifiedProjectService.DeleteWelderQualifiedProjectByWelderQualifiedProjectId(oldCode.WelderQualifiedProjectId);
}
}
}
else
{
var oldCode = (from x in Funs.DB.HJGL_BS_WelderQualifiedProject where x.WED_ID == s.WED_ID && x.QualifiedProjectCode == q.MIDWelder_QualifiedProjectCode && x.LimitDate.Value.Date == q.MIDWelder_LimitDate.Value.Date select x).FirstOrDefault();
if (oldCode != null)
{
BLL.HJGL_WelderQualifiedProjectService.DeleteWelderQualifiedProjectByWelderQualifiedProjectId(oldCode.WelderQualifiedProjectId);
}
}
}
}
}
var que = from x in Funs.DB.HJGL_BS_WelderQualifiedProject select x;
if (que.Count() > 0)
{
foreach (var q in que)
{
string weldMethod = string.Empty;
string materialType = string.Empty;
string location = string.Empty;
string weldType = string.Empty;
decimal thicknessMax = 0; // 0表示不限
decimal sizesMin = 0; // 0表示不限
string materialTypeName = string.Empty;
string[] queProject = q.QualifiedProjectCode.Split('-');
// 焊接方法和钢材类型
weldMethod = queProject[0].Trim();
if (queProject.Count() > 1)
{
if (q.IsDemoteUse == true)
{
string[] demoteUseSteelType = q.DemoteUseSteelType.Split(',');
if (demoteUseSteelType.Count() > 0)
{
foreach (string type in demoteUseSteelType)
{
if (type == "FeIV" || type == "FeⅣ")
{
materialType = materialType + "FeⅣ" + ",";
materialTypeName = materialTypeName + "铬钼钢" + ",";
}
if (type == "FeIII" || type == "FeⅢ")
{
materialType = materialType + "FeⅢ" + ",";
materialTypeName = materialTypeName + "合金钢" + ",";
}
if (type == "FeII" || type == "FeⅡ")
{
materialType = materialType + "FeⅡ" + ",";
materialTypeName = materialTypeName + "不锈钢" + ",";
}
if (type == "FeI" || type == "FeⅠ")
{
materialType = materialType + "FeⅠ" + ",";
materialTypeName = materialTypeName + "碳钢" + ",";
}
}
if (materialType.Length > 0 && materialTypeName.Length > 0)
{
materialType = materialType.Substring(0, materialType.Length - 1);
materialTypeName = materialTypeName.Substring(0, materialTypeName.Length - 1);
}
}
}
else
{
if (weldMethod.Contains("GTAW") || weldMethod.Contains("SAW"))
{
if (queProject[1].Trim() == ("FeI") || queProject[1].Trim() == ("FeⅠ"))
{
materialType = "FeⅠ";
materialTypeName = "碳钢";
}
else if (queProject[1].Trim() == ("FeII") || queProject[1].Trim() == ("FeⅡ"))
{
materialType = "FeⅡ,FeⅠ";
materialTypeName = "不锈钢,碳钢";
}
else if (queProject[1].Trim() == ("FeIII") || queProject[1].Trim() == ("FeⅢ"))
{
materialType = "FeⅢ";
materialTypeName = "合金钢";
}
else if (queProject[1].Trim() == ("FeIV") || queProject[1].Trim() == ("FeⅣ"))
{
materialType = "FeⅣ";
materialTypeName = "铬钼钢";
}
else if (queProject[1].Trim().Contains("Ni"))
{
materialType = "NiⅤ,NiⅣ,NiⅢ,NiⅡ,NiⅠ";
materialTypeName = "镍基合金";
}
else if (queProject[1].Trim().Contains("P61"))
{
materialType = "Zr3";
materialTypeName = "其它";
}
else if (queProject[1].Trim().Contains("P62"))
{
materialType = "Zr5";
materialTypeName = "其它";
}
else if (queProject[1].Trim().Contains("TiⅡ"))
{
materialType = "TiⅡ,TiⅠ";
materialTypeName = "钛合金";
}
else if (queProject[1].Trim().Contains("TiⅠ"))
{
materialType = "TiⅠ";
materialTypeName = "钛合金";
}
else
{
materialType = "FeⅣ,FeⅢ,FeⅡ,FeⅠ";
materialTypeName = "其它";
}
}
else if (weldMethod.Contains("SMAW") || weldMethod.Contains("GMAW") || weldMethod.Contains("FCAW"))
{
if (queProject[1].Trim() == ("FeI") || queProject[1].Trim() == ("FeⅠ"))
{
materialType = "FeⅠ";
materialTypeName = "碳钢";
}
else if (queProject[1].Trim() == ("FeII") || queProject[1].Trim() == ("FeⅡ"))
{
materialType = "FeⅡ,FeⅠ";
materialTypeName = "不锈钢,碳钢";
}
else if (queProject[1].Trim() == ("FeIII") || queProject[1].Trim() == ("FeⅢ"))
{
materialType = "FeⅢ,FeⅡ,FeⅠ";
materialTypeName = "合金钢,不锈钢,碳钢";
}
else if (queProject[1].Trim() == ("FeIV") || queProject[1].Trim() == ("FeⅣ"))
{
materialType = "FeⅣ";
materialTypeName = "铬钼钢";
}
else if (queProject[1].Trim().Contains("Ni"))
{
materialType = "NiⅤ,NiⅣ,NiⅢ,NiⅡ,NiⅠ";
materialTypeName = "镍基合金";
}
else if (queProject[1].Trim().Contains("P61"))
{
materialType = "Zr3";
materialTypeName = "其它";
}
else if (queProject[1].Trim().Contains("P62"))
{
materialType = "Zr5";
materialTypeName = "其它";
}
else if (queProject[1].Trim().Contains("TiⅡ"))
{
materialType = "TiⅡ,TiⅠ";
materialTypeName = "钛合金";
}
else if (queProject[1].Trim().Contains("TiⅠ"))
{
materialType = "TiⅠ";
materialTypeName = "钛合金";
}
else
{
materialType = queProject[1].Trim();
materialTypeName = "其它";
}
}
else
{
if (queProject[1].Trim().Contains("Ni"))
{
materialType = "NiⅤ,NiⅣ,NiⅢ,NiⅡ,NiⅠ";
materialTypeName = "镍基合金";
}
else if (queProject[1].Trim().Contains("P61"))
{
materialType = "Zr3";
materialTypeName = "其它";
}
else if (queProject[1].Trim().Contains("P62"))
{
materialType = "Zr5";
materialTypeName = "其它";
}
else if (queProject[1].Trim().Contains("TiⅡ"))
{
materialType = "TiⅡ,TiⅠ";
materialTypeName = "钛合金";
}
else if (queProject[1].Trim().Contains("TiⅠ"))
{
materialType = "TiⅠ";
materialTypeName = "钛合金";
}
else
{
materialType = queProject[1].Trim();
materialTypeName = "其它";
}
}
}
}
if (queProject.Count() > 2)
{
// 焊接位置
if (queProject[2].Contains("6G"))
{
location = "ALL";
}
else if (queProject[2].Contains("2G"))
{
location = "1G,2G";
}
else if (queProject[2].Contains("3G"))
{
location = "1G,2G,3G";
}
else if (queProject[2].Contains("4G"))
{
location = "1G,3G,4G";
}
else if (queProject[2].Contains("5G"))
{
location = "1G,2G,3G,5G";
}
else if (queProject[2].Contains("6FG"))
{
location = "ALL";
}
else if (queProject[2].Contains("5FG"))
{
location = "2FG,5FG";
}
else if (queProject[2].Contains("4FG"))
{
location = "2FG,4FG";
}
else
{
location = queProject[2].Trim();
if (weldMethod.Contains("GTAW") || weldMethod.Contains("SAW"))
{
location = queProject[1].Trim();
}
}
// 1-对接,2-角焊缝,3-支管连接焊缝
if (queProject[2].Contains("FG"))
{
weldType = "2,3";
}
else
{
weldType = "1,2";
}
}
if (queProject.Count() > 3)
{
// 壁厚和外径
string[] thickSize = queProject[3].Split('/');
if (thickSize.Count() == 2)
{
double t = 0.0;
double s = 0.0;
if (double.TryParse(thickSize[0], out t))
{
decimal thick = Convert.ToDecimal(t);
if (thick < 12)
{
//thicknessMax = "≤" + thick * 2;
thicknessMax = thick * 2;
}
else
{
thicknessMax = 0;
}
}
if (double.TryParse(thickSize[1], out s))
{
decimal size = Convert.ToDecimal(s);
if (size < 25)
{
//sizesMin = "≥" + size;
sizesMin = size;
}
else if (size >= 25 && size < 76)
{
//sizesMin = "≥25";
sizesMin = 25;
}
else
{
//sizesMin = "≥76";
sizesMin = 76;
}
}
}
else if (thickSize.Count() == 1)
{
thicknessMax = 0;
//sizesMin = "≥76";
sizesMin = 76;
}
}
if (queProject.Count() > 4)
{
if (queProject[4].Contains("Ni"))
{
materialType = "NiⅤ,NiⅣ,NiⅢ,NiⅡ,NiⅠ";
materialTypeName = "镍基合金";
}
}
Model.HJGL_BS_WelderQualifiedProject updateQue = new Model.HJGL_BS_WelderQualifiedProject();
updateQue.WelderQualifiedProjectId = q.WelderQualifiedProjectId;
updateQue.WED_ID = q.WED_ID;
updateQue.QualifiedProjectCode = q.QualifiedProjectCode;
updateQue.LimitDate = q.LimitDate;
updateQue.WeldingMethodId = weldMethod;
updateQue.MaterialType = materialType;
updateQue.WeldingLocationId = location;
updateQue.WeldType = weldType;
updateQue.ThicknessMax = thicknessMax;
updateQue.SizesMin = sizesMin;
updateQue.MaterialTypeName = materialTypeName;
BLL.HJGL_WelderQualifiedProjectService.UpdateWelderQualifiedProject(updateQue);
}
}
bool b = false;
string orderTime = string.Empty;
if (intHour == 8)
{
orderTime = "7:00 - 8:00";
}
else if (intHour == 9)
{
orderTime = "8:00 - 9:00";
}
else if (intHour == 10)
{
orderTime = "9:00 - 10:00";
}
else if (intHour == 11)
{
orderTime = "10:00 - 11:00";
}
else if (intHour == 12)
{
orderTime = "11:00 - 12:00";
}
else if (intHour == 13)
{
orderTime = "12:00 - 13:00";
}
else if (intHour == 14)
{
orderTime = "13:00 - 14:00";
}
else if (intHour == 15)
{
orderTime = "14:00 - 15:00";
}
else if (intHour == 16)
{
orderTime = "15:00 - 16:00";
}
else if (intHour == 17)
{
orderTime = "16:00 - 17:00";
}
else if (intHour == 18)
{
orderTime = "17:00 - 18:00";
}
else if (intHour == 19)
{
orderTime = "18:00 - 19:00";
}
else if (intHour == 20)
{
orderTime = "19:00 - 20:00";
}
else if (intHour == 21)
{
orderTime = "20:00 - 21:00";
}
if (!string.IsNullOrEmpty(orderTime))
{
b = true;
}
if (b)
{
string lastPlan = @"SELECT p.UsingPlanId FROM dbo.Weld_UsingPlan p
WHERE p.OrderDate listStr = new List();
listStr.Add(new SqlParameter("@OrderTime", orderTime));
SqlParameter[] parameter = listStr.ToArray();
DataTable dt = SQLHelper.GetDataTableRunText(lastPlan, parameter);
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
string usingPlanId = dt.Rows[i]["UsingPlanId"].ToString();
BLL.UsingPlanService.UpdateIsCancel(usingPlanId, "超时未领用");
}
}
}
#region 自动生成热处理委托信息,按管线号生成
Model.SGGLDB db = Funs.DB;
var allJoints = from x in db.HJGL_PW_JointInfo
where (from y in db.HJGL_CH_HotProessTrustItem where y.JOT_ID == x.JOT_ID select y).Count() == 0 && x.IS_Proess == "1"
select x;
var allIsoIds = allJoints.Select(x => x.ISO_ID).Distinct();
var allIsos = from x in db.HJGL_PW_IsoInfo
join y in db.Base_Project on x.ProjectId equals y.ProjectId
where allIsoIds.Contains(x.ISO_ID)
select new { x.ISO_ID, x.ProjectId, x.ISO_IsoNo, x.BSU_ID, y.ProjectName, y.ProjectCode };
var allProjectUser = from x in db.Project_User
join y in db.Sys_User on x.UserId equals y.UserId
select new { x.UserId, x.ProjectId, y.UnitId };
string HotProessTrustId = string.Empty;
List trusts = new List();
List trustItems = new List();
List hotProessResults = new List();
foreach (var item in allIsos)
{
Model.HJGL_CH_HotProessTrust newHotProessTrust = new Model.HJGL_CH_HotProessTrust();
newHotProessTrust.ProjectId = item.ProjectId;
newHotProessTrust.HotProessTrustCode = BLL.SQLHelper.RunProcNewIdByProjectId("SpGetNewCode2ByProjectIdNoR", "dbo.HJGL_CH_HotProessTrust", "HotProessTrustCode", item.ProjectId, item.ProjectCode + "-" + string.Format("{0:MMdd}", DateTime.Now) + "-");
newHotProessTrust.TrustUnitId = item.BSU_ID;
newHotProessTrust.ProjectName = item.ProjectName;
newHotProessTrust.ConstructionNo = item.ProjectCode;
var projectUser = allProjectUser.FirstOrDefault(x => x.ProjectId == item.ProjectId && x.UnitId == item.BSU_ID);
if (projectUser != null)
{
newHotProessTrust.TrstManId = projectUser.UserId;
}
HotProessTrustId = SQLHelper.GetNewID(typeof(Model.HJGL_CH_HotProessTrust));
newHotProessTrust.HotProessTrustId = HotProessTrustId;
newHotProessTrust.TrustType = "1"; //正常口
db.HJGL_CH_HotProessTrust.InsertOnSubmit(newHotProessTrust);
db.SubmitChanges();
//trusts.Add(newHotProessTrust);
var joints = allJoints.Where(x => x.ISO_ID == item.ISO_ID);
foreach (var joint in joints)
{
if (!string.IsNullOrEmpty(joint.ProessTypes))
{
string[] proessTypes = joint.ProessTypes.Split('|');
for (int i = 0; i < proessTypes.Length; i++)
{
Model.HJGL_CH_HotProessTrustItem newItem = new Model.HJGL_CH_HotProessTrustItem();
newItem.HotProessTrustId = HotProessTrustId;
newItem.JOT_ID = joint.JOT_ID;
newItem.ProessTypes = proessTypes[i];
//item.TrustDate = Funs.GetNewDateTime(values.Value("TrustDate").ToString());
newItem.TrustDate = DateTime.Now;
newItem.Remark = string.Empty;
newItem.HotProessTrustItemId = SQLHelper.GetNewID(typeof(Model.HJGL_CH_HotProessTrustItem));
trustItems.Add(newItem);
//if (newItem.ProessTypes.Contains("4") || newItem.ProessTypes.Contains("5")) //需要进入热处理报告的记录
//{
// Model.HJGL_HotProessItem hotProessItem = new Model.HJGL_HotProessItem();
// hotProessItem.HotProessItemId = SQLHelper.GetNewID(typeof(Model.HJGL_HotProessItem));
// hotProessItem.JOT_ID = newItem.JOT_ID;
// hotProessItem.HotProessTrustId = HotProessTrustId;
// hotProessItem.ProessTypes = newItem.ProessTypes;
// hotProessItem.SortIndex = BLL.HJGL_HotProessManageEditService.GetSortIndex(HotProessTrustId, newItem.JOT_ID, newItem.ProessTypes);
// Model.HJGL_CH_HotProessTrustItem hotProessTrustItem = BLL.HJGL_CH_HotProessTrustService.GetCH_HotProessTrustItemByHotProessTrustIdAndJotId(HotProessTrustId, newItem.JOT_ID);
// if (hotProessTrustItem != null)
// {
// BLL.HJGL_HotProessManageEditService.AddHotProessItem(hotProessItem, "", null);
// }
// //回写焊口热处理委托时间
// BLL.HJGL_PW_JointInfoService.WriteBackHotProessTrustDate(newItem.JOT_ID, newItem.TrustDate);
//}
//进入热处理结果反馈
Model.HJGL_CH_HotProessResult hotProessResult = new Model.HJGL_CH_HotProessResult();
hotProessResult.JOT_ID = newItem.JOT_ID;
hotProessResult.HotProessTrustId = HotProessTrustId;
hotProessResult.ProessTypes = newItem.ProessTypes;
hotProessResult.HotProessResultId = SQLHelper.GetNewID(typeof(Model.HJGL_CH_HotProessResult));
hotProessResults.Add(hotProessResult);
}
}
}
}
db.HJGL_CH_HotProessTrust.InsertAllOnSubmit(trusts);
db.SubmitChanges();
db.HJGL_CH_HotProessTrustItem.InsertAllOnSubmit(trustItems);
db.SubmitChanges();
db.HJGL_CH_HotProessResult.InsertAllOnSubmit(hotProessResults);
db.SubmitChanges();
//已焊接口
var allWeldJoints = from x in db.HJGL_PW_JointInfo
where x.DReportID != null && x.IS_Proess == "1" && (x.ProessTypes.Contains("4") || x.ProessTypes.Contains("5"))
&& (from y in db.HJGL_HotProessItem where y.JOT_ID == x.JOT_ID select y).Count() == 0
select x;
foreach (var item in allWeldJoints)
{
BLL.HJGL_HotProessManageEditService.AddHotProessItemByJoint(item);
}
#endregion
}
protected void Session_Start(object sender, EventArgs e)
{
Session.Timeout = 36000;
// 这种统计在线人数的做法会有一定的误差
Application.Lock();
Application["OnlineUserCount"] = (int)Application["OnlineUserCount"] + 1;
Application.UnLock();
}
protected void Application_BeginRequest(object sender, EventArgs e)
{
}
protected void Application_AuthenticateRequest(object sender, EventArgs e)
{
}
protected void Application_Error(object sender, EventArgs e)
{
StringBuilder errLog = null;
Exception ex = null;
try
{
// 获取错误类
ex = Server.GetLastError().InnerException;
if (ex == null)
{
ex = Server.GetLastError().GetBaseException();
}
errLog = new StringBuilder();
errLog.Append(String.Format(CultureInfo.InvariantCulture, "出错文件:{0}\r\n", Request.Url.AbsoluteUri));
if (Request.UserHostAddress != null)
{
errLog.Append(String.Format(CultureInfo.InvariantCulture, "IP地址:{0}\r\n", Request.UserHostAddress));
}
if (Session != null && Session["CurrUser"] != null)
{
errLog.Append(String.Format(CultureInfo.InvariantCulture, "操作人员:{0}\r\n", BLL.Sys_UserService.GetUsersByUserId(((Model.Sys_User)Session["CurrUser"]).UserId).UserName));
}
else
{
PageBase.ZXRefresh(Request.ApplicationPath + "/LogOff.aspx");
}
if (ex is HttpRequestValidationException)
{
PageBase.ZXRefresh(Request.ApplicationPath + "/Wrong.aspx?Message=0");
}
else if (ex is FriendlyException)
{
PageBase.ZXRefresh(Request.ApplicationPath + "/Wrong.aspx?MessageText=" + ex.Message);
}
}
catch
{
try
{
PageBase.ZXRefresh(Request.ApplicationPath + "/OperationError.aspx");
}
catch
{
}
}
finally
{
ErrLogInfo.WriteLog(ex, errLog == null ? null : errLog.ToString());
Server.ClearError();
PageBase.ZXRefresh(Request.ApplicationPath + "/OperationError.aspx");
}
}
protected void Session_End(object sender, EventArgs e)
{
}
protected void Application_End(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(1000);
string RequestURL = "http://hjgl.izpje.com:88/";
//这里设置你的web地址,可以随便指向你的任意一个aspx页面甚至不存在的页面,目的是要激发Application_Start
HttpWebRequest __HttpWebRequest = (HttpWebRequest)WebRequest.Create(RequestURL);
HttpWebResponse __HttpWebResponse = (HttpWebResponse)__HttpWebRequest.GetResponse();
Stream __rStream = __HttpWebResponse.GetResponseStream();//得到回写的字节流
//当不再需要计时器时,请使用 Dispose 方法释放计时器持有的资源。
__rStream.Close();
__rStream.Dispose();
}
}
}