| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344 |
- using System;
- using System.Globalization;
- using System.ServiceModel.Activation;
- using System.Timers;
- using System.Web;
- using System.Web.Routing;
- using Curtain.DataAccess;
- 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.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)
- );
- DataAccess.DefaultConnectionString = DataManager.ConnectionString;
- DataAccess.DefaultDataBaseType = Curtain.DataAccess.DataBaseType.Oracle;
- // SAP接口自动调用
- InitSAP_HEGII(ini.ReadIniData("SAP_HEGII", "Interval"));
- }
- 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/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 void InitSAP_HEGII(string interval)
- {
- try
- {
- 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)
- {
- try
- {
- lock (Timer_Loker)
- {
- INIUtility ini = INIUtility.Instance(INIUtility.IniFile.Config);
- string nextDate = ini.ReadIniData("SAP_HEGII", "NextDate");
- string nextDate6002 = ini.ReadIniData("SAP_HEGII", "NextDate6002");
- if (!string.IsNullOrWhiteSpace(nextDate))
- {
- string byTime = ini.ReadIniData("SAP_HEGII", "ByTime");
- if (string.IsNullOrWhiteSpace(byTime))
- {
- byTime = "00:00";
- }
- //OutputLog.TraceLog(LogPriority.Information,
- // "Global",
- // "OnTimedEvent ",
- // "OnTimedEvent begin : " + nextDate + " - " + byTime,
- // LocalPath.LogExePath + "SAP_HEGII\\Timer_");
- DateTime ndate;
- if (DateTime.TryParseExact(nextDate + " " + byTime, "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", "NextDate", date.AddDays(1).ToString("yyyy-MM-dd"));
- string funCode = 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_");
- }
- }
- }
- if (!string.IsNullOrWhiteSpace(nextDate6002))
- {
- DateTime ndate;
- 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_");
- }
- }
- }
- }
- }
- 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_");
- }
- }
- #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)
- {
- }
- 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_");
- }
- }
- }
- }
|