private void GetOperator(string bcode, int zcode, string transdate) { string url = _read.serviceUrl(); try { WebRequest request = WebRequest.Create(url + "/Operator/?bcode=" + bcode + "&zcode=" + zcode); request.Credentials = CredentialCache.DefaultCredentials; WebResponse response = request.GetResponse(); Stream datastream = response.GetResponseStream(); StreamReader reader = new StreamReader(datastream); string responseFromService = reader.ReadToEnd(); var serviceReponse = JsonConvert.DeserializeObject <OperatorResponse>(responseFromService); if (serviceReponse.respcode == 0) { _domesticSO.GetSendoutDomestic(bcode, zcode, transdate, serviceReponse.respdata); _domesticPO.GetPayoutDomestic(bcode, zcode, transdate, serviceReponse.respdata); _domesticSOCancel.GetSendoutCancelDomestic(bcode, zcode, transdate, serviceReponse.respdata); _domesticPOCancel.GetPayoutCancelDomestic(bcode, zcode, transdate, serviceReponse.respdata); } else if (serviceReponse.respcode == 1) { _logger.Info(serviceReponse.respmsg + " - BranchCode: " + bcode + " ZoneCode: " + zcode); } else if (serviceReponse.respcode == 2) { _logger.Error(serviceReponse.respmsg + " - BranchCode: " + bcode + " ZoneCode: " + zcode); } } catch (Exception ex) { _logger.Error(ex.ToString()); } }
public void GetSendoutDomestic(string bcode, int zcode, string transactionDate, List <Operators> _operator) { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; string url = _read.serviceUrl(); try { foreach (var emp in _operator) { int persist = 0; while (persist < 2) { string kptn = _query.getKPTN(tableName, transactionDate, emp.userlogin, bcode); UTF8Encoding enc = new UTF8Encoding(); _sendoutRequest.kptn = kptn; _sendoutRequest.transdate = transactionDate; _sendoutRequest.bcode = bcode; _sendoutRequest.zcode = zcode; _sendoutRequest.employee = emp.userlogin; string stringRequest = JsonConvert.SerializeObject(_sendoutRequest); byte[] postDataBytes = enc.GetBytes(stringRequest); WebRequest request = WebRequest.Create(url + "/Domestic/Sendout"); request.Method = "POST"; request.ContentType = "application/json"; request.ContentLength = postDataBytes.Length; Stream stream = request.GetRequestStream(); stream.Write(postDataBytes, 0, postDataBytes.Length); stream.Close(); WebResponse result = request.GetResponse(); Stream response = result.GetResponseStream(); StreamReader reader = new StreamReader(response); string responseFromService = reader.ReadToEnd(); reader.Close(); response.Close(); var serviceResponse = JsonConvert.DeserializeObject <DomesticSendoutResponse>(responseFromService); if (serviceResponse.respcode == 0) { FetchSendoutDomestic(serviceResponse.respdata, transactionDate, emp.userlogin, emp.fullname, bcode); } else if (serviceResponse.respcode == 1) { _logger.Info("Domestic [SENDOUT] " + serviceResponse.respmsg + " - KPTN: " + kptn + " - Transdate: " + transactionDate + " - BranchCode: " + bcode + " - ZoneCode: " + zcode + " - Operator: " + emp.userlogin); persist++; } else if (serviceResponse.respcode == 2) { _logger.Error("Domestic [SENDOUT] " + serviceResponse.respmsg + " - KPTN: " + kptn + " - Transdate: " + transactionDate + " - BranchCode: " + bcode + " - ZoneCode: " + zcode + " - Operator: " + emp.userlogin); return; } } } } catch (Exception ex) { _logger.Error(ex.ToString()); } }