/// <summary>
        /// It's an application so let's start it all
        /// </summary>
        private static void ApplicationMain()
        {
            // Welcome and Start listening
            _logger = new Logger(MethodBase.GetCurrentMethod().DeclaringType);
            _logger.AddLog("*** FECS Application Started *** ", LoggerSeverities.Info);
            /// Determine logging level
            LoggerSeverities logSeverity = ReadLoggerSeverity();

            _logger.AddLog(string.Format("Setting logger severity to {0}: ", logSeverity.ToString()), LoggerSeverities.Info);

            //OPS.Comm.Messaging.CommMain.Logger.AddLogMessage += new AddLogMessageHandler(Logger_AddLogMessage);
            //OPS.Comm.Messaging.CommMain.Logger.AddLogException += new AddLogExceptionHandler(Logger_AddLogException);

            // Start running
            FecsEngine engine = new FecsEngine();

            engine.Start();

            // Wait to end
            _logger.AddLog("*** Press Enter to exit ***", LoggerSeverities.Info);
            Console.ReadLine();
            _logger.AddLog("Quitting...", LoggerSeverities.Info);

            // Stop running
            engine.Stop();

            // Clean up before we go home
            //GC.Collect();
            GC.WaitForPendingFinalizers();
        }
Esempio n. 2
0
        /// <summary>
        /// Process the Message. The process of this message is specified in OPS_D_M14.doc
        /// </summary>
        /// <returns>Response for the message (1 string)</returns>
        public StringCollection Process()
        {
            ILogger logger = null;

            logger = DatabaseFactory.Logger;
            if (logger != null)
            {
                logger.AddLog("Msg14:Process", LoggerSeverities.Debug);
            }

            CmpPDMMessagesStatDB pmsDB = new CmpPDMMessagesStatDB();

            int j = 0;

            for (int i = 0; i < _statisticsNames.Length; i++)
            {
                logger.AddLog("Inserting: " + _unit.ToString() + " " + _date.ToString("F") + _statisticsNames[i],
                              LoggerSeverities.Info);
                for (j = 0; j < _statisticslong[i].Length; j++)
                {
                    logger.AddLog("Long Statistic[" + j.ToString() + "]=" + _statisticslong[i][j].ToString(),
                                  LoggerSeverities.Info);
                }
                for (j = 0; j < _statisticsfloat[i].Length; j++)
                {
                    logger.AddLog("Float Statistic[" + j.ToString() + "]=" + _statisticsfloat[i][j].ToString(),
                                  LoggerSeverities.Info);
                }
                pmsDB.Insert(_unit, _date, _statisticsNames[i],
                             _statisticslong[i], _statisticsfloat[i]);
            }

            return(ReturnAck(AckMessage.AckTypes.ACK_PROCESSED));
        }
Esempio n. 3
0
        public Point DoClean(Point currentPosition, ILogger logger)
        {
            // for the start point
            logger.AddLog(currentPosition);

            for (int i = 0; i < Steps; i++)
            {
                switch (Direction)
                {
                case Direction.N:
                    currentPosition = new Point(currentPosition.X, currentPosition.Y + 1);
                    break;

                case Direction.E:
                    currentPosition = new Point(currentPosition.X + 1, currentPosition.Y);
                    break;

                case Direction.S:
                    currentPosition = new Point(currentPosition.X, currentPosition.Y - 1);
                    break;

                case Direction.W:
                    currentPosition = new Point(currentPosition.X - 1, currentPosition.Y);
                    break;
                }

                logger.AddLog(currentPosition);
            }

            return(currentPosition);
        }
Esempio n. 4
0
        /// <summary>
        /// Process the Message. The process of this message is specified in OPS_D_M12.doc
        /// </summary>
        /// <returns>Response for the message (1 string)</returns>
        public StringCollection Process()
        {
            ILogger logger = null;

            try
            {
                logger = DatabaseFactory.Logger;
                if (logger != null)
                {
                    logger.AddLog("Msg12:Process", LoggerSeverities.Debug);
                }


                CmpUnitsMeasuresDB unitmesdb = new CmpUnitsMeasuresDB();

                unitmesdb.InsertMeasures(_unit, _date,
                                         _measures[0], _measures[1],
                                         _measures[2], _measures[3],
                                         _measures[4]);

                return(ReturnAck(AckMessage.AckTypes.ACK_PROCESSED));
            }
            catch (Exception ex)
            {
                if (logger != null)
                {
                    logger.AddLog("[Msg12:Process] ERRROR: " + ex.ToString(), LoggerSeverities.Error);
                }
                return(ReturnNack(NackMessage.NackTypes.NACK_ERROR_BECS));
            }
        }
        /// <summary>
        /// Constructs a new MsgCeceived with the data of the string and sets logger
        /// </summary>
        /// <param name="msgXml"></param>
        /// <param name="logger"></param>
        protected MsgReceived(XmlDocument msgXml, ILogger logger)
        {
            m_logger = logger;
            m_logger.AddLog("[MsgReceived]: Setting Message", LoggerSeverities.Debug);
            try
            {
                //
                _docXml = msgXml;
                // Gets some attributes from the message (ID, optional ret, optional dst) that are common to ALL messages
                _root = _docXml.DocumentElement;
                XmlAttributeCollection attrs = _root.Attributes;
                if (attrs != null)
                {
                    _msgId = Convert.ToInt64(attrs["id"].Value);
                    XmlAttribute attr = attrs["ret"];
                    _msgRetry = attr != null?Convert.ToInt32(attr.Value) : 0;

                    attr     = attrs["dst"];
                    _msgDest = attr != null ? attr.Value : null;
                }
                // Parses the message
                DoParseMessage();
                //
            }
            catch (Exception ex)
            {
                m_logger.AddLog("[MsgReceived]: EXCEPTION " + ex.ToString(), LoggerSeverities.Debug);
                throw ex;
            }
        }
Esempio n. 6
0
        public bool InsertFine(OracleConnection BDCon, string[] fields, string[] values, ILogger logger)
        {
            bool          bRet        = false;
            OracleCommand BDCommand   = null;
            string        command     = "";
            string        list_fields = "(";
            string        list_values = "(";

            try
            {
                BDCommand = BDCon.CreateCommand();

                for (int i = 0; i < fields.Length; i++)
                {
                    list_fields = list_fields + fields[i];
                    list_values = list_values + values[i];

                    if (i < (fields.Length - 1))
                    {
                        list_fields = list_fields + ", ";
                        list_values = list_values + ", ";
                    }
                    else
                    {
                        list_fields = list_fields + ") ";
                        list_values = list_values + ") ";
                    }
                }

                command = "INSERT INTO FINES" + list_fields + "VALUES" + list_values;

                logger.AddLog("[Msg53:InsertFine]: SQL: " + command, LoggerSeverities.Info);

                BDCommand.CommandText = command;
                BDCommand.ExecuteNonQuery();
                BDCommand.Dispose();
                BDCommand = null;

                bRet = true;
            }
            catch (Exception e)
            {
                logger.AddLog("[Msg53:InsertFine]: Error: " + e.Message, LoggerSeverities.Error);

                if (BDCommand != null)
                {
                    BDCommand.Dispose();
                    BDCommand = null;
                }
            }

            return(bRet);
        }
 /// <summary>
 /// Starts the thread
 /// </summary>
 public void Start()
 {
     if (_logger != null)
     {
         _logger.AddLog("MSG_D::Start() called - current slice time (ms) is is " + _slice, LoggerSeverities.Debug);
     }
     if (!_running)
     {
         _running = true;
         _thread.Start();
         if (_logger != null)
         {
             _logger.AddLog("MSG_D::Thread started", LoggerSeverities.Debug);
         }
     }
 }
Esempio n. 8
0
        public override void OnException(MethodExecutionArgs args)
        {
            var message = $"An error occured while {args.Method.Name} method running. Exception : {args.Exception.StackTrace}";

            _logger.AddLog(message, LogLevel.Error);

            args.ReturnValue = new ErrorResult(message);
        }
Esempio n. 9
0
        //Dont't use, very slow
        public async Task ReadFileAsync(Stream inStream, T instance, ILogger logger = null)
        {
            var tasklist = new List <Task>();

            using (var streamReader = new StreamReader(inStream)) {
                var    lineTask = Task.Factory.StartNew(streamReader.ReadLineAsync);
                var    lineNr   = 1;
                string line;
                var    section     = "";
                var    filesection = _sections.FirstOrDefault(s => string.IsNullOrEmpty(s.Section))?.GetCopy();
                filesection?.SetModel(instance);
                while ((line = await lineTask.Result) != null)
                {
                    lineTask = Task.Factory.StartNew(streamReader.ReadLineAsync);
                    if (string.Empty != line && !line.StartsWith("//"))
                    {
                        if (line.StartsWith("["))
                        {
                            section     = line.Trim('[', ' ', ']');
                            filesection = _sections.FirstOrDefault(s => string.Equals(s.Section, section, StringComparison.CurrentCultureIgnoreCase))?.GetCopy();
                            filesection?.SetModel(instance);
                        }
                        else if (filesection != null)
                        {
                            var l  = line;
                            var ln = lineNr;
                            var fs = filesection;

                            tasklist.Add(Task.Run(() => {
                                try { fs.ReadLine(l); }
                                catch (Exception ex) {
                                    logger?.AddLog(new LogMessage(LogSeverity.Error, $"line {ln} ({l}): {ex.Message}"));
                                }
                            }));
                        }
                        else
                        {
                            logger?.AddLog(new LogMessage(LogSeverity.Warning, $"Line {lineNr} ({line}) was read in undefined section {section}"));
                        }
                    }
                    lineNr++;
                }
                await Task.WhenAll(tasklist);
            }
            //await WhenAll(tasklist);
        }
Esempio n. 10
0
        public bool UpdateFine(OracleConnection BDCon, string[] fields, string[] values, ILogger logger)
        {
            bool          bRet      = false;
            OracleCommand BDCommand = null;
            string        command   = "";

            try
            {
                BDCommand = BDCon.CreateCommand();

                command = "UPDATE FINES SET ";

                for (int i = 0; i < fields.Length; i++)
                {
                    command = command + fields[i] + " = " + values[i];

                    if (i < (fields.Length - 1))
                    {
                        command = command + ", ";
                    }
                }

                command = command + " WHERE FIN_ID = " + iFine.ToString();

                logger.AddLog("[Msg53:UpdateFine]: SQL: " + command, LoggerSeverities.Info);

                BDCommand.CommandText = command;
                BDCommand.ExecuteNonQuery();
                BDCommand.Dispose();
                BDCommand = null;

                bRet = true;
            }
            catch (Exception e)
            {
                logger.AddLog("[Msg53:UpdateFine]: Error: " + e.Message, LoggerSeverities.Error);

                if (BDCommand != null)
                {
                    BDCommand.Dispose();
                    BDCommand = null;
                }
            }

            return(bRet);
        }
        // purchasecard username cardname
        public void Execute(IEnumerable <string> parameters)
        {
            var args = parameters.ToList();

            string username = args[0];
            string cardname = args[1];

            try
            {
                purchaseService.PurchaseCard(username, cardname);
            }
            catch (NotEnoughCoinsException ex)
            {
                logger.AddLog(ex.Message);
            }

            logger.AddLog($"Player {username} purchases {cardname} card successfully");
        }
Esempio n. 12
0
        /// <summary>
        /// Overriding of the DoParseMessage to get the unit,
        /// all the alarms and the status and to store them in private vars
        /// </summary>
        protected override void DoParseMessage()
        {
            ILogger logger = null;

            logger = DatabaseFactory.Logger;

            try
            {
                foreach (XmlNode node in _root.ChildNodes)
                {
                    switch (node.Name)
                    {
                    case "u": _unit = Convert.ToInt32(node.InnerText); break;

                    case "s": _status = Convert.ToInt32(node.InnerText); break;

                    case "a":                                           // Tag <a> has an hexa number (can be bigger than 32 bits). ==> Each 8 chars are a uint
                        System.Text.StringBuilder sHexa = new System.Text.StringBuilder(node.InnerText.Trim());
                        int sHexaLength = sHexa.Length;
                        int nblocks     = (int)Math.Ceiling(sHexaLength / 8.0);                                         // 8 chars are a uint...
                        _alarmsMasks = new uint[nblocks];
                        // get each one of the blocks (8 hexa digits each one)
                        for (int i = 0; i < nblocks; i++)
                        {
                            string sBlock = null;
                            if (sHexa.Length <= 8)
                            {
                                sBlock = sHexa.ToString();
                            }
                            else
                            {
                                sBlock = sHexa.ToString().Substring(sHexaLength - 8, 8);
                                sHexa.Remove(sHexaLength - 8, 8);
                                sHexaLength = sHexa.Length;
                            }
                            // The block is a hexa number (uint) that is stored in _maskAlarms[i]
                            _alarmsMasks[i] = UInt32.Parse(sBlock, System.Globalization.NumberStyles.AllowHexSpecifier);
                        }
                        break;

                    case "d": _date = OPS.Comm.Dtx.StringToDtx(node.InnerText); break;

                    case "lus": _loadUnloadStatus = Convert.ToInt32(node.InnerText); break;

                    case "us": _user = Convert.ToInt32(node.InnerText); break;
                    }
                }
            }
            catch (Exception ex)
            {
                if (logger != null)
                {
                    logger.AddLog("[Msg12:DoParseMessage] ERRROR: " + ex.ToString(), LoggerSeverities.Error);
                }
                throw ex;
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Inserts a new register in the OPERATIONS table, and if everything is succesful sends an ACK_PROCESSED
        /// </summary>
        /// <returns>Message to send back to the sender</returns>
        public System.Collections.Specialized.StringCollection Process()
        {
            StringCollection res       = null;
            OracleConnection oraDBConn = null;
            OracleCommand    oraCmd    = null;
            ILogger          logger    = null;


            try
            {
                Database d = OPS.Components.Data.DatabaseFactory.GetDatabase();
                logger = DatabaseFactory.Logger;
                System.Data.IDbConnection DBCon = d.GetNewConnection();
                oraDBConn = (OracleConnection)DBCon;
                oraDBConn.Open();

                if (oraDBConn.State == System.Data.ConnectionState.Open)
                {
                    if (logger != null)
                    {
                    }

                    // Build response
                    string response = "<s>3</s>";
                    response += "<v0>890</v0><v1>1780</v1>";

                    res = new StringCollection();
                    res.Add(new AckMessage(_msgId, response).ToString());
                }
            }
            catch (Exception e)
            {
                if (logger != null)
                {
                    logger.AddLog("[Msg9:Process]: Error: " + e.Message, LoggerSeverities.Error);
                }
                res = ReturnNack(NackMessage.NackTypes.NACK_ERROR_BECS);
            }
            finally
            {
                if (oraCmd != null)
                {
                    oraCmd.Dispose();
                    oraCmd = null;
                }


                if (oraDBConn != null)
                {
                    oraDBConn.Close();
                    oraDBConn.Dispose();
                    oraDBConn = null;
                }
            }

            return(res);
        }
 /// <summary>
 /// Sends a message to the queue
 /// </summary>
 /// <param name="header">A MSMQHeader compatible header</param>
 /// <param name="body">The contents of the message</param>
 public void Send(MSMQHeader header, string body)
 {
     lock (_queue)
     {
         _queue.Send(body, header.ToString());
     }
     if (_logger != null)
     {
         _logger.AddLog("Sending message [" + body + "] with header [" + header.ToString() + "]", LoggerSeverities.Debug);
     }
 }
        public void Execute(IEnumerable <string> parameters)
        {
            var args = parameters.ToList();

            string playerOne   = args[0];
            string playerTwo   = args[1];
            int    coinsReward = int.Parse(args[2]);
            int    xpReward    = int.Parse(args[3]);

            try
            {
                _combatService.CreateBattle(playerOne, playerTwo, coinsReward, xpReward);
            }
            catch (Exception ex)
            {
                logger.AddLog(ex.Message);
                throw new InvalidBattleException(ex.Message);
            }
            logger.AddLog("Battle commenced successfully!");
        }
Esempio n. 16
0
        private static int CleanErrorsInDecryptedTags(ref string xml, ILogger logger)
        {
            string[] tagList = new string[] { "tm", "tdd", "rtm" };
            int      numberOfTagsReplaced = 0;

            foreach (string tag in tagList)
            {
                try
                {
                    int posIni = xml.IndexOf("<" + tag + ">");
                    if (posIni > 0)
                    {
                        int    posEnd    = xml.IndexOf("</" + tag + ">");
                        string innerText = xml.Substring(posIni + tag.Length + 2, posEnd - (posIni + tag.Length + 2));
                        Regex  rgx       = new Regex("[^a-zA-Z0-9/_*. -]");
                        if (rgx.IsMatch(innerText))
                        {
                            numberOfTagsReplaced++;
                            if (logger != null)
                            {
                                logger.AddLog("[Message Factory::CleanErrorsInDecryptedTags] Initial status of tag <" + tag + ">: " + innerText, LoggerSeverities.Debug);
                            }
                            string innerTextOutput = rgx.Replace(innerText, "*");
                            xml = xml.Replace(innerText, innerTextOutput);
                            if (logger != null)
                            {
                                logger.AddLog("[Message Factory::CleanErrorsInDecryptedTags] Final status of tag <" + tag + ">: " + innerTextOutput, LoggerSeverities.Debug);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    if (logger != null)
                    {
                        logger.AddLog("[Message Factory::CleanErrorsInDecryptedTags] Exception cleaning tag <" + tag + ">: " + ex.ToString(), LoggerSeverities.Error);
                    }
                }
            }
            return(numberOfTagsReplaced);
        }
Esempio n. 17
0
 public void ReadFile(Stream inStream, T instance, ILogger logger = null)
 {
     using (var streamReader = new StreamReader(inStream)) {
         var line        = streamReader.ReadLine();
         var lineNr      = 1;
         var section     = "";
         var filesection = _sections.FirstOrDefault(s => string.IsNullOrEmpty(s.Section))?.GetCopy();
         filesection?.SetModel(instance);
         while (line != null)
         {
             if (string.Empty != line && !line.StartsWith("//"))
             {
                 if (line.StartsWith("["))
                 {
                     section     = line.Trim('[', ' ', ']');
                     filesection = _sections.FirstOrDefault(s => string.Equals(s.Section, section, StringComparison.CurrentCultureIgnoreCase))?.GetCopy();
                     filesection?.SetModel(instance);
                 }
                 else
                 {
                     try {
                         if (filesection == null)
                         {
                             logger?.AddLog(new LogMessage(LogSeverity.Warning, $"Line {lineNr} ({line}) was read in undefined section {section}"));
                         }
                         else
                         {
                             filesection.ReadLine(line);
                         }
                     }
                     catch (Exception ex) {
                         logger?.AddLog(new LogMessage(LogSeverity.Error, $"line {lineNr} ({line}): {ex.Message}"));
                     }
                 }
             }
             lineNr++;
             line = streamReader.ReadLine();
         }
     }
 }
Esempio n. 18
0
        private static void ProcessCopy(List <EntityPerson> persons, string file)
        {
            ProcessUniver(persons);

            try
            {
                _repOutput.CreateUser(persons, file);
                _repOutput.CreatePhote(persons);
                _repOutput.CreateCareer(persons);
                _repOutput.CreateMilitary(persons);
                _repOutput.CreateRelationPartner(persons);
                _repOutput.CreateRelation(persons);
                _repOutput.CreateSchool(persons);
                _repOutput.CreateUniversity(persons);
            }
            catch (Exception ex)
            {
                var log = $"{file} Error: {ex.Message}";
                _logger.AddLog(log);
                Console.WriteLine(log);
            }
        }
Esempio n. 19
0
        private static void FilteredLog(ILogger logger, LogLevel level, string message, Exception exception = null, string customer = "")
        {
            //don't log thread abort exception
            if (exception is System.Threading.ThreadAbortException)
            {
                return;
            }

            if (logger.IsEnabled(level))
            {
                string fullMessage = exception == null ? string.Empty : exception.ToString();
                logger.AddLog(level, message, fullMessage, customer);
            }
        }
Esempio n. 20
0
        static public bool ListaNegra(ILogger logger, string szCCNumber, int iBinFormat)
        {
            bool bRet = false;

            try
            {
                if (szCCNumber.Length > 0)
                {
                    if ((iBinFormat != DEF_BIN_FORMAT_CARDEASEXML) &&
                        (iBinFormat != DEF_BIN_FORMAT_EMV_CREDITCALL) &&
                        (iBinFormat != DEF_BIN_FORMAT_EMV_TAS) &&
                        (iBinFormat != DEF_BIN_FORMAT_TRANSAX))
                    {
                        Database d = OPS.Components.Data.DatabaseFactory.GetDatabase();
                        System.Data.IDbConnection DBCon = d.GetNewConnection();
                        OracleCommand             cmd   = new OracleCommand();
                        try
                        {
                            DBCon.Open();
                            cmd.Connection  = (OracleConnection)DBCon;
                            cmd.CommandText = String.Format("select count(*) " +
                                                            "from  blacklist_cards b " +
                                                            "where b.bc_number = '{0}' ", szCCNumber);
                            if (Convert.ToInt32(cmd.ExecuteScalar()) > 0)
                            {
                                if (logger != null)
                                {
                                    logger.AddLog("[Msg07:ListaNegra]: Credit Card " + szCCNumber + " is in blacklist", LoggerSeverities.Debug);
                                }
                                bRet = true;
                            }
                        }
                        catch
                        {
                        }
                        finally
                        {
                            cmd.Dispose();
                            DBCon.Close();
                            DBCon.Dispose();
                        }
                    }
                }
            }
            catch
            {
            }

            return(bRet);
        }
        /// <summary>
        /// It's an application so let's start it all
        /// </summary>
        private static void ApplicationMain()
        {
            // Welcome and Start listening
            _logger = new Logger(MethodBase.GetCurrentMethod().DeclaringType);
            _logger.AddLog("*** BECS Application Started *** ", LoggerSeverities.Info);

            //OPS.Comm.Messaging.CommMain.Logger.AddLogMessage += new AddLogMessageHandler(Logger_AddLogMessage);
            //OPS.Comm.Messaging.CommMain.Logger.AddLogException += new AddLogExceptionHandler(Logger_AddLogException);

            // Start running
            BecsEngine engine = new BecsEngine();

            try
            {
                engine.Start();
            }
            catch (Exception)
            {
                engine = null;
                _logger.AddLog("An error has occurred. Quitting...", LoggerSeverities.Info);
                _logger = null;
                return;
            }

            // Wait to end
            _logger.AddLog("*** Press Enter to exit ***", LoggerSeverities.Info);
            Console.ReadLine();
            _logger.AddLog("Quitting...", LoggerSeverities.Info);

            // Stop running
            engine.Stop();

            // Clean up before we go home
            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
Esempio n. 22
0
        public List <EntityPerson> GetPersons(string fileName)
        {
            List <EntityPerson> list = new List <EntityPerson>();

            var str = File.ReadLines(fileName);

            foreach (var item in str)
            {
                try
                {
                    var obj = JsonConvert.DeserializeObject <Response>(item);

                    list.Add(obj.CollectionPerson[0]);
                }
                catch (Exception ex)
                {
                    _logger?.AddLog(ex.Message);
                    _logger?.AddLog(item);
                    Console.WriteLine($"Ошибка разбора данных: {ex.Message} В файле {Path.Combine(Directory.GetCurrentDirectory(), "log.txt")} подробности");
                }
            }

            return(list);
        }
Esempio n. 23
0
        public Session(Socket socket, int bufferSize, ILogger logger)
        {
            logger?.AddLog($"{this.GetType().Name}.{MethodBase.GetCurrentMethod().Name}");

            this.logger = logger;

            this.receiveArgs = new SocketAsyncEventArgs();
            this.receiveArgs.AcceptSocket = socket;
            this.receiveArgs.Completed   += new EventHandler <SocketAsyncEventArgs>(ReceiveCompleted);
            this.receiveArgs.SetBuffer(new byte[bufferSize], 0, bufferSize);

            this.sendArgs = new SocketAsyncEventArgs();
            this.sendArgs.AcceptSocket = socket;
            this.sendArgs.Completed   += new EventHandler <SocketAsyncEventArgs>(SendCompleted);
            this.sendArgs.SetBuffer(new byte[bufferSize], 0, bufferSize);
        }
 public void TraceMessage()
 {
     if (m_logger != null)
     {
         m_logger.AddLog("[MsgReceived]: ID " + _msgId.ToString(), LoggerSeverities.Debug);
         //		_docXml;
         // ID of the message
         //protected long _msgId;
         // # of retries (0 based)
         //protected int  _msgRetry;
         // ID of the destination
         //protected string _msgDest;
         // root of the document
         //protected XmlNode _root;
     }
 }                 // end if
Esempio n. 25
0
        static public bool IsCardInBlackList(ILogger logger, string strCardNumber)
        {
            bool bRet = false;

            try
            {
                if (strCardNumber.Length > 0)
                {
                    Database d = OPS.Components.Data.DatabaseFactory.GetDatabase();
                    System.Data.IDbConnection DBCon = d.GetNewConnection();
                    OracleCommand             cmd   = new OracleCommand();
                    try
                    {
                        DBCon.Open();
                        cmd.Connection  = (OracleConnection)DBCon;
                        cmd.CommandText = String.Format("select count(*) " +
                                                        "from black_lists t " +
                                                        "where blis_dblis_id = {0} " +
                                                        "and TRIM(blis_value) = '{1}' " +
                                                        "and blis_Valid = 1 " +
                                                        "and blis_deleted = 0", DEF_CARD_BLACKLIST_TYPE_CHIPCARD, strCardNumber.Trim());
                        if (Convert.ToInt32(cmd.ExecuteScalar()) > 0)
                        {
                            if (logger != null)
                            {
                                logger.AddLog("[Msg07:IsCardInBlackList]: Card " + strCardNumber + " is in blacklist", LoggerSeverities.Debug);
                            }
                            bRet = true;
                        }
                    }
                    catch
                    {
                    }
                    finally
                    {
                        cmd.Dispose();
                        DBCon.Close();
                        DBCon.Dispose();
                    }
                }
            }
            catch
            {
            }

            return(bRet);
        }
Esempio n. 26
0
        private bool Bines4B(ILogger logger)
        {
            bool bRet = false;

            try
            {
                if (_szCCNumber.Length >= 6)
                {
                    Database d = OPS.Components.Data.DatabaseFactory.GetDatabase();
                    System.Data.IDbConnection DBCon = d.GetNewConnection();
                    OracleCommand             cmd   = new OracleCommand();
                    try
                    {
                        DBCon.Open();
                        cmd.Connection  = (OracleConnection)DBCon;
                        cmd.CommandText = String.Format("select count(*) from ebin_cards " +
                                                        "where substr(ec_bin, 5, 6) = '{0}' ", _szCCNumber.Substring(0, 6));
                        if (Convert.ToInt32(cmd.ExecuteScalar()) == 0)
                        {
                            if (logger != null)
                            {
                                logger.AddLog("[Msg07:Process]: Credit Card " + _szCCNumber + " isn't in bin list", LoggerSeverities.Debug);
                            }
                        }
                        else
                        {
                            bRet = true;
                        }
                    }
                    catch
                    {
                    }
                    finally
                    {
                        cmd.Dispose();
                        DBCon.Close();
                        DBCon.Dispose();
                    }
                }
            }
            catch
            {
            }

            return(bRet);
        }
        /// <summary>
        /// The main entry point for the process
        /// </summary>
        private static void ServiceMain()
        {
            System.Configuration.AppSettingsReader appSettings = new System.Configuration.AppSettingsReader();

            _logger = new Logger(MethodBase.GetCurrentMethod().DeclaringType);

            /// Determine logging level
            LoggerSeverities logSeverity = ReadLoggerSeverity();

            _logger.AddLog(string.Format("Setting logger severity to: {0} ", logSeverity.ToString()), LoggerSeverities.Info);

            //OPS.Comm.Messaging.CommMain.Logger.AddLogMessage += new AddLogMessageHandler(Logger_AddLogMessage);
            //OPS.Comm.Messaging.CommMain.Logger.AddLogException += new AddLogExceptionHandler(Logger_AddLogException);

            System.ServiceProcess.ServiceBase[] ServicesToRun =
                new System.ServiceProcess.ServiceBase[] { new FecsAgent() };
            System.ServiceProcess.ServiceBase.Run(ServicesToRun);
        }
Esempio n. 28
0
        /// <summary>
        /// Overriding of the DoParseMessage to get the unit,
        /// all the alarms and the status and to store them in private vars
        /// </summary>
        protected override void DoParseMessage()
        {
            ILogger logger = null;

            logger = DatabaseFactory.Logger;

            for (int i = 0; i < MeasuresNum; i++)
            {
                _measures[i] = 0;
            }

            foreach (XmlNode node in _root.ChildNodes)
            {
                try
                {
                    switch (node.Name)
                    {
                    case "u": _unit = Convert.ToInt32(node.InnerText); break;

                    case "d": _date = OPS.Comm.Dtx.StringToDtx(node.InnerText); break;

                    // CFE - Quick but not elegant
                    case "ms1":     _measures[0] = Convert.ToSingle(node.InnerText); break;

                    case "ms2": _measures[1] = Convert.ToSingle(node.InnerText); break;

                    case "ms3": _measures[2] = Convert.ToSingle(node.InnerText); break;

                    case "ms4": _measures[3] = Convert.ToSingle(node.InnerText); break;

                    case "ms5": _measures[4] = Convert.ToSingle(node.InnerText); break;
                    }
                }
                catch (Exception ex)
                {
                    if (logger != null)
                    {
                        logger.AddLog("[Msg03:DoParseMessage] ERRROR: " + ex.ToString(), LoggerSeverities.Error);
                    }
                    throw ex;
                }
            }
        }
Esempio n. 29
0
 public void ReadFile(Stream inStream, T instance, ILogger logger = null)
 {
     using (var binaryReader = new BinaryReader(inStream)) {
         for (var line = 0; line < _fileLines.Count; line++)
         {
             var fileLine = _fileLines[line];
             try {
                 fileLine.ReadValue(binaryReader, ref instance);
             }
             catch (Exception ex) {
                 if (ex is EndOfStreamException)
                 {
                     throw ex;
                 }
                 logger?.AddLog(new LogMessage(LogSeverity.Error, $"{line + 1}: {ex}"));
                 fileLine.SetDefaultValue(instance);
             }
         }
     }
 }
Esempio n. 30
0
        private bool InsertFraudMsgs(ILogger logger)
        {
            bool bRet = false;

            try
            {
                Database d = OPS.Components.Data.DatabaseFactory.GetDatabase();
                System.Data.IDbConnection DBCon = d.GetNewConnection();
                DBCon.Open();
                try
                {
                    String strSQL = String.Format("insert into MSGS_XML_FRAUD_OPERATIONS (MXF_UNI_ID,MXF_MOVDATE,MXF_NUMBER,MXF_NAME,MXF_XPRTN_DATE,MXF_FIN_ID,MXF_XML) values " +
                                                  "({0},to_date('{1}','hh24missddmmyy'),'{2}','{3}',to_date('{4}','hh24missddmmyy'),{5},'{6}')",
                                                  _unitId,
                                                  OPS.Comm.Dtx.DtxToString(_date),
                                                  _szCCNumber,
                                                  _szCCName,
                                                  OPS.Comm.Dtx.DtxToString(_dtExpirDate),
                                                  _fineNumber,
                                                  _root.OuterXml);

                    logger.AddLog("[Msg04:Process]: " + strSQL, LoggerSeverities.Debug);
                    OracleCommand cmd = new OracleCommand(strSQL, (OracleConnection)DBCon);
                    if (cmd.ExecuteNonQuery() == 1)
                    {
                        bRet = true;
                    }
                    cmd.Dispose();
                }
                catch
                {
                }

                DBCon.Close();
            }
            catch
            {
            }

            return(bRet);
        }