Exemplo n.º 1
0
        public void Test4()
        {
            new AddActivedClientInformation("permittedClient", "已知的公司", theDal).Excute();

            //客户信息对象
            List <ClientInformationModel> allClients = theDal.GetAllClientInfomationModel();

            Assert.AreEqual(1, allClients.Count);
            ClientInformationModel theObj = allClients[0];

            Assert.AreEqual("已知的公司", theObj.CompanyDescription);
            Assert.AreEqual("permittedClient", theObj.HrmisId);
            Assert.AreEqual(true, theObj.IsPermitted);
            //地址对象
            Assert.AreEqual(0, theObj.TheAddressModelCollcetion.Count);

            //模拟客户端发起调用
            new RegisterClientAddressTransaction("http://knownaddress", "permittedClient", theClientProxyMocks, theDal).Excute();

            Assert.AreEqual(1, theObj.TheAddressModelCollcetion.Count);
            ListenAddressModel lam = theObj.TheAddressModelCollcetion[0];

            Assert.IsTrue(lam.IsActivited);
            Assert.IsTrue(lam.IsPermitted);
            Assert.IsTrue(lam.IsPermitted);
            Assert.AreEqual("http://knownaddress", lam.ListenAddress);
            Console.WriteLine(lam.LastTryActivitedTime);
        }
Exemplo n.º 2
0
        public void Test1()
        {
            try
            {
                new RegisterClientAddressTransaction("http://unknown/", "unknownId", theClientProxyMocks, theDal).Excute();
                Assert.Fail("期望失败");
            }
            catch (ApplicationException ae)
            {
                Assert.AreEqual("当前客户端HrmisId未被允许", ae.Message);
            }
            //客户信息对象
            List <ClientInformationModel> allClients = theDal.GetAllClientInfomationModel();

            Assert.AreEqual(1, allClients.Count);
            ClientInformationModel theObj = allClients[0];

            Assert.AreEqual("未定义的公司", theObj.CompanyDescription);
            Assert.AreEqual("unknownId", theObj.HrmisId);
            Assert.IsFalse(theObj.IsPermitted);
            //地址对象
            Assert.AreEqual(1, theObj.TheAddressModelCollcetion.Count);
            ListenAddressModel lam = theObj.TheAddressModelCollcetion[0];

            Assert.IsTrue(lam.IsActivited);
            Assert.IsFalse(lam.IsPermitted);
            Assert.AreEqual("http://unknown/", lam.ListenAddress);
            Console.WriteLine(lam.LastTryActivitedTime);
        }
Exemplo n.º 3
0
        public void Test3()
        {
            try
            {
                RegisterClientAddressTransaction anUnknowClient = new RegisterClientAddressTransaction(
                    "http://unknown/", "unknownId", theClientProxyMocks, theDal);
                anUnknowClient.Excute();
                Assert.Fail("期望失败");
            }
            catch (ApplicationException)
            {
            }

            ClientInformationModel theClientInformationModel = theDal.GetAllClientInfomationModel()[0];
            ListenAddressModel     theListenAddressModel     = theClientInformationModel.TheAddressModelCollcetion[0];

            Assert.IsFalse(theListenAddressModel.IsPermitted);
            //打开信道
            new ActiveTheListenAddressProxy(theClientInformationModel.Pkid, theListenAddressModel.Pkid, theClientProxyMocks, theDal).Excute();
            Assert.IsTrue(theListenAddressModel.IsPermitted);

            Assert.AreEqual(1, MockSingleSmsClientContract._TheServiceStatusChanged.Count);
            Assert.AreEqual("http://unknown/", MockSingleSmsClientContract._TheServiceStatusChanged[0]);
            //关闭信道
            new DisableTheListenAddressProxy(theClientInformationModel.Pkid, theListenAddressModel.Pkid, theClientProxyMocks, theDal).Excute();
            Assert.IsFalse(theListenAddressModel.IsPermitted);

            Assert.AreEqual(2, MockSingleSmsClientContract._TheServiceStatusChanged.Count);
            Assert.AreEqual("http://unknown/", MockSingleSmsClientContract._TheServiceStatusChanged[1]);
        }
        protected override void ChangeTheObject(ClientInformationModel theModelTobeUpdated)
        {
            ListenAddressModel theAddressModel = theModelTobeUpdated.GetTheAddressModelById(_TheListenAddressId);

            if (theAddressModel == null)
            {
                throw new ApplicationException("无法找到该Id标记的地址信息");
            }
            theAddressModel.IsPermitted = SetTheListenAddressStatus();
        }
        private void InsertListenAddressModel(int clientInformationId, ListenAddressModel aClientAddressModel)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.Parameters.Add(_PKID, SqlDbType.Int).Direction                  = ParameterDirection.Output;
            cmd.Parameters.Add(_ClientInformationId, SqlDbType.Int).Value       = clientInformationId;
            cmd.Parameters.Add(_ListenAddress, SqlDbType.NVarChar, 255).Value   = aClientAddressModel.ListenAddress;
            cmd.Parameters.Add(_IsPermitted, SqlDbType.Int).Value               = aClientAddressModel.IsPermitted;
            cmd.Parameters.Add(_IsActived, SqlDbType.Int).Value                 = aClientAddressModel.IsActivited;
            cmd.Parameters.Add(_LastTryActivitedTime, SqlDbType.DateTime).Value = aClientAddressModel.LastTryActivitedTime;
            int pkid;

            SqlHelper.TransExecuteNonQueryReturnPKID("ListenAddressInsert", cmd, _Conn, _Trans, out pkid);
            aClientAddressModel.Pkid = pkid;
        }
        private void LoadListenAddressFor(ClientInformationModel theObject)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.Parameters.Add(_ClientInformationId, SqlDbType.Int).Value = theObject.Pkid;
            using (SqlDataReader sdr = SqlHelper.ExecuteReader("GetListenAddressByClientInformationId", cmd))
            {
                while (sdr.Read())
                {
                    bool isPermitted            = int.Parse(sdr[_DBIsPermitted].ToString()) > 0 ? true : false;
                    bool isActived              = int.Parse(sdr[_DBIsActived].ToString()) > 0 ? true : false;
                    ListenAddressModel theModel = new ListenAddressModel(sdr[_DBListenAddress].ToString(), isPermitted, isActived, DateTime.Parse(sdr[_DBLastTryActivitedTime].ToString()));
                    theModel.Pkid = int.Parse(sdr[_DBPKID].ToString());

                    theObject.TheAddressModelCollcetion.Add(theModel);
                }
            }
        }
        private void AfterChangeTheObject(ClientInformationModel theModelTobeUpdated)
        {
            ListenAddressModel listenAddressModel = theModelTobeUpdated.GetTheAddressModelById(_TheListenAddressId);

            if (!listenAddressModel.IsActivited)
            {
                return;
            }

            try
            {
                _TheClientProxy.TheServiceStatusChanged(true, listenAddressModel.ListenAddress);
            }
            catch (FaultException)
            {
                throw new ApplicationException("业务已经完成,但是通知客户端服务已经改变未能成功,可能是客户端已经关闭");
            }
        }