515 lines
25 KiB
C#
515 lines
25 KiB
C#
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;
|
||
|
||
public class Global : System.Web.HttpApplication
|
||
{
|
||
/// <summary>
|
||
/// 自动启用插件标志文件路径
|
||
/// </summary>
|
||
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"];
|
||
}
|
||
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 * 20;
|
||
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;
|
||
// 定制时间; 在9点的时候执行焊工同步
|
||
if (intHour == 9)
|
||
{
|
||
// 要执行的代码
|
||
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 select x;
|
||
|
||
foreach (var q in welders)
|
||
{
|
||
var s = from x in Funs.DB.HJGL_BS_Welder where x.WED_Code == q.MID_Code select x;
|
||
var u = BLL.Base_UnitService.GetUnit(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 = q.MID_Unit;
|
||
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);
|
||
}
|
||
}
|
||
|
||
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);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
// 10点
|
||
if (intHour == 10)
|
||
{
|
||
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"))
|
||
{
|
||
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
|
||
{
|
||
materialType = queProject[1].Trim();
|
||
materialTypeName = "其它";
|
||
}
|
||
}
|
||
else if (weldMethod.Contains("SMAW"))
|
||
{
|
||
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
|
||
{
|
||
materialType = queProject[1].Trim();
|
||
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();
|
||
}
|
||
|
||
// 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;
|
||
}
|
||
}
|
||
|
||
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);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
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();
|
||
|
||
}
|
||
}
|
||
}
|