Example #1
0
        public string GetUpdateXml(string pn)
        {
            SoapLabelPrintResult soapRet = null;
            Exception            soapExp = null;

            try
            {
                soapRet = soapClient.GetLabelPrintResult(pn);
            }
            catch (Exception exp)
            {
                soapExp = exp;
            }

            UpdateResult ret = null;

            if (soapRet != null && soapRet.IsNoError)
            {
                ret = GenUpdateResultFromSoapResult(soapRet);
                this.saveSvc.SaveToLocal(soapRet);
            }
            else
            {
                ret = this.GetDasCacheUpdateResult(pn);
                ret.SoapErrorMsg = GetSoapErrorMsg(soapExp, soapRet);
            }

            return(ret.ToXML("", Encoding.ASCII));
        }
Example #2
0
        public void SaveToLocal(SoapLabelPrintResult soapRet)
        {
            if (soapRet != null && soapRet.Files != null)
            {
                foreach (var item in soapRet.Files)
                {
                    if (IsFileFromFirstPrinter(item))
                    {
                        var pdfFullpath = Path.Combine(this.sapPushSettings.PushStoredFolder, item.FileName);
                        var xmlFullPath = pdfFullpath.ToLower().Replace(".pdf", ".xml");

                        File.WriteAllBytes(pdfFullpath, item.Content);

                        CLPBasicData basicData = new CLPBasicData {
                            TimestampFormat = item.TimestampFormat
                        };
                        File.WriteAllText(xmlFullPath, basicData.ToXML("", Encoding.UTF8), Encoding.UTF8);
                    }
                    else
                    {
                        //ignore
                    }
                }
            }
        }
        private RequestResult GenRequestResultFromSoapResult(string pn, SoapLabelPrintResult soapRet)
        {
            RequestResult ret = new RequestResult();

            ret.Pn = pn;

            ret.IsSucceed = soapRet.IsNoError;

            ret.ErrorCode    = soapRet.ErrorType;
            ret.ExceptionMsg = soapRet.ErrorMessage;

            return(ret);
        }
Example #4
0
        private string GetSoapErrorMsg(Exception soapExp, SoapLabelPrintResult soapRet)
        {
            StringBuilder builder = new StringBuilder(512);

            if (soapRet != null && !soapRet.IsNoError)
            {
                builder.AppendLine("SoapErrorType:" + soapRet.ErrorType);
                builder.AppendLine("SoapErrorMsg:" + soapRet.ErrorMessage);
            }

            if (soapExp != null)
            {
                builder.AppendLine(soapExp.ToString());

                builder.AppendLine(soapExp.GetDetailErrorText());
            }

            return(builder.ToString());
        }
        public RequestResult DoRequest(string pn)
        {
            SoapLabelPrintResult soapRet = null;
            Exception            soapExp = null;

            try
            {
                soapRet = soapClient.GetLabelPrintResult(pn);
            }
            catch (Exception exp)
            {
                soapExp = exp;
                return(SoapRequestException(pn, exp));
            }

            if (soapRet != null && soapRet.IsNoError)
            {
                this.saveSvc.SaveToLocal(soapRet);
            }

            return(GenRequestResultFromSoapResult(pn, soapRet));
        }
Example #6
0
        private UpdateResult GenUpdateResultFromSoapResult(SoapLabelPrintResult soapRet)
        {
            UpdateResult ret = new UpdateResult();

            ret.IsOK = soapRet.IsNoError;

            ret.ErrorCode         = "";
            ret.LabelUpdateSource = "SAP";

            ret.SoapErrorMsg = "";

            if (!soapRet.Files.IsNullOrEmpty())
            {
                var fileItem = soapRet.Files.First();
                ret.LabelFileName = fileItem.FileName;
                ret.CLPBasicData  = new CLPBasicData()
                {
                    TimestampFormat = fileItem.TimestampFormat
                };
                ret.LabelFileBase64Content = fileItem.Content.ToBase64String();
            }

            return(ret);
        }