Beispiel #1
0
        public bool processMessageForOFACCheck(Request request, bool fromErrorQueue)
        {
            //AuditUtil.getInstance().audit(request.RequestId, AuditLevel.Info, "Started processing the message");
            bool      bLocked  = false;
            int       iStatus  = 0;
            bool      bSuccess = false;
            Interface i        = InterfaceManager.getInterface(request.InterfaceId);

            try
            {
                bLocked = _dbUtils.acquireLock(request.RequestId);
                if (bLocked)
                {
                    iStatus = _dbUtils.getStatusByRequest(request.RequestId);
                    if (iStatus == Convert.ToInt32(Status.Review))
                    {
                        bSuccess = i.Driver.sendForOfacCheck(request);
                        if (bSuccess)
                        {
                            request.Status  = Status.SentForOfacCheck;
                            request.IsError = false;
                            _dbUtils.changeStatus(request);
                            AuditUtil.getInstance().audit(request.RequestId, AuditLevel.Info, "Message sent for watchlist filtering check");
                        }
                    }
                }
                else
                {
                    LogUtil.logError("Cannot acquire lock for message :" + request.RequestId + ". Translation incomplete");
                    AuditUtil.getInstance().audit(request.RequestId, AuditLevel.Error, "Abort processing. Cannot acquire lock");
                }
            }
            catch (Exception e)
            {
                LogUtil.log("Error while sending the message for OFAC check:" + request.RequestId, e);
                AuditUtil.getInstance().audit(request.RequestId, AuditLevel.Error, "Error while sending the message for OFAC check");
            }
            finally
            {
                if (bLocked)
                {
                    _dbUtils.releaseLock(request.RequestId);
                }
            }
            return(bSuccess);
        }
Beispiel #2
0
        protected override void OnStart(string[] args)
        {
            Assembly assembly = Assembly.GetExecutingAssembly();
            String   fileName = assembly.Location + ".config";

            if (!File.Exists(fileName))
            {
                throw new Exception("Missing configuration file. Expecting file @" + fileName);
            }

            LogUtil.logInfo("Starting Wei Service");
            try
            {
                _dbUtils          = EnterpriseLibraryContainer.Current.GetInstance <DBUtil>();
                _interfaceManager = EnterpriseLibraryContainer.Current.GetInstance <InterfaceManager>();
                _requestManager   = new RequestManager(_dbUtils);
                _interfaceManager.initailize(this);

                if (serviceHost != null)
                {
                    serviceHost.Close();
                }

                // Create a ServiceHost for the CalculatorService type and
                // provide the base address.
                serviceHost = new ServiceHost(typeof(WeiMonitoring));

                // Open the ServiceHostBase to create listeners and start
                // listening for messages.

                serviceHost.Open();
                instance = this;
                LogUtil.logInfo("Started Wei Service");
            }
            catch (AddressAlreadyInUseException e)
            {
                LogUtil.log("Service address is already in use", e);
            }
            catch (Exception e)
            {
                LogUtil.log("Error Starting Wei Service", e);
                throw (e);
            }
        }
Beispiel #3
0
        public void processResponse(int requestId, int interfaceId, String identifier, String responseBody, OfacStatus ofacStatus)
        {
            AuditUtil.getInstance().audit(requestId, AuditLevel.Info, "Received " + ofacStatus.ToString() + " response");

            bool      bLocked  = false;
            bool      bSuccess = false;
            Request   request  = null;
            Interface i        = InterfaceManager.getInterface(interfaceId);

            try
            {
                bLocked = _dbUtils.acquireLock(requestId);
                if (bLocked)
                {
                    request = _dbUtils.getRequest(requestId);

                    if (request == null)
                    {
                        LogUtil.logError("Cannot retrieve the message:" + requestId);
                        return;
                    }

                    if (request.Status != Status.SentForOfacCheck)
                    {
                        LogUtil.logError("Cannot process response for the message :" + requestId + " . Current status is " + request.Status + ". Expecting " + Status.SentForOfacCheck);
                        return;
                    }

                    request.Status     = Status.OfacResponseReceived;
                    request.IsError    = false;
                    request.OfacStatus = ofacStatus;

                    _dbUtils.changeStatus(request);


                    request.ResponseMessage = i.Handler.getRepackagedResponseString(request.MessageBody, responseBody);

                    if (i.Driver.sendResponse(request, identifier))
                    {
                        request.Status  = Status.Processed;
                        request.IsError = false;

                        _dbUtils.addResponseMessage(request);
                        bSuccess = true;
                        AuditUtil.getInstance().audit(requestId, AuditLevel.Info, "Sent response for the message ");
                    }
                }
            }
            catch (Exception e)
            {
                bSuccess = false;
                LogUtil.log("Cannot process response for the message :" + requestId, e);
                AuditUtil.getInstance().audit(requestId, AuditLevel.Error, "Error processing response for the message ");
            }
            finally
            {
                try
                {
                    if (!bSuccess)
                    {
                        _dbUtils.markRequestError(requestId);
                        //send it to error
                        if (request != null && i.Driver.shouldMoveToError())
                        {
                            i.Driver.moveToError(request);
                        }
                    }
                    if (bLocked)
                    {
                        _dbUtils.releaseLock(request.RequestId);
                    }
                }
                catch (Exception e)
                {
                    LogUtil.log("Exception when trying to backout of another exception for message:" + requestId, e);
                }
            }
        }
Beispiel #4
0
        public void process(Request request)
        {
            AuditUtil.getInstance().audit(request.RequestId, AuditLevel.Info, "Started processing the message");
            bool bLocked  = false;
            bool bSuccess = false;



            Interface i = InterfaceManager.getInterface(request.InterfaceId);

            try
            {
                bLocked = _dbUtils.acquireLock(request.RequestId);
                if (bLocked)
                {
                    //if (!_bSentForOFACCheck)
                    //{
                    bSuccess = translateRequest(request, i);
                    //If translation was success and the review flag is false
                    //if (bSuccess && (_brequiresReview == false) && (_bSentForOFACCheck == false))
                    //{
                    //    bSuccess = i.Driver.sendForOfacCheck(request);
                    if (!bSuccess)
                    //{
                    //    request.Status = Status.SentForOfacCheck;
                    //    request.IsError = false;
                    //    _dbUtils.changeStatus(request);
                    //    AuditUtil.getInstance().audit(request.RequestId, AuditLevel.Info, "Translation review flag is not set. Message directly sent for watchlist filtering check");
                    //}
                    //else
                    {
                        request.Status  = Status.Translated;
                        request.IsError = true;
                        _dbUtils.changeStatus(request);
                        LogUtil.logError("Error sending the message - " + request.RequestId + " for watchlist filtering check");
                        AuditUtil.getInstance().audit(request.RequestId, AuditLevel.Error, "Error sending the message for watchlist filtering check");
                    }
                    //}
                }

                else
                {
                    LogUtil.logError("Cannot acquire lock for message :" + request.RequestId + ". Translation incomplete");
                    AuditUtil.getInstance().audit(request.RequestId, AuditLevel.Error, "Abort processing. Cannot acquire lock");
                }
            }
            catch (Exception e)
            {
                LogUtil.log("Error processing the message:" + request.RequestId, e);
                AuditUtil.getInstance().audit(request.RequestId, AuditLevel.Error, "Error processing the message");
            }
            finally
            {
                if (!bSuccess)
                {
                    _dbUtils.markRequestError(request.RequestId);
                    if (i.Driver.shouldMoveToError())
                    {
                        //send it to error
                        i.Driver.moveToError(request);
                    }
                }
                if (bLocked)
                {
                    _dbUtils.releaseLock(request.RequestId);
                }
            }
        }