예제 #1
0
        public void Receive(MATISSUE_REQ request)
        {
            ((SQLDomainDataProvider)DataProvider).PersistBroker.AutoCloseConnection = false;
            ((SQLDomainDataProvider)DataProvider).PersistBroker.OpenConnection();
            try
            {
                TransferFacade     transferFacade = new TransferFacade(this.DataProvider);
                SAPDataTransferLog log;
                DBDateTime         currentDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider);
                string             xmlFilePath;
                if (request.TransactionCode == null || request.TransactionCode == string.Empty)
                {
                    // New Log
                    log = transferFacade.CreateNewSAPDataTransferLog();
                    //log.ErrorMessage
                    //log.FinishedDate
                    //log.FinishedTime
                    log.JobID               = TransferFacade.MaterialIssueJobID;
                    log.OrganizationID      = 2000;
                    log.ReceivedRecordCount = (request.IssueList == null || request.IssueList.Count == 0) ? 0 : request.IssueList.Count;
                    log.TransactionCode     = TransferFacade.MaterialIssueJobID + "_"
                                              + currentDateTime.DBDate.ToString() + "_"
                                              + currentDateTime.DBTime.ToString()
                                              + DateTime.Now.Millisecond.ToString();
                    log.TransactionSequence = 1;
                    xmlFilePath             = SerializeUtil.SerializeFile(log.TransactionCode + "_Response.xml",
                                                                          typeof(MATISSUE_REQ), request);
                    log.RequestContent = xmlFilePath;
                    log.RequestDate    = currentDateTime.DBDate;
                    log.RequestTime    = currentDateTime.DBTime;
                    //log.Result
                    log.SendRecordCount = 0;
                    transferFacade.AddSAPDataTransferLog(log);

                    request.TransactionCode = log.TransactionCode;
                }
                else
                {
                    // Update log
                    log = transferFacade.GetSAPDataTransferLog(request.TransactionCode, 1) as SAPDataTransferLog;
                    //log.ErrorMessage
                    //log.FinishedDate
                    //log.FinishedTime
                    log.ReceivedRecordCount = (request.IssueList == null || request.IssueList.Count == 0) ? 0 : request.IssueList.Count;
                    xmlFilePath             = SerializeUtil.SerializeFile(log.TransactionCode + "_Response.xml",
                                                                          typeof(MATISSUE_REQ), request);
                    log.ResponseContent = xmlFilePath;
                    log.ResponseDate    = currentDateTime.DBDate;
                    log.ResponseTime    = currentDateTime.DBTime;
                    //log.Result
                    transferFacade.UpdateSAPDataTransferLog(log);
                }

                if (request.IssueList == null || request.IssueList.Count == 0)
                {
                    log.Result       = "Fail";
                    log.ErrorMessage = "Raw Issue list is null.";
                    log.FinishedDate = 0;
                    log.FinishedTime = 0;

                    transferFacade.UpdateSAPDataTransferLog(log);
                    return;
                }
                else
                {
                    MaterialStockFacade msf = new MaterialStockFacade(this.DataProvider);
                    RawIssue4SAP        rawIssue4SAP;
                    InventoryFacade     inventoryFacade = new InventoryFacade(this.DataProvider);

                    List <SAPMaterialTrans> confirmSAPMaterialTransList = new List <SAPMaterialTrans>();

                    try
                    {
                        this.DataProvider.BeginTransaction();

                        foreach (MES_MATISSUE matIssue in request.IssueList)
                        {
                            rawIssue4SAP = msf.CreateNewRawIssue4SAP();
                            rawIssue4SAP.ErrorMessage         = matIssue.ErrorMessage;
                            rawIssue4SAP.Flag                 = matIssue.Flag;
                            rawIssue4SAP.MaintainDate         = currentDateTime.DBDate;
                            rawIssue4SAP.MaintainTime         = currentDateTime.DBTime;
                            rawIssue4SAP.MaintainUser         = "******";
                            rawIssue4SAP.MaterialDocument     = matIssue.MaterialDocument;
                            rawIssue4SAP.MaterialDocumentYear = matIssue.MaterialDocumentYear;
                            rawIssue4SAP.TransactionCode      = request.TransactionCode;
                            rawIssue4SAP.VendorCode           = matIssue.VendorCode;

                            msf.AddRawIssue4SAP(rawIssue4SAP);

                            if (string.Compare(matIssue.Flag, "Y", true) == 0)  // Post OK
                            {
                                object[] sapMaterialTransList = inventoryFacade.QuerySAPMaterialTrans(request.TransactionCode);

                                if (sapMaterialTransList != null)
                                {
                                    foreach (SAPMaterialTrans sapMaterialTrans in sapMaterialTransList)
                                    {
                                        if (sapMaterialTrans.Flag == FlagStatus.FlagStatus_POST)
                                        {
                                            confirmSAPMaterialTransList.Add(sapMaterialTrans);
                                        }
                                    }
                                }
                            }
                        }

                        this.DataProvider.CommitTransaction();
                    }
                    catch (Exception ex)
                    {
                        this.DataProvider.RollbackTransaction();

                        log.Result       = "Fail";
                        log.ErrorMessage = ex.Message;
                        log.FinishedDate = 0;
                        log.FinishedTime = 0;

                        transferFacade.UpdateSAPDataTransferLog(log);
                    }

                    try
                    {
                        log.Result       = "OK";
                        log.ErrorMessage = "";
                        currentDateTime  = FormatHelper.GetNowDBDateTime(this.DataProvider);
                        log.FinishedDate = currentDateTime.DBDate;
                        log.FinishedTime = currentDateTime.DBTime;

                        transferFacade.UpdateSAPDataTransferLog(log);

                        foreach (SAPMaterialTrans sapMaterialTrans in confirmSAPMaterialTransList)
                        {
                            sapMaterialTrans.Flag = FlagStatus.FlagStatus_SAP;
                            inventoryFacade.UpdateSAPMaterialTrans(sapMaterialTrans);
                        }
                    }
                    catch (Exception ex)
                    {
                        this.DataProvider.RollbackTransaction();

                        log.Result       = "Fail";
                        log.ErrorMessage = ex.Message;
                        log.FinishedDate = 0;
                        log.FinishedTime = 0;

                        transferFacade.UpdateSAPDataTransferLog(log);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ((SQLDomainDataProvider)DataProvider).PersistBroker.CloseConnection();
                ((SQLDomainDataProvider)DataProvider).PersistBroker.AutoCloseConnection = true;
            }
        }
예제 #2
0
        public void Receive(DNCONFIRM_REQ request)
        {
            ((SQLDomainDataProvider)DataProvider).PersistBroker.AutoCloseConnection = false;
            ((SQLDomainDataProvider)DataProvider).PersistBroker.OpenConnection();
            try
            {
                TransferFacade     transferFacade = new TransferFacade(this.DataProvider);
                SAPDataTransferLog log;
                DBDateTime         currentDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider);
                string             xmlFilePath;
                if (request.TransactionCode == null || request.TransactionCode == string.Empty)
                {
                    // New Log
                    log = transferFacade.CreateNewSAPDataTransferLog();
                    //log.ErrorMessage
                    //log.FinishedDate
                    //log.FinishedTime
                    log.JobID               = TransferFacade.InvertoryJobID;
                    log.OrganizationID      = 2000;
                    log.ReceivedRecordCount = (request.DNConfirmList == null || request.DNConfirmList.Count == 0) ? 0 : request.DNConfirmList.Count;
                    log.TransactionCode     = TransferFacade.DNConfirmJobID + "_"
                                              + currentDateTime.DBDate.ToString() + "_"
                                              + currentDateTime.DBTime.ToString()
                                              + DateTime.Now.Millisecond.ToString();
                    log.TransactionSequence = 1;
                    xmlFilePath             = SerializeUtil.SerializeFile(log.TransactionCode + "_Response.xml",
                                                                          typeof(DNCONFIRM_REQ), request);
                    log.RequestContent = xmlFilePath;
                    log.RequestDate    = currentDateTime.DBDate;
                    log.RequestTime    = currentDateTime.DBTime;
                    //log.Result
                    log.SendRecordCount = 0;
                    transferFacade.AddSAPDataTransferLog(log);

                    request.TransactionCode = log.TransactionCode;
                }
                else
                {
                    // Update log
                    log = transferFacade.GetSAPDataTransferLog(request.TransactionCode, 1) as SAPDataTransferLog;
                    //log.ErrorMessage
                    //log.FinishedDate
                    //log.FinishedTime
                    log.ReceivedRecordCount = (request.DNConfirmList == null || request.DNConfirmList.Count == 0) ? 0 : request.DNConfirmList.Count;
                    xmlFilePath             = SerializeUtil.SerializeFile(log.TransactionCode + "_Response.xml",
                                                                          typeof(DNCONFIRM_REQ), request);
                    log.ResponseContent = xmlFilePath;
                    log.ResponseDate    = currentDateTime.DBDate;
                    log.ResponseTime    = currentDateTime.DBTime;
                    //log.Result
                    transferFacade.UpdateSAPDataTransferLog(log);
                }

                this.DataProvider.BeginTransaction();
                try
                {
                    DeliveryFacade deliveryFacade = new DeliveryFacade(this.DataProvider);
                    DN2SAP         dn2sap;
                    foreach (MES_DNConfirm dnconfirm in request.DNConfirmList)
                    {
                        dn2sap              = deliveryFacade.CreateNewDN2SAP();
                        dn2sap.Active       = "Y";
                        dn2sap.DNCode       = dnconfirm.DNNo;
                        dn2sap.ErrorMessage = dnconfirm.Message;
                        dn2sap.Flag         = dnconfirm.Flag;
                        dn2sap.MaintainDate = currentDateTime.DBDate;
                        dn2sap.MaintainTime = currentDateTime.DBTime;
                        dn2sap.MaintainUser = "******";

                        deliveryFacade.UpdateDN2SAPStatusByDNNo(dn2sap.DNCode.ToUpper());

                        deliveryFacade.AddDN2SAP(dn2sap);

                        if (string.Compare(dnconfirm.Flag, "Y", true) == 0)  // Post OK
                        {
                            // Update tbldn.flag to SAP
                            deliveryFacade.UpdateDNFlag(dnconfirm.DNNo, FlagStatus.FlagStatus_SAP);
                        }
                    }

                    this.DataProvider.CommitTransaction();

                    log.Result       = "OK";
                    log.ErrorMessage = "";
                    currentDateTime  = FormatHelper.GetNowDBDateTime(this.DataProvider);
                    log.FinishedDate = currentDateTime.DBDate;
                    log.FinishedTime = currentDateTime.DBTime;

                    transferFacade.UpdateSAPDataTransferLog(log);
                }
                catch (Exception ex)
                {
                    this.DataProvider.RollbackTransaction();

                    log.Result       = "Fail";
                    log.ErrorMessage = ex.Message;
                    log.FinishedDate = 0;
                    log.FinishedTime = 0;

                    transferFacade.UpdateSAPDataTransferLog(log);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ((SQLDomainDataProvider)DataProvider).PersistBroker.CloseConnection();
                ((SQLDomainDataProvider)DataProvider).PersistBroker.AutoCloseConnection = true;
            }
        }
예제 #3
0
        public void Receive(DNRecive_REQ request)
        {
            ((SQLDomainDataProvider)DataProvider).PersistBroker.AutoCloseConnection = false;
            ((SQLDomainDataProvider)DataProvider).PersistBroker.OpenConnection();
            try
            {
                TransferFacade     transferFacade = new TransferFacade(this.DataProvider);
                SAPDataTransferLog log;
                DBDateTime         currentDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider);
                string             xmlFilePath;
                if (request.TransactionCode == null || request.TransactionCode == string.Empty)
                {
                    // New Log
                    log = transferFacade.CreateNewSAPDataTransferLog();
                    //log.ErrorMessage
                    //log.FinishedDate
                    //log.FinishedTime
                    log.JobID               = TransferFacade.DNTransferJobID;
                    log.OrganizationID      = 2000;
                    log.ReceivedRecordCount = (request.DNList == null || request.DNList.Count == 0) ? 0 : request.DNList.Count;
                    log.TransactionCode     = TransferFacade.DNTransferJobID + "_"
                                              + currentDateTime.DBDate.ToString() + "_"
                                              + currentDateTime.DBTime.ToString()
                                              + DateTime.Now.Millisecond.ToString();
                    log.TransactionSequence = 1;
                    xmlFilePath             = SerializeUtil.SerializeFile(log.TransactionCode + "_Response.xml",
                                                                          typeof(DNRecive_REQ), request);
                    log.RequestContent = xmlFilePath;
                    log.RequestDate    = currentDateTime.DBDate;
                    log.RequestTime    = currentDateTime.DBTime;
                    //log.Result
                    log.SendRecordCount = 0;
                    transferFacade.AddSAPDataTransferLog(log);

                    request.TransactionCode = log.TransactionCode;
                }
                else
                {
                    // Update log
                    log = transferFacade.GetSAPDataTransferLog(request.TransactionCode, 1) as SAPDataTransferLog;
                    //log.ErrorMessage
                    //log.FinishedDate
                    //log.FinishedTime
                    log.ReceivedRecordCount = (request.DNList == null || request.DNList.Count == 0) ? 0 : request.DNList.Count;
                    xmlFilePath             = SerializeUtil.SerializeFile(log.TransactionCode + "_Response.xml",
                                                                          typeof(DNRecive_REQ), request);
                    log.ResponseContent = xmlFilePath;
                    log.ResponseDate    = currentDateTime.DBDate;
                    log.ResponseTime    = currentDateTime.DBTime;
                    //log.Result
                    transferFacade.UpdateSAPDataTransferLog(log);
                }

                if (string.Compare(request.Flag, "Y", true) == 0)
                {
                    if (request.DNList == null || request.DNList.Count == 0)
                    {
                        log.Result       = "Fail";
                        log.ErrorMessage = "DN list is null.";
                        log.FinishedDate = 0;
                        log.FinishedTime = 0;

                        transferFacade.UpdateSAPDataTransferLog(log);
                        return;
                    }
                    else
                    {
                        this.DataProvider.BeginTransaction();
                        try
                        {
                            this.DealDN(request.DNList, currentDateTime);

                            this.DataProvider.CommitTransaction();

                            log.Result       = "OK";
                            log.ErrorMessage = "";
                            currentDateTime  = FormatHelper.GetNowDBDateTime(this.DataProvider);
                            log.FinishedDate = currentDateTime.DBDate;
                            log.FinishedTime = currentDateTime.DBTime;

                            transferFacade.UpdateSAPDataTransferLog(log);
                        }
                        catch (Exception ex)
                        {
                            this.DataProvider.RollbackTransaction();

                            log.Result       = "Fail";
                            log.ErrorMessage = ex.Message;
                            log.FinishedDate = 0;
                            log.FinishedTime = 0;

                            transferFacade.UpdateSAPDataTransferLog(log);
                        }
                    }
                }
                else
                {
                    log.Result       = "Fail";
                    log.ErrorMessage = request.Message;
                    log.FinishedDate = 0;
                    log.FinishedTime = 0;

                    transferFacade.UpdateSAPDataTransferLog(log);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ((SQLDomainDataProvider)DataProvider).PersistBroker.CloseConnection();
                ((SQLDomainDataProvider)DataProvider).PersistBroker.AutoCloseConnection = true;
            }
        }
예제 #4
0
        public void Receive(INVReceive_REQ request)
        {
            ((SQLDomainDataProvider)DataProvider).PersistBroker.AutoCloseConnection = false;
            ((SQLDomainDataProvider)DataProvider).PersistBroker.OpenConnection();
            try
            {
                TransferFacade     transferFacade = new TransferFacade(this.DataProvider);
                SAPDataTransferLog log;
                DBDateTime         currentDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider);
                string             xmlFilePath;
                if (request.TransactionCode == null || request.TransactionCode == string.Empty)
                {
                    // New Log
                    log = transferFacade.CreateNewSAPDataTransferLog();
                    //log.ErrorMessage
                    //log.FinishedDate
                    //log.FinishedTime
                    log.JobID               = TransferFacade.InvertoryJobID;
                    log.OrganizationID      = 2000;
                    log.ReceivedRecordCount = (request.INVList == null || request.INVList.Count == 0) ? 0 : request.INVList.Count;
                    log.TransactionCode     = TransferFacade.InvertoryJobID + "_"
                                              + currentDateTime.DBDate.ToString() + "_"
                                              + currentDateTime.DBTime.ToString()
                                              + DateTime.Now.Millisecond.ToString();
                    log.TransactionSequence = 1;
                    xmlFilePath             = SerializeUtil.SerializeFile(log.TransactionCode + "_Response.xml",
                                                                          typeof(INVReceive_REQ), request);
                    log.RequestContent = xmlFilePath;
                    log.RequestDate    = currentDateTime.DBDate;
                    log.RequestTime    = currentDateTime.DBTime;
                    //log.Result
                    log.SendRecordCount = 0;
                    transferFacade.AddSAPDataTransferLog(log);

                    request.TransactionCode = log.TransactionCode;
                }
                else
                {
                    // Update log
                    log = transferFacade.GetSAPDataTransferLog(request.TransactionCode, 1) as SAPDataTransferLog;
                    //log.ErrorMessage
                    //log.FinishedDate
                    //log.FinishedTime
                    log.ReceivedRecordCount = (request.INVList == null || request.INVList.Count == 0) ? 0 : request.INVList.Count;
                    xmlFilePath             = SerializeUtil.SerializeFile(log.TransactionCode + "_Response.xml",
                                                                          typeof(INVReceive_REQ), request);
                    log.ResponseContent = xmlFilePath;
                    log.ResponseDate    = currentDateTime.DBDate;
                    log.ResponseTime    = currentDateTime.DBTime;
                    //log.Result
                    transferFacade.UpdateSAPDataTransferLog(log);
                }

                if (string.Compare(request.Flag, "Y", true) == 0)
                {
                    if (request.INVList == null || request.INVList.Count == 0)
                    {
                        log.Result       = "Fail";
                        log.ErrorMessage = "Inventory list is null.";
                        log.FinishedDate = 0;
                        log.FinishedTime = 0;

                        transferFacade.UpdateSAPDataTransferLog(log);
                        return;
                    }
                    else
                    {
                        this.DataProvider.BeginTransaction();
                        try
                        {
                            InventoryFacade inventoryFacade = new InventoryFacade(this.DataProvider);
                            SAPStorageInfo  sapStorageInfo;
                            foreach (MES_INV inv in request.INVList)
                            {
                                sapStorageInfo           = inventoryFacade.CreateNewSAPStorageInfo();
                                sapStorageInfo.ItemCode  = inv.ItemCode;
                                sapStorageInfo.OrgID     = inv.OrgID;
                                sapStorageInfo.StorageID = inv.StorageID;
                                sapStorageInfo.CINSMQty  = inv.CINSMQTY;
                                sapStorageInfo.CLABSQty  = inv.CLABSQTY;
                                sapStorageInfo.CSPEMQty  = inv.CSPEMQTY;
                                sapStorageInfo.CUMLQty   = inv.CUMLQTY;
                                sapStorageInfo.Division  = inv.Division;
                                //sapStorageInfo.ItemDescription = inv.ItemDescription;
                                sapStorageInfo.ItemDescription = "";
                                sapStorageInfo.ItemGrade       = inv.ItemGrade;
                                sapStorageInfo.ModelCode       = string.Empty;
                                sapStorageInfo.StorageName     = inv.StorageName;
                                sapStorageInfo.MaintainDate    = currentDateTime.DBDate;
                                sapStorageInfo.MaintainTime    = currentDateTime.DBTime;
                                sapStorageInfo.MaintainUser    = "******";

                                object oldStorageInfo = inventoryFacade.GetSAPStorageInfo(inv.ItemCode.ToUpper(), inv.OrgID, inv.StorageID.ToUpper(), inv.ItemGrade.ToUpper());

                                if (oldStorageInfo == null)
                                {
                                    inventoryFacade.AddSAPStorageInfo(sapStorageInfo);
                                }
                                else
                                {
                                    inventoryFacade.DeleteSAPStorageInfo(oldStorageInfo as SAPStorageInfo);
                                    inventoryFacade.AddSAPStorageInfo(sapStorageInfo);
                                }
                            }

                            object[] queryList = inventoryFacade.QuerySAPStorageQuery(string.Empty, request.TransactionCode);
                            if (queryList != null)
                            {
                                foreach (SAPStorageQuery query in queryList)
                                {
                                    query.Flag = FlagStatus.FlagStatus_SAP;
                                    inventoryFacade.UpdateSAPStorageQuery(query);
                                }
                            }

                            this.DataProvider.CommitTransaction();

                            log.Result       = "OK";
                            log.ErrorMessage = "";
                            currentDateTime  = FormatHelper.GetNowDBDateTime(this.DataProvider);
                            log.FinishedDate = currentDateTime.DBDate;
                            log.FinishedTime = currentDateTime.DBTime;

                            transferFacade.UpdateSAPDataTransferLog(log);
                        }
                        catch (Exception ex)
                        {
                            this.DataProvider.RollbackTransaction();

                            log.Result       = "Fail";
                            log.ErrorMessage = ex.Message;
                            log.FinishedDate = 0;
                            log.FinishedTime = 0;

                            transferFacade.UpdateSAPDataTransferLog(log);
                        }
                    }
                }
                else
                {
                    log.Result       = "Fail";
                    log.ErrorMessage = request.Message;
                    log.FinishedDate = 0;
                    log.FinishedTime = 0;

                    transferFacade.UpdateSAPDataTransferLog(log);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ((SQLDomainDataProvider)DataProvider).PersistBroker.CloseConnection();
                ((SQLDomainDataProvider)DataProvider).PersistBroker.AutoCloseConnection = true;
            }
        }