コード例 #1
0
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        //Send Document : Used from Tests and From Timer Service

        public static ServicesATSoapResult SendDocument(FIN_DocumentFinanceMaster documentMaster)
        {
            //Send Document
            ServicesAT sendDocument = new ServicesAT(documentMaster);
            //Get Result from SendDocument Object
            string resultSend = sendDocument.Send();
            //Post
            ServicesATSoapResult soapResult = sendDocument.SoapResult;

            //Show Result
            //Log(string.Format("SendDocument DocumentMaster: [{0}]", documentMaster.DocumentNumber));
            //Log(string.Format("SendDocument ResultRaw: [{0}]", resultSend));
            //if (sendDocument.SoapResult != null) {
            //    Log(string.Format(@"{0}ResultCode: [{1}]{0}ResultMessage: [{2}]"
            //        , Environment.NewLine
            //        , sendDocument.SoapResult.ReturnCode
            //        , sendDocument.SoapResult.ReturnMessage
            //    ));
            //    //WB
            //    if (!string.IsNullOrEmpty(sendDocument.SoapResult.ATDocCodeID))
            //    {
            //        Log(string.Format(@"ATDocCodeID: [{0}]", sendDocument.SoapResult.ATDocCodeID));
            //    }
            //}

            return(soapResult);
        }
コード例 #2
0
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        //Timer Service

        public static Dictionary <FIN_DocumentFinanceMaster, ServicesATSoapResult> ServiceSendPendentDocuments()
        {
            Dictionary <FIN_DocumentFinanceMaster, ServicesATSoapResult> result = new Dictionary <FIN_DocumentFinanceMaster, ServicesATSoapResult>();
            Guid key = Guid.Empty;
            FIN_DocumentFinanceMaster documentMaster = null;
            ServicesATSoapResult      soapResult     = new ServicesATSoapResult();

            try
            {
                //Invoice Documents
                if (SettingsApp.ServiceATSendDocuments)
                {
                    string sqlDocuments = GetDocumentsQuery(false);
                    //_log.Debug(String.Format("sqlDocuments: [{0}]", FrameworkUtils.RemoveCarriageReturnAndExtraWhiteSpaces(sqlDocuments)));

                    XPSelectData xPSelectData = FrameworkUtils.GetSelectedDataFromQuery(sqlDocuments);
                    foreach (SelectStatementResultRow row in xPSelectData.Data)
                    {
                        key            = new Guid(row.Values[xPSelectData.GetFieldIndex("Oid")].ToString());
                        documentMaster = (FIN_DocumentFinanceMaster)GlobalFramework.SessionXpo.GetObjectByKey(typeof(FIN_DocumentFinanceMaster), key);
                        //SendDocument
                        soapResult = SendDocument(documentMaster);

                        //Helper to Detect Documents
                        //Detect if Document is Already in AT System / -3 = "Já foi registado um documento idêntico."
                        //200 = Detect The operation has timed out | The remote name could not be resolved: 'servicos.portaldasfinancas.gov.pt'
                        //if (soapResult.ReturnCode.Equals("-3"))
                        //{
                        //    _log.Debug("BREAK");
                        //}

                        result.Add(documentMaster, soapResult);
                    }
                }

                //WayBill Documents
                if (SettingsApp.ServiceATSendDocumentsWayBill)
                {
                    string sqlDocumentsWayBill = GetDocumentsQuery(true);
                    //_log.Debug(String.Format("sqlDocumentsWayBill: [{0}]", FrameworkUtils.RemoveCarriageReturnAndExtraWhiteSpaces(sqlDocumentsWayBill)));

                    XPSelectData xPSelectData = FrameworkUtils.GetSelectedDataFromQuery(sqlDocumentsWayBill);
                    foreach (SelectStatementResultRow row in xPSelectData.Data)
                    {
                        key            = new Guid(row.Values[xPSelectData.GetFieldIndex("Oid")].ToString());
                        documentMaster = (FIN_DocumentFinanceMaster)GlobalFramework.SessionXpo.GetObjectByKey(typeof(FIN_DocumentFinanceMaster), key);
                        //SendDocument
                        soapResult = SendDocument(documentMaster);
                        result.Add(documentMaster, soapResult);
                    }
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
                Console.Write($"Error: [{ex.Message}]");
            }

            return(result);
        }
コード例 #3
0
        //ATWS: Send Document to AT WebWebService : UI Part, With Retry Dialog, Calling above SendDocumentToATWS
        public static bool SendDocumentToATWSDialog(Window pSourceWindow, fin_documentfinancemaster pDocumentFinanceMaster)
        {
            //Send Document to AT WebServices - With Retry to notify user and force user to skip
            ServicesATSoapResult sendDocumentResult = new ServicesATSoapResult();
            ResponseType         dialogResponse     = ResponseType.Yes;
            /* IN009083 - returns true when WS call fails and user opts to do not retry */
            bool isCanceledByUser = false;

            while (sendDocumentResult.ReturnCode != "0" && dialogResponse == ResponseType.Yes)
            {
                //Call SendDocumentToATWS and Receive Result
                sendDocumentResult = SendDocumentToATWS(pDocumentFinanceMaster);

                if (sendDocumentResult == null || sendDocumentResult.ReturnCode != "0")
                {
                    dialogResponse = Utils.ShowMessageTouch(pSourceWindow, DialogFlags.Modal, new Size(700, 440), MessageType.Error, ButtonsType.YesNo, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_error"),
                                                            string.Format(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_message_error_in_at_webservice"), sendDocumentResult.ReturnCode, sendDocumentResult.ReturnMessage)
                                                            );
                    /* IN009083 - returns true when WS call fails and user opts to do not retry */
                    if (ResponseType.No.Equals(dialogResponse))
                    {
                        isCanceledByUser = true;
                    }
                }
            }
            return(isCanceledByUser);
        }
コード例 #4
0
ファイル: Service1.svc.cs プロジェクト: Rampaul770/logicPOS
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        //AT WebServices

        public ServicesATSoapResult SendDocument(Guid pDocumentMaster)
        {
            ServicesATSoapResult result = null;

            try
            {
                FIN_DocumentFinanceMaster documentMaster = (FIN_DocumentFinanceMaster)GlobalFramework.SessionXpo.GetObjectByKey(typeof(FIN_DocumentFinanceMaster), pDocumentMaster);

                if (documentMaster != null)
                {
                    //Send Document
                    ServicesAT servicesAT = new ServicesAT(documentMaster);
                    //Get Result from SendDocument Object
                    string resultSend = servicesAT.Send();
                    //Get SoapResult
                    result = servicesAT.SoapResult;

                    if (
                        //Error: Não foi possível resolver o nome remoto: 'servicos.portaldasfinancas.gov.pt'
                        result == null
                        //Error: <faultcode>33</faultcode>
                        ||
                        result != null && string.IsNullOrEmpty(result.ReturnCode)
                        )
                    {
                        result = new ServicesATSoapResult("200", resultSend);
                        servicesAT.PersistResult(result);
                        Utils.Log(string.Format("Error {0}: [{1}]", result.ReturnCode, result.ReturnMessage));
                    }
                    else
                    {
                        //Output in ServiceAT With Log, here is optional
                        //Utils.Log(string.Format("SendDocument Result: [{0}]:[{1}]:[{2}]", result.ReturnCode, result.ReturnMessage, result.ReturnRaw));
                    }
                }
                else
                {
                    //All messages are in PT, from ATWS, dont required translation here
                    string errorMsg = string.Format("Documento Inválido: {0}", pDocumentMaster);
                    result = new ServicesATSoapResult("202", errorMsg);
                    Utils.Log(string.Format("Error {0}: [{1}]", result.ReturnCode, result.ReturnMessage));
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
                if (Environment.UserInteractive)
                {
                    Utils.Log(ex.Message);
                }
                //Send Error Message : 210 is All Exceptions Errors
                result = new ServicesATSoapResult("210", ex.Message);
            }

            //Dont Send null ServicesATSoapResult here, else triggers erros outside
            return(result);
        }
コード例 #5
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);
        }
コード例 #6
0
ファイル: FrameworkCalls.cs プロジェクト: Rampaul770/logicPOS
        //ATWS: Send Document to AT WebWebService : UI Part, With Retry Dialog, Calling above SendDocumentToATWS
        public static void SendDocumentToATWSDialog(Window pSourceWindow, FIN_DocumentFinanceMaster pDocumentFinanceMaster)
        {
            //Send Document to AT WebServices - With Retry to notify user and force user to skip
            ServicesATSoapResult sendDocumentResult = new ServicesATSoapResult();
            ResponseType         dialogResponse     = ResponseType.Yes;

            while (sendDocumentResult.ReturnCode != "0" && dialogResponse == ResponseType.Yes)
            {
                //Call SendDocumentToATWS and Receive Result
                sendDocumentResult = SendDocumentToATWS(pDocumentFinanceMaster);

                if (sendDocumentResult == null || sendDocumentResult.ReturnCode != "0")
                {
                    dialogResponse = Utils.ShowMessageTouch(pSourceWindow, DialogFlags.Modal, new Size(700, 440), MessageType.Error, ButtonsType.YesNo, Resx.global_error,
                                                            string.Format(Resx.dialog_message_error_in_at_webservice, sendDocumentResult.ReturnCode, sendDocumentResult.ReturnMessage)
                                                            );
                }
            }
        }