| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722 |
- using System;
- using System.Globalization;
- using System.ServiceModel.Activation;
- using System.Timers;
- using System.Web;
- using System.Web.Routing;
- using Curtain.DataAccess;
- using Curtain.Extension.ExObjectConvert;
- using Curtain.Log;
- using Dongke.IBOSS.PRD.Basics.BaseResources;
- using Dongke.IBOSS.PRD.Basics.DataAccess;
- using Dongke.IBOSS.PRD.Basics.Library;
- using Dongke.IBOSS.PRD.WCF.Contracts;
- using Dongke.IBOSS.PRD.WCF.ExHGS3QRS;
- using Dongke.IBOSS.PRD.WCF.Services;
- namespace Dongke.IBOSS.PRD.WCF.WebHosting
- {
- public class Global : HttpApplication
- {
- protected void Application_Start(object sender, EventArgs e)
- {
- Logger.DefaultLogDirectory = "Log";
- InitService();
- // 更改连接串
- INIUtility ini = INIUtility.Instance(INIUtility.IniFile.Config);
- DataManager.ConnectionString = string.Format(DataManager.ConnectionStringFormat,
- ini.ReadIniData("DBSetting", "DBIP"),
- ini.ReadIniData("DBSetting", "DBPort"),
- ini.ReadIniData("DBSetting", "SID"),
- ini.ReadIniData("DBSetting", "DBUser"),
- Encryption.DecryptDES(ini.ReadIniData("DBSetting", "DBPassword"), Constant.S_ENCRYPTION_KEY)
- );
- DataManager.ConnectionStringReport = DataManager.ConnectionString;
- try
- {
- string DBIP = ini.ReadIniData("DBSettingReport", "DBIP");
- if (!string.IsNullOrWhiteSpace(DBIP))
- {
- DataManager.ConnectionStringReport = string.Format(DataManager.ConnectionStringFormat,
- DBIP,
- ini.ReadIniData("DBSettingReport", "DBPort"),
- ini.ReadIniData("DBSettingReport", "SID"),
- ini.ReadIniData("DBSettingReport", "DBUser"),
- Encryption.DecryptDES(ini.ReadIniData("DBSettingReport", "DBPassword"), Constant.S_ENCRYPTION_KEY)
- );
- }
- }
- catch
- {
- }
- DataAccess.DefaultDataBaseType = Curtain.DataAccess.DataBaseType.Oracle;
- DataAccess.DefaultConnectionString = DataManager.ConnectionString;
- // SAP接口自动调用
- InitSAP_HEGII();
- }
- private void InitService()
- {
- // 此处处理需要进行映射的服务类
- /* ServiceRoute实体
- * 第一个参数为客户端调用终结点地址的名称
- * 第二个参数固定写法
- * 第三个参数为终结点调用对应的服务类
- */
- RouteTable.Routes.Add
- (
- new ServiceRoute
- (
- "DKService/PDAModuleService", new WebServiceHostFactory(), typeof(PDAModuleService)
- )
- );
- RouteTable.Routes.Add
- (
- new ServiceRoute
- (
- "DKService/DKIBOSSPRDService", new WebServiceHostFactory(), typeof(DKIBOSSPRDService)
- )
- );
- RouteTable.Routes.Add
- (
- new ServiceRoute
- (
- "DKService/CommonModuleService", new WebServiceHostFactory(), typeof(CommonModuleService)
- )
- );
- RouteTable.Routes.Add
- (
- new ServiceRoute
- (
- "DKService/SystemModuleService", new WebServiceHostFactory(), typeof(SystemModuleService)
- )
- );
- RouteTable.Routes.Add
- (
- new ServiceRoute
- (
- "DKService/HRModuleService", new WebServiceHostFactory(), typeof(HRModuleService)
- )
- );
- RouteTable.Routes.Add
- (
- new ServiceRoute
- (
- "DKService/PCModuleService", new WebServiceHostFactory(), typeof(PCModuleService)
- )
- );
- RouteTable.Routes.Add
- (
- new ServiceRoute
- (
- "DKService/PMModuleService", new WebServiceHostFactory(), typeof(PMModuleService)
- )
- );
- RouteTable.Routes.Add
- (
- new ServiceRoute
- (
- "DKService/TATModuleService", new WebServiceHostFactory(), typeof(TATModuleService)
- )
- );
- RouteTable.Routes.Add
- (
- new ServiceRoute
- (
- "DKService/ReportModuleService", new WebServiceHostFactory(), typeof(ReportModuleService)
- )
- );
- RouteTable.Routes.Add
- (
- new ServiceRoute
- (
- "DKService/WCFTestService", new WebServiceHostFactory(), typeof(WCFTestService)
- )
- );
- RouteTable.Routes.Add
- (
- new ServiceRoute
- (
- "DKService/CMNModuleService", new WebServiceHostFactory(), typeof(CMNModuleService)
- )
- );
- RouteTable.Routes.Add
- (
- new ServiceRoute
- (
- "DKService/PMModuleServiceNew", new WebServiceHostFactory(), typeof(PMModuleServiceNew)
- )
- );
- RouteTable.Routes.Add
- (
- new ServiceRoute
- (
- "DKService/PCModuleServiceNew", new WebServiceHostFactory(), typeof(PCModuleServiceNew)
- )
- );
- RouteTable.Routes.Add
- (
- new ServiceRoute
- (
- "DKService/PAMModuleService", new WebServiceHostFactory(), typeof(PAMModuleService)
- )
- );
- RouteTable.Routes.Add
- (
- new ServiceRoute
- (
- "DKService/PublicModuleService", new WebServiceHostFactory(), typeof(PublicModuleService)
- )
- );
- RouteTable.Routes.Add
- (
- new ServiceRoute
- (
- "DKService/SmartDeviceService", new WebServiceHostFactory(), typeof(SmartDeviceService)
- )
- );
- RouteTable.Routes.Add
- (
- new ServiceRoute
- (
- "DKService/ExHGS3QR", new WebServiceHostFactory(), typeof(ExHGS3QR)
- )
- );
- RouteTable.Routes.Add
- (
- new ServiceRoute
- (
- "DKService/SAPDataService", new WebServiceHostFactory(), typeof(SAPDataService)
- )
- );
- RouteTable.Routes.Add
- (
- new ServiceRoute
- (
- "DKService/PPModuleService", new WebServiceHostFactory(), typeof(PPModuleService)
- )
- );
- }
- #region SAP_HEGII
- private class TimerLocker
- {
- public string LockerName = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffffff");
- }
- private static Timer SAP_HEGII_Timer = null;
- private static TimerLocker Timer_Loker = null;
- private static bool Timer_doing = false;
- public static void InitSAP_HEGII()
- {
- try
- {
- INIUtility ini = INIUtility.Instance(INIUtility.IniFile.SAP_HEGII);
- // 下次开始时间
- string SAP_ING = ini.ReadIniData("SAP_HEGII", "SAP_ING");
- if (SAP_ING != "1")
- {
- OutputLog.TraceLog(LogPriority.Information,
- "Global",
- "Application_Start - InitSAP_HEGII",
- "Timer not Started",
- LocalPath.LogExePath + "SAP_HEGII\\Timer_");
- return;
- }
- //if (string.IsNullOrWhiteSpace(interval))
- //{
- // return;
- //}
- double intt = 60000;
- //if (!double.TryParse(interval, out intt) || intt < 30000)
- //{
- // intt = 60000;
- //}
- Timer_Loker = new TimerLocker();
- SAP_HEGII_Timer = new Timer();
- SAP_HEGII_Timer.Interval = intt;
- SAP_HEGII_Timer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
- SAP_HEGII_Timer.AutoReset = true;
- SAP_HEGII_Timer.Enabled = true;
- OutputLog.TraceLog(LogPriority.Information,
- "Global",
- "Application_Start - InitSAP_HEGII",
- "Timer Started : " + Timer_Loker.LockerName + " - " + intt,
- LocalPath.LogExePath + "SAP_HEGII\\Timer_");
- }
- catch (Exception ex)
- {
- OutputLog.TraceLog(LogPriority.Error,
- "Global",
- "InitSAP_HEGII",
- ex.ToString(),
- LocalPath.LogExePath + "SAP_HEGII\\Error_");
- }
- }
- private static void OnTimedEvent(object source, ElapsedEventArgs e)
- {
- if (Timer_doing)
- {
- return;
- }
- try
- {
- Timer_doing = true;
- lock (Timer_Loker)
- {
- // 当前时间
- IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(Basics.DataAccess.DataBaseType.ORACLE, DataManager.ConnectionString);
- DateTime dateTimeNow = Convert.ToDateTime(oracleConn.GetSqlResultToObj("SELECT SYSDATE FROM DUAL"));
- oracleConn.Close();
- DateTime ndate;
- INIUtility ini = INIUtility.Instance(INIUtility.IniFile.SAP_HEGII);
- #region 报工_1001
- string nextDate_BG_1001 = ini.ReadIniData("SAP_HEGII", "NextDate_BG_1001");
- string strInterval_BG_1001 = ini.ReadIniData("SAP_HEGII", "Interval_BG_1001");
- if (!string.IsNullOrWhiteSpace(nextDate_BG_1001) && !string.IsNullOrWhiteSpace(strInterval_BG_1001) &&
- DateTime.TryParseExact(nextDate_BG_1001, "yyyy-MM-dd HH:mm", null, DateTimeStyles.None, out ndate) && ndate <= dateTimeNow)
- {
- // 间隔时间(分钟)
- int interva_BG_1001 = strInterval_BG_1001.ToInt32();
- DateTime nextDateINI_BG_1001 = ndate.AddMinutes(interva_BG_1001);
- while (nextDateINI_BG_1001 <= dateTimeNow)
- {
- nextDateINI_BG_1001 = nextDateINI_BG_1001.AddMinutes(interva_BG_1001);
- }
- // 更新下次执行时间
- ini.WriteIniData("SAP_HEGII", "NextDate_BG_1001", nextDateINI_BG_1001.ToString("yyyy-MM-dd HH:mm"));
- OutputLog.TraceLog(LogPriority.Information,
- "Global2",
- "OnTimedEvent begin: ",
- "SyncSap5000 : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
- + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + $" -date:" + ndate.ToString("yyyy-MM-dd HH:mm:ss")
- + $" -[{interva_BG_1001}]" + nextDateINI_BG_1001.ToString("yyyy-MM-dd HH:mm:ss"),
- LocalPath.LogExePath + "SAP_HEGII\\Timer_");
- Service.SAPHegiiDataService.SAPDataLogic.AutoWorkDataToSAP5000("1001", ndate);
- OutputLog.TraceLog(LogPriority.Information,
- "Global2",
- "OnTimedEvent end",
- "SyncSap5000 : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
- + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + " - " + ndate.ToString("yyyy-MM-dd HH:mm:ss"),
- LocalPath.LogExePath + "SAP_HEGII\\Timer_");
- }
- #endregion
- #region 报工_10,20,30,40
- string nextDate_BG = ini.ReadIniData("SAP_HEGII", "NextDate_BG");
- string strInterval_BG = ini.ReadIniData("SAP_HEGII", "Interval_BG");
- if (!string.IsNullOrWhiteSpace(nextDate_BG) && !string.IsNullOrWhiteSpace(strInterval_BG) &&
- DateTime.TryParseExact(nextDate_BG, "yyyy-MM-dd HH:mm", null, DateTimeStyles.None, out ndate) && ndate <= dateTimeNow)
- {
- // 间隔时间(分钟)
- int interva_BG = strInterval_BG.ToInt32();
- DateTime nextDateINI_BG = ndate.AddMinutes(interva_BG);
- while (nextDateINI_BG <= dateTimeNow)
- {
- nextDateINI_BG = nextDateINI_BG.AddMinutes(interva_BG);
- }
- // 更新下次执行时间
- ini.WriteIniData("SAP_HEGII", "NextDate_BG", nextDateINI_BG.ToString("yyyy-MM-dd HH:mm"));
- OutputLog.TraceLog(LogPriority.Information,
- "Global2",
- "OnTimedEvent begin: ",
- "SyncSap5000 : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
- + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + $" -date:" + ndate.ToString("yyyy-MM-dd HH:mm:ss")
- + $" -[{interva_BG}]" + nextDateINI_BG.ToString("yyyy-MM-dd HH:mm:ss"),
- LocalPath.LogExePath + "SAP_HEGII\\Timer_");
- Service.SAPHegiiDataService.SAPDataLogic.AutoWorkDataToSAP5000("10,20,30,40", ndate);
- OutputLog.TraceLog(LogPriority.Information,
- "Global2",
- "OnTimedEvent end",
- "SyncSap5000 : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
- + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + " - " + ndate.ToString("yyyy-MM-dd HH:mm:ss"),
- LocalPath.LogExePath + "SAP_HEGII\\Timer_");
- }
- #endregion
- #region 报工_50
- string nextDate_BG_50 = ini.ReadIniData("SAP_HEGII", "NextDate_BG_50");
- string strInterval_BG_50 = ini.ReadIniData("SAP_HEGII", "Interval_BG_50");
- if (!string.IsNullOrWhiteSpace(nextDate_BG_50) && !string.IsNullOrWhiteSpace(strInterval_BG_50) &&
- DateTime.TryParseExact(nextDate_BG_50, "yyyy-MM-dd HH:mm", null, DateTimeStyles.None, out ndate) && ndate <= dateTimeNow)
- {
- // 间隔时间(分钟)
- int interva_BG_50 = strInterval_BG_50.ToInt32();
- DateTime nextDateINI_BG_50 = ndate.AddMinutes(interva_BG_50);
- while (nextDateINI_BG_50 <= dateTimeNow)
- {
- nextDateINI_BG_50 = nextDateINI_BG_50.AddMinutes(interva_BG_50);
- }
- // 更新下次执行时间
- ini.WriteIniData("SAP_HEGII", "NextDate_BG_50", nextDateINI_BG_50.ToString("yyyy-MM-dd HH:mm"));
- OutputLog.TraceLog(LogPriority.Information,
- "Global2",
- "OnTimedEvent begin: ",
- "SyncSap5000 : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
- + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + $" -date:" + ndate.ToString("yyyy-MM-dd HH:mm:ss")
- + $" -[{interva_BG_50}]" + nextDateINI_BG_50.ToString("yyyy-MM-dd HH:mm:ss"),
- LocalPath.LogExePath + "SAP_HEGII\\Timer_");
- Service.SAPHegiiDataService.SAPDataLogic.AutoWorkDataToSAP5000("50", ndate);
- OutputLog.TraceLog(LogPriority.Information,
- "Global2",
- "OnTimedEvent end",
- "SyncSap5000 : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
- + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + " - " + ndate.ToString("yyyy-MM-dd HH:mm:ss"),
- LocalPath.LogExePath + "SAP_HEGII\\Timer_");
- }
- #endregion
- #region 报工_60
- string nextDate_BG_60 = ini.ReadIniData("SAP_HEGII", "NextDate_BG_60");
- string strInterval_BG_60 = ini.ReadIniData("SAP_HEGII", "Interval_BG_60");
- if (!string.IsNullOrWhiteSpace(nextDate_BG_60) && !string.IsNullOrWhiteSpace(strInterval_BG_60) &&
- DateTime.TryParseExact(nextDate_BG_60, "yyyy-MM-dd HH:mm", null, DateTimeStyles.None, out ndate) && ndate <= dateTimeNow)
- {
- // 间隔时间(分钟)
- int interva_BG_60 = strInterval_BG_60.ToInt32();
- DateTime nextDateINI_BG_60 = ndate.AddMinutes(interva_BG_60);
- while (nextDateINI_BG_60 <= dateTimeNow)
- {
- nextDateINI_BG_60 = nextDateINI_BG_60.AddMinutes(interva_BG_60);
- }
- // 更新下次执行时间
- ini.WriteIniData("SAP_HEGII", "NextDate_BG_60", nextDateINI_BG_60.ToString("yyyy-MM-dd HH:mm"));
- OutputLog.TraceLog(LogPriority.Information,
- "Global2",
- "OnTimedEvent begin: ",
- "SyncSap5000 : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
- + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + $" -date:" + ndate.ToString("yyyy-MM-dd HH:mm:ss")
- + $" -[{interva_BG_60}]" + nextDateINI_BG_60.ToString("yyyy-MM-dd HH:mm:ss"),
- LocalPath.LogExePath + "SAP_HEGII\\Timer_");
- Service.SAPHegiiDataService.SAPDataLogic.AutoWorkDataToSAP5000("60", ndate);
- OutputLog.TraceLog(LogPriority.Information,
- "Global2",
- "OnTimedEvent end",
- "SyncSap5000 : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
- + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + " - " + ndate.ToString("yyyy-MM-dd HH:mm:ss"),
- LocalPath.LogExePath + "SAP_HEGII\\Timer_");
- }
- #endregion
- #region 移库
- string nextDate_YK = ini.ReadIniData("SAP_HEGII", "NextDate_YK");
- string strInterval_YK = ini.ReadIniData("SAP_HEGII", "Interval_YK");
- if (!string.IsNullOrWhiteSpace(nextDate_YK) && !string.IsNullOrWhiteSpace(strInterval_YK) &&
- DateTime.TryParseExact(nextDate_YK, "yyyy-MM-dd HH:mm", null, DateTimeStyles.None, out ndate) && ndate <= dateTimeNow)
- {
- // 间隔时间(分钟)
- int interva_YK = strInterval_YK.ToInt32();
- DateTime nextDateINI_YK = ndate.AddMinutes(interva_YK);
- while (nextDateINI_YK <= dateTimeNow)
- {
- nextDateINI_YK = nextDateINI_YK.AddMinutes(interva_YK);
- }
- // 更新下次执行时间
- ini.WriteIniData("SAP_HEGII", "NextDate_YK", nextDateINI_YK.ToString("yyyy-MM-dd HH:mm"));
- OutputLog.TraceLog(LogPriority.Information,
- "Global2",
- "OnTimedEvent begin: ",
- "BGYKToSAP : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
- + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + $" -date:" + ndate.ToString("yyyy-MM-dd HH:mm:ss")
- + $" -[{interva_YK}]" + nextDateINI_YK.ToString("yyyy-MM-dd HH:mm:ss"),
- LocalPath.LogExePath + "SAP_HEGII\\Timer_");
- Service.SAPHegiiDataService.SAPDataLogic.BGYKToSAP(ndate, ndate);
- OutputLog.TraceLog(LogPriority.Information,
- "Global2",
- "OnTimedEvent end",
- "BGYKToSAP : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
- + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + " - " + ndate.ToString("yyyy-MM-dd HH:mm:ss"),
- LocalPath.LogExePath + "SAP_HEGII\\Timer_");
- }
- #endregion
- #region 跨车间作业
- string nextDate_KCJ = ini.ReadIniData("SAP_HEGII", "NextDate_KCJ");
- //string strInterval_KCJ = ini.ReadIniData("SAP_HEGII", "Interval_KCJ");
- if (!string.IsNullOrWhiteSpace(nextDate_KCJ) &&
- DateTime.TryParseExact(nextDate_KCJ, "yyyy-MM-dd", null, DateTimeStyles.None, out ndate) && ndate <= dateTimeNow)
- {
- // 间隔时间(分钟)
- //int interva_KCJ = strInterval_KCJ.ToInt32();
- DateTime nextDateINI_KCJ = ndate.AddMonths(1);
- while (nextDateINI_KCJ <= dateTimeNow)
- {
- nextDateINI_KCJ = nextDateINI_KCJ.AddMonths(1);
- }
- // 更新下次执行时间
- ini.WriteIniData("SAP_HEGII", "NextDate_KCJ", nextDateINI_KCJ.ToString("yyyy-MM-dd"));
- OutputLog.TraceLog(LogPriority.Information,
- "Global2",
- "OnTimedEvent begin: ",
- "CrossWorkshopToSAP : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
- + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + $" -date:" + ndate.ToString("yyyy-MM-dd HH:mm:ss")
- + $" -[{1}]" + nextDateINI_KCJ.ToString("yyyy-MM-dd HH:mm:ss"),
- LocalPath.LogExePath + "SAP_HEGII\\Timer_");
- Service.SAPHegiiDataService.SAPDataLogic.CrossWorkshopToSAP(ndate, ndate);
- OutputLog.TraceLog(LogPriority.Information,
- "Global2",
- "OnTimedEvent end",
- "CrossWorkshopToSAP : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
- + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + " - " + ndate.ToString("yyyy-MM-dd HH:mm:ss"),
- LocalPath.LogExePath + "SAP_HEGII\\Timer_");
- }
- #endregion
- #region 商标变更
- string nextDate_SBBG = ini.ReadIniData("SAP_HEGII", "NextDate_SBBG");
- string strInterval_SBBG = ini.ReadIniData("SAP_HEGII", "Interval_SBBG");
- if (!string.IsNullOrWhiteSpace(nextDate_SBBG) && !string.IsNullOrWhiteSpace(strInterval_SBBG) &&
- DateTime.TryParseExact(nextDate_SBBG, "yyyy-MM-dd HH:mm", null, DateTimeStyles.None, out ndate) && ndate <= dateTimeNow)
- {
- // 间隔时间(分钟)
- int interva_SBBG = strInterval_SBBG.ToInt32();
- DateTime nextDateINI_SBBG = ndate.AddMinutes(interva_SBBG);
- while (nextDateINI_SBBG <= dateTimeNow)
- {
- nextDateINI_SBBG = nextDateINI_SBBG.AddMinutes(interva_SBBG);
- }
- // 更新下次执行时间
- ini.WriteIniData("SAP_HEGII", "nextDate_SBBG", nextDateINI_SBBG.ToString("yyyy-MM-dd HH:mm"));
- OutputLog.TraceLog(LogPriority.Information,
- "Global2",
- "OnTimedEvent begin: ",
- "SyncSap5000 : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
- + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + $" -date:" + ndate.ToString("yyyy-MM-dd HH:mm:ss")
- + $" -[{interva_SBBG}]" + nextDateINI_SBBG.ToString("yyyy-MM-dd HH:mm:ss"),
- LocalPath.LogExePath + "SAP_HEGII\\Timer_");
- Service.SAPHegiiDataService.SAPDataLogic.AutoWorkDataToSAP5000SBBG( ndate);
- OutputLog.TraceLog(LogPriority.Information,
- "Global2",
- "OnTimedEvent end",
- "SyncSap5000 : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
- + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + " - " + ndate.ToString("yyyy-MM-dd HH:mm:ss"),
- LocalPath.LogExePath + "SAP_HEGII\\Timer_");
- }
- #endregion
- //2022年9月23日13:06:25 添加时间限制,10月1号零点10分不再传输原接口产量数据
- //DateTime setTime = new DateTime(2022, 10, 1, 0, 10, 0);
- // 下次开始时间
- //string nextDate = ini.ReadIniData("SAP_HEGII", "NextDate");
- //string strInterval = ini.ReadIniData("SAP_HEGII", "Interval");
- #region 原报工(注销)
- //if (dateTimeNow < setTime
- // && !string.IsNullOrWhiteSpace(nextDate) && !string.IsNullOrWhiteSpace(strInterval))
- //{
- // ndate = DateTime.ParseExact(nextDate, "yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture);
- // DateTime.TryParseExact(nextDate, "yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture, DateTimeStyles.None, out ndate);
- // if (ndate != null && ndate <= dateTimeNow)
- // {
- // // 间隔时间(分钟)
- // int interval = strInterval.ToInt32();
- // DateTime nextDateINI = ndate.AddMinutes(interval);
- // while (nextDateINI <= dateTimeNow)
- // {
- // nextDateINI = nextDateINI.AddMinutes(interval);
- // }
- // // 更新下次执行时间
- // ini.WriteIniData("SAP_HEGII", "NextDate", nextDateINI.ToString("yyyy-MM-dd HH:mm"));
- // string funCode = ini.ReadIniData("SAP_HEGII", "FunCode");
- // OutputLog.TraceLog(LogPriority.Information,
- // "Global2",
- // "OnTimedEvent begin: " + funCode,
- // "AutoWorkDataToSAP : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
- // + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + $" -date:" + ndate.ToString("yyyy-MM-dd HH:mm:ss")
- // + $" -[{interval}]" + nextDateINI.ToString("yyyy-MM-dd HH:mm:ss"),
- // LocalPath.LogExePath + "SAP_HEGII\\Timer_");
- // Service.SAPHegiiDataService.SAPDataLogic.AutoWorkDataToSAP(ndate, funCode, ndate);
- // OutputLog.TraceLog(LogPriority.Information,
- // "Global2",
- // "OnTimedEvent end",
- // "AutoWorkDataToSAP : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
- // + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + " - " + ndate.ToString("yyyy-MM-dd HH:mm:ss"),
- // LocalPath.LogExePath + "SAP_HEGII\\Timer_");
- // }
- //}
- #endregion
- #region 50(注销)
- //string nextDate50 = ini.ReadIniData("SAP_HEGII", "NextDate50");
- //string strInterval50 = ini.ReadIniData("SAP_HEGII", "Interval50");
- ////2022年9月23日13:06:25 添加时间限制,10月1号零点10分不再传输原接口产量数据
- //if (dateTimeNow < setTime &&
- // !string.IsNullOrWhiteSpace(nextDate50) && !string.IsNullOrWhiteSpace(strInterval50) &&
- // DateTime.TryParseExact(nextDate50, "yyyy-MM-dd HH:mm", null, DateTimeStyles.None, out ndate) &&
- //ndate <= dateTimeNow)
- //{
- // // 间隔时间(分钟)
- // int interval50 = strInterval50.ToInt32();
- // DateTime nextDateINI50 = ndate.AddMinutes(interval50);
- // while (nextDateINI50 <= dateTimeNow)
- // {
- // nextDateINI50 = nextDateINI50.AddMinutes(interval50);
- // }
- // // 更新下次执行时间
- // ini.WriteIniData("SAP_HEGII", "NextDate50", nextDateINI50.ToString("yyyy-MM-dd HH:mm"));
- // string funCode = "50";
- // OutputLog.TraceLog(LogPriority.Information,
- // "Global2",
- // "OnTimedEvent begin: " + funCode,
- // "AutoWorkDataToSAP : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
- // + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + $" -date:" + ndate.ToString("yyyy-MM-dd HH:mm:ss")
- // + $" -[{interval50}]" + nextDateINI50.ToString("yyyy-MM-dd HH:mm:ss"),
- // LocalPath.LogExePath + "SAP_HEGII\\Timer_");
- // Service.SAPHegiiDataService.SAPDataLogic.AutoWorkDataToSAP(ndate, funCode, ndate);
- // OutputLog.TraceLog(LogPriority.Information,
- // "Global2",
- // "OnTimedEvent end",
- // "AutoWorkDataToSAP : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
- // + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + " - " + ndate.ToString("yyyy-MM-dd HH:mm:ss"),
- // LocalPath.LogExePath + "SAP_HEGII\\Timer_");
- //}
- #endregion
- #region 6002(注销)
- /*
- string nextDate6002 = ini.ReadIniData("SAP_HEGII", "NextDate6002");
- if (!string.IsNullOrWhiteSpace(nextDate6002))
- {
- if (DateTime.TryParseExact(nextDate6002, "yyyy-MM-dd HH:mm", null, DateTimeStyles.None, out ndate))
- {
- //DateTime date = e.SignalTime; //DateTime.Now;
- DateTime date = DateTime.Now;
- if (ndate <= date)
- {
- //ini.WriteIniData("SAP_HEGII", "NextDate6002", date.AddHours(1).ToString("yyyy-MM-dd HH:")+ ndate.ToString("mm"));
- ini.WriteIniData("SAP_HEGII", "NextDate6002", date.AddMinutes(20).ToString("yyyy-MM-dd HH:mm"));
- string funCode = "6002"; // ini.ReadIniData("SAP_HEGII", "FunCode");
- OutputLog.TraceLog(LogPriority.Information,
- "Global",
- "OnTimedEvent begin: " + funCode,
- "AutoWorkDataToSAP : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
- + " - " + date.ToString("yyyy-MM-dd HH:mm:ss") + " - " + ndate.ToString("yyyy-MM-dd HH:mm:ss"),
- LocalPath.LogExePath + "SAP_HEGII\\Timer_");
- Service.SAPHegiiDataService.SAPDataLogic.AutoWorkDataToSAP(date, funCode);
- OutputLog.TraceLog(LogPriority.Information,
- "Global",
- "OnTimedEvent end",
- "AutoWorkDataToSAP : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
- + " - " + date.ToString("yyyy-MM-dd HH:mm:ss") + " - " + ndate.ToString("yyyy-MM-dd HH:mm:ss"),
- LocalPath.LogExePath + "SAP_HEGII\\Timer_");
- }
- }
- }
- */
- #endregion
- }
- }
- catch (Exception ex)
- {
- OutputLog.TraceLog(LogPriority.Error,
- "Global",
- "OnTimedEvent - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss"),
- ex.ToString(),
- LocalPath.LogExePath + "SAP_HEGII\\Error_");
- }
- finally
- {
- Timer_doing = false;
- }
- }
- #endregion
- protected void Session_Start(object sender, EventArgs e)
- {
- }
- protected void Application_BeginRequest(object sender, EventArgs e)
- {
- }
- protected void Application_AuthenticateRequest(object sender, EventArgs e)
- {
- }
- protected void Application_Error(object sender, EventArgs e)
- {
- //try
- //{
- // Logger.Error(
- //}
- //catch
- //{
- //}
- }
- protected void Session_End(object sender, EventArgs e)
- {
- }
- protected void Application_End(object sender, EventArgs e)
- {
- SAP_HEGII_Timer?.Dispose();
- SAP_HEGII_Timer = null;
- string lockerName = Timer_Loker?.LockerName;
- Timer_Loker = null;
- if (!string.IsNullOrEmpty(lockerName))
- {
- OutputLog.TraceLog(LogPriority.Information,
- "Global",
- "Application_End",
- "Timer End : " + lockerName,
- LocalPath.LogExePath + "SAP_HEGII\\Timer_");
- }
- }
- }
- }
|