Beispiel #1
0
        public static OnceDataStorage Instance(CmdModel cmd)
        {
            OnceDataStorage obj = null;

            switch (cmd.CounterType)
            {
            case CounterTypeEnum.Nil:
                break;

            case CounterTypeEnum.Business:
                obj = new BizCounter();
                break;

            case CounterTypeEnum.Custom:
                obj = new CoustomCounter();
                break;

            case CounterTypeEnum.Error:
                obj = new ErrorCounter();
                break;

            default:
                throw new Exception("not found this CounterType");
                break;
            }
            obj.Cmd = cmd;
            return(obj);
        }
Beispiel #2
0
        /// <summary>
        /// 添加数据
        /// </summary>
        /// <param name="model"></param>
        public static void AddData(BaseModel model)
        {
            OnceDataStorage obj = null;

            switch (model.CounterType)
            {
            case CounterTypeEnum.Nil:
                break;

            case CounterTypeEnum.Business:
                obj = new BizCounter();
                break;

            case CounterTypeEnum.Custom:
                obj = new CoustomCounter();
                break;

            case CounterTypeEnum.Error:
                obj = new ErrorCounter();
                break;

            default:
                break;
            }
            if (obj != null)
            {
                obj.Add(model);
            }
        }
Beispiel #3
0
        // 락이 없는 함수로 푸시 말고는 쓰기 동작이 없어야 한다.
        // Stop이 불리고 나서도 로그가 푸시될 수 있는 것을 감안한다(이런 로그는 Stop에서 처리).
        private Int64 PushImpl(String type, Object log, Boolean doSerialize)
        {
            try
            {
                if (CheckAvailablePush(type, log) == false)
                {
                    return(INVALID_SEQUENCE);
                }

                DateTime now         = Now.NowDateTime();
                Int64    sequence    = _sequenceGenerator.Generate();
                Boolean  successPush = _logQueue.Push(new Log()
                {
                    Sequence    = sequence,
                    LogType     = type,
                    LogObject   = log,
                    TimeStamp   = Now.TimestampSec(now),
                    TimeStampNS = Now.TimestampNS(now),
                    IsRawString = doSerialize
                });

                if (successPush)
                {
                    Watcher.IncrementPushLogCount();
                    return(sequence);
                }

                return(INVALID_SEQUENCE);
            }
            catch (Exception exception)
            {
                ErrorCounter.RaiseError($"Fail Push: {exception.Message}");
                return(INVALID_SEQUENCE);
            }
        }
Beispiel #4
0
        public bool HandlePeekedMessage(IMsmqTransport transport, OpenedQueue queue, Message message)
        {
            bool doesNotHaveMessageId = message.Extension.Length < 16;

            if (doesNotHaveMessageId)
            {
                const string errorMessage = "Message does not have Extension set to at least 16 bytes, which will be used as the message id. Probably not a bus message.";
                transport.RaiseMessageSerializationException(queue, message, errorMessage);
                MoveToErrorQueue(queue, message, errorMessage);
                return(true);
            }

            var          id           = message.GetMessageId();
            ErrorCounter errorCounter = null;

            failureCounts.Read(reader => reader.TryGetValue(id, out errorCounter));

            if (errorCounter == null)
            {
                return(false);
            }

            if (errorCounter.FailureCount < numberOfRetries)
            {
                return(false);
            }

            failureCounts.Write(writer =>
            {
                writer.Remove(id);
                MoveToErrorQueue(queue, message, errorCounter.ExceptionText);
            });

            return(true);
        }
Beispiel #5
0
        /// <summary>
        /// Constructor.  Reads the file and stores any data needed for corrections later on.
        /// </summary>
        public FwDataFixer(string filename, IProgress progress, ErrorLogger logger, ErrorCounter counter)
        {
            m_filename   = filename;
            m_progress   = progress;
            errorLogger  = logger;
            errorCounter = counter;

            m_progress.Minimum  = 0;
            m_progress.Maximum  = 1000;
            m_progress.Position = 0;
            m_progress.Message  = String.Format(Strings.ksReadingTheInputFile, m_filename);
            m_crt = 0;
            // The following fixers will be run on each rt element during FixErrorsAndSave()
            // Note: every change to the file MUST log an error. This is used in FixFwData to set a return code indicating whether anything changed.
            // This in turn is used in Send/Receive to determine whether we need to re-split the file before committing.
            // N.B.: Order is important here!!!!!!!
            m_rtLevelFixers.Add(new DuplicateStyleFixer());
            m_rtLevelFixers.Add(new OriginalFixer());
            m_rtLevelFixers.Add(new CustomPropertyFixer());
            m_rtLevelFixers.Add(new BasicCustomPropertyFixer());
            var senseFixer = new GrammaticalSenseFixer();

            m_rtLevelFixers.Add(senseFixer);
            m_rtLevelFixers.Add(new MorphBundleFixer(senseFixer));             // after we've possibly removed MSAs in GrammaticalSenseFixer
            m_rtLevelFixers.Add(new SequenceFixer());
            m_rtLevelFixers.Add(new HomographFixer());
            m_rtLevelFixers.Add(new DuplicateWordformFixer());
            m_rtLevelFixers.Add(new CustomListNameFixer());
            InitializeFixers(m_filename);
        }
Beispiel #6
0
 internal void Initialize(Logger logger)
 {
     _id         = logger.Config.ID;
     _instanceID = logger.InstanceID;
     _compressLogThresholdByte = logger.Config.CompressLogThresholdByte;
     _errorCounter             = logger.ErrorCounter;
 }
Beispiel #7
0
		/// <summary>
		/// Constructor.  Reads the file and stores any data needed for corrections later on.
		/// </summary>
		public FwDataFixer(string filename, IProgress progress, ErrorLogger logger, ErrorCounter counter)
		{
			m_filename = filename;
			m_progress = progress;
			errorLogger = logger;
			errorCounter = counter;

			m_progress.Minimum = 0;
			m_progress.Maximum = 1000;
			m_progress.Position = 0;
			m_progress.Message = String.Format(Strings.ksReadingTheInputFile, m_filename);
			m_crt = 0;
			// The following fixers will be run on each rt element during FixErrorsAndSave()
			// Note: every change to the file MUST log an error. This is used in FixFwData to set a return code indicating whether anything changed.
			// This in turn is used in Send/Receive to determine whether we need to re-split the file before committing.
			// N.B.: Order is important here!!!!!!!
			m_rtLevelFixers.Add(new DuplicateStyleFixer());
			m_rtLevelFixers.Add(new OriginalFixer());
			m_rtLevelFixers.Add(new CustomPropertyFixer());
			m_rtLevelFixers.Add(new BasicCustomPropertyFixer());
			var senseFixer = new GrammaticalSenseFixer();
			m_rtLevelFixers.Add(senseFixer);
			m_rtLevelFixers.Add(new MorphBundleFixer(senseFixer)); // after we've possibly removed MSAs in GrammaticalSenseFixer
			m_rtLevelFixers.Add(new SequenceFixer());
			m_rtLevelFixers.Add(new HomographFixer());
			m_rtLevelFixers.Add(new DuplicateWordformFixer());
			m_rtLevelFixers.Add(new CustomListNameFixer());
			InitializeFixers(m_filename);
		}
        private void CreateErrorCounter()
        {
            if (Reporter == null)
            {
                throw new LoggerStartException(StartResultType.Undefined); // 초기화 실수.
            }

            ErrorCounter = new ErrorCounter(Reporter, Config.MaxSerialErrorCount, Pause);
        }
Beispiel #9
0
        public SourceUnitTree Parse(SourceUnit /*!*/ sourceUnit, RubyCompilerOptions /*!*/ options, ErrorSink /*!*/ errorSink)
        {
            Assert.NotNull(sourceUnit, options, errorSink);

            ErrorCounter counter = new ErrorCounter(errorSink);

            _tokenizer.ErrorSink     = counter;
            _tokenizer.Compatibility = options.Compatibility;

            _lexicalScopes.Clear();

            EnterScope(CreateTopScope(options.LocalNames));

            using (SourceCodeReader reader = sourceUnit.GetReader()) {
                _sourceUnit = sourceUnit;
                _tokenizer.Initialize(null, reader, sourceUnit, options.InitialLocation);

                // Default encoding when hosted (ignore KCODE, we are reading from Unicode buffer):
                _tokenizer.Encoding = (reader.Encoding != null) ? RubyEncoding.GetRubyEncoding(reader.Encoding) : RubyEncoding.UTF8;
                _tokenizer.AllowNonAsciiIdentifiers = _tokenizer.Encoding != RubyEncoding.Binary;

                try {
                    Parse();
                    LeaveScope();
                } catch (InternalSyntaxError) {
                    _ast = null;
                    _lexicalScopes.Clear();
                } finally {
                    ScriptCodeParseResult props;
                    if (counter.AnyError)
                    {
                        _ast = null;

                        if (_tokenizer.UnterminatedToken)
                        {
                            props = ScriptCodeParseResult.IncompleteToken;
                        }
                        else if (_tokenizer.EndOfFileReached)
                        {
                            props = ScriptCodeParseResult.IncompleteStatement;
                        }
                        else
                        {
                            props = ScriptCodeParseResult.Invalid;
                        }
                    }
                    else
                    {
                        props = ScriptCodeParseResult.Complete;
                    }

                    sourceUnit.CodeProperties = props;
                }

                return(_ast);
            }
        }
Beispiel #10
0
        public SourceUnitTree Parse(SourceUnit /*!*/ sourceUnit, RubyCompilerOptions /*!*/ options, ErrorSink /*!*/ errorSink)
        {
            Assert.NotNull(sourceUnit, options, errorSink);

            ErrorCounter counter = new ErrorCounter(errorSink);

            _tokenizer.ErrorSink     = counter;
            _tokenizer.Compatibility = options.Compatibility;

            _lexicalScopes.Clear();

            EnterScope(CreateTopScope(options.LocalNames));

            using (SourceCodeReader reader = sourceUnit.GetReader()) {
                _sourceUnit = sourceUnit;
                _tokenizer.Initialize(null, reader, sourceUnit, options.InitialLocation);

                // default encoding when hosted:
                _encoding = reader.Encoding ?? RubyEncoding.GetDefaultHostEncoding(options.Compatibility);

                try {
                    Parse();
                    LeaveScope();
                } catch (InternalSyntaxError) {
                    _ast = null;
                    _lexicalScopes.Clear();
                } finally {
                    ScriptCodeParseResult props;
                    if (counter.AnyError)
                    {
                        _ast = null;

                        if (_tokenizer.UnterminatedToken)
                        {
                            props = ScriptCodeParseResult.IncompleteToken;
                        }
                        else if (_tokenizer.IsEndOfFile)
                        {
                            props = ScriptCodeParseResult.IncompleteStatement;
                        }
                        else
                        {
                            props = ScriptCodeParseResult.Invalid;
                        }
                    }
                    else
                    {
                        props = ScriptCodeParseResult.Complete;
                    }

                    sourceUnit.CodeProperties = props;
                }

                return(_ast);
            }
        }
Beispiel #11
0
 internal void Initialize(Logger logger)
 {
     _config               = logger.Config;
     _reporter             = logger.Reporter;
     _watcher              = logger.Watcher;
     _errorCounter         = logger.ErrorCounter;
     _completePutNotifier  = logger.CompletePutNotifier;
     _throughputController = logger.ThroughputController;
     _kinesisPutAPI        = new PutAPI(_config.AWSs.Region, _config.AWSs.DecryptedAccessID, _config.AWSs.DecryptedSecretKey, _config.AWSs.KinesisStreamName, OnPutRequestCompleted);
 }
Beispiel #12
0
        internal void Initialize(Logger logger, NoticeCompletePutDelegate noticeCompletePut)
        {
            if (noticeCompletePut == null || logger.CompletePutNoticeType == CompletePutNoticeType.None)
            {
                throw new LoggerException($"Fail {nameof(CompletePutNotifier)}::{nameof(Initialize)}");
            }

            _config                = logger.Config;
            _errorCounter          = logger.ErrorCounter;
            _completePutNoticeType = logger.CompletePutNoticeType;
            _noticeCompletePut     = noticeCompletePut;
        }
 internal void Initialize(Logger logger)
 {
     lock (_lock)
     {
         _putter            = logger.Putter;
         _errorCounter      = logger.ErrorCounter;
         _describeStreamAPI = new DescribeStreamAPI(logger.Config.AWSs.Region,
                                                    logger.Config.AWSs.DecryptedAccessID,
                                                    logger.Config.AWSs.DecryptedSecretKey,
                                                    logger.Config.AWSs.KinesisStreamName,
                                                    OnDescribeStreamRequestCompleted);
     }
 }
        private void Transport_OnMessageProcessingCompleted(CurrentMessageInformation information, Exception ex)
        {
            if (ex != null)
            {
                return;
            }

            ErrorCounter val = null;

            failureCounts.Read(reader => reader.TryGetValue(information.TransportMessageId, out val));
            if (val == null)
            {
                return;
            }
            failureCounts.Write(writer => writer.Remove(information.TransportMessageId));
        }
 private void Transport_OnMessageProcessingFailure(CurrentMessageInformation information, Exception exception)
 {
     failureCounts.Write(writer =>
     {
         ErrorCounter errorCounter;
         if (writer.TryGetValue(information.TransportMessageId, out errorCounter) == false)
         {
             errorCounter = new ErrorCounter
             {
                 ExceptionText = exception == null ? null : exception.ToString(),
                 FailureCount  = 0
             };
             writer.Add(information.TransportMessageId, errorCounter);
         }
         errorCounter.FailureCount += 1;
     });
 }
Beispiel #16
0
 private void Transport_OnMessageProcessingFailure(CurrentMessageInformation information, Exception exception)
 {
     var id = information.MessageId;
     failureCounts.Write(writer =>
     {
         ErrorCounter errorCounter;
         if (writer.TryGetValue(id, out errorCounter) == false)
         {
             errorCounter = new ErrorCounter
             {
                 ExceptionText = exception.ToString(),
                 FailureCount = 0
             };
             writer.Add(id, errorCounter);
         }
         errorCounter.FailureCount += 1;
     });
 }
Beispiel #17
0
        public SourceUnitTree Parse(CompilerContext context)
        {
            _tokenizer = new Tokenizer();
            _context   = context;
            ErrorCounter counter = new ErrorCounter(context.Errors);

            _tokenizer.ErrorSink = counter;
            using (var reader = context.SourceUnit.GetReader())
            {
                _tokenizer.Initialize(null, reader, context.SourceUnit, SourceLocation.MinValue);
                SourceUnitTree ast;
                try { ast = Parse(); }
                catch (InternalInvalidSyntaxException) { ast = null; }
                finally
                {
                    ScriptCodeParseResult props;
                    if (counter.AnyError)
                    {
                        ast = null;
                        if (_tokenizer.NextToken.Type == TokenType.EndOfStream)
                        {
                            props = ScriptCodeParseResult.IncompleteStatement;
                        }
                        else
                        {
                            props = ScriptCodeParseResult.Invalid;
                        }
                    }
                    else if (_parsedIncompleteIf)
                    {
                        props = ScriptCodeParseResult.IncompleteStatement;
                    }
                    else
                    {
                        props = ScriptCodeParseResult.Complete;
                    }
                    context.SourceUnit.CodeProperties = props;
                }
                return(ast);
            }
        }
        public frmProfile()
        {
            InitializeComponent();
            InitializeCommandManager();
            hlpProviderProfile.HelpNamespace = Properties.Resources.FileHelpName;

            ErrorCounterWindows   = new ErrorCounter();
            this.pf               = new profile();
            pf.codeLanguage       = new profileCodeLanguage();
            pf.codeLanguage.paths = new profileCodeLanguagePaths();

            windows    = new BindingList <profileWindow>();
            this.IsNew = true;

            windows.AddingNew += (s, a) =>
            {
                profileWindow pfWind = new profileWindow();
                pfWind.Parent = windows;
                pfWind.Errors = ErrorCounterWindows;
                a.NewObject   = pfWind;
            };

            this.DgWindowsAddImgColumns();

            profileWindow wp = windows.AddNew();

            wp.name  = @"Notepad";
            wp.value = @"ahk_class Notepad";

            this.dgWindows.UserDeletingRow     += dgWindows_UserDeletingRow;
            this.dgWindows.CellClick           += dgWindows_CellClick;
            this.dgWindows.DefaultValuesNeeded += dgWindows_DefaultValuesNeeded;
            this.WindowSpyPath = WindowSpy.GetPath();
            if (!string.IsNullOrEmpty(this.WindowSpyPath))
            {
                this.WindowSpyFound = true;
            }
        }
        private bool Transport_OnMessageArrived(CurrentMessageInformation information)
        {
            var          info = (SqlQueueCurrentMessageInformation)information;
            ErrorCounter val  = null;

            failureCounts.Read(reader => reader.TryGetValue(info.TransportMessageId, out val));
            if (val == null || val.FailureCount < numberOfRetries)
            {
                return(false);
            }

            var result = false;

            failureCounts.Write(writer =>
            {
                if (writer.TryGetValue(info.TransportMessageId, out val) == false)
                {
                    return;
                }

                info.Queue.MoveTo(SubQueue.Errors.ToString(), info.TransportMessage);
                info.Queue.EnqueueDirectlyTo(SubQueue.Errors.ToString(), new MessagePayload
                {
                    Data    = val.ExceptionText == null ? null : Encoding.Unicode.GetBytes(val.ExceptionText),
                    Headers = new NameValueCollection
                    {
                        { "correlation-id", info.TransportMessageId },
                        { "retries", val.FailureCount.ToString() }
                    }
                });

                result = true;
            });

            return(result);
        }
 private void CheckStandingData()
 {
     if (cashFlowInformation.Fund.IsHqTrustFund)
     {
         if (cashFlowInformation.Fund.InitiatorId == 0)
         {
             ErrorCounter++;
             AddError(cashFlowInformation.Fund, "Es ist kein Initiator erfasst!");
         }
         else
         {
             if (string.IsNullOrEmpty(cashFlowInformation.Fund.Initiator.FooterLine1))
             {
                 ErrorCounter++;
                 AddError(cashFlowInformation.Fund, "Für den Initiator sind keine Fusszeilen erfasst!");
             }
         }
     }
     foreach (CashFlowDetail detail in cashFlowInformation.InvestorDetails)
     {
         if (string.IsNullOrEmpty(detail.Reference))
         {
             errorCounter++;
             AddError(detail.Investor, "Weder beim Investor noch beim Commitment wurde eine Referenz angegeben.");
         }
         if (detail.BankAccount == null)
         {
             errorCounter++;
             AddError(detail.Investor, "Eine Bankverbindung fehlt");
         }
         if (detail.Investor.SendEmail == true)
         {
             if (detail.Investor.EMailAccounts.Count == 0 && string.IsNullOrEmpty(detail.Investor.IName.EmailAddress))
             {
                 errorCounter++;
                 AddError(detail.Investor, "Für diesen Investor sollen E-Mails verschickt werden. Es sind keine E-Mail-Adressen angegeben");
             }
         }
     }
     if (Errors.Count == 0)
     {
         CashFlowErrors error = new CashFlowErrors()
         {
             InvestorId = 0,
             PeFundId   = 0,
             ErrorText  = "Es wurden keine Fehler festgestellt",
             ObjectName = string.Empty
         };
         Errors.Add(error);
         CanGotoNextStep = true;
         CashFlowInformation.InvestorsChecked = true;
     }
     else
     {
         CashFlowErrors error = new CashFlowErrors()
         {
             InvestorId = 0,
             PeFundId   = 0,
             ObjectName = "Zusammenfassung:",
             ErrorText  = $"Es wurden {ErrorCounter.ToString()} Fehler entdeckt."
         };
         Errors.Insert(0, error);
         if (Properties.Settings.Default.Anwender == "BLL")
         {
             CanGotoNextStep = true;
             CashFlowInformation.InvestorsChecked = true;
         }
     }
 }
 /// <summary>
 /// Initalize client socket
 /// </summary>
 public TCPClientASocket()
 {
     this.ip    = GetMyIP();
     errCounter = new ErrorCounter(20);             //Number of garbage collected to be determined
 }
Beispiel #22
0
 public BitCoinTicker(Hashtable datas)
 {
     SetMemberValue(datas);
     ticker       = new TickerApi();
     errorCounter = new ErrorCounter(10, 4);
 }
Beispiel #23
0
 public BitCoinTicker(double upThreshold, double downThreshold)
 {
     SetMemberValue(upThreshold, downThreshold);
     ticker       = new TickerApi();
     errorCounter = new ErrorCounter(10, 4);
 }
Beispiel #24
0
        }                                                       //上次询问的价格

        public BitCoinTicker()
        {
            SetMemberValue();
            ticker       = new TickerApi();
            errorCounter = new ErrorCounter(10, 4);
        }
Beispiel #25
0
 private void CreateAndStartLoggerThread()
 {
     for (Int32 i = 0; i < Config.WorkThreadCount; ++i)
     {
         var thread = new NaiveLoopThread(Tick, Config.WorkThreadIntervalMS, e => ErrorCounter.RaiseError(e), $"{nameof(Tick)}:{i}");
         _loggerThreads.Add(thread);
         thread.Start();
     }
 }