/// <summary> /// Generate quotation office combobox /// </summary> /// <param name="helper"></param> /// <param name="id"></param> /// <param name="attribute"></param> /// <param name="firstElement"></param> /// <returns></returns> public static MvcHtmlString QuotationOfficeComboBox(this HtmlHelper helper, string id, object attribute = null, string firstElement = null) { List <OfficeDataDo> nLst = new List <OfficeDataDo>(); try { dsTransDataModel dstrans = CommonUtil.dsTransData; if (dstrans != null) { List <OfficeDataDo> lst = new List <OfficeDataDo>(); List <OfficeDataDo> clst = dstrans.dtOfficeData; if (clst != null) { foreach (OfficeDataDo off in clst) { if (off.FunctionQuatation != SECOM_AJIS.Common.Util.ConstantValue.FunctionQuotation.C_FUNC_QUOTATION_NO) { lst.Add(off); } } } nLst = CommonUtil.ClonsObjectList <OfficeDataDo, OfficeDataDo>(lst); CommonUtil.MappingObjectLanguage <OfficeDataDo>(nLst); } } catch { } return(CommonUtil.CommonComboBoxWithCustomFirstElement <OfficeDataDo>(id, nLst, "OfficeCodeName", "OfficeCode", firstElement, attribute)); }
public static void SetTransDataForJobScheduler(string userId, DateTime?batchDate) { dsTransDataModel dsTransTemp = new dsTransDataModel(); dsTransTemp.dtTransHeader = new TransHeaderDo(); dsTransTemp.dtTransHeader.Language = CommonValue.DEFAULT_LANGUAGE_EN; dsTransTemp.dtUserData = new UserDataDo() { EmpNo = userId, EmpFirstNameEN = userId, EmpFirstNameLC = userId, EmpLastNameEN = userId, EmpLastNameLC = userId, }; dsTransTemp.dtUserBelongingData = new List <UserBelongingData>(); dsTransTemp.dtOfficeData = new List <OfficeDataDo>(); dsTransTemp.dtUserPermissionData = new Dictionary <string, UserPermissionDataDo>(); dsTransTemp.dtOperationData = new OperationDataDo(); dsTransTemp.dtOperationData.ProcessDateTime = (batchDate ?? DateTime.Now); dsTransTemp.dtCommonSearch = new CommonSearchDo(); CommonUtil.dsTransData = dsTransTemp; }
/// <summary> /// Event on action executing for check user permission /// </summary> /// <param name="filterContext"></param> public override void OnActionExecuting(ActionExecutingContext filterContext) { //filterContext.HttpContext.Response.Write("Before action:" + Function); try { PropertyInfo pinfo = typeof(FunctionID).GetProperty(Function); string functionId=pinfo.GetValue(null,null).ToString(); dsTransDataModel dsTrans = CommonUtil.dsTransData; if (dsTrans.dtUserPermissionData != null) { string screenId = filterContext.RouteData.Values["action"].ToString(); screenId = screenId.Substring(0, 6); string permissionKey = screenId + "." + functionId; if (!dsTrans.dtUserPermissionData.ContainsKey(permissionKey) == true) return; base.OnActionExecuting(filterContext); } } catch (NullReferenceException e) { } }
/// <summary> /// Check user permission by ScreenID and Function. /// </summary> /// <param name="ScreenID">Screen ID</param> /// <param name="FunctionID">Funtion ID</param> /// <returns></returns> protected bool CheckUserPermission(string ScreenID, string FunctionID) { try { dsTransDataModel dsTrans = CommonUtil.dsTransData; if (dsTrans == null && ScreenID != null && FunctionID != null) { return(false); } if (dsTrans.dtUserPermissionData != null) { string permissionKey = ScreenID + "." + FunctionID; // 2016.06 modify tanaka start return(true); //if (dsTrans.dtUserPermissionData.ContainsKey(permissionKey) == true) // return true; // 20.16.06 modify tanaka end } } catch (Exception) { } return(false); }
/// <summary> /// Get current language /// </summary> /// <param name="includeLang2"></param> /// <returns></returns> public static LANGUAGE_LIST CurrentLanguage(bool includeLang2 = true) { dsTransDataModel dsTrans = dsTransData; if (dsTrans != null) { if (dsTrans.dtTransHeader != null) { if (includeLang2 && dsTrans.dtTransHeader.Language == CommonValue.DEFAULT_LANGUAGE_JP) { return(LANGUAGE_LIST.LANGUAGE_2); } else if (dsTrans.dtTransHeader.Language == CommonValue.DEFAULT_LANGUAGE_EN || dsTrans.dtTransHeader.Language == CommonValue.DEFAULT_LANGUAGE_JP) { return(LANGUAGE_LIST.LANGUAGE_1); } else { return(LANGUAGE_LIST.LANGUAGE_3); } } } return(LANGUAGE_LIST.LANGUAGE_1); }
/// <summary> /// Insert customer group /// </summary> /// <param name="groupList"></param> /// <returns></returns> public int InsertCustomerGroup(List <dtCustomeGroupData> groupList) { try { List <tbm_CustomerGroup> gLst = CommonUtil.ClonsObjectList <dtCustomeGroupData, tbm_CustomerGroup>(groupList); dsTransDataModel dsTrans = CommonUtil.dsTransData; foreach (tbm_CustomerGroup group in gLst) { ApplicationErrorException.CheckMandatoryField <tbm_CustomerGroup, dtCustomerGroupDataCondition>(group); group.CreateDate = dsTrans.dtOperationData.ProcessDateTime; group.CreateBy = dsTrans.dtUserData.EmpNo; group.UpdateDate = dsTrans.dtOperationData.ProcessDateTime; group.UpdateBy = dsTrans.dtUserData.EmpNo; } List <tbm_CustomerGroup> lst = InsertCustomerGroup(CommonUtil.ConvertToXml_Store <tbm_CustomerGroup>(gLst)); return(lst.Count); } catch (Exception) { throw; } }
public List <tbm_Site> InsertSite(doSite site) { try { //set CreateDate, CreateBy, UpdateDate and UpdateBy dsTransDataModel dsTrans = CommonUtil.dsTransData; site.CreateDate = dsTrans.dtOperationData.ProcessDateTime; site.CreateBy = dsTrans.dtUserData.EmpNo; site.UpdateDate = dsTrans.dtOperationData.ProcessDateTime; site.UpdateBy = dsTrans.dtUserData.EmpNo; ApplicationErrorException.CheckMandatoryField <doSite, tbm_SiteCondition>(site); List <tbm_Site> lst = this.InsertSite(site.SiteCode, site.CustCode, site.SiteNo, site.SiteNameEN, site.SiteNameLC, site.SECOMContactPerson, site.PersonInCharge, site.PhoneNo, site.BuildingUsageCode, site.AddressEN, site.AlleyEN, site.RoadEN, site.SubDistrictEN, site.AddressFullEN, site.AddressLC, site.AlleyLC, site.RoadLC, site.SubDistrictLC, site.AddressFullLC, site.DistrictCode, site.ProvinceCode, site.ZipCode, site.CreateDate, site.CreateBy, site.UpdateDate, site.UpdateBy); //Insert Log if (lst.Count > 0) { doTransactionLog logData = new doTransactionLog(); logData.TransactionType = doTransactionLog.eTransactionType.Insert; logData.TableName = TableName.C_TBL_NAME_SITE; logData.TableData = CommonUtil.ConvertToXml(lst); ILogHandler hand = ServiceContainer.GetService <ILogHandler>() as ILogHandler; hand.WriteTransactionLog(logData); } return(lst); } catch (Exception) { throw; } }
/// <summary> /// /// </summary> /// <param name="billingClient"></param> /// <returns></returns> public List <tbm_BillingClient> InsertBillingClient(tbm_BillingClient billingClient) { try { //1. Check Mandatory Fields for input parameter. //BillingClientCode, CustTypeCode, NameEN, NameLC, AddressEN, AddressLC ApplicationErrorException.CheckMandatoryField <tbm_BillingClient, tbm_BillingClientCondition>(billingClient); dsTransDataModel dsTrans = CommonUtil.dsTransData; billingClient.CreateDate = dsTrans.dtOperationData.ProcessDateTime; billingClient.CreateBy = dsTrans.dtUserData.EmpNo; billingClient.UpdateDate = dsTrans.dtOperationData.ProcessDateTime; billingClient.UpdateBy = dsTrans.dtUserData.EmpNo; List <tbm_BillingClient> insertList = this.InsertBillingClient(billingClient.BillingClientCode, billingClient.NameEN, billingClient.NameLC, billingClient.FullNameEN, billingClient.FullNameLC, billingClient.BranchNo, billingClient.BranchNameEN, billingClient.BranchNameLC, billingClient.CustTypeCode, billingClient.CompanyTypeCode, billingClient.BusinessTypeCode, billingClient.PhoneNo, billingClient.IDNo, billingClient.RegionCode, billingClient.AddressEN, billingClient.AddressLC, billingClient.CreateDate, billingClient.CreateBy, billingClient.UpdateDate, billingClient.UpdateBy, billingClient.DeleteFlag); //Insert Log if (insertList.Count > 0) { doTransactionLog logData = new doTransactionLog(); logData.TransactionType = doTransactionLog.eTransactionType.Insert; logData.TableName = TableName.C_TBL_NAME_BILLING_CLIENT; logData.TableData = CommonUtil.ConvertToXml(insertList); ILogHandler hand = ServiceContainer.GetService <ILogHandler>() as ILogHandler; hand.WriteTransactionLog(logData); } return(insertList); } catch (Exception ex) { throw ex; } }
/// <summary> /// Keep history of current user.<br /> /// Clear transaction data. /// </summary> /// <returns></returns> public ActionResult Logout() { dsTransDataModel dsTrans = CommonUtil.dsTransData; if (dsTrans != null) { ILoginHandler handLogin = ServiceContainer.GetService <ILoginHandler>() as ILoginHandler; handLogin.KeepHistory(CommonUtil.dsTransData.dtUserData.EmpNo, LogType.C_LOG_OUT); CommonUtil.dsTransData = null; } return(Json(true)); }
/// <summary> /// Change current language and reload screen with selected language. /// </summary> /// <param name="lang"></param> /// <returns></returns> public void changeLanguageDsTransData(string lang) { try { if (!CommonUtil.IsNullOrEmpty(lang)) { dsTransDataModel dstrans = CommonUtil.dsTransData; lang = lang.ToLower(); if (lang == CommonValue.DEFAULT_SHORT_LANGUAGE_EN) { dstrans.dtTransHeader.Language = CommonValue.DEFAULT_LANGUAGE_EN; } else if (lang == CommonValue.DEFAULT_SHORT_LANGUAGE_JP) { dstrans.dtTransHeader.Language = CommonValue.DEFAULT_LANGUAGE_JP; } else { dstrans.dtTransHeader.Language = CommonValue.DEFAULT_LANGUAGE_LC; } //Update Language CommonUtil.MappingObjectLanguage <OfficeDataDo>(dstrans.dtOfficeData); CommonUtil.dsTransData = dstrans; //Update Language for menu list CommonUtil.MappingObjectLanguage <MenuName>(CommonUtil.MenuNameList); Session.Remove("Menu"); ScreenParameter param = GetScreenObject <object>() as ScreenParameter; if (param != null) { ScreenParameter nparam = ScreenParameter.ResetScreenParameter(param); if (nparam != null) { nparam.IsLoaded = false; nparam.BackStep = true; UpdateScreenObject(nparam); } } } } catch (Exception) { } }
/// <summary> /// Refresh user data of dsTrans object /// </summary> /// <param name="dsTrans"></param> /// <param name="EmpNo"></param> public void RefreshUserData(dsTransDataModel dsTrans, string EmpNo) { try { dsTrans.dtUserData = null; IEmployeeMasterHandler handEmp = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler; List <dtEmployeeData> dtEmp = handEmp.GetUserData(EmpNo); if (dtEmp.Count > 0) { dsTrans.dtUserData = CommonUtil.CloneObject <dtEmployeeData, UserDataDo>(dtEmp[0]); } } catch (Exception) { throw; } }
/// <summary> /// Update contract email data /// </summary> /// <param name="listEmail"></param> /// <returns></returns> public int UpdateTbt_ContractEmail(List <tbt_ContractEmail> listEmail) //Add by Jutarat A. on 14012014 { try { if (listEmail != null) { List <tbt_ContractEmail> rList; dsTransDataModel dsTrans = CommonUtil.dsTransData; foreach (tbt_ContractEmail data in listEmail) { rList = this.GetTbt_ContractEmail(data.ContractEmailID); if (DateTime.Compare(rList[0].UpdateDate.Value, data.UpdateDate.Value) != 0) { throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0019); } data.UpdateDate = dsTrans.dtOperationData.ProcessDateTime; data.UpdateBy = dsTrans.dtUserData.EmpNo; } } List <tbt_ContractEmail> res = this.UpdateTbt_ContractEmail(CommonUtil.ConvertToXml_Store <tbt_ContractEmail>(listEmail)); #region Log doTransactionLog logData = new doTransactionLog() { TransactionType = doTransactionLog.eTransactionType.Update, TableName = TableName.C_TBL_NAME_CON_EMAIL, TableData = CommonUtil.ConvertToXml(res) }; ILogHandler hand = ServiceContainer.GetService <ILogHandler>() as ILogHandler; hand.WriteTransactionLog(logData); #endregion return(res.Count); } catch (Exception) { throw; } }
/// <summary> /// Insert draft sale email /// </summary> /// <param name="draftLst"></param> /// <returns></returns> private int InsertTbt_DraftSaleEmail(List <tbt_DraftSaleEmail> draftLst) { try { if (draftLst != null) { dsTransDataModel dsTrans = CommonUtil.dsTransData; foreach (tbt_DraftSaleEmail draft in draftLst) { draft.CreateDate = dsTrans.dtOperationData.ProcessDateTime; draft.CreateBy = dsTrans.dtUserData.EmpNo; draft.UpdateDate = dsTrans.dtOperationData.ProcessDateTime; draft.UpdateBy = dsTrans.dtUserData.EmpNo; } } List <tbt_DraftSaleEmail> res = this.InsertTbt_DraftSaleEmail( CommonUtil.ConvertToXml_Store <tbt_DraftSaleEmail>(draftLst)); #region Log doTransactionLog logData = new doTransactionLog() { TransactionType = doTransactionLog.eTransactionType.Insert, TableName = TableName.C_TBL_NAME_DRF_SALE_EMAIL, TableData = CommonUtil.ConvertToXml(res) }; ILogHandler hand = ServiceContainer.GetService <ILogHandler>() as ILogHandler; hand.WriteTransactionLog(logData); #endregion return(res.Count); } catch (Exception) { throw; } }
/// <summary> /// Insert contract email data /// </summary> /// <param name="listEmail"></param> /// <returns></returns> public int InsertTbt_ContractEmail(List <tbt_ContractEmail> listEmail) { try { if (listEmail != null) { dsTransDataModel dsTrans = CommonUtil.dsTransData; foreach (tbt_ContractEmail relationType in listEmail) { relationType.CreateDate = dsTrans.dtOperationData.ProcessDateTime; relationType.CreateBy = dsTrans.dtUserData.EmpNo; relationType.UpdateDate = dsTrans.dtOperationData.ProcessDateTime; relationType.UpdateBy = dsTrans.dtUserData.EmpNo; } } List <tbt_ContractEmail> res = this.InsertTbt_ContractEmail( CommonUtil.ConvertToXml_Store <tbt_ContractEmail>(listEmail)); #region Log doTransactionLog logData = new doTransactionLog() { TransactionType = doTransactionLog.eTransactionType.Insert, TableName = TableName.C_TBL_NAME_CON_EMAIL, TableData = CommonUtil.ConvertToXml(res) }; ILogHandler hand = ServiceContainer.GetService <ILogHandler>() as ILogHandler; hand.WriteTransactionLog(logData); #endregion return(res.Count); } catch (Exception) { throw; } }
/// <summary> /// Check user permission by ScreenID only. /// </summary> /// <param name="ScreenID">Screen ID</param> /// <returns></returns> protected bool CheckUserPermission(string ScreenID) { try { dsTransDataModel dsTrans = CommonUtil.dsTransData; if (dsTrans == null) { return(false); } if (dsTrans.dtUserPermissionData != null) { var hasPermit = from a in dsTrans.dtUserPermissionData where a.Key.StartsWith(ScreenID) select a; return(hasPermit.Count() > 0); } } catch { } return(false); }
/// <summary> /// Refresh office data of dsTrans object /// </summary> /// <param name="dsTrans"></param> public void RefreshOfficeData(dsTransDataModel dsTrans) { try { #region Belonging User dsTrans.dtUserBelongingData = new List <UserBelongingData>(); IEmployeeMasterHandler handEmp = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler; List <dtUserBelonging> dtUserBelong = handEmp.getBelongingByEmpNo(dsTrans.dtUserData.EmpNo); foreach (dtUserBelonging usrb in dtUserBelong) { UserBelongingData UsrBelong = new UserBelongingData( usrb.OfficeCode, usrb.DepartmentCode, usrb.PositionCode); dsTrans.dtUserBelongingData.Add(UsrBelong); } #endregion #region Office dsTrans.dtOfficeData = new List <OfficeDataDo>(); IOfficeMasterHandler handOffice = ServiceContainer.GetService <IOfficeMasterHandler>() as IOfficeMasterHandler; List <dtAuthorizeOffice> dtAuthorizedOffice = handOffice.GetAuthorizeOffice(CommonUtil.ConvertToXml_Store <dtUserBelonging>(dtUserBelong)); dsTrans.dtOfficeData = CommonUtil.ConvertObjectbyLanguage <dtAuthorizeOffice, OfficeDataDo>(dtAuthorizedOffice, "OfficeName"); #endregion } catch (Exception) { throw; } }
/// <summary> /// Update draft sale contract /// </summary> /// <param name="draft"></param> /// <returns></returns> public int UpdateTbt_DraftSaleContract(tbt_DraftSaleContract draft) { try { List <tbt_DraftSaleContract> draftLst = new List <tbt_DraftSaleContract>(); if (draft != null) { dsTransDataModel dsTrans = CommonUtil.dsTransData; draft.UpdateDate = dsTrans.dtOperationData.ProcessDateTime; draft.UpdateBy = dsTrans.dtUserData.EmpNo; draftLst.Add(draft); } List <tbt_DraftSaleContract> res = this.UpdateTbt_DraftSaleContract( CommonUtil.ConvertToXml_Store <tbt_DraftSaleContract>(draftLst)); #region Log doTransactionLog logData = new doTransactionLog() { TransactionType = doTransactionLog.eTransactionType.Update, TableName = TableName.C_TBL_NAME_DRF_RNT_CONTRACT, TableData = CommonUtil.ConvertToXml(res) }; ILogHandler hand = ServiceContainer.GetService <ILogHandler>() as ILogHandler; hand.WriteTransactionLog(logData); #endregion return(res.Count); } catch (Exception) { throw; } }
/// <summary> /// Insert contract customer history /// </summary> /// <param name="docLst"></param> /// <returns></returns> public List <tbt_ContractCustomerHistory> InsertTbt_ContractCustomerHistory(List <tbt_ContractCustomerHistory> docLst) { try { if (docLst != null) { dsTransDataModel dsTrans = CommonUtil.dsTransData; foreach (tbt_ContractCustomerHistory doc in docLst) { doc.CreateDate = dsTrans.dtOperationData.ProcessDateTime; doc.CreateBy = dsTrans.dtUserData.EmpNo; doc.UpdateDate = dsTrans.dtOperationData.ProcessDateTime; doc.UpdateBy = dsTrans.dtUserData.EmpNo; } } return(this.InsertTbt_ContractCustomerHistory(CommonUtil.ConvertToXml_Store <tbt_ContractCustomerHistory>(docLst))); } catch (Exception) { throw; } }
/// <summary> /// Refresh permission data of dsTrans object /// </summary> /// <param name="dsTrans"></param> public void RefreshPermissionData(dsTransDataModel dsTrans) { try { dsTrans.dtUserPermissionData = new Dictionary <string, UserPermissionDataDo>(); string xmlDtBelonging = CommonUtil.ConvertToXml_Store <UserBelongingData>(dsTrans.dtUserBelongingData); List <dtUserPermission> dtUserPermiss = base.RefreshPermissionData(dsTrans.dtUserData.EmpNo, xmlDtBelonging); foreach (dtUserPermission i in dtUserPermiss) { string key = dsTrans.GenerateKey(i.ObjectID, i.FuncionID.ToString()); dsTrans.dtUserPermissionData[key] = new UserPermissionDataDo(i.ObjectID, (int)i.FuncionID, i.ObjectTypeCode); } if (dsTrans.dtUserPermissionData.Count <= 0) { throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0033); } } catch (Exception) { throw; } }
/// <summary> /// Update customer /// </summary> /// <param name="customer"></param> /// <returns></returns> public List <tbm_Customer> UpdateCustomer(doCustomer customer) { try { //Check whether this record is the most updated data List <tbm_Customer> sList = this.GetTbm_Customer(customer.CustCode); if (sList == null || sList.Count == 0 || sList[0] == null || sList[0].UpdateDate == null || customer.UpdateDate == null || !customer.UpdateDate.HasValue) { throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007, new string[] { "UpdateDate" }); } if (DateTime.Compare(sList[0].UpdateDate.Value, customer.UpdateDate.Value) != 0) { throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0019); } dsTransDataModel dsTrans = CommonUtil.dsTransData; //customer.UpdateDate = dsTrans.dtOperationData.ProcessDateTime; //customer.UpdateBy = dsTrans.dtUserData.EmpNo; List <tbm_Customer> lst = this.UpdateCustomer(customer.CustCode, customer.CustStatus, customer.ImportantFlag, customer.CustNameEN, customer.CustNameLC, customer.CustFullNameEN, customer.CustFullNameLC, customer.RepPersonName, customer.ContactPersonName, customer.SECOMContactPerson, customer.CustTypeCode, customer.CompanyTypeCode, customer.FinancialMarketTypeCode, customer.BusinessTypeCode, customer.PhoneNo, customer.FaxNo, customer.IDNo, customer.DummyIDFlag, customer.RegionCode, customer.URL, customer.Memo, customer.AlleyEN, customer.AddressEN, customer.RoadEN, customer.SubDistrictEN, customer.AddressFullEN, customer.AddressLC, customer.AlleyLC, customer.RoadLC, customer.SubDistrictLC, customer.AddressFullLC, customer.DistrictCode, customer.ProvinceCode, customer.ZipCode, customer.DeleteFlag, dsTrans.dtOperationData.ProcessDateTime, dsTrans.dtUserData.EmpNo); //Insert Log if (lst.Count > 0) { doTransactionLog logData = new doTransactionLog(); logData.TransactionType = doTransactionLog.eTransactionType.Update; logData.TableName = TableName.C_TBL_NAME_CUSTOMER; logData.TableData = CommonUtil.ConvertToXml(lst); ILogHandler hand = ServiceContainer.GetService <ILogHandler>() as ILogHandler; hand.WriteTransactionLog(logData); } return(lst); } catch (Exception) { throw; } }
/// <summary> /// Insert customer /// </summary> /// <param name="customer"></param> /// <returns></returns> public List <tbm_Customer> InsertCustomer(doCustomer customer) { try { dsTransDataModel dsTrans = CommonUtil.dsTransData; customer.CustStatus = CustomerStatus.C_CUST_STATUS_NEW; customer.ImportantFlag = false; customer.DummyIDFlag = customer.DummyIDFlag == null ? false : customer.DummyIDFlag; customer.DeleteFlag = false; customer.CreateDate = dsTrans.dtOperationData.ProcessDateTime; customer.CreateBy = dsTrans.dtUserData.EmpNo; customer.UpdateDate = dsTrans.dtOperationData.ProcessDateTime; customer.UpdateBy = dsTrans.dtUserData.EmpNo; List <tbm_Customer> lst = this.InsertCustomer(customer.CustCode, customer.CustStatus, customer.ImportantFlag, customer.CustNameEN, customer.CustNameLC, customer.CustFullNameEN, customer.CustFullNameLC, customer.RepPersonName, customer.ContactPersonName, customer.SECOMContactPerson, customer.CustTypeCode, customer.CompanyTypeCode, customer.FinancialMarketTypeCode, customer.BusinessTypeCode, customer.PhoneNo, customer.FaxNo, customer.IDNo, customer.DummyIDFlag, customer.RegionCode, customer.URL, customer.Memo, customer.AlleyEN, customer.AddressEN, customer.RoadEN, customer.SubDistrictEN, customer.AddressFullEN, customer.AddressLC, customer.AlleyLC, customer.RoadLC, customer.SubDistrictLC, customer.AddressFullLC, customer.DistrictCode, customer.ProvinceCode, customer.ZipCode, customer.DeleteFlag, customer.CreateDate, customer.CreateBy, customer.UpdateDate, customer.UpdateBy); //Insert Log if (lst.Count > 0) { doTransactionLog logData = new doTransactionLog(); logData.TransactionType = doTransactionLog.eTransactionType.Insert; logData.TableName = TableName.C_TBL_NAME_CUSTOMER; logData.TableData = CommonUtil.ConvertToXml(lst); ILogHandler hand = ServiceContainer.GetService <ILogHandler>() as ILogHandler; hand.WriteTransactionLog(logData); } return(lst); } catch (Exception) { throw; } }
public List <tbm_Site> UpdateSite(doSite site) { try { ApplicationErrorException.CheckMandatoryField <doSite, tbm_SiteCondition>(site); //Check whether this record is the most updated data List <doGetTbm_Site> sList = this.GetTbm_Site(site.SiteCode); if (DateTime.Compare(sList[0].UpdateDate.Value, site.UpdateDate.Value) != 0) { throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0019); } dsTransDataModel dsTrans = CommonUtil.dsTransData; site.CreateDate = dsTrans.dtOperationData.ProcessDateTime; site.CreateBy = dsTrans.dtUserData.EmpNo; site.UpdateDate = dsTrans.dtOperationData.ProcessDateTime; site.UpdateBy = dsTrans.dtUserData.EmpNo; List <tbm_Site> lst = this.UpdateSite(site.SiteCode, site.CustCode, site.SiteNo, site.SiteNameEN, site.SiteNameLC, site.SECOMContactPerson, site.PersonInCharge, site.PhoneNo, site.BuildingUsageCode, site.AddressEN, site.AlleyEN, site.RoadEN, site.SubDistrictEN, site.AddressFullEN, site.AddressLC, site.AlleyLC, site.RoadLC, site.SubDistrictLC, site.AddressFullLC, site.DistrictCode, site.ProvinceCode, site.ZipCode, site.UpdateDate, site.UpdateBy); //Insert Log if (lst.Count > 0) { doTransactionLog logData = new doTransactionLog(); logData.TransactionType = doTransactionLog.eTransactionType.Update; logData.TableName = TableName.C_TBL_NAME_SITE; logData.TableData = CommonUtil.ConvertToXml(lst); ILogHandler hand = ServiceContainer.GetService <ILogHandler>() as ILogHandler; hand.WriteTransactionLog(logData); } return(lst); } catch (Exception) { throw; } }
/// <summary> /// Event on action executing for check session is expired? /// </summary> /// <param name="filterContext"></param> public override void OnActionExecuting(ActionExecutingContext filterContext) { try { bool checkScreenSession = true; string action = filterContext.RouteData.Values["action"].ToString(); if (action == "CMS000" || action == "CMS010" || action == "Login" || action == "CMS010_CHECK" || action == "CMS020_Retrive" || action == "GetMessage" || action == "changeLanguageDsTransData" || action == "Logout" || action == "GetLanguageMessage" || action == "ClearCurrentScreenSession" || action == "CMS000_RedirectScreen" || action.ToUpper().Contains("UPLOAD") || action.ToUpper().Contains("ATTACH")) { checkScreenSession = false; } dsTransDataModel dsTrans = CommonUtil.dsTransData; if (dsTrans == null) { //if (checkScreenSession) //{ //Check Action from ajax caller or load view string ajax = filterContext.HttpContext.Request["ajax"]; if ((ajax == "1") && action != "CMS010" && action != "CMS010_CHECK" && action != "Login") { RedirectObject o = new RedirectObject(); o.URL = CommonUtil.GenerateURL("Common", "CMS010") + "?timeout=1"; JsonResult jRes = new JsonResult(); jRes.Data = o; filterContext.Result = jRes; } else if (checkScreenSession == true) { bool skip = false; doDirectScreen dos = null; /* *** This method will only in case url has send parameter (expect "k" parameter). *** */ #region Initial redirect method if (action != "CMS020") { dos = new doDirectScreen(); dos.Controller = filterContext.RouteData.Values["controller"].ToString(); dos.ScreenID = action; foreach (string key in filterContext.HttpContext.Request.QueryString.AllKeys) { if (key == "k") { skip = true; break; } string val = filterContext.HttpContext.Request[key]; if (dos.Parameters == null) { dos.Parameters = new List <string>(); dos.Values = new List <string>(); } dos.Parameters.Add(key); dos.Values.Add(val); } } #endregion if (skip == false && dos != null) { CommonUtil.SetSession("DIRECT_SCREEN", dos); filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Common", action = "CMS000" })); } else { if (action == "CMS020") { BaseController bController = filterContext.Controller as BaseController; if (bController != null) { filterContext.Result = bController.RedirectToLogin(); } } else { filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Common", action = "CMS010" })); } } } return; //} } else { BaseController bController = filterContext.Controller as BaseController; if (bController != null) { ScreenParameter param = bController.GetScreenObject <object>() as ScreenParameter; if (param != null) { dsTrans.dtTransHeader.ScreenID = param.ScreenID; } else if (checkScreenSession) { bool isInitial = false; MethodInfo method = bController.GetType().GetMethod(action); if (method != null) { if (method.GetCustomAttributes(typeof(InitializeAttribute), true).Length > 0) { isInitial = true; } } if (action.EndsWith("_Authority") || isInitial == true) { dsTrans.dtTransHeader.ScreenID = action.Replace("_Authority", ""); /* *** This method will only in case url has send parameter (expect "k" parameter). *** */ #region Initial redirect method if (action != "CMS020" && isInitial == true) { doDirectScreen dos = new doDirectScreen(); dos.Controller = filterContext.RouteData.Values["controller"].ToString(); dos.ScreenID = action; bool skip = false; foreach (string key in filterContext.HttpContext.Request.QueryString.AllKeys) { if (key == "k") { skip = true; break; } string val = filterContext.HttpContext.Request[key]; if (dos.Parameters == null) { dos.Parameters = new List <string>(); dos.Values = new List <string>(); } dos.Parameters.Add(key); dos.Values.Add(val); } if (skip == false) { CommonUtil.SetSession("DIRECT_SCREEN", dos); filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Common", action = "CMS000" })); } } #endregion } else { if (CommonUtil.dsTransData != null) { RedirectObject o = new RedirectObject(); o.URL = CommonUtil.GenerateURL("Common", "CMS020"); JsonResult jRes = new JsonResult(); jRes.Data = o; filterContext.Result = jRes; } else { RedirectObject o = new RedirectObject(); o.URL = CommonUtil.GenerateURL("Common", "CMS010") + "?timeout=1"; JsonResult jRes = new JsonResult(); jRes.Data = o; filterContext.Result = jRes; return; } } } } DateTime dateTime = DateTime.Now; dateTime = dateTime.AddTicks(-(dateTime.Ticks % TimeSpan.TicksPerSecond)); dsTrans.dtOperationData.ProcessDateTime = dateTime; dsTrans.dtOperationData.GUID = Guid.NewGuid().ToString().ToUpper(); CommonUtil.dsTransData = dsTrans; } string actionUpper = action.ToUpper(); if (actionUpper.Contains("EDIT") || actionUpper.Contains("SAVE") || actionUpper.Contains("UPDATE") || actionUpper.Contains("DELETE")) { string[] aItem = actionUpper.Split('_'); string screenID = aItem[0]; } base.OnActionExecuting(filterContext); } catch { } }
/// <summary> /// Event on action executing for initial screen information /// </summary> /// <param name="filterContext"></param> public override void OnActionExecuting(ActionExecutingContext filterContext) { try { if (CheckURLAction(filterContext) == false) { return; } dsTransDataModel dsTrans = CommonUtil.dsTransData; if (dsTrans == null) { return; } BaseController bController = filterContext.Controller as BaseController; #region Init Menu InitialMenu(filterContext); #endregion #region Screen ID //dsTrans.dtTransHeader.ScreenID = ScreenID; filterContext.Controller.ViewBag.ScreenCode = ScreenID; #endregion #region Screen Name string SubObjectID = "0"; if (bController != null) { ScreenParameter param = bController.GetScreenObject <object>() as ScreenParameter; if (param != null) { SubObjectID = param.SubObjectID; } } string strScreenName = null; //List<MenuName> mm = CommonUtil.MenuNameList; // Edit by Narupon W. : 1/Jan/2012 //List<MenuName> mm = CommonUtil.dsTransData.dtMenuNameList; List <MenuName> mm = new List <MenuName>(); if (CommonUtil.dsTransData != null) { if (CommonUtil.dsTransData.dtMenuNameList != null) { mm = CommonUtil.dsTransData.dtMenuNameList; } else { mm = CommonUtil.MenuNameList; } } else { mm = CommonUtil.MenuNameList; } if (!CommonUtil.IsNullOrEmpty(mm)) { IEnumerable <MenuName> ScrNameIEnum = (from c in mm where c.ObjectID == ScreenID && c.SubObjectID == SubObjectID select c); if (ScrNameIEnum != null && ScrNameIEnum.ToList().Count > 0) { CommonUtil.MappingObjectLanguage(ScrNameIEnum.ToList()[0]); strScreenName = ScrNameIEnum.ToList()[0].ObjectName; } } filterContext.Controller.ViewBag.ScreenName = strScreenName; #endregion #region Common search if (bController != null) { ScreenSearchParameter param = bController.GetScreenObject <object>() as ScreenSearchParameter; if (param != null) { if (param.CommonSearch != null) { filterContext.Controller.ViewBag.SearchContractCode = param.CommonSearch.ContractCode; filterContext.Controller.ViewBag.SearchProjectCode = param.CommonSearch.ProjectCode; } } } #endregion // Change title to {Screen Name} [SECOM-AJIS] ////filterContext.Controller.ViewBag.Title = CommonUtil.TextCodeName(ScreenID, strScreenName, "-"); //filterContext.Controller.ViewBag.Title = String.Format("{0} [SECOM-AJIS]", strScreenName); filterContext.Controller.ViewBag.Title = String.Format("{0} [SIMS]", strScreenName); //Modify by Jutarat A. on 21022013 filterContext.Controller.ViewBag.UserName = dsTrans.dtUserData.EmpFullName; filterContext.Controller.ViewBag.ROWS_PER_PAGE_FOR_SEARCHPAGE = CommonValue.ROWS_PER_PAGE_FOR_SEARCHPAGE; filterContext.Controller.ViewBag.ROWS_PER_PAGE_FOR_VIEWPAGE = CommonValue.ROWS_PER_PAGE_FOR_VIEWPAGE; filterContext.Controller.ViewBag.ROWS_PER_PAGE_FOR_INVENTORY_CHECKING = CommonValue.ROWS_PER_PAGE_FOR_INVENTORY_CHECKING; /* --- Update Data --- */ CommonUtil.dsTransData = dsTrans; base.OnActionExecuting(filterContext); } catch (Exception) { } }
/// <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)); }