private void LoginAuthentication() { LogEvent logEvent = new LogEvent(); TransactionProvider transactionProvider = new TransactionProvider(); try { using (WsDev.B2BAIWebServiceDMZ wsB2B = new WsDev.B2BAIWebServiceDMZ()) { var User = transactionProvider.GetUser("SERA", "SERA", "B2BAITAG"); if (User != null) { var loginReq = new WsDev.LoginRequest(); loginReq.UserName = User.UserCode; loginReq.Password = User.PassCode; loginReq.ClientTag = User.ClientTag; //WebProxy myProxy = new WebProxy(Resources.WebProxyAddress, true); //myProxy.Credentials = new NetworkCredential(Resources.NetworkCredentialUserName, Resources.NetworkCredentialPassword, Resources.NetworkCredentialProxy); //WebProxy myProxy = new WebProxy(); //myProxy.Credentials = new NetworkCredential(Resources.NetworkCredentialUserName, Resources.NetworkCredentialPassword, Resources.NetworkCredentialProxy); //myProxy.Credentials = new NetworkCredential("backup", "serasibackup", "trac.astra.co.id"); //myProxy.Credentials = new NetworkCredential("rika009692", "mickey1988", "trac.astra.co.id"); //myProxy.Credentials = new NetworkCredential("genrpt", "serasera", "trac.astra.co.id"); //wsB2B.Proxy = myProxy; var wsResult = wsB2B.LoginAuthentication(loginReq); acknowledge = wsResult.Acknowledge; ticketNo = wsResult.TicketNo; message = wsResult.Message; } LblResult.Text = "Service Result = "; LblAcknowledge.Text = "Acknowledge : " + acknowledge; LblTicketNo.Text = "TicketNo : " + ticketNo; LblMessage.Text = "Message :" + message; //logevent login succeded logEvent.WriteDBLog("B2BAIWebServiceDMZ", "LoginAuthentication", acknowledge, ticketNo, message, fileType, "SERA"); } } catch (Exception ex) { LblResult.Text = ex.Message; LblAcknowledge.Text = ""; LblTicketNo.Text = ""; LblMessage.Text = ""; //logevent login failed logEvent.WriteDBLog("B2BAIWebServiceDMZ", "LoginAuthentication", acknowledge, ticketNo, "webservice message : " + message + ". exception message : " + ex.Message, fileType, "SERA"); } }
private void Download() { LogEvent logEvent = new LogEvent(); try { using (WsDev.B2BAIWebServiceDMZ wsB2B = new WsDev.B2BAIWebServiceDMZ()) { //Sample Data Download Request var downloadRequest = SampleDataDownloadRequestNew(); //hit web service //WebProxy myProxy = new WebProxy(Resources.WebProxyAddress, true); //myProxy.Credentials = new NetworkCredential(Resources.NetworkCredentialUserName, Resources.NetworkCredentialPassword, Resources.NetworkCredentialProxy); //WebProxy myProxy = new WebProxy(); //myProxy.Credentials = new NetworkCredential(Resources.NetworkCredentialUserName, Resources.NetworkCredentialPassword, Resources.NetworkCredentialProxy); //myProxy.Credentials = new NetworkCredential("backup", "serasibackup", "trac.astra.co.id"); //myProxy.Credentials = new NetworkCredential("rika009692", "mickey1988", "trac.astra.co.id"); //myProxy.Credentials = new NetworkCredential("genrpt", "serasera", "trac.astra.co.id"); //wsB2B.Proxy = myProxy; var wsResult = wsB2B.DownloadDocument(downloadRequest); acknowledge = wsResult.Acknowledge; ticketNo = wsResult.TicketNo; message = wsResult.Message; //end hit web service if (wsResult.transactionData == null) { downloadRequest = SampleDataDownloadRequestInProgress(); wsResult = wsB2B.DownloadDocument(downloadRequest); acknowledge = wsResult.Acknowledge; ticketNo = wsResult.TicketNo; message = wsResult.Message; } List <B2BAISERA.Models.TransactionDataViewModel> listTransactionDataModel = new List <B2BAISERA.Models.TransactionDataViewModel>(); if (wsResult.transactionData != null) { WsDev.TransactionData[] transactionData = wsResult.transactionData; for (int i = 0; i < transactionData.Length; i++) { B2BAISERA.Models.TransactionDataViewModel transactionDataModel = new B2BAISERA.Models.TransactionDataViewModel(); transactionDataModel.AIID = transactionData[i].ID; transactionDataModel.TransGUID = transactionData[i].TransGUID; transactionDataModel.DocumentNumber = transactionData[i].DocumentNumber; transactionDataModel.FileType = transactionData[i].FileType; transactionDataModel.IPAddress = transactionData[i].IPAddress; transactionDataModel.DestinationUser = transactionData[i].DestinationUser; transactionDataModel.Key1 = transactionData[i].Key1; transactionDataModel.Key2 = transactionData[i].Key2; transactionDataModel.Key3 = transactionData[i].Key3; transactionDataModel.DataLength = transactionData[i].DataLength; if (transactionData[i].Data.Count() > 0) { List <string> arrData1 = new List <string>(); for (int j = 0; j < transactionData[i].Data.Count(); j++) { arrData1.Add(transactionData[i].Data[j]); } transactionDataModel.Data = arrData1.ToArray(); } listTransactionDataModel.Add(transactionDataModel); } } logEvent.WriteDBLog("B2BAIWebServiceDMZ", "DownloadDocumentS02008", acknowledge, ticketNo, message, fileType, "SERA"); LblResult.Text = "Service Result = "; LblAcknowledge.Text = "Acknowledge : " + acknowledge; LblTicketNo.Text = "TicketNo : " + ticketNo; LblMessage.Text = "Message :" + message; TransactionProvider transactionProvider = new TransactionProvider(); int updateTransaction = 0; int insertTransaction = 0; if (listTransactionDataModel.Count > 0) { //2. UPDATE DB EPROC FROM listTransactionDataModel updateTransaction = transactionProvider.UpdateTransactionS02008(listTransactionDataModel); //3. SUCCEDED OR FAILED, CALL METHOD UPDATEDOCUMENTSTATUS if (updateTransaction == 1) { //4. INSERT INTO CUSTOM_TRANSACTION + CUSTOM_TRANSACTIONDATA + CUSTOM_TRANSACTIONDATADETAIL + CUSTOM_S02008 insertTransaction = transactionProvider.InsertLogTransactionDownloadS02008(acknowledge, ticketNo, message, "Succeeded", listTransactionDataModel); if (insertTransaction == 1) { var updateStatusRequest = SucceededDataUpdateStatusRequest(listTransactionDataModel); var wsResultUpdateDocStatus = wsB2B.UpdateDocumentStatus(updateStatusRequest); acknowledge = wsResultUpdateDocStatus.Acknowledge; ticketNo = wsResultUpdateDocStatus.TicketNo; message = wsResultUpdateDocStatus.Message; } } else { //4. INSERT INTO CUSTOM_TRANSACTION + CUSTOM_TRANSACTIONDATA + CUSTOM_TRANSACTIONDATADETAIL + CUSTOM_S02008 insertTransaction = transactionProvider.InsertLogTransactionDownloadS02008(acknowledge, ticketNo, message, "Failed", listTransactionDataModel); if (insertTransaction == 1) { //var updateStatusRequest = FailedDataUpdateStatusRequest(listTransactionDataModel); //var wsResultUpdateDocStatus = wsB2B.UpdateDocumentStatus(updateStatusRequest); //acknowledge = wsResultUpdateDocStatus.Acknowledge; //ticketNo = wsResultUpdateDocStatus.TicketNo; //message = wsResultUpdateDocStatus.Message; ////message += ", but Update Data Failed."; } } logEvent.WriteDBLog("B2BAIWebServiceDMZ", "UpdateDocumentStatusS02008", acknowledge, ticketNo, message, fileType, "SERA"); LblResult.Text = "Service Result = "; LblAcknowledge.Text = "Acknowledge : " + acknowledge; LblTicketNo.Text = "TicketNo : " + ticketNo; LblMessage.Text = "Message :" + message; } } } catch (Exception ex) { LblResult.Text = ex.Message; logEvent.WriteDBLog("B2BAIWebServiceDMZ", "DownloadDocumentS02008", acknowledge, ticketNo, message, fileType, "SERA"); } }
private void Upload(List <CUSTOM_S02009_TEMP_HS> tempHSISChecked, List <CUSTOM_S02009_TEMP_IS> tempHSISChecked2) { LogEvent logEvent = new LogEvent(); TransactionProvider transactionProvider = new TransactionProvider(); TransactionViewModel transaction = null; WsDev.TransactionData[] transactionDataArray = null; List <S02009HSViewModel> transactionDataDetailHS = new List <S02009HSViewModel>(); List <S02009ISViewModel> transactionDataDetailIS = new List <S02009ISViewModel>(); List <string> arrHSIS = null; try { //4.INSERT INTO LOG TRANSACTION HEADER DETAIL + DELETE TEMP var intResult = transactionProvider.InsertLogTransaction(tempHSISChecked, tempHSISChecked2); //5.GET DATA FROM LOG TRANSACTION HEADER DETAIL if (intResult != 0) { //a.GET TRANSACTION transaction = transactionProvider.GetTransaction(); //b.GET TRANSACTION DATA if (transaction != null) { //transactionData = transactionProvider.GetTransactionData(transaction.ID); transactionDataArray = transactionProvider.GetTransactionDataArray(transaction.ID); //c.GET TRANSACTIONDATA DETAIL / HS-IS for (int i = 0; i < transactionDataArray.Count(); i++) { var DataDetailHS = transactionProvider.GetTransactionDataDetailHS(transactionDataArray[i].ID); var DataDetailIS = transactionProvider.GetTransactionDataDetailIS(transactionDataArray[i].ID); for (int j = 0; j < DataDetailHS.Count; j++) { transactionDataDetailHS.Add(DataDetailHS[j]); //masukan ke array arrHSIS = new List <string>(); arrHSIS.Add(transactionProvider.ConcateStringHS(DataDetailHS[j])); for (int k = 0; k < DataDetailIS.Count; k++) { if (DataDetailHS[j].PONumber == DataDetailIS[k].PONumber) { transactionDataDetailIS.Add(DataDetailIS[k]); //masukan ke array arrHSIS.Add(transactionProvider.ConcateStringIS(DataDetailIS[k])); } } //masukan ke transactionDataArray. transactionDataArray[i].Data = arrHSIS.ToArray(); transactionDataArray[i].DataLength = arrHSIS.Count; } } //6.SEND TO WEB SERVICE using (WsDev.B2BAIWebServiceDMZ wsB2B = new WsDev.B2BAIWebServiceDMZ()) { WsDev.UploadRequest uploadRequest = new WsDev.UploadRequest(); var lastTicketNo = transactionProvider.GetLastTicketNo(fileType); uploadRequest.TicketNo = lastTicketNo; //from session ticketNo login uploadRequest.ClientTag = Resources.ClientTag; uploadRequest.transactionData = transactionDataArray; //WebProxy myProxy = new WebProxy(Resources.WebProxyAddress, true); //myProxy.Credentials = new NetworkCredential(Resources.NetworkCredentialUserName, Resources.NetworkCredentialPassword, Resources.NetworkCredentialProxy); //wsB2B.Proxy = myProxy; var wsResult = wsB2B.UploadDocument(uploadRequest); acknowledge = wsResult.Acknowledge; ticketNo = wsResult.TicketNo; message = wsResult.Message; } } else if (transaction == null) { logEvent.WriteDBLog("", "UploadS02009_Load", false, "", "transaction == null", "s02009", "SERA"); Process.Start("taskkill.exe", "/f /im B2BAISERA_S02009.exe"); } } else if (intResult == 0) { //delete temp table transactionProvider.DeleteAllTempHSIS(); acknowledge = false; ticketNo = ""; message = "No Data Upload."; } LblResult.Text = "Service Result = "; LblAcknowledge.Text = "Acknowledge : " + acknowledge; LblTicketNo.Text = "TicketNo : " + ticketNo; LblMessage.Text = "Message :" + message; //logevent login succeded logEvent.WriteDBLog("B2BAIWebServiceDMZ", "UploadDocumentS02009", acknowledge, ticketNo, message, fileType, "SERA"); } catch (Exception ex) { //delete temp table transactionProvider.DeleteAllTempHSIS(); LblResult.Text = ex.Message; LblAcknowledge.Text = ""; LblTicketNo.Text = ""; LblMessage.Text = ""; //logevent login failed logEvent.WriteDBLog("B2BAIWebServiceDMZ", "UploadDocumentS02009", acknowledge, ticketNo, "webservice message : " + message + ". exception message : " + ex.Message, fileType, "SERA"); Process.Start("taskkill.exe", "/f /im B2BAISERA_S02009.exe"); } }