public InputContext input()
    {
        InputContext _localctx = new InputContext(Context, State);

        EnterRule(_localctx, 0, RULE_input);
        int _la;

        try {
            State = 24;
            ErrorHandler.Sync(this);
            switch (Interpreter.AdaptivePredict(TokenStream, 1, Context))
            {
            case 1:
                _localctx = new ToSetVarContext(_localctx);
                EnterOuterAlt(_localctx, 1);
                {
                    State = 14; setVar();
                    State = 15; Match(NL);
                    State = 16; input();
                }
                break;

            case 2:
                _localctx = new CalculateContext(_localctx);
                EnterOuterAlt(_localctx, 2);
                {
                    State = 18; plusOrMinus(0);
                    State = 20;
                    ErrorHandler.Sync(this);
                    _la = TokenStream.LA(1);
                    if (_la == NL)
                    {
                        {
                            State = 19; Match(NL);
                        }
                    }

                    State = 22; Match(Eof);
                }
                break;
            }
        }
        catch (RecognitionException re) {
            _localctx.exception = re;
            ErrorHandler.ReportError(this, re);
            ErrorHandler.Recover(this, re);
        }
        finally {
            ExitRule();
        }
        return(_localctx);
    }
Beispiel #2
0
        private void PublishCalculate(string sessinId, DateTime nowTime, DateTime leftTime, DateTime rightTime, IMetaData[] ds, string desc)
        {
            if (ds.Length > 0)
            {
                ICalculateContext calculateContext = new CalculateContext(Name, desc + "_" + CalculateOperator.GetType().ToString(), leftTime, rightTime, CalculateType.Aggregate, new CalculateInpute(sessinId, "", rightTime, ds), null, CalculateOperator);

                GlobalContext.ActionBlock.Post(calculateContext);

                ds = null;
            }
            else
            {
                Logger.Log.Info(true, Name + " 没有要发布的窗口任务");
            }
        }
Beispiel #3
0
        internal void PublishCalculate()
        {
            DateTime nowTime = DateTime.Now;

            IMetaData[] mds = new MetaData[PatternDataList.Count];
            for (int i = 0; i < mds.Length; i++)
            {
                mds[i] = new MetaData()
                {
                    TagId = PatternDataList[i]
                };
            }

            ICalculateContext calculateContext = new CalculateContext(Name, ExpressionCalculateType.ToString(), nowTime, nowTime, CalculateType.Expression, new CalculateInpute(Id, Script, nowTime, mds), null, CalculateOperators);

            GlobalContext.ActionBlock.Post(calculateContext);

            mds = null;
        }
 public bool LogCalculation(LogCalculation logCalculation)
 {
     try
     {
         using (var ctx = new CalculateContext())
         {
             var logCalc = new LogCalculation()
             {
                 ClientIp        = logCalculation.ClientIp,
                 Calculationdate = logCalculation.Calculationdate
             };
             ctx.LogCalculations.Add(logCalc);
             ctx.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
     }
     return(false);
 }
        /// <inheritdoc />
        public async Task <long> CalculateAllSizeAsync()
        {
            var cacheFolder = await GetCacheFolderAsync();

            if (cacheFolder == null)
            {
                return(0L);
            }

            var cacheFiles = await cacheFolder.GetFilesAsync();

            var context = new CalculateContext();
            var tasks   = cacheFiles.Select(async temp =>
            {
                var basicProperties = await temp.GetBasicPropertiesAsync();
                context._totalSize += basicProperties.Size;
            }).ToList();

            await Task.WhenAll(tasks);

            return((long)context._totalSize);
        }
        private void ParallelCalculate(ICalculateContext context)
        {
            if (context == null)
            {
                Logger.Log.Info(true, "ParallelCalculate参数(context)为空");
                return;
            }

            try
            {
                bool isCalc = true;
                if (context.CalculateType == CalculateType.Expression)
                {
                    foreach (IMetaData md in context.CalculateInpute.DataSource)
                    {
                        if (_winList.ContainsKey(md.TagId))
                        {
                            md.TagName  = _winList[md.TagId].Current.TagName;
                            md.TagTime  = _winList[md.TagId].Current.TagTime;
                            md.TagValue = _winList[md.TagId].Current.TagValue;
                        }
                        else
                        {
                            isCalc = false;
                            break;
                        }
                    }
                }

                if (isCalc)
                {
                    if (_channelMessageHandler.ClientCount > 0)
                    {
                        #region
                        CalculateContext calcContext = (CalculateContext)context;

                        DownTransmission downTrans = new DownTransmission(DownTransmission.GetNewTransmissionId(calcContext.Name, calcContext.LeftTime, context.RightTime), calcContext);

                        byte[] data = TransmissionUtil.SerializeAndCompress <DownTransmission>(downTrans);

                        if (data != null && data.Length > 0)
                        {
                            _masterCache.WriteCache(downTrans.Key, data);

                            _masterCacheList.TryAdd(downTrans.Key, data);

                            Logger.Log.Info(false, $"{downTrans.Key},增加任务,内存计算任务数量:" + _masterCacheList.Count.ToString());
                        }

                        calcContext = null;
                        downTrans   = null;
                        data        = null;
                        #endregion
                    }
                    else
                    {
                        #region
                        if (_workList.Count <= 0)
                        {
                            if (_defaultWorker == null)
                            {
                                _defaultWorker = Worker.Worker.GetDefaultWorker();
                            }

                            _defaultWorker.DoWork(context);
                        }
                        else
                        {
                            IWorker worker = GetPollWorker();
                            if (worker != null)
                            {
                                worker.DoWork(context);
                            }
                        }
                        #endregion
                    }
                }
                context.CalculateInpute.DataSource = null;
                context = null;
            }
            catch (Exception ex)
            {
                Logger.Log.Info(true, $"{context.Name}-{context.Desc}-线程({Thread.CurrentThread.ManagedThreadId.ToString("0000")}):【{context.LeftTime.ToString()}-{context.RightTime.ToString()}】,异常:", ex);
            }
        }
Beispiel #7
0
 public DeleteModel(CalculateContext context)
 {
     _context = context;
 }
Beispiel #8
0
 public OstatnieModel(CalculateContext context)
 {
     _context = context;
 }
Beispiel #9
0
 public DownTransmission(string key, CalculateContext context)
 {
     Key = key;
     CalculateContext = context;
 }