예제 #1
0
        public void ProcessCreateTester()
        {
            ProcessFactory.Init();
            IAggProcess process = ProcessFactory.GetAggProcess(AggWay.Avg);

            Assert.IsNotNull(process);
            process = ProcessFactory.GetAggProcess(AggWay.Min);
            Assert.IsNotNull(process);
            process = ProcessFactory.GetAggProcess(AggWay.Max);
            Assert.IsNotNull(process);
        }
예제 #2
0
        public void MinProcessTester()
        {
            ProcessFactory.Init();
            IAggProcess process = ProcessFactory.GetAggProcess(AggWay.Min);

            AggResult result = process.AggProcess(CreateAggRawData());

            Assert.IsNotNull(result);

            foreach (var aggdata in result.AggDatas)
            {
                Assert.IsTrue(aggdata.Values.Count == 3);
                foreach (var value in aggdata.Values)
                {
                    Assert.IsTrue(value == Convert.ToDouble(100));
                }
            }
        }
예제 #3
0
        public static IAggProcess GetAggProcess(AggWay way)
        {
            IAggProcess process = null;

            if (processes.ContainsKey(way))
            {
                processes.TryGetValue(way, out process);
            }
            else
            {
                process = CreateAggProcess(way);
                if (process != null)
                {
                    processes.TryAdd(way, process);
                }
            }
            return(process);
        }
예제 #4
0
        private static IAggProcess CreateAggProcess(AggWay way)
        {
            IAggProcess iProcess = null;

            if (!processTypes.ContainsKey(way.ToString()))
            {
                iProcess = null;
                return(iProcess);
            }
            Type type = processTypes[way.ToString()];

            try
            {
                iProcess = Activator.CreateInstance(type) as IAggProcess;
            }
            catch (Exception e)
            {
                Log.ErrorFormat("create aggprocess failed, type:{0},error:{1},stacktrace{2}", way.ToString(), e.Message, e.StackTrace);
            }
            return(iProcess);
        }
예제 #5
0
 public AggTask(IDataPool dataPool, IAggProcess aggProcess)
 {
     this.dataPool = dataPool;
     this.process  = aggProcess;
 }