Exemplo n.º 1
0
        private static object ProcessCmd(CmdModel model)
        {
            object obj = null;

            try
            {
                switch (model.ModuleType)
                {
//                    case ModuleTypeEnum.OnceData:
//                        return OnceDataStorage.Instance(model).ExecCmd(model);
//                        break;
//                    case ModuleTypeEnum.HeartBeatData:
//                        return HeartBeatDataStorage.Instance().ExecCmd(model);
//                        break;
//                    case ModuleTypeEnum.SystemData:
//                        obj = SystemDataStorage.GetSystemInfo();
//                        break;
                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
            }

            return(obj);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        public void TimeFormat()
        {
            Assert.AreEqual(1, CmdModel.ParseSeconds("0:1"));
            Assert.AreEqual(1, CmdModel.ParseSeconds("00:01"));
            Assert.AreEqual(1, CmdModel.ParseSeconds("00:00:01"));

            Assert.AreEqual(5141, CmdModel.ParseSeconds("01:25:41"));
            Assert.AreEqual(1541, CmdModel.ParseSeconds("25:41"));
        }
Exemplo n.º 4
0
 public CmdViewModel()
 {
     cmd = CmdModel.GetCmd();
     GalaSoft.MvvmLight.Messaging.Messenger.Default.Register <byte[]>(this, "TC2IMCS00", Refresh);
 }
Exemplo n.º 5
0
 public void InvalidInteger()
 {
     Assert.Throws <FormatException>(() => CmdModel.ParseSeconds("a:b:c:d"));
 }
Exemplo n.º 6
0
 public void Invalid()
 {
     Assert.Throws <FormatException>(() => CmdModel.ParseSeconds("a"));
     Assert.Throws <FormatException>(() => CmdModel.ParseSeconds("b"));
     Assert.Throws <FormatException>(() => CmdModel.ParseSeconds("0:0:0:0"));
 }
Exemplo n.º 7
0
 public void Integer()
 {
     Assert.AreEqual(1, CmdModel.ParseSeconds("1"));
     Assert.AreEqual(0, CmdModel.ParseSeconds("0"));
     Assert.AreEqual(1000, CmdModel.ParseSeconds("1000"));
 }