public ActionResult Edit(CampaignViewModel campaignVM) { Logger.Info(_logMsg.Clear().SetPrefixMsg("Save Recommended Campaign").Add("CardNo", campaignVM.CardNo.MaskCardNo()) .Add("HasInterested", campaignVM.Interested).Add("FirstName", campaignVM.FirstName).Add("LastName", campaignVM.LastName) .Add("PhoneNo", campaignVM.PhoneNo).ToInputLogString()); _auditLog = new AuditLogEntity(); _auditLog.Module = Constants.Module.Customer; _auditLog.Action = Constants.AuditAction.RecommendedCampaign; _auditLog.IpAddress = ApplicationHelpers.GetClientIP(); _auditLog.Status = LogStatus.Success; _auditLog.CreateUserId = this.UserInfo.UserId; try { if (ModelState.IsValid) { _userFacade = new UserFacade(); _commonFacade = new CommonFacade(); var searchFilter = new CampaignSearchFilter { CampaignId = campaignVM.CampaignId, HasOffered = Constants.CMTParamConfig.Offered, IsInterested = campaignVM.Interested, Comments = campaignVM.Comments, UpdatedBy = this.UserInfo.Username, FirstName = campaignVM.FirstName, LastName = campaignVM.LastName, PhoneNo = campaignVM.PhoneNo, Email = campaignVM.Email, CardNo = campaignVM.CardNo, ChannelName = campaignVM.ChannelName, AvailableTime = campaignVM.AvailableTime, ContractNoRefer = campaignVM.ContractNoRefer }; int?ownerLeadId = campaignVM.OwnerLead.ToNullable <int>(); if (ownerLeadId != null) { UserEntity ownerLead = _userFacade.GetUserById(ownerLeadId.Value); searchFilter.OwnerLeadCode = ownerLead.EmployeeCode; } _campaignFacade = new CampaignFacade(); if (Constants.CMTParamConfig.Interested.Equals(campaignVM.Interested)) { Ticket resLead = _campaignFacade.CreateLead(_auditLog, searchFilter); Logger.Info(_logMsg.Clear().SetPrefixMsg("Create Lead").Add("ResponseCode", resLead.ResponseCode) .Add("ResponseMessage", resLead.ResponseMessage).ToSuccessLogString()); } UpdateCampaignFlagsResponse resCamp = _campaignFacade.SaveCampaignFlags(_auditLog, campaignVM.CardNo, searchFilter); Logger.Info(_logMsg.Clear().SetPrefixMsg("Save Recommended Campaign").Add("UpdateStatus", resCamp.UpdateStatus).ToSuccessLogString()); // Call CMT and SLM Services return(Json(new { Valid = true, Error = string.Empty, })); } return(Json(new { Valid = false, Error = string.Empty, Errors = GetModelValidationErrors() })); } catch (CustomException cex) { Logger.Info(_logMsg.Clear().SetPrefixMsg("Search Campaign").Add("Error Message", cex.Message).ToFailLogString()); return(Json(new { Valid = false, Error = cex.Message })); } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); Logger.Info(_logMsg.Clear().SetPrefixMsg("Search Campaign").Add("Error Message", ex.Message).ToFailLogString()); return(Json(new { Valid = false, Error = ex.Message })); } }
private UpdateCampaignFlagsResponse UpdateCampaignFlagsByCustomer(AuditLogEntity auditLog, string cardNo, CampaignSearchFilter searchFilter) { var stopwatch = System.Diagnostics.Stopwatch.StartNew(); Logger.Debug("I:--START--:--CmtService.UpdateCustomerFlags--"); try { Header profile = GetHeaderByServiceName <Header>(Constants.ServiceName.CampaignByCustomer); var criteria = new CMT.UpdInquiry { CampaignId = searchFilter.CampaignId, HasOffered = searchFilter.HasOffered, IsInterested = searchFilter.IsInterested, UpdatedBy = searchFilter.UpdatedBy, Comments = searchFilter.Comments, Command = profile.command }; CMT.UpdateCustomerFlagsRequest reqCamp = new CMT.UpdateCustomerFlagsRequest { header = new CMT.Header { password = profile.password, reference_no = profile.reference_no, service_name = profile.service_name, system_code = profile.system_code, transaction_date = profile.transaction_date, user_name = profile.user_name }, UpdateCustFlag = new CMT.ReqUpdFlagEntity { CitizenId = cardNo, UpdInquiries = new CMT.UpdInquiry[] { criteria } } }; CMT.UpdateCustomerFlagsResponse resCamp = null; #region "Call Service" string flgCatchErrorCode = string.Empty; try { Retry.Do(() => { flgCatchErrorCode = string.Empty; Logger.DebugFormat("-- XMLRequest --\n{0}", reqCamp.SerializeObject()); using (var client = new CMT.CmtServiceClient()) { resCamp = ((CMT.ICmtService)client).UpdateCustomerFlags(reqCamp); if (client != null) { ((ICommunicationObject)client).Abort(); } } }, TimeSpan.FromSeconds(WebConfig.GetServiceRetryInterval()), WebConfig.GetServiceRetryNo()); } catch (AggregateException aex) { aex.Handle((x) => { if (x is EndpointNotFoundException) { flgCatchErrorCode = Constants.ErrorCode.CSM0002; Logger.Error("EndpointNotFoundException occur:\n", x); return(true); } else if (x is CommunicationException) { flgCatchErrorCode = Constants.ErrorCode.CSM0002; Logger.Error("CommunicationException occur:\n", x); return(true); } else if (x is TimeoutException) { flgCatchErrorCode = Constants.ErrorCode.CSM0001; Logger.Error("TimeoutException occur:\n", x); return(true); } else { flgCatchErrorCode = Constants.ErrorCode.CSM0003; Logger.Error("Exception occur:\n", x); return(true); } }); } if (!string.IsNullOrEmpty(flgCatchErrorCode)) { AppLog.AuditLog(auditLog, LogStatus.Fail, GetMessageResource(flgCatchErrorCode, true)); throw new CustomException(GetMessageResource(flgCatchErrorCode, false)); } #endregion if (resCamp != null) { Logger.DebugFormat("-- XMLResponse --\n{0}", resCamp.SerializeObject()); UpdateCampaignFlagsResponse response = new UpdateCampaignFlagsResponse(); response.StatusResponse.Status = resCamp.status.status; response.StatusResponse.ErrorCode = resCamp.status.error_code; response.StatusResponse.Description = resCamp.status.description; if (Constants.StatusResponse.Success.Equals(response.StatusResponse.Status)) { response.CitizenId = resCamp.detail.CitizenId; if (resCamp.detail.Result != null) { response.UpdateStatus = resCamp.detail.Result.UpdateStatus; } AppLog.AuditLog(auditLog, LogStatus.Success, string.Empty); return(response); } // Log DB AppLog.AuditLog(auditLog, LogStatus.Fail, GetMessageResource(Constants.SystemName.CMT, Constants.ServiceName.UpdateCustomerFlags, response.StatusResponse.ErrorCode, true)); throw new CustomException(GetMessageResource(Constants.SystemName.CMT, Constants.ServiceName.UpdateCustomerFlags, response.StatusResponse.ErrorCode, false)); } } finally { stopwatch.Stop(); Logger.DebugFormat("O:--Finish--:ElapsedMilliseconds/{0}", stopwatch.ElapsedMilliseconds); } return(null); }