public override IMovilwayApiResponse PerformKinacuOperation(IMovilwayApiRequest requestObject, SaleInterface kinacuWS, String sessionID) { if (sessionID.Equals("0")) { return new GetChildListResponseBody() { ResponseCode = 90, ResponseMessage = "error session", TransactionID = 0, ChildList = new ChildList() } } ; //GetChildListRequestBody request = requestObject as GetChildListRequestBody; GetChildListRequestBody request = requestObject as GetChildListRequestBody; GetChildListResponseBody response = new GetChildListResponseBody(); LogisticsInterface logisticsWS = new LogisticsInterface(); logger.InfoLow("[KIN] " + base.LOG_PREFIX + "[GetChildListProvider] [SEND-DATA] getChildRetailersParameters {UserId=" + sessionID + "}"); KinacuLogisticsWebService.Retailer[] childList = logisticsWS.GetChildRetailers(int.Parse(sessionID)); if (childList == null || childList.Count() <= 0) { logger.InfoLow("[KIN] " + base.LOG_PREFIX + "[GetChildListProvider] [RECV-DATA] getChildRetailersResult {No posee Hijos}"); } else { StringBuilder sb = new StringBuilder(); KinacuLogisticsWebService.Retailer retailer = childList[0]; sb.Append("Retailer={Id=" + retailer.Id + ",Name=" + retailer.Name + "},"); if (childList.Length > 1) { retailer = childList[1]; sb.Append("Retailer={Id=" + retailer.Id + ",Name=" + retailer.Name + "},"); } sb.Remove(sb.Length - 1, 1); sb.Append("..."); logger.InfoLow("[KIN] " + base.LOG_PREFIX + "[GetChildListProvider] [RECV-DATA] getChildRetailersResult {response=" + childList.Length + ",[" + sb.ToString() + "]}"); } response = new GetChildListResponseBody() { ResponseCode = (childList != null ? 0 : 99), ResponseMessage = (childList != null ? "exito" : "error"), TransactionID = 0 }; if (childList != null && childList.Length > 0) { response.ChildList = new ChildList(); foreach (KinacuLogisticsWebService.Retailer retailer in childList) { response.ChildList.Add(new BasicAgentInfo() { Agent = retailer.Id.ToString(), Name = retailer.Name }); } if (request.ExtendedValues ?? false) { var extendedValues = Utils.GetAgentExtendedValues(String.Join(",", response.ChildList.Select(ch => ch.Agent))); var rand = new Random(); foreach (BasicAgentInfo item in response.ChildList) { if (extendedValues.Any(e => e.Agent == item.Agent)) { var values = extendedValues.Single(e => e.Agent == item.Agent); item.Email = values.Email; item.Department = values.Department; item.City = values.City; item.CurrentBalance = values.CurrentBalance; item.Status = values.Status; item.ChildsCount = values.ChildsCount; item.PDVId = values.PDVId; } } } } return(response); } }
public override IMovilwayApiResponse PerformUtibaOperation(IMovilwayApiRequest requestObject, UMarketSCClient utibaClientProxy, String sessionID) { GetChildListRequestBody request = requestObject as GetChildListRequestBody; GetChildListResponseBody response = null; logger.InfoLow("[UTI] " + base.LOG_PREFIX + "[GetChildListProvider] [SEND-DATA] getChildListByReferenceRequest {sessionid=" + sessionID + ",device_type=" + request.DeviceType + ",agentReference=" + request.Agent + "}"); getChildListByReferenceResponse utibaGetChildListResponse = utibaClientProxy.getChildListByReference(new getChildListByReferenceRequest() { getChildListByReferenceRequestType = new getChildListByReferenceRequestType() { sessionid = sessionID, device_type = request.DeviceType, agentReference = request.Agent } }); StringBuilder sb = new StringBuilder(); foreach (var agent in utibaGetChildListResponse.getChildListByReferenceResponseType.agentList) { sb.Append("agentList={ID=" + agent.ID + ",referenceID=" + agent.referenceID + ",agentID=" + agent.agentID + ",ownerID=" + agent.ownerID + ",name=" + agent.name + ",MSISDN=" + agent.MSISDN + ",reference=" + agent.reference + ",entityReference={reference=" + agent.entityReference.reference + "}" + ",salt=" + agent.salt + ",upstream=" + agent.upstream + ",status=" + agent.status + ",agentType=" + agent.agentType + ",primaryGroup=" + agent.primaryGroup + ",depth=" + agent.depth + ",organisation=0,DSComission=0,POSComission=0,category=agent},"); } if (sb.Length > 0) { sb.Remove(sb.Length - 1, 1); } logger.InfoLow("[UTI] " + base.LOG_PREFIX + "[GetChildListProvider] [RECV-DATA] getChildListByReferenceResponse {transid=" + utibaGetChildListResponse.getChildListByReferenceResponseType.transid + ",result=" + utibaGetChildListResponse.getChildListByReferenceResponseType.result + ",result_namespace=" + utibaGetChildListResponse.getChildListByReferenceResponseType.result_message + "," + sb.ToString() + "}"); if (utibaGetChildListResponse != null) { response = new GetChildListResponseBody() { ResponseCode = Utils.BuildResponseCode(utibaGetChildListResponse.getChildListByReferenceResponseType.result, utibaGetChildListResponse.getChildListByReferenceResponseType.result_namespace), ResponseMessage = utibaGetChildListResponse.getChildListByReferenceResponseType.result_message, TransactionID = utibaGetChildListResponse.getChildListByReferenceResponseType.transid }; if (utibaGetChildListResponse.getChildListByReferenceResponseType.agentList != null && utibaGetChildListResponse.getChildListByReferenceResponseType.agentList.Length > 0) { response.ChildList = new ChildList(); foreach (Agent agent in utibaGetChildListResponse.getChildListByReferenceResponseType.agentList) { response.ChildList.Add(new BasicAgentInfo() { Agent = agent.reference, Name = agent.name }); } } } return(response); }