Пример #1
0
        //ATWS: Send Document to AT WebWebService
        public static ServicesATSoapResult SendDocumentToATWS(fin_documentfinancemaster pDocumentFinanceMaster)
        {
            ServicesATSoapResult result = new ServicesATSoapResult();

            //Detect Document and Check if is a document to Sent to ATWS
            bool   sendDocumentToATWS       = SendDocumentToATWSEnabled(pDocumentFinanceMaster);
            string sendDocumentToATWSResult = string.Empty;

            //Send Document to WebServices and Get String Result
            if (sendDocumentToATWS)
            {
                string endpointAddress = FrameworkUtils.GetEndpointAddress();
                if (FrameworkUtils.IsWebServiceOnline(endpointAddress))
                {
                    try
                    {
                        //Init Client
                        Service1Client serviceClient = new Service1Client();
                        //SendDocuments
                        result = serviceClient.SendDocument(pDocumentFinanceMaster.Oid);
                        //Check Result
                        if (result != null)
                        {
                            _log.Debug(string.Format("DocumentNumber: [{0}] - AT WebService ReturnCode: [{1}], ReturnMessage: [{2}]", pDocumentFinanceMaster.DocumentNumber, result.ReturnCode, result.ReturnMessage));
                        }
                        else
                        {
                            _log.Error(String.Format("Error null resultResultObject: [{0}]", result));
                        }

                        // Always Close Client
                        serviceClient.Close();
                    }
                    catch (Exception ex)
                    {
                        _log.Error(ex.Message, ex);
                    }
                }
                else
                {
                    result               = new ServicesATSoapResult();
                    result.ReturnCode    = "201";
                    result.ReturnMessage = string.Format("Erro a comunicar com o WebService:{0}{1}", Environment.NewLine, endpointAddress);
                    _log.Debug(string.Format("EndpointAddress OffLine, Please check URI: {0}", endpointAddress));
                }
            }

            return(result);
        }