/// <summary> /// Check username and password.<br /> /// Check is Employee No. active.<br /> /// Get user default language.<br/> /// Refresh user data. /// </summary> /// <param name="Cond"></param> /// <returns></returns> public ActionResult Login(doLogin Cond) { ObjectResultData res = new ObjectResultData(); try { if (ModelState.IsValid == false) { ValidatorUtil.BuildErrorMessage(res, this); return(Json(res)); } //1.2 ILoginHandler handLogin = ServiceContainer.GetService <ILoginHandler>() as ILoginHandler; bool bLogDomain = handLogin.LoginDomain(Cond); //if (!bLogDomain) //{ // if (handLogin.IsLockedEmployee(Cond.EmployeeNo)) // { // res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0PWL); // } // else // { // //Comment for Test Only : Nattapong N. // res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0099); // } // ILogHandler handLog = ServiceContainer.GetService<ILogHandler>() as ILogHandler; // handLog.WriteWindowLog(EventType.C_EVENT_TYPE_ERROR, LogMessage.C_LOG_INVALID_USER, EventID.C_EVENT_ID_LOGIN_FAIL); // return Json(res); //} // Clear Temporary pdf file where crate date < today bool isClear = ReportUtil.ClearTemporaryFile(); //1.3 IEmployeeMasterHandler handEmp = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler; bool blnExistEmployee = handEmp.CheckExistActiveEmployee(Cond.EmployeeNo); //if (!blnExistEmployee) //{ // res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0099); // return Json(res); //} dsTransDataModel dsTrans = new dsTransDataModel(); ITransDataHandler handTrans = ServiceContainer.GetService <ITransDataHandler>() as ITransDataHandler; #region Language dsTrans.dtTransHeader = new TransHeaderDo(); dsTrans.dtTransHeader.Language = CommonValue.DEFAULT_LANGUAGE_EN; if (this.RouteData.Values["lang"] != null && !string.IsNullOrWhiteSpace(this.RouteData.Values["lang"].ToString())) { // set the culture from the route data (url) string lang = this.RouteData.Values["lang"].ToString(); if (lang.ToLower() == CommonValue.DEFAULT_SHORT_LANGUAGE_EN) { dsTrans.dtTransHeader.Language = CommonValue.DEFAULT_LANGUAGE_EN; } else if (lang.ToLower() == CommonValue.DEFAULT_SHORT_LANGUAGE_JP) { dsTrans.dtTransHeader.Language = CommonValue.DEFAULT_LANGUAGE_JP; } else if (lang.ToLower() == CommonValue.DEFAULT_SHORT_LANGUAGE_LC) { dsTrans.dtTransHeader.Language = CommonValue.DEFAULT_LANGUAGE_LC; } } CommonUtil.dsTransData = dsTrans; #endregion #region Refesh Data handTrans.RefreshUserData(dsTrans, Cond.EmployeeNo); handTrans.RefreshOfficeData(dsTrans); handTrans.RefreshPermissionData(dsTrans); #endregion handLogin.KeepHistory(Cond.EmployeeNo, LogType.C_LOG_IN); dsTrans.dtOperationData = new OperationDataDo(); dsTrans.dtOperationData.ProcessDateTime = DateTime.Now; dsTrans.dtCommonSearch = new CommonSearchDo(); CommonUtil.dsTransData = dsTrans; //-----------Add by Narupon W.-------(Menu list)-----------------// IMasterHandler handMAS = ServiceContainer.GetService <IMasterHandler>() as IMasterHandler; List <tbm_Object> menuList = handMAS.GetTbm_Object(); dsTrans.dtMenuNameList = CommonUtil.ClonsObjectList <tbm_Object, MenuName>(menuList); CommonUtil.MappingObjectLanguage <MenuName>(dsTrans.dtMenuNameList); //-----------END Add by Narupon W.-------(Menu list)-------------// res.ResultData = "/Common/CMS020"; doDirectScreen dos = CommonUtil.GetSession <doDirectScreen>("DIRECT_SCREEN"); if (dos != null) { res.ResultData = dos; CommonUtil.SetSession("DIRECT_SCREEN", null); } } catch (Exception ex) { res.AddErrorMessage(ex); } return(Json(res)); }