Ejemplo n.º 1
0
        public override bool Equals(object obj)
        {
            SAPQuota another = obj as SAPQuota;

            if (another == null)
            {
                return(false);
            }
            else
            {
                return(this.Id == another.Id);
            }
        }
Ejemplo n.º 2
0
        public void GetSAPQuota(string itemCode, string plantCode)
        {
            try
            {
                log.Debug("导入SAP配额开始。");
                com.Sconit.Service.SAP.MI_QUOTA_OUT.MI_QUOTA_OUTService mqos = new com.Sconit.Service.SAP.MI_QUOTA_OUT.MI_QUOTA_OUTService();
                mqos.Credentials = base.Credentials;
                mqos.Timeout = base.TimeOut;
                mqos.Url = ReplaceSAPServiceUrl(mqos.Url);

                com.Sconit.Service.SAP.MI_QUOTA_OUT.ZTMATNR_IN zTMATNR_IN = new com.Sconit.Service.SAP.MI_QUOTA_OUT.ZTMATNR_IN();
                zTMATNR_IN.MATNR = itemCode;
                zTMATNR_IN.WERKS = plantCode;
                com.Sconit.Service.SAP.MI_QUOTA_OUT.ZSEQUPK[] zSEQUPKArray = mqos.MI_QUOTA_OUT(zTMATNR_IN);

                if (zSEQUPKArray != null && zSEQUPKArray.Length > 0)
                {
                    log.DebugFormat("接收SAP配额{0}条。", zSEQUPKArray.Length);
                    DateTime dateTimeNow = DateTime.Now;
                    int batchNo = int.Parse(numberControlMgr.GetNextSequence(SAP_QUOTA_BATCHNO));
                    foreach (var zSEQUPK in zSEQUPKArray)
                    {
                        SAPQuota sapQuota = new SAPQuota();
                        sapQuota.QUNUM = zSEQUPK.QUNUM;
                        sapQuota.QUPOS = zSEQUPK.QUPOS;
                        sapQuota.LIFNR = zSEQUPK.LIFNR;
                        sapQuota.WERKS = zSEQUPK.WERKS;
                        sapQuota.BEWRK = zSEQUPK.BEWRK;
                        sapQuota.MATNR = zSEQUPK.MATNR;
                        sapQuota.VDATU = zSEQUPK.VDATU;
                        sapQuota.BDATU = zSEQUPK.BDATU;
                        sapQuota.BESKZ = zSEQUPK.BESKZ;
                        sapQuota.SOBES = zSEQUPK.SOBES;
                        sapQuota.QUOTE = zSEQUPK.QUOTE;
                        sapQuota.BatchNo = batchNo;
                        sapQuota.CreateDate = dateTimeNow;
                        genericMgr.Create(sapQuota);
                    }
                    genericMgr.FlushSession();

                    com.Sconit.Entity.ACC.User user = com.Sconit.Entity.SecurityContextHolder.Get();
                    IList<string> msgList = genericMgr.FindAllWithNativeSql<string>("exec USP_IF_ProcessSAPQuota ?,?,?",
                        new object[] { batchNo, user.Id, user.FullName },
                        new IType[] { NHibernateUtil.Int32, NHibernateUtil.Int32, NHibernateUtil.String });

                    if (msgList != null && msgList.Count > 0)
                    {
                        IList<ErrorMessage> errorMessageList = new List<ErrorMessage>();
                        foreach (string msg in msgList)
                        {
                            errorMessageList.Add(new ErrorMessage
                            {
                                Template = NVelocityTemplateRepository.TemplateEnum.ImportSapQuotaFail,
                                Message = "导入SAP配额发生错误, 错误信息:" + msg,
                            });
                        }
                        this.SendErrorMessage(errorMessageList);
                    }
                }
                else
                {
                    log.DebugFormat("接收SAP配额0条。");
                }

                log.Debug("导入SAP配额完成。");
            }
            catch (Exception ex)
            {
                log.Error("导入SAP配额发生异常, 异常信息:" + ex.Message, ex);
                IList<ErrorMessage> errorMessageList = new List<ErrorMessage>();
                errorMessageList.Add(new ErrorMessage
                {
                    Template = NVelocityTemplateRepository.TemplateEnum.ImportSapQuotaFail,
                    Message = "导入SAP配额发生异常, 异常信息:" + ex.Message,
                    Exception = ex
                });
                this.SendErrorMessage(errorMessageList);
            }
        }