private System.Collections.Generic.List <ShipBackDTO> CreateDispatch(DispatchOutWhCarSV bpObj)
        {
            System.Collections.Generic.List <ShipBackDTO> result = new System.Collections.Generic.List <ShipBackDTO>();
            //object result2;
            try
            {
                if (bpObj.CarShipLineDTOs == null || bpObj.CarShipLineDTOs.Count == 0)
                {
                    string msg = "传入参数不可为空";
                    result.Add(new ShipBackDTO
                    {
                        IsSuccess = false,
                        ErrorInfo = msg,
                        Timestamp = System.DateTime.Now
                    });
                    //result2 = result;
                    HBHCommon.LoggerError(msg);
                }
                else
                {
                    System.Collections.Generic.List <CarShipLineDTO> shiplist       = new System.Collections.Generic.List <CarShipLineDTO>();
                    System.Collections.Generic.List <CarShipLineDTO> transferinlist = new System.Collections.Generic.List <CarShipLineDTO>();
                    string errormessage = this.ValidateParamNullOrEmpty(bpObj, ref shiplist, ref transferinlist);
                    if (!string.IsNullOrEmpty(errormessage))
                    {
                        string msg = "请检查传入参数";
                        result.Add(new ShipBackDTO
                        {
                            IsSuccess = false,
                            ErrorInfo = errormessage + "请检查传入参数",
                            Timestamp = System.DateTime.Now
                        });
                        //result2 = result;
                        HBHCommon.LoggerError(msg);
                    }
                    else
                    {
                        System.Collections.Generic.List <DocKeyDTOData>            shipidlist    = new System.Collections.Generic.List <DocKeyDTOData>();
                        System.Collections.Generic.List <CommonArchiveDataDTOData> transinidlist = new System.Collections.Generic.List <CommonArchiveDataDTOData>();
                        if (shiplist != null && shiplist.Count > 0)
                        {
                            try
                            {
                                CreateShipSVProxy proxy = new CreateShipSVProxy();
                                proxy.ShipDTOs = (this.GetShipDTOList(shiplist));
                                shipidlist     = proxy.Do();

                                // 整车生成开立的出货单;
                            }
                            catch (System.Exception e)
                            {
                                //result.Add(new ShipBackDTO
                                //{
                                //    IsSuccess = false,
                                //    ErrorInfo = "生成出货单失败:" + e.Message,
                                //    Timestamp = System.DateTime.Now
                                //});
                                //result2 = result;
                                //return result2;
                                ShipBackDTO backDTO = new ShipBackDTO();
                                backDTO.IsSuccess = false;
                                backDTO.ErrorInfo = "生成出货单失败:" + e.Message;
                                backDTO.Timestamp = System.DateTime.Now;
                                HBHCommon.LoggerError(backDTO.ErrorInfo + "/r/n" + e.StackTrace);
                                result.Add(backDTO);
                                return(result);
                            }
                            if (shipidlist == null || shipidlist.Count <= 0)
                            {
                                //result.Add(new ShipBackDTO
                                //{
                                //    IsSuccess = false,
                                //    ErrorInfo = "生单失败:没有生成出货单",
                                //    Timestamp = System.DateTime.Now
                                //});
                                //result2 = result;
                                //return result2;

                                ShipBackDTO backDTO = new ShipBackDTO();
                                backDTO.IsSuccess = false;
                                backDTO.ErrorInfo = "生单失败:没有生成出货单";
                                backDTO.Timestamp = System.DateTime.Now;
                                HBHCommon.LoggerError(backDTO.ErrorInfo);
                                result.Add(backDTO);
                                return(result);
                            }
                        }
                        if (transferinlist != null && transferinlist.Count > 0)
                        {
                            //using (UBFTransactionScope trans = new UBFTransactionScope(TransactionOption.Required))
                            {
                                try
                                {
                                    UFIDA.U9.ISV.TransferInISV.Proxy.CommonCreateTransferInSVProxy proxy2 = new UFIDA.U9.ISV.TransferInISV.Proxy.CommonCreateTransferInSVProxy();
                                    proxy2.TransferInDTOList = (this.GetTransferInDTOList(transferinlist));
                                    transinidlist            = proxy2.Do();
                                    if (transinidlist == null || transinidlist.Count <= 0)
                                    {
                                        //result.Add(new ShipBackDTO
                                        //{
                                        //    IsSuccess = false,
                                        //    ErrorInfo = "生单失败:没有生成调入单",
                                        //    Timestamp = System.DateTime.Now
                                        //});
                                        //result2 = result;
                                        //return result2;

                                        ShipBackDTO backDTO = new ShipBackDTO();
                                        backDTO.IsSuccess = false;
                                        backDTO.ErrorInfo = "生单失败:没有生成调入单";
                                        backDTO.Timestamp = System.DateTime.Now;
                                        HBHCommon.LoggerError(backDTO.ErrorInfo);
                                        result.Add(backDTO);
                                        return(result);
                                    }
                                    TransferInBatchApproveSRVProxy approveproxy = new TransferInBatchApproveSRVProxy();
                                    approveproxy.DocList    = (transinidlist);
                                    approveproxy.ApprovedBy = (Context.LoginUser);
                                    approveproxy.ApprovedOn = (System.DateTime.Now);
                                    approveproxy.Do();
                                    //trans.Commit();
                                }
                                catch (System.Exception e)
                                {
                                    //trans.Rollback();
                                    //result.Add(new ShipBackDTO
                                    //{
                                    //    IsSuccess = false,
                                    //    ErrorInfo = "生成调入单失败:" + e.Message,
                                    //    Timestamp = System.DateTime.Now
                                    //});
                                    //result2 = result;
                                    //return result2;
                                    ShipBackDTO backDTO = new ShipBackDTO();
                                    backDTO.IsSuccess = false;
                                    backDTO.ErrorInfo = "生成调入单失败:" + e.Message;
                                    backDTO.Timestamp = System.DateTime.Now;
                                    HBHCommon.LoggerError(backDTO.ErrorInfo + "/r/n" + e.StackTrace);
                                    result.Add(backDTO);
                                    return(result);
                                }
                            }
                        }
                        foreach (DocKeyDTOData shipid in shipidlist)
                        {
                            Ship ship = Ship.Finder.FindByID(shipid.DocID);
                            if (ship != null)
                            {
                                result.Add(new ShipBackDTO
                                {
                                    IsSuccess = true,
                                    ErrorInfo = "生单出货单成功",
                                    Timestamp = System.DateTime.Now,
                                    ERPDocNo  = shipid.DocNO,
                                    DMSDocNo  = ship.DescFlexField.PubDescSeg7
                                });
                            }
                        }
                        foreach (CommonArchiveDataDTOData transin in transinidlist)
                        {
                            TransferIn t = TransferIn.Finder.FindByID(transin.ID);
                            if (t != null)
                            {
                                result.Add(new ShipBackDTO
                                {
                                    IsSuccess = true,
                                    ErrorInfo = "生单调入单成功",
                                    Timestamp = System.DateTime.Now,
                                    ERPDocNo  = transin.Code,
                                    DMSDocNo  = t.TransInLines[0].DescFlexSegments.PubDescSeg5
                                });
                            }
                        }
                        //result2 = result;
                    }
                }
            }
            catch (System.Exception e)
            {
                //result.Add(new ShipBackDTO
                //{
                //    IsSuccess = false,
                //    ErrorInfo = e.Message,
                //    Timestamp = System.DateTime.Now
                //});
                //result2 = result;

                ShipBackDTO backDTO = new ShipBackDTO();
                backDTO.IsSuccess = false;
                backDTO.ErrorInfo = e.Message;
                backDTO.Timestamp = System.DateTime.Now;
                HBHCommon.LoggerError(backDTO.ErrorInfo + "/r/n" + e.StackTrace);
                result.Add(backDTO);
            }
            //return result2;
            return(result);
        }
Ejemplo n.º 2
0
        private List <TransferInResultDTO> CreateTransferIn(CreateApprovedTransferInSV bpObj)
        {
            System.Collections.Generic.List <TransferInResultDTO> result = new System.Collections.Generic.List <TransferInResultDTO>();
            //object result2;
            try
            {
                if (bpObj.TransferInLineDTOList == null || bpObj.TransferInLineDTOList.Count == 0)
                {
                    //result.Add(new TransferInResultDTO
                    //{
                    //    IsSuccess = false,
                    //    ErrorInfo = "传入参数不可为空",
                    //    Timestamp = System.DateTime.Now
                    //});
                    //result2 = result;

                    TransferInResultDTO backDTO = new TransferInResultDTO();
                    backDTO.IsSuccess = false;
                    backDTO.ErrorInfo = "传入参数不可为空";
                    backDTO.Timestamp = System.DateTime.Now;
                    HBHCommon.LoggerError(backDTO.ErrorInfo);
                    result.Add(backDTO);
                }
                else
                {
                    string errormessage = this.ValidateParamNullOrEmpty(bpObj);
                    if (!string.IsNullOrEmpty(errormessage))
                    {
                        //result.Add(new TransferInResultDTO
                        //{
                        //    IsSuccess = false,
                        //    ErrorInfo = errormessage + "请检查传入参数",
                        //    Timestamp = System.DateTime.Now
                        //});
                        //result2 = result;

                        TransferInResultDTO backDTO = new TransferInResultDTO();
                        backDTO.IsSuccess = false;
                        backDTO.ErrorInfo = errormessage + "请检查传入参数";
                        backDTO.Timestamp = System.DateTime.Now;
                        HBHCommon.LoggerError(backDTO.ErrorInfo);
                    }
                    else
                    {
                        System.Collections.Generic.List <CommonArchiveDataDTOData> transinidlist;
                        //using (UBFTransactionScope trans = new UBFTransactionScope(TransactionOption.Required))
                        {
                            try
                            {
                                UFIDA.U9.ISV.TransferInISV.Proxy.CommonCreateTransferInSVProxy proxy = new UFIDA.U9.ISV.TransferInISV.Proxy.CommonCreateTransferInSVProxy();
                                proxy.TransferInDTOList = (this.GetTransferInDTOList(bpObj));
                                transinidlist           = proxy.Do();
                                if (transinidlist == null || transinidlist.Count <= 0)
                                {
                                    //result.Add(new TransferInResultDTO
                                    //{
                                    //    IsSuccess = false,
                                    //    ErrorInfo = "生单失败:没有生成调入单",
                                    //    Timestamp = System.DateTime.Now
                                    //});
                                    //result2 = result;
                                    //return result2;

                                    TransferInResultDTO backDTO = new TransferInResultDTO();
                                    backDTO.IsSuccess = false;
                                    backDTO.ErrorInfo = "生单失败:没有生成调入单";
                                    backDTO.Timestamp = System.DateTime.Now;
                                    HBHCommon.LoggerError(backDTO.ErrorInfo);
                                    return(result);
                                }
                                TransferInBatchApproveSRVProxy approveproxy = new TransferInBatchApproveSRVProxy();
                                approveproxy.DocList    = (transinidlist);
                                approveproxy.ApprovedBy = (Context.LoginUser);
                                approveproxy.ApprovedOn = (System.DateTime.Now);
                                approveproxy.Do();
                                //trans.Commit();
                            }
                            catch (System.Exception e)
                            {
                                //trans.Rollback();
                                //result.Add(new TransferInResultDTO
                                //{
                                //    IsSuccess = false,
                                //    ErrorInfo = "生单失败:" + e.Message,
                                //    Timestamp = System.DateTime.Now
                                //});
                                //result2 = result;
                                //return result2;

                                TransferInResultDTO backDTO = new TransferInResultDTO();
                                backDTO.IsSuccess = false;
                                backDTO.ErrorInfo = "生单失败:" + e.Message;
                                backDTO.Timestamp = System.DateTime.Now;
                                HBHCommon.LoggerError(backDTO.ErrorInfo + "/r/n" + e.StackTrace);
                                return(result);
                            }
                        }
                        foreach (CommonArchiveDataDTOData transin in transinidlist)
                        {
                            TransferIn t = TransferIn.Finder.FindByID(transin.ID);
                            if (t != null)
                            {
                                result.Add(new TransferInResultDTO
                                {
                                    IsSuccess  = true,
                                    ErrorInfo  = "生单成功",
                                    Timestamp  = System.DateTime.Now,
                                    ERPDocNo   = transin.Code,
                                    TransDocNo = t.DescFlexField.PrivateDescSeg4
                                });
                            }
                        }
                        //result2 = result;
                    }
                }
            }
            catch (System.Exception e)
            {
                //result.Add(new TransferInResultDTO
                //{
                //    IsSuccess = false,
                //    ErrorInfo = e.Message,
                //    Timestamp = System.DateTime.Now
                //});
                //result2 = result;

                TransferInResultDTO backDTO = new TransferInResultDTO();
                backDTO.IsSuccess = false;
                backDTO.ErrorInfo = e.Message;
                backDTO.Timestamp = System.DateTime.Now;
                HBHCommon.LoggerError(backDTO.ErrorInfo + "/r/n" + e.StackTrace);
            }
            //return result2;
            return(result);
        }
        // 创建SO
        /// <summary>
        /// 创建SO
        /// </summary>
        /// <param name="bpObj"></param>
        /// <returns></returns>
        private List <SoBackDTO> CreateSO(CreateApprovedSaleOrderSV bpObj)
        {
            System.Collections.Generic.List <SoBackDTO> results = new System.Collections.Generic.List <SoBackDTO>();
            SoBackDTO result = new SoBackDTO();

            //object result2;
            try
            {
                if (bpObj.SoLineDto == null || bpObj.SoLineDto.Count == 0)
                {
                    result.IsSuccess = false;
                    result.ErrorInfo = "传入参数不可为空";
                    result.Timestamp = System.DateTime.Now.ToString();
                    HBHCommon.LoggerError(result.ErrorInfo);
                    results.Add(result);
                    //result2 = results;
                }
                else
                {
                    string usercode     = bpObj.SoLineDto[0].UserCode;
                    string enterprise   = bpObj.SoLineDto[0].EnterpriseCode;
                    string errormessage = this.ValidateParamNullOrEmpty(bpObj);
                    if (!string.IsNullOrEmpty(errormessage))
                    {
                        result.IsSuccess = false;
                        result.ErrorInfo = errormessage;
                        result.Timestamp = System.DateTime.Now.ToString();
                        HBHCommon.LoggerError(result.ErrorInfo);
                        results.Add(result);
                        //result2 = results;
                    }
                    else
                    {
                        List <string> lstProjectCode = new List <string>();

                        System.Collections.Generic.List <SOStatusDTOData> statusDTOs = null;
                        //using (UBFTransactionScope trans = new UBFTransactionScope(TransactionOption.Required))
                        {
                            using (ISession session = Session.Open())
                            {
                                foreach (SoLineDTO line in bpObj.SoLineDto)
                                {
                                    if (!string.IsNullOrEmpty(line.DmsSaleNo))
                                    {
                                        Project project = Project.Finder.Find(string.Format("Org={0} and Code='{1}'", Context.LoginOrg.ID, line.DmsSaleNo), new OqlParam[0]);
                                        if (project == null)
                                        {
                                            Project p = Project.Create();
                                            p.Org                     = (Context.LoginOrg);
                                            p.StartDate               = (System.DateTime.Now);
                                            p.EndDate                 = (System.DateTime.Now);
                                            p.Code                    = (line.DmsSaleNo);
                                            p.Name                    = (line.DmsSaleNo);
                                            p.Effective               = (new Effective());
                                            p.Effective.IsEffective   = (true);
                                            p.Effective.EffectiveDate = (System.Convert.ToDateTime("2000.01.01 00:00:00"));
                                            p.Effective.DisableDate   = (System.Convert.ToDateTime("9999.12.31"));
                                        }

                                        if (!lstProjectCode.Contains(line.DmsSaleNo))
                                        {
                                            lstProjectCode.Add(line.DmsSaleNo);
                                        }
                                    }
                                }
                                session.Commit();
                            }
                            // 先不下发,下发直接死掉了

                            //foreach (string projCode in lstProjectCode)
                            //{
                            //    Project project2 = Project.Finder.Find(string.Format("Org={0} and Code='{1}'", Context.LoginOrg.ID, projCode), new OqlParam[0]);
                            //    if (project2 != null)
                            //    {
                            //        try
                            //        {
                            //            OnlineSendObjsProxy onlineSendObjsProxy = new OnlineSendObjsProxy();
                            //            onlineSendObjsProxy.FullName = ("UFIDA.U9.CBO.SCM.ProjectTask.Project");
                            //            onlineSendObjsProxy.IDs = (new System.Collections.Generic.List<long>());
                            //            onlineSendObjsProxy.IDs.Add(project2.ID);
                            //            onlineSendObjsProxy.FromOrg = (Context.LoginOrg.ID);
                            //            onlineSendObjsProxy.ToOrgList = (new System.Collections.Generic.List<long>());
                            //            //Organization org = Organization.Finder.Find("Code='10'", new OqlParam[0]);
                            //            //if (org != null)
                            //            //{
                            //            //    onlineSendObjsProxy.ToOrgList.Add(org.ID);
                            //            //}
                            //            //Organization org2 = Organization.Finder.Find("Code='30'", new OqlParam[0]);
                            //            //if (org2 != null)
                            //            //{
                            //            //    onlineSendObjsProxy.ToOrgList.Add(org2.ID);
                            //            //}
                            //            if (HBHCommon.ProjectSendOrgCode.Count > 0)
                            //            {
                            //                foreach (string orgCode in HBHCommon.ProjectSendOrgCode)
                            //                {
                            //                    Organization org = Organization.Finder.Find("Code=@OrgCode"
                            //                        , new OqlParam(orgCode)
                            //                        );
                            //                    if (org != null)
                            //                    {
                            //                        onlineSendObjsProxy.ToOrgList.Add(org.ID);
                            //                    }
                            //                }
                            //            }
                            //            if (onlineSendObjsProxy.ToOrgList.Count > 0)
                            //            {
                            //                onlineSendObjsProxy.Do();
                            //            }
                            //        }
                            //        catch (System.Exception e)
                            //        {
                            //            //throw new System.ApplicationException(string.Format("{0}项目下发失败:{1}", project2.Code, ex.Message));
                            //            result.IsSuccess = false;
                            //            result.ErrorInfo = e.Message;
                            //            result.Timestamp = System.DateTime.Now.ToString();
                            //            results.Add(result);
                            //            //result2 = results;
                            //            //return result2;
                            //            return results;
                            //        }
                            //    }
                            //}

                            // 如果已经生成了订单,则看看是否审核、没有审核 则 审核之;


                            List <SO> lstSO;

                            CommonCreateSOSRVProxy proxy = new CommonCreateSOSRVProxy();
                            proxy.SOs = this.GetSaleOrderDTODataList(bpObj, out lstSO);

                            if (proxy.SOs != null &&
                                proxy.SOs.Count > 0
                                )
                            {
                                try
                                {
                                    //proxy.ContextDTO = (new ContextDTOData());
                                    //proxy.ContextDTO.OrgID = (Context.LoginOrg.ID);
                                    //proxy.ContextDTO.OrgCode = (Context.LoginOrg.Code);
                                    //proxy.ContextDTO.EntCode = (enterprise);
                                    //proxy.ContextDTO.UserCode = (usercode);
                                    //proxy.ContextDTO.CultureName = (Context.LoginLanguageCode);
                                    System.Collections.Generic.List <CommonArchiveDataDTOData> resultsolist = proxy.Do();
                                    if (resultsolist == null || resultsolist.Count == 0)
                                    {
                                        result.IsSuccess = false;
                                        result.ErrorInfo = "没有生成销售订单";
                                        result.Timestamp = System.DateTime.Now.ToString();
                                        results.Add(result);
                                        //result2 = results;

                                        HBHCommon.LoggerError(result.ErrorInfo);
                                        return(results);
                                    }
                                    SOStatusTransferBPProxy bp = new SOStatusTransferBPProxy();
                                    bp.SOKeyDTOList = new System.Collections.Generic.List <SM.SO.SOKeyDTOData>();
                                    foreach (CommonArchiveDataDTOData d in resultsolist)
                                    {
                                        SM.SO.SOKeyDTOData dto = new SM.SO.SOKeyDTOData();
                                        dto.SOkey        = (d.ID);
                                        dto.TargetStatus = (2);
                                        bp.SOKeyDTOList.Add(dto);
                                    }
                                    statusDTOs      = bp.Do();
                                    bp              = new SOStatusTransferBPProxy();
                                    bp.SOKeyDTOList = (new System.Collections.Generic.List <SM.SO.SOKeyDTOData>());
                                    foreach (SOStatusDTOData dt in statusDTOs)
                                    {
                                        SM.SO.SOKeyDTOData dto = new SM.SO.SOKeyDTOData();
                                        dto.SOkey        = (dt.SOID);
                                        dto.SOSysVersion = (dt.SysVersion);
                                        dto.TargetStatus = (3);
                                        bp.SOKeyDTOList.Add(dto);
                                    }
                                    statusDTOs = bp.Do();
                                    //trans.Commit();
                                }
                                catch (System.Exception e)
                                {
                                    //trans.Rollback();
                                    result.IsSuccess = false;
                                    result.ErrorInfo = e.Message;
                                    result.Timestamp = System.DateTime.Now.ToString();
                                    results.Add(result);
                                    //result2 = results;
                                    //return result2;
                                    HBHCommon.LoggerError(result.ErrorInfo + "/r/n" + e.StackTrace);
                                    return(results);
                                }
                            }

                            // 已经存在的订单,试着审核
                            if (lstSO != null &&
                                lstSO.Count > 0
                                )
                            {
                                SOStatusTransferBPProxy bp = new SOStatusTransferBPProxy();
                                bp.SOKeyDTOList = new System.Collections.Generic.List <SM.SO.SOKeyDTOData>();
                                foreach (SO so in lstSO)
                                {
                                    if (so != null &&
                                        so.Status == SODocStatusEnum.Open
                                        )
                                    {
                                        SM.SO.SOKeyDTOData dto = new SM.SO.SOKeyDTOData();
                                        dto.SOkey        = so.ID;
                                        dto.TargetStatus = (2);
                                        bp.SOKeyDTOList.Add(dto);
                                    }
                                }
                                if (bp.SOKeyDTOList != null &&
                                    bp.SOKeyDTOList.Count > 0
                                    )
                                {
                                    bp.Do();

                                    // 重新取订单,可以取到最新的订单状态
                                    foreach (SM.SO.SOKeyDTOData dto in bp.SOKeyDTOList)
                                    {
                                        if (dto != null &&
                                            dto.SOkey > 0
                                            )
                                        {
                                            for (int i = 0; i < lstSO.Count; i++)
                                            {
                                                SO so = lstSO[i];

                                                if (so != null &&
                                                    so.ID == dto.SOkey
                                                    )
                                                {
                                                    lstSO[i] = SO.Finder.FindByID(dto.SOkey);
                                                }
                                            }
                                        }
                                    }
                                }

                                bp = new SOStatusTransferBPProxy();
                                bp.SOKeyDTOList = (new System.Collections.Generic.List <SM.SO.SOKeyDTOData>());
                                foreach (SO so in lstSO)
                                {
                                    if (so != null &&
                                        so.Status == SODocStatusEnum.Open
                                        )
                                    {
                                        SM.SO.SOKeyDTOData dto = new SM.SO.SOKeyDTOData();
                                        dto.SOkey        = so.ID;
                                        dto.SOSysVersion = (so.SysVersion);
                                        dto.TargetStatus = (3);
                                        bp.SOKeyDTOList.Add(dto);
                                    }
                                }
                                if (bp.SOKeyDTOList != null &&
                                    bp.SOKeyDTOList.Count > 0
                                    )
                                {
                                    bp.Do();
                                }

                                if (statusDTOs == null)
                                {
                                    statusDTOs = new List <SOStatusDTOData>();
                                }

                                // 组织创建结果DTO
                                foreach (SO so in lstSO)
                                {
                                    if (so != null
                                        )
                                    {
                                        SOStatusDTOData resultDTO = new SOStatusDTOData();
                                        resultDTO.SOID = so.ID;

                                        statusDTOs.Add(resultDTO);
                                    }
                                }
                            }
                        }
                        if (statusDTOs != null && statusDTOs.Count > 0)
                        {
                            foreach (SOStatusDTOData dt in statusDTOs)
                            {
                                SO so = SO.Finder.FindByID(dt.SOID);
                                if (so != null)
                                {
                                    result.IsSuccess = true;
                                    result.ErrorInfo = "生单成功";
                                    result.DMSDocNo  = so.DescFlexField.PubDescSeg5;
                                    result.ERPDocNo  = so.DocNo;
                                    results.Add(result);
                                }
                            }
                        }
                        //result2 = results;
                    }
                }
            }
            catch (System.Exception e)
            {
                result.IsSuccess = false;
                result.ErrorInfo = e.Message;
                result.Timestamp = System.DateTime.Now.ToString();
                HBHCommon.LoggerError(result.ErrorInfo + "/r/n" + e.StackTrace);
                results.Add(result);
                //result2 = results;
            }
            //return result2;
            return(results);
        }
Ejemplo n.º 4
0
        private List <ShipBackDTO> CreateRMA(CreateRMASV bpObj)
        {
            System.Collections.Generic.List <ShipBackDTO> result = new System.Collections.Generic.List <ShipBackDTO>();
            //object result2;
            try
            {
                if (bpObj.RMALineDTOs == null || bpObj.RMALineDTOs.Count == 0)
                {
                    //result.Add(new ShipBackDTO
                    //{
                    //    IsSuccess = false,
                    //    ErrorInfo = "传入参数不可为空",
                    //    Timestamp = System.DateTime.Now
                    //});
                    //result2 = result;

                    ShipBackDTO backDTO = new ShipBackDTO();
                    backDTO.IsSuccess = false;
                    backDTO.ErrorInfo = "传入参数不可为空";
                    backDTO.Timestamp = System.DateTime.Now;
                    HBHCommon.LoggerError(backDTO.ErrorInfo);
                    result.Add(backDTO);
                }
                else
                {
                    string errormessage = this.ValidateParamNullOrEmpty(bpObj);
                    if (!string.IsNullOrEmpty(errormessage))
                    {
                        //result.Add(new ShipBackDTO
                        //{
                        //    IsSuccess = false,
                        //    ErrorInfo = errormessage + "请检查传入参数",
                        //    Timestamp = System.DateTime.Now
                        //});
                        //result2 = result;
                        ShipBackDTO backDTO = new ShipBackDTO();
                        backDTO.IsSuccess = false;
                        backDTO.ErrorInfo = errormessage + "请检查传入参数";
                        backDTO.Timestamp = System.DateTime.Now;
                        HBHCommon.LoggerError(backDTO.ErrorInfo);
                        result.Add(backDTO);
                    }
                    else
                    {
                        System.Collections.Generic.List <DocKeyDTOData> rmaidlist = null;
                        try
                        {
                            CreateRMASRVProxy proxy = new CreateRMASRVProxy();
                            proxy.RMADTOs = (this.GetRMADTOList(bpObj));
                            //proxy.ContextDTO = (new ContextDTOData());
                            //proxy.ContextDTO.OrgID = (Context.LoginOrg.ID);
                            //proxy.ContextDTO.OrgCode = (Context.LoginOrg.Code);
                            //proxy.ContextDTO.EntCode = (bpObj.RMALineDTOs[0].EnterpriseCode);
                            //proxy.ContextDTO.UserID = (long.Parse(Context.LoginUserID));
                            //proxy.ContextDTO.UserCode = (Context.LoginUser);
                            //proxy.ContextDTO.CultureName = (Context.LoginLanguageCode);
                            rmaidlist = proxy.Do();
                        }
                        catch (System.Exception e)
                        {
                            //result.Add(new ShipBackDTO
                            //{
                            //    IsSuccess = false,
                            //    ErrorInfo = "生单失败:" + e.Message,
                            //    Timestamp = System.DateTime.Now
                            //});
                            //result2 = result;
                            //return result2;

                            ShipBackDTO backDTO = new ShipBackDTO();
                            backDTO.IsSuccess = false;
                            backDTO.ErrorInfo = "生单失败:" + e.Message;
                            backDTO.Timestamp = System.DateTime.Now;
                            HBHCommon.LoggerError(backDTO.ErrorInfo + "/r/n" + e.StackTrace);
                            result.Add(backDTO);
                            return(result);
                        }
                        if (rmaidlist == null || rmaidlist.Count <= 0)
                        {
                            //result.Add(new ShipBackDTO
                            //{
                            //    IsSuccess = false,
                            //    ErrorInfo = "生单失败:没有生成退回处理单",
                            //    Timestamp = System.DateTime.Now
                            //});
                            //result2 = result;

                            ShipBackDTO backDTO = new ShipBackDTO();
                            backDTO.IsSuccess = false;
                            backDTO.ErrorInfo = "生单失败:没有生成退回处理单";
                            backDTO.Timestamp = System.DateTime.Now;
                            HBHCommon.LoggerError(backDTO.ErrorInfo);
                            result.Add(backDTO);
                        }
                        else
                        {
                            foreach (DocKeyDTOData rmaid in rmaidlist)
                            {
                                result.Add(new ShipBackDTO
                                {
                                    IsSuccess = true,
                                    ErrorInfo = "生单成功",
                                    Timestamp = System.DateTime.Now,
                                    ERPDocNo  = rmaid.DocNO
                                });
                            }
                            //result2 = result;
                        }
                    }
                }
            }
            catch (System.Exception e)
            {
                //result.Add(new ShipBackDTO
                //{
                //    IsSuccess = false,
                //    ErrorInfo = e.Message,
                //    Timestamp = System.DateTime.Now
                //});
                //result2 = result;

                ShipBackDTO backDTO = new ShipBackDTO();
                backDTO.IsSuccess = false;
                backDTO.ErrorInfo = e.Message;
                backDTO.Timestamp = System.DateTime.Now;
                HBHCommon.LoggerError(backDTO.ErrorInfo + "/r/n" + e.StackTrace);
                result.Add(backDTO);
            }
            //return result2;
            return(result);
        }