// ใช้สำหรับแปลง Date ในรูปแบบ String ไปเป็น Object private CovertToDateResult ConvertToDate(string dateString) { CovertToDateResult obj = new CovertToDateResult(); string[] delimeterString = new string[] { "/" }; string[] splitedString = dateString.Split(delimeterString, StringSplitOptions.RemoveEmptyEntries); obj.Day = Convert.ToInt32(splitedString[0].ToString()); obj.Month = Convert.ToInt32(splitedString[1].ToString()); obj.Year = Convert.ToInt32(splitedString[2].ToString()) - 543; return(obj); }
public CheckAgentAuthentication_Result CheckAgentAuthentication(string partnerUsername, string partnerPassword, string agentNumber, string agentPassword) { CheckAgentAuthentication_Result obj = new CheckAgentAuthentication_Result(); RefRunningTBBLL runningobj = new RefRunningTBBLL(); this.refnum = runningobj.AddRefRunningTBAndReturn(); WSLogBLL logobj = new WSLogBLL(); string methodName = "CheckAgentAuthentication"; try { if (partnerUsername == "" || partnerPassword == "" || agentNumber == "" || agentPassword == "") { this.partnerName = partnerUsername; // LogRequest: Insert Log Request logobj.AddWSLog(this.partnerName, this.ipaddress, "Request", this.webserviceName, methodName, partnerUsername + "|" + agentNumber + "|" + agentPassword, this.refnum); obj.Result = "notpass_กรุณาระบุข้อมูลให้ครบถ้วน"; } else if (agentNumber.Length != 6 || !MTL.Utils.ThisWeb.CheckIsNumeric(agentNumber)) { this.partnerName = partnerUsername; // LogRequest: Insert Log Request logobj.AddWSLog(this.partnerName, this.ipaddress, "Request", this.webserviceName, methodName, partnerUsername + "|" + agentNumber + "|" + agentPassword, this.refnum); obj.Result = "notpass_กรุณาระบุเลขที่ตัวแทนให้ถูกต้อง"; } else if (agentPassword.Length != 6 || !MTL.Utils.ThisWeb.CheckIsNumeric(agentPassword)) { this.partnerName = partnerUsername; // LogRequest: Insert Log Request logobj.AddWSLog(this.partnerName, this.ipaddress, "Request", this.webserviceName, methodName, partnerUsername + "|" + agentNumber + "|" + agentPassword, this.refnum); obj.Result = "notpass_กรุณาระบุรหัสผ่านตัวแทนให้ถูกต้อง"; } else { // พิสูจน์ตัวตนของพันธมิตรก่อนที่จะให้ใช้งานจริง NETWS_ForPartnerAuthenticationChecking.CheckPartnerAuthentication_Result pacobj = CheckPartnerAuthenticationReturnDetail(partnerUsername, partnerPassword, this.ipaddress); if (pacobj.Result.Trim().ToLower() == "passed") { this.partnerName = pacobj.PartnerName; // LogRequest: Insert Log Request logobj.AddWSLog(this.partnerName, this.ipaddress, "Request", this.webserviceName, methodName, partnerUsername + "|" + agentNumber + "|" + agentPassword, this.refnum); // ตรวจสอบสิทธิ์ของตัวแทนกับ ApplinX WS_Agent ApplinXCheckAgentAuthenticationResult resAgentObj = new ApplinXCheckAgentAuthenticationResult(); MTL.WS_Agent.WS_Agent_ForMTLmPOS.WS_Agent_ForMPosService agentWSObj = new MTL.WS_Agent.WS_Agent_ForMTLmPOS.WS_Agent_ForMPosService(); resAgentObj.fld_result = agentWSObj.CheckAgentAuthentication(ref agentNumber, agentPassword, out resAgentObj.fld_sessionID, out resAgentObj.fld_agent_name, out resAgentObj.fld_agent_department, out resAgentObj.fld_agent_position, out resAgentObj.fld_agent_type); if (resAgentObj.fld_result.Trim().ToLower() == "passed") { // ดึงข้อมูลรายละเอียดของตัวแทนกับ ApplinX WS_Admin ApplinXGetAgentDetailResult resAdminObj = new ApplinXGetAgentDetailResult(); MTL.WS_Admin.WS_Admin_ForMTLmPOS.WS_Admin_ForMPosService adminWSObj = new MTL.WS_Admin.WS_Admin_ForMTLmPOS.WS_Admin_ForMPosService(); resAdminObj.fld_result = adminWSObj.getAgentDetail(this.admin_username, this.admin_password, agentNumber, out resAdminObj.fld_sessionID, out resAdminObj.fld_agent_addrdoc_line1, out resAdminObj.fld_agent_addrdoc_line2, out resAdminObj.fld_agent_addrdoc_phone, out resAdminObj.fld_agent_address_line1, out resAdminObj.fld_agent_address_line2, out resAdminObj.fld_agent_bank_account, out resAdminObj.fld_agent_client_number, out resAdminObj.fld_agent_department, out resAdminObj.fld_agent_dob, out resAdminObj.fld_agent_end_date, out resAdminObj.fld_agent_gender, out resAdminObj.fld_agent_license_expire_date, out resAdminObj.fld_agent_license_number, out resAdminObj.fld_agent_license_start_date, out resAdminObj.fld_agent_name, out resAdminObj.fld_agent_office, out resAdminObj.fld_agent_phone, out resAdminObj.fld_agent_pid, out resAdminObj.fld_agent_policy_out, out resAdminObj.fld_agent_position, out resAdminObj.fld_agent_remark_type, out resAdminObj.fld_agent_start_date, out resAdminObj.fld_agent_status_code, out resAdminObj.fld_agent_status_description, out resAdminObj.fld_agent_tax_number, out resAdminObj.fld_agent_type, out resAdminObj.fld_agent_under_to, out resAdminObj.fld_agent_surname, out resAdminObj.fld_agent_title, out resAdminObj.fld_agent_no); if (resAdminObj.fld_result.Trim().ToLower() == "found") { // เช็คใบอนุญาติตัวแทนว่าหมดอายุหรือยัง? CovertToDateResult dateObj = new CovertToDateResult(); dateObj = ConvertToDate(resAdminObj.fld_agent_license_expire_date.Trim()); DateTime agentLicenseExpiryDate = new DateTime(dateObj.Year, dateObj.Month, dateObj.Day); if (agentLicenseExpiryDate > DateTime.Now) { obj.Result = "passed"; obj.SessionID = resAdminObj.fld_sessionID.Trim(); obj.AgentName = resAdminObj.fld_agent_name.Trim() + " " + resAdminObj.fld_agent_surname.Trim(); obj.AgentStatus = resAdminObj.fld_agent_status_code.Trim(); obj.AgentType = resAdminObj.fld_agent_type.Trim(); obj.AgentPosition = resAdminObj.fld_agent_position.Trim(); obj.AgentDepartment = resAdminObj.fld_agent_department.Trim(); } else { obj.Result = "notpass_ท่านไม่สามารถใช้งานได้ เนื่องจากเลขที่ตัวแทนที่ท่านระบุไม่มีผลบังคับแล้ว"; } } else { obj.Result = resAdminObj.fld_result.Trim().Replace("notfound_", "notpass_"); } } else { obj.Result = resAgentObj.fld_result.Trim(); } } else { this.partnerName = pacobj.PartnerName; // LogRequest: Insert Log Request logobj.AddWSLog(this.partnerName, this.ipaddress, "Request", this.webserviceName, methodName, partnerUsername + "|" + agentNumber + "|" + agentPassword, this.refnum); obj.Result = pacobj.Result.Trim(); } } // LogResponse: Insert Log Response logobj.AddWSLog(this.partnerName, this.ipaddress, "Response", this.webserviceName, methodName, obj.Result + "|" + obj.AgentName + "|" + obj.AgentStatus + "|" + obj.AgentType + "|" + obj.AgentPosition + "|" + obj.AgentDepartment + "|" + obj.SessionID, this.refnum); return(obj); } catch (Exception ex) { obj.Result = "notpass_" + ex.Message.ToString(); // LogResponse: Insert Log Response logobj.AddWSLog(this.partnerName, this.ipaddress, "Response", this.webserviceName, methodName, obj.Result + "|" + obj.SessionID, this.refnum); return(obj); } }
public string AddTemporaryReceiptNumberToUsingLog(string partnerUsername, string partnerPassword, string temporaryReceiptNumber, string temporaryReceiptDate, string payFor, string payForNumber, string payAmount, string agentNumber) { string result = ""; RefRunningTBBLL runningobj = new RefRunningTBBLL(); this.refnum = runningobj.AddRefRunningTBAndReturn(); WSLogBLL logobj = new WSLogBLL(); string methodName = "AddTemporaryReceiptNumberToUsingLog"; try { if (partnerUsername == "" || partnerPassword == "" || temporaryReceiptNumber == "" || temporaryReceiptDate == "" || payFor == "" || payForNumber == "" || payAmount == "" || agentNumber == "") { this.partnerName = partnerUsername; // LogRequest: Insert Log Request logobj.AddWSLog(this.partnerName, this.ipaddress, "Request", this.webserviceName, methodName, partnerUsername + "|" + temporaryReceiptNumber + "|" + temporaryReceiptDate + "|" + payFor + "|" + payForNumber + "|" + payAmount + "|" + agentNumber, this.refnum); result = "notcomplete_กรุณาระบุข้อมูลให้ครบถ้วน"; } else if (temporaryReceiptNumber.Length != 12 || !MTL.Utils.ThisWeb.CheckIsNumeric(temporaryReceiptNumber)) { this.partnerName = partnerUsername; // LogRequest: Insert Log Request logobj.AddWSLog(this.partnerName, this.ipaddress, "Request", this.webserviceName, methodName, partnerUsername + "|" + temporaryReceiptNumber + "|" + temporaryReceiptDate + "|" + payFor + "|" + payForNumber + "|" + payAmount + "|" + agentNumber, this.refnum); result = "notconmplete_กรุณาระบุเลขที่ใบรับเงินชั่วคราวให้ถูกต้อง"; } else if (payForNumber.Length < 10 || payForNumber.Length > 11 || !MTL.Utils.ThisWeb.CheckIsNumeric(payForNumber)) { this.partnerName = partnerUsername; // LogRequest: Insert Log Request logobj.AddWSLog(this.partnerName, this.ipaddress, "Request", this.webserviceName, methodName, partnerUsername + "|" + temporaryReceiptNumber + "|" + temporaryReceiptDate + "|" + payFor + "|" + payForNumber + "|" + payAmount + "|" + agentNumber, this.refnum); result = "notcomplete_กรุณาระบุเลขที่กรมธรรม์ หรือเลขที่ใบคำขอเอาประกันภัยให้ถูกต้อง"; } else if (agentNumber.Length != 6 || !MTL.Utils.ThisWeb.CheckIsNumeric(agentNumber)) { this.partnerName = partnerUsername; // LogRequest: Insert Log Request logobj.AddWSLog(this.partnerName, this.ipaddress, "Request", this.webserviceName, methodName, partnerUsername + "|" + temporaryReceiptNumber + "|" + temporaryReceiptDate + "|" + payFor + "|" + payForNumber + "|" + payAmount + "|" + agentNumber, this.refnum); result = "notcomplete_กรุณาระบุเลขที่ตัวแทนให้ถูกต้อง"; } else { // พิสูจน์ตัวตนของพันธมิตรก่อนที่จะให้ใช้งานจริง NETWS_ForPartnerAuthenticationChecking.CheckPartnerAuthentication_Result pacobj = CheckPartnerAuthenticationReturnDetail(partnerUsername, partnerPassword, this.ipaddress); if (pacobj.Result.Trim().ToLower() == "passed") { this.partnerName = pacobj.PartnerName; // LogRequest: Insert Log Request logobj.AddWSLog(this.partnerName, this.ipaddress, "Request", this.webserviceName, methodName, partnerUsername + "|" + temporaryReceiptNumber + "|" + temporaryReceiptDate + "|" + payFor + "|" + payForNumber + "|" + payAmount + "|" + agentNumber, this.refnum); // ตรวจสอบเลขที่ใบรับเงินชั่วคราว MTL.Utils.ThisWeb thisweb = new MTL.Utils.ThisWeb(); if (thisweb.CheckIsValidTemporaryBillNumber(temporaryReceiptNumber)) { // ตรวจสอบเลขที่ใบรับเงินชั่วคราวว่าได้ถูกบันทึกว่าตัวแทนส่งงานเข้ามายังบริษัทฯ (เก็บอยู่ใน AS400) แล้วหรือยัง หรือสามารถนำมาใช้ได้หรือไม่ ผ่าน OSB EAppService CheckTemporaryReceiptNumberInAs400IsCanUse_Result checkResult = new CheckTemporaryReceiptNumberInAs400IsCanUse_Result(); // 20150129: Comment ไว้เพื่อทดสอบไม่ต้องใช้ค่าจาก Web Services ว่าน checkResult = this.CheckTemporaryReceiptNumberInAs400IsCanUse(temporaryReceiptNumber); // 20150129: สำหรับทดสอบโดยไม่ต้องใช้ค่าจาก Web Services ว่าน //checkResult.Result = "testja"; if (checkResult.Result == "false") { result = "notcomplete_" + checkResult.ErrorMessage.Trim(); } else { // 20150129: ตรวจสอบเลขที่ใบรับเงินชั่วคราว กับเลขที่ใบคำขอเอาประกันหรือเลขที่กรมธรรม์ว่าเคยถูกใช้ไปแล้วครบจำนวนครั้งที่กำหนดหรือยัง ถ้าพบว่าเคยใช้ไปแล้วจะไม่สามารถนำไปใช้งานได้อีก // 20150527: ปรับใช้ class รองรับการตรวจสอบว่าใช้เลขที่ใบรับเงินชั่วคราวนี้ได้อีกกี่ครั้ง CheckTemporaryReceiptNumberAndNumberToPayInSqlIsUsedExceedLimit_Result checkTempAndNumberInSqlObj = new CheckTemporaryReceiptNumberAndNumberToPayInSqlIsUsedExceedLimit_Result(); checkTempAndNumberInSqlObj = this.CheckTemporaryReceiptNumberAndNumberToPayInSqlIsUsedExceedLimit(temporaryReceiptNumber, payForNumber); if (checkTempAndNumberInSqlObj.Result == true) { result = "notcomplete_เลขที่ใบรับเงินชั่วคราวนี้ถูกนำไปใช้แล้ว"; } else { using (var dbContext = new DAL.MTL_mPOSEntities()) { DAL.TemporaryReceiptUsingLog tempReceipt = new DAL.TemporaryReceiptUsingLog(); tempReceipt.TemporaryReceiptNumber = temporaryReceiptNumber.Trim(); CovertToDateResult dateObj = new CovertToDateResult(); dateObj = ConvertToDate(temporaryReceiptDate); DateTime tempReceiptDate = new DateTime(dateObj.Year, dateObj.Month, dateObj.Day); tempReceipt.TemporaryReceiptDate = tempReceiptDate; tempReceipt.PayFor = payFor.Trim(); tempReceipt.PayForNumber = payForNumber.Trim(); tempReceipt.PayAmount = payAmount.Trim(); tempReceipt.AgentNumber = agentNumber.Trim(); tempReceipt.LogDateTime = DateTime.Now; dbContext.AddToTemporaryReceiptUsingLog(tempReceipt); dbContext.SaveChanges(); result = "completed"; } } } } else { result = "notcomplete_เลขที่ใบรับเงินชั่วคราวไม่ถูกต้อง"; } } else { this.partnerName = pacobj.PartnerName; // LogRequest: Insert Log Request logobj.AddWSLog(this.partnerName, this.ipaddress, "Request", this.webserviceName, methodName, partnerUsername + "|" + temporaryReceiptNumber + "|" + temporaryReceiptDate + "|" + payFor + "|" + payForNumber + "|" + payAmount + "|" + agentNumber, this.refnum); result = pacobj.Result.Trim().Replace("notpass_", "notcomplete_"); } } // LogResponse: Insert Log Response logobj.AddWSLog(this.partnerName, this.ipaddress, "Response", this.webserviceName, methodName, result + "|" + temporaryReceiptNumber + "|" + temporaryReceiptDate + "|" + payFor + "|" + payForNumber + "|" + payAmount + "|" + agentNumber, this.refnum); return result; } catch (Exception ex) { result = "notcomplete_" + ex.Message.ToString(); // LogResponse: Insert Log Response logobj.AddWSLog(this.partnerName, this.ipaddress, "Response", webserviceName, methodName, result + "|", this.refnum); return result; } }
// ใช้สำหรับแปลง Date ในรูปแบบ String ไปเป็น Object private CovertToDateResult ConvertToDate(string dateString) { CovertToDateResult obj = new CovertToDateResult(); string[] delimeterString = new string[] { "/" }; string[] splitedString = dateString.Split(delimeterString, StringSplitOptions.RemoveEmptyEntries); obj.Day = Convert.ToInt32(splitedString[0].ToString()); obj.Month = Convert.ToInt32(splitedString[1].ToString()); obj.Year = Convert.ToInt32(splitedString[2].ToString()) - 543; return obj; }
public CheckAgentAuthentication_Result CheckAgentAuthentication(string partnerUsername, string partnerPassword, string agentNumber, string agentPassword) { CheckAgentAuthentication_Result obj = new CheckAgentAuthentication_Result(); RefRunningTBBLL runningobj = new RefRunningTBBLL(); this.refnum = runningobj.AddRefRunningTBAndReturn(); WSLogBLL logobj = new WSLogBLL(); string methodName = "CheckAgentAuthentication"; try { if (partnerUsername == "" || partnerPassword == "" || agentNumber == "" || agentPassword == "") { this.partnerName = partnerUsername; // LogRequest: Insert Log Request logobj.AddWSLog(this.partnerName, this.ipaddress, "Request", this.webserviceName, methodName, partnerUsername + "|" + agentNumber + "|" + agentPassword, this.refnum); obj.Result = "notpass_กรุณาระบุข้อมูลให้ครบถ้วน"; } else if (agentNumber.Length != 6 || !MTL.Utils.ThisWeb.CheckIsNumeric(agentNumber)) { this.partnerName = partnerUsername; // LogRequest: Insert Log Request logobj.AddWSLog(this.partnerName, this.ipaddress, "Request", this.webserviceName, methodName, partnerUsername + "|" + agentNumber + "|" + agentPassword, this.refnum); obj.Result = "notpass_กรุณาระบุเลขที่ตัวแทนให้ถูกต้อง"; } else if (agentPassword.Length != 6 || !MTL.Utils.ThisWeb.CheckIsNumeric(agentPassword)) { this.partnerName = partnerUsername; // LogRequest: Insert Log Request logobj.AddWSLog(this.partnerName, this.ipaddress, "Request", this.webserviceName, methodName, partnerUsername + "|" + agentNumber + "|" + agentPassword, this.refnum); obj.Result = "notpass_กรุณาระบุรหัสผ่านตัวแทนให้ถูกต้อง"; } else { // พิสูจน์ตัวตนของพันธมิตรก่อนที่จะให้ใช้งานจริง NETWS_ForPartnerAuthenticationChecking.CheckPartnerAuthentication_Result pacobj = CheckPartnerAuthenticationReturnDetail(partnerUsername, partnerPassword, this.ipaddress); if (pacobj.Result.Trim().ToLower() == "passed") { this.partnerName = pacobj.PartnerName; // LogRequest: Insert Log Request logobj.AddWSLog(this.partnerName, this.ipaddress, "Request", this.webserviceName, methodName, partnerUsername + "|" + agentNumber + "|" + agentPassword, this.refnum); // ตรวจสอบสิทธิ์ของตัวแทนกับ ApplinX WS_Agent ApplinXCheckAgentAuthenticationResult resAgentObj = new ApplinXCheckAgentAuthenticationResult(); MTL.WS_Agent.WS_Agent_ForMTLmPOS.WS_Agent_ForMPosService agentWSObj = new MTL.WS_Agent.WS_Agent_ForMTLmPOS.WS_Agent_ForMPosService(); resAgentObj.fld_result = agentWSObj.CheckAgentAuthentication(ref agentNumber, agentPassword, out resAgentObj.fld_sessionID, out resAgentObj.fld_agent_name, out resAgentObj.fld_agent_department, out resAgentObj.fld_agent_position, out resAgentObj.fld_agent_type); if (resAgentObj.fld_result.Trim().ToLower() == "passed") { // ดึงข้อมูลรายละเอียดของตัวแทนกับ ApplinX WS_Admin ApplinXGetAgentDetailResult resAdminObj = new ApplinXGetAgentDetailResult(); MTL.WS_Admin.WS_Admin_ForMTLmPOS.WS_Admin_ForMPosService adminWSObj = new MTL.WS_Admin.WS_Admin_ForMTLmPOS.WS_Admin_ForMPosService(); resAdminObj.fld_result = adminWSObj.getAgentDetail(this.admin_username, this.admin_password, agentNumber, out resAdminObj.fld_sessionID, out resAdminObj.fld_agent_addrdoc_line1, out resAdminObj.fld_agent_addrdoc_line2, out resAdminObj.fld_agent_addrdoc_phone, out resAdminObj.fld_agent_address_line1, out resAdminObj.fld_agent_address_line2, out resAdminObj.fld_agent_bank_account, out resAdminObj.fld_agent_client_number, out resAdminObj.fld_agent_department, out resAdminObj.fld_agent_dob, out resAdminObj.fld_agent_end_date, out resAdminObj.fld_agent_gender, out resAdminObj.fld_agent_license_expire_date, out resAdminObj.fld_agent_license_number, out resAdminObj.fld_agent_license_start_date, out resAdminObj.fld_agent_name, out resAdminObj.fld_agent_office, out resAdminObj.fld_agent_phone, out resAdminObj.fld_agent_pid, out resAdminObj.fld_agent_policy_out, out resAdminObj.fld_agent_position, out resAdminObj.fld_agent_remark_type, out resAdminObj.fld_agent_start_date, out resAdminObj.fld_agent_status_code, out resAdminObj.fld_agent_status_description, out resAdminObj.fld_agent_tax_number, out resAdminObj.fld_agent_type, out resAdminObj.fld_agent_under_to, out resAdminObj.fld_agent_surname, out resAdminObj.fld_agent_title, out resAdminObj.fld_agent_no); if (resAdminObj.fld_result.Trim().ToLower() == "found") { // เช็คใบอนุญาติตัวแทนว่าหมดอายุหรือยัง? CovertToDateResult dateObj = new CovertToDateResult(); dateObj = ConvertToDate(resAdminObj.fld_agent_license_expire_date.Trim()); DateTime agentLicenseExpiryDate = new DateTime(dateObj.Year, dateObj.Month, dateObj.Day); if (agentLicenseExpiryDate > DateTime.Now) { obj.Result = "passed"; obj.SessionID = resAdminObj.fld_sessionID.Trim(); obj.AgentName = resAdminObj.fld_agent_name.Trim() + " " + resAdminObj.fld_agent_surname.Trim(); obj.AgentStatus = resAdminObj.fld_agent_status_code.Trim(); obj.AgentType = resAdminObj.fld_agent_type.Trim(); obj.AgentPosition = resAdminObj.fld_agent_position.Trim(); obj.AgentDepartment = resAdminObj.fld_agent_department.Trim(); } else { obj.Result = "notpass_ท่านไม่สามารถใช้งานได้ เนื่องจากเลขที่ตัวแทนที่ท่านระบุไม่มีผลบังคับแล้ว"; } } else { obj.Result = resAdminObj.fld_result.Trim().Replace("notfound_", "notpass_"); } } else { obj.Result = resAgentObj.fld_result.Trim(); } } else { this.partnerName = pacobj.PartnerName; // LogRequest: Insert Log Request logobj.AddWSLog(this.partnerName, this.ipaddress, "Request", this.webserviceName, methodName, partnerUsername + "|" + agentNumber + "|" + agentPassword, this.refnum); obj.Result = pacobj.Result.Trim(); } } // LogResponse: Insert Log Response logobj.AddWSLog(this.partnerName, this.ipaddress, "Response", this.webserviceName, methodName, obj.Result + "|" + obj.AgentName + "|" + obj.AgentStatus + "|" + obj.AgentType + "|" + obj.AgentPosition + "|" + obj.AgentDepartment + "|" + obj.SessionID, this.refnum); return obj; } catch (Exception ex) { obj.Result = "notpass_" + ex.Message.ToString(); // LogResponse: Insert Log Response logobj.AddWSLog(this.partnerName, this.ipaddress, "Response", this.webserviceName, methodName, obj.Result + "|" + obj.SessionID, this.refnum); return obj; } }