Esempio n. 1
0
        public string GetToken(string v)
        {
            ApiResult apiResult;
            var       jsonStr = "";
            var       decrypt = AesUtility.Decrypt(v);

            try
            {
                var model       = decrypt.FromJson <GetTokenModel.Input>();
                var checkResult = model.IsValid <string>();
                if (checkResult.ErrorCode != EnumItem.Get(Ref.ErrorCode._000).FinalValue)
                {
                    jsonStr = ReturnJsonString(checkResult);
                    return(jsonStr);
                }
                var service = new SecurityService();

                apiResult = service.Execute(model);

                jsonStr = ReturnJsonString(apiResult);
            }
            catch (Exception ex)
            {
                LogRecord.Create()
                .SetMessage(ex.Message)
                .Error()
                ;
            }

            return(jsonStr);
        }
Esempio n. 2
0
        public void IsValidTest()
        {
            GetTokenModel model1   = new GetTokenModel();
            var           result1  = model1.IsValid <ApiResult>();
            var           expected = EnumItem.Get(Ref.ErrorCode._002).FinalValue;
            var           actual   = result1.ErrorCode;

            Assert.AreEqual(expected, actual);
        }
Esempio n. 3
0
        public void IsValidTest()
        {
            GetTokenModel.Input model1 = new GetTokenModel.Input();
            var result1  = model1.IsValid <GetTokenModel.Ouput>();
            var expected = EnumItem.Get(Ref.ErrorCode._002).FinalValue;
            var actual   = result1.ErrorCode;

            Assert.AreEqual(expected, actual);

            GetTokenModel.Input model2 = new GetTokenModel.Input();

            model2.CallTime  = DateTime.Now.ToString("yyyyMMddhhmmss");
            model2.MachineID = "machineA";
            model2.Mask      = model1.GetInMask();
            model2.CallTime  = DateTime.Now.ToString("yyyyMMddhhmmss");
            var result2 = model2.IsValid <GetTokenModel.Ouput>();
            var exp     = EnumItem.Get(Ref.ErrorCode._001).FinalValue;
            var act     = result2.ErrorCode;

            Assert.AreEqual(exp, act);
        }