private void Upload(List <CUSTOM_S02007_TEMP> tempHSChecked)
        {
            LogEvent             logEvent            = new LogEvent();
            TransactionProvider  transactionProvider = new TransactionProvider();
            TransactionViewModel transaction         = null;

            //List<TransactionDataViewModel> transactionData = null;
            wsB2B.TransactionData[] transactionDataArray    = null;
            List <S02007ViewModel>  transactionDataDetailHS = new List <S02007ViewModel>();
            List <string>           arrHSIS = null;

            try
            {
                ////1.Get HS FROM EPROC //2.INSERT INTO TEMP //3.GET FROM TEM
                var tempHS = transactionProvider.SendActualReceiptInvoice();
                ////CHECKING EVER SEND TO UPLOAD BY PONUMBER
                //var tempHSChecked = transactionProvider.CheckingHistoryHS(tempHS);

                //4.INSERT INTO LOG TRANSACTION HEADER DETAIL
                var intResult = transactionProvider.InsertLogTransactionS02007(tempHSChecked);

                //5.GET DATA FROM LOG TRANSACTION HEADER DETAIL
                if (intResult != 0)
                {
                    //a.GET TRANSACTION
                    transaction = transactionProvider.GetTransactionS02007();

                    //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.GetTransactionDataDetailHSS02007(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.ConcateStringHSS02007(DataDetailHS[j]));

                                //masukan ke transactionDataArray.
                                transactionDataArray[i].Data       = arrHSIS.ToArray();
                                transactionDataArray[i].DataLength = arrHSIS.Count;
                            }
                        }
                        //6.SEND TO WEB SERVICE
                        using (wsB2B.B2BAIWebServiceDMZ wsB2B = new wsB2B.B2BAIWebServiceDMZ())
                        {
                            wsB2B.UploadRequest uploadRequest = new wsB2B.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);

                            //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.UploadDocument(uploadRequest);
                            acknowledge = wsResult.Acknowledge;
                            ticketNo    = wsResult.TicketNo;
                            message     = wsResult.Message;
                        }
                    }
                }
                else if (intResult == 0)
                {
                    //delete temp table
                    transactionProvider.DeleteAllTempHSS02007();
                    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", "UploadDocumentS02007", acknowledge, ticketNo, message, fileType, "SERA");
            }
            catch (Exception ex)
            {
                LblResult.Text      = ex.Message;
                LblAcknowledge.Text = "";
                LblTicketNo.Text    = "";
                LblMessage.Text     = "";

                //logevent login failed
                logEvent.WriteDBLog("B2BAIWebServiceDMZ", "UploadDocumentS02007", acknowledge, ticketNo, "webservice message : " + message + ". exception message : " + ex.Message, fileType, "SERA");
                Process.Start("taskkill.exe", "/f /im B2BAISERA_S02007.exe");
            }
        }
        private void Upload(List <CUSTOM_S02001_TEMP_HS> tempHSISChecked, List <CUSTOM_S02001_TEMP_IS> tempHSISChecked2)
        {
            LogEvent             logEvent            = new LogEvent();
            TransactionProvider  transactionProvider = new TransactionProvider();
            TransactionViewModel transaction         = null;

            wsB2B.TransactionData[]  transactionDataArray    = null;
            List <S02001HSViewModel> transactionDataDetailHS = new List <S02001HSViewModel>();
            List <S02001ISViewModel> transactionDataDetailIS = new List <S02001ISViewModel>();
            List <string>            arrHSIS = null;

            try
            {
                ////1.Get HS/IS FROM EPROC+STREAMLINER //2.INSERT INTO TEMP_HS + TEMP_IS //3.GET FROM TEMP_HS + TEMP_IS
                //var tempHS = transactionProvider.CreatePOSeraToAI_HS();
                //var tempIS = transactionProvider.CreatePOSeraToAI_IS();

                ////todo error sequence
                ////CHECK IF IT HAS BEEN SENT TO UPLOAD OR NOT BY PONUMBER
                //var tempHSISChecked = transactionProvider.CheckingHistoryHSIS(tempHS, tempIS);
                //var tempHSISChecked2 = transactionProvider.CheckingHistoryHSIS2(tempHS, tempIS);
                ////var tempHSChecked = transactionProvider.CheckingHistoryHS(tempHS);
                ////var tempISChecked = transactionProvider.CheckingHistoryIS(tempIS);

                //4.INSERT INTO LOG TRANSACTION HEADER DETAIL + DELETE TEMP
                CommonResponse commonResponse = new CommonResponse()
                {
                    Acknowledge = acknowledge,
                    TicketNo    = ticketNo,
                    Message     = message
                };

                var intResult = transactionProvider.InsertLogTransaction(tempHSISChecked, tempHSISChecked2, commonResponse, clientTag);

                //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 (wsB2B.B2BAIWebServiceDMZ wsB2B = new wsB2B.B2BAIWebServiceDMZ())
                        {
                            wsB2B.UploadRequest uploadRequest = new wsB2B.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);

                            //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;

                            //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.UploadDocument(uploadRequest);
                            acknowledge = wsResult.Acknowledge;
                            ticketNo    = wsResult.TicketNo;
                            message     = wsResult.Message;

                            //TODO 16-08-2013: IF INVALID TICKETNO RE-LOGIN
                            // Get file info
                        }
                    }

                    //add 03.06.2014 by fhi
                    else if (transaction == null)
                    {
                        logEvent.WriteDBLog("", "UploadS02001_Load", false, "", "transaction == null", "S02001", "SERA");
                        Process.Start("taskkill.exe", "/f /im B2BAISERA_S02001.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", "UploadDocumentS02001", 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", "UploadDocumentS02001", acknowledge, ticketNo, "webservice message : " + message + ". exception message : " + ex.Message, fileType, "SERA");

                Process.Start("taskkill.exe", "/f /im B2BAISERA_S02001.exe");
            }
        }
        private void Upload(List <CUSTOM_S02005_TEMP_HS> tempHSISChecked, List <CUSTOM_S02005_TEMP_IS> tempHSISChecked2)
        {
            LogEvent             logEvent            = new LogEvent();
            TransactionProvider  transactionProvider = new TransactionProvider();
            TransactionViewModel transaction         = null;

            wsB2B.TransactionData[]     transactionDataArray    = null;
            List <S02005HSNewViewModel> transactionDataDetailHS = new List <S02005HSNewViewModel>();
            List <S02005ISNewViewModel> transactionDataDetailIS = new List <S02005ISNewViewModel>();
            List <string> arrHSIS = null;

            try
            {
                ////1.Get HS/IS FROM EPROC+STREAMLINER //2.INSERT INTO TEMP_HS + TEMP_IS //3.GET FROM TEMP_HS + TEMP_IS
                //var tempHS = transactionProvider.PaymentSeraToAIHS();
                //var tempIS = transactionProvider.PaymentSeraToAIIS();

                ////CHECKING EVER SEND TO UPLOAD BY PONUMBER
                //var tempHSISChecked = transactionProvider.CheckingHistoryHSIS(tempHS, tempIS);
                //var tempHSISChecked2 = transactionProvider.CheckingHistoryHSIS2(tempHS, tempIS);

                //4.INSERT INTO LOG TRANSACTION HEADER DETAIL + DELETE TEMP
                var intResult = transactionProvider.InsertLogTransactionS02005New(tempHSISChecked, tempHSISChecked2);

                //5.GET DATA FROM LOG TRANSACTION HEADER DETAIL
                if (intResult != 0)
                {
                    //a.GET TRANSACTION
                    transaction = transactionProvider.GetTransactionS02005New();

                    //b.GET TRANSACTION DATA
                    if (transaction != null)
                    {
                        //transactionData = transactionProvider.GetTransactionData(transaction.ID);
                        transactionDataArray = transactionProvider.GetTransactionDataArray(transaction.ID);
                        int flagUpdatePoStatusID = 0;

                        //c.GET TRANSACTIONDATA DETAIL / HS-IS
                        for (int i = 0; i < transactionDataArray.Count(); i++)
                        {
                            var DataDetailHS = transactionProvider.GetTransactionDataDetailHSS02005New(transactionDataArray[i].ID);
                            var DataDetailIS = transactionProvider.GetTransactionDataDetailISS02005New(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.ConcateStringHSS02005New(DataDetailHS[j]));

                                for (int k = 0; k < DataDetailIS.Count; k++)
                                {
                                    if (DataDetailHS[j].GroupingCode == DataDetailIS[k].GroupingCode)
                                    {
                                        transactionDataDetailIS.Add(DataDetailIS[k]);
                                        //masukan ke array
                                        arrHSIS.Add(transactionProvider.ConcateStringISS02005New(DataDetailIS[k]));
                                    }
                                }
                                //masukan ke transactionDataArray.
                                transactionDataArray[i].Data       = arrHSIS.ToArray();
                                transactionDataArray[i].DataLength = arrHSIS.Count;
                            }
                        }
                        //6.SEND TO WEB SERVICE
                        using (wsB2B.B2BAIWebServiceDMZ wsB2B = new wsB2B.B2BAIWebServiceDMZ())
                        {
                            wsB2B.UploadRequest uploadRequest = new wsB2B.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;
                            if (wsResult.Acknowledge && wsResult.Message.Contains("Succeeded"))
                            {
                                flagUpdatePoStatusID = 1;
                            }
                        }

                        //NEW FOR LIVE 2013-NOV-20
                        if (flagUpdatePoStatusID == 1)
                        {
                            for (int i = 0; i < transactionDataArray.Count(); i++)
                            {
                                for (int j = 1; j <= transactionDataArray[i].Data.Count() - 1; j++)
                                {
                                    string poNumber = transactionDataArray[i].Data[j].Split('|')[10].Trim();

                                    transactionProvider.UpdateCustomPOPaymentStatusTerkirim(poNumber, 1);
                                }
                            }
                        }
                    }
                }
                else if (intResult == 0)
                {
                    //delete temp table
                    transactionProvider.DeleteAllTempHSISS02005();
                    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", "UploadDocumentS02005", acknowledge, ticketNo, message, fileType, "SERA");
            }
            catch (Exception ex)
            {
                LblResult.Text      = ex.Message;
                LblAcknowledge.Text = "";
                LblTicketNo.Text    = "";
                LblMessage.Text     = "";

                //logevent login failed
                logEvent.WriteDBLog("B2BAIWebServiceDMZ", "UploadDocumentS02005", acknowledge, ticketNo, "webservice message : " + message + ". exception message : " + ex.Message, fileType, "SERA");
                // add taks kill when failed : by fhi 04.06.2014
                Process.Start("taskkill.exe", "/f /im B2BAISERA_S02005.exe");
                //end
            }
        }