public ModelInvokeResult <NormalAccountPK> Nullify(string strId) { ModelInvokeResult <NormalAccountPK> result = new ModelInvokeResult <NormalAccountPK> { Success = true }; try { List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>(); NormalAccount normalAccount = new NormalAccount { Id = int.Parse(strId), Status = 0 }; /***********************begin 自定义代码*******************/ /***********************end 自定义代码*********************/ statements.Add(new IBatisNetBatchStatement { StatementName = normalAccount.GetUpdateMethodName(), ParameterObject = normalAccount.ToStringObjectDictionary(false), Type = SqlExecuteType.UPDATE }); /***********************begin 自定义代码*******************/ /***********************此处添加自定义代码*****************/ /***********************end 自定义代码*********************/ BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements); result.instance = new NormalAccountPK { Id = int.Parse(strId) }; } catch (Exception ex) { result.Success = false; result.ErrorMessage = ex.Message; } return(result); }
public ModelInvokeResult <NormalAccountPK> Create(NormalAccount normalAccount) { ModelInvokeResult <NormalAccountPK> result = new ModelInvokeResult <NormalAccountPK> { Success = true }; try { List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>(); if (normalAccount.Id == -1) { normalAccount.Id = null; } /***********************begin 自定义代码*******************/ /***********************end 自定义代码*********************/ statements.Add(new IBatisNetBatchStatement { StatementName = normalAccount.GetCreateMethodName(), ParameterObject = normalAccount.ToStringObjectDictionary(false), Type = SqlExecuteType.INSERT }); /***********************begin 自定义代码*******************/ /***********************此处添加自定义代码*****************/ /***********************end 自定义代码*********************/ BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements); result.instance = new NormalAccountPK { Id = normalAccount.Id }; } catch (Exception ex) { result.Success = false; result.ErrorMessage = ex.Message; } return(result); }
public void tokenSetup() { ac1 = new NormalAccount("Ben", "Watt", DateTime.Now); ac2 = new NormalAccount("Ellie", "Full", DateTime.Now); tk = new Ticket(new Journeys.Location("Kings Cross"), new Journeys.Location("Victoria"), ac1, DateTime.Now); sc = new SmartCard(ac2, false, 0); sc2 = new SmartCard(ac2, false, 1); }
public void updateBalanceNullTest() { // Setup var account = new NormalAccount("Will Smith", "Fre$hPrince", DateTime.Now); // Method account.updateBalance(0); }
public void getCreditAmountTest() { // Setup var account = new NormalAccount("Will Smith", "Fre$hPrince", DateTime.Now); float expected = 0.0f; // Method float actual = account.getCreditAmount(); // Assertion Assert.AreEqual(expected, actual); }
public void getTypeTest() { // Setup var account = new NormalAccount("Will Smith", "Fre$hPrince", DateTime.Now); string expected = "Normal"; // Method string actual = account.getType(); // Assertion Assert.AreEqual(expected, actual); }
public void digitalReaderSetup() { ac = new NormalAccount("Ben", "Watt", DateTime.Now); sc = new SmartCard(ac, false, 0); ac2 = new NormalAccount("Alex", "Ogde", DateTime.Now); sc2 = new SmartCard(ac2, false, 0); SetOfAccounts.Instance.addAccount(ac); SetOfAccounts.Instance.addAccount(ac2); SetOfTokens.Instance.addToken(sc); SetOfTokens.Instance.addToken(sc2); }
public InvokeResult <NormalAccount> GetWXUserInfo(string openId) { InvokeResult <NormalAccount> result = new InvokeResult <NormalAccount> { Success = true }; NormalAccount normalAccount = _GetWXUserInfo(openId); if (normalAccount != null) { result.ret = normalAccount; } return(result); }
protected void insertNormalAccount(OAuthUser user, string IDNo, string Mobile) { //ModelInvokeResult<NormalAccountPK> result = new ModelInvokeResult<NormalAccountPK> { Success = true }; NormalAccount normalAccount = new NormalAccount(); try { List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>(); normalAccount.AccountCode = user.openid + "$" + user.nickname; normalAccount.IDNo = IDNo; normalAccount.Mobile = Mobile; normalAccount.CheckInTime = DateTime.Now; normalAccount.NickName = user.nickname; normalAccount.Gender = user.sex; normalAccount.Language = user.language; normalAccount.Country = user.country; normalAccount.Province = user.province; normalAccount.City = user.city; normalAccount.HeadImgUrl = user.headimgurl; //更新条件 var parameterObject = normalAccount.ToStringObjectDictionary(false); parameterObject["OpenId"] = user.openid; var dictionary = new StringObjectDictionary().MixInJson("{'OpenId':'" + user.openid + "'}"); int count = BuilderFactory.DefaultBulder().List <NormalAccount>(dictionary).Count; Util.WriteTxt("count:" + count); if (count == 0) { normalAccount.OpenId = user.openid; Util.WriteTxt("插入1111"); statements.Add(new IBatisNetBatchStatement { StatementName = normalAccount.GetCreateMethodName(), ParameterObject = normalAccount.ToStringObjectDictionary(false), Type = SqlExecuteType.INSERT }); } else { Util.WriteTxt("更新1111"); //Util.WriteTxt("更新" + normalAccount.NickName + " : " + normalAccount.Language + " openid: " + user.openid); statements.Add(new IBatisNetBatchStatement { StatementName = "NormalAccount_Update2", ParameterObject = parameterObject, Type = SqlExecuteType.UPDATE }); } BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements); } catch (Exception ex) { Util.WriteTxt(ex.ToString()); } //Util.WriteTxt("更新完毕"); }
public Stream GetWXUserInfoAsJSONP(string openId, string callback) { InvokeResult <NormalAccount> result = new InvokeResult <NormalAccount> { Success = true }; NormalAccount normalAccount = _GetWXUserInfo(openId); if (normalAccount != null) { result.ret = normalAccount; } byte[] resultBytes = Encoding.UTF8.GetBytes(callback + "(" + result.ToJson() + ")"); WebOperationContext.Current.OutgoingResponse.ContentType = "application/json; charset=utf-8"; return(new MemoryStream(resultBytes)); }
public void updateBalanceTest() { // Setup var account = new NormalAccount("Will Smith", "Fre$hPrince", DateTime.Now); float expected = 30; float negativeExpected = 10; // Method account.updateBalance(30); float actual = account.getCreditAmount(); account.updateBalance(-20); float negativeActual = account.getCreditAmount(); // Assertion Assert.AreEqual(expected, actual); Assert.AreEqual(negativeExpected, negativeActual); }
public InvokeResult NullifySelected(string strIds) { InvokeResult result = new InvokeResult { Success = true }; try { List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>(); string[] arrIds = strIds.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (arrIds.Length == 0) { result.Success = false; result.ErrorCode = 59996; return(result); } string statementName = new NormalAccount().GetUpdateMethodName(); foreach (string strId in arrIds) { NormalAccount normalAccount = new NormalAccount { Id = int.Parse(strId), Status = 0 }; /***********************begin 自定义代码*******************/ /***********************end 自定义代码*********************/ statements.Add(new IBatisNetBatchStatement { StatementName = statementName, ParameterObject = normalAccount.ToStringObjectDictionary(false), Type = SqlExecuteType.UPDATE }); } BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements); } catch (Exception ex) { result.Success = false; result.ErrorMessage = ex.Message; } return(result); }
public InvokeResult DeleteSelected(string strIds) { InvokeResult result = new InvokeResult { Success = true }; try { List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>(); string[] arrIds = strIds.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (arrIds.Length == 0) { result.Success = false; result.ErrorCode = 59996; return(result); } string statementName = new NormalAccount().GetDeleteMethodName(); foreach (string strId in arrIds) { NormalAccountPK pk = new NormalAccountPK { Id = int.Parse(strId) }; DeleteCascade(statements, pk); statements.Add(new IBatisNetBatchStatement { StatementName = statementName, ParameterObject = pk, Type = SqlExecuteType.DELETE }); } BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements); } catch (Exception ex) { result.Success = false; result.ErrorMessage = ex.Message; } return(result); }
public void Edit(NormalAccount Compte) { }
public void Delete(NormalAccount Compte) { Session.Delete(Compte); Session.Flush(); }
public void createNullPasswordAccountTest() { var account = new NormalAccount("Will Smith", null, DateTime.Now); }
public void createNullUsernameAccountTest() { var account = new NormalAccount(null, "Fre$hPrince", DateTime.Now); }
public Stream ReceiveWXMessage(Stream s) { string result = ""; using (StreamReader sr = new StreamReader(s)) { result = sr.ReadToEnd(); } //result = OperationContext.Current.RequestContext.RequestMessage.ToString(); if (result != "") { WXReceiveMessage receiveMessage = XmlSerializeAdapter.Deserialize <WXReceiveMessage>(result); /* * XmlSerializer serializer = new XmlSerializer(typeof(WXReceiveMessage)); * using (StringReader rdr = new StringReader(result)) * { * WXReceiveMessage requestMessage = serializer.Deserialize(rdr) as WXReceiveMessage; * * } */ if (receiveMessage.MsgType.Equals("text")) { WXReceiveTextMessage requestTextMessage = XmlSerializeAdapter.Deserialize <WXReceiveTextMessage>(result); result = GlobalManager.TheWeiXinResponser.ResponseText(requestTextMessage); if (string.IsNullOrEmpty(result)) { result = GlobalManager.TheWeiXinDispatcher.DesideDispatchWho(requestTextMessage); GlobalManager.TheWeiXinDispatcher.DispatchText(requestTextMessage); } } else if (receiveMessage.MsgType.Equals("event")) { WXReceiveEventMessage requestEventMessage = XmlSerializeAdapter.Deserialize <WXReceiveEventMessage>(result); if (requestEventMessage.Event.Equals("subscribe")) { #region 关注 NormalAccount normalAccount = BuilderFactory.DefaultBulder(GlobalManager.getConnectString()).List <NormalAccount>(new NormalAccount { OpenId = requestEventMessage.FromUserName, AccountCode = GlobalManager.TheServiceAccount.AccountCode }).FirstOrDefault(); if (normalAccount == null) { //第一次关注 BuilderFactory.DefaultBulder(GlobalManager.getConnectString()).Create <NormalAccount>(new NormalAccount { AccountCode = GlobalManager.TheServiceAccount.AccountCode, OpenId = requestEventMessage.FromUserName, Gender = "F", SubscribeTime = DateTime.Now }); result = GlobalManager.TheWeiXinResponser.FormatOutputText(requestEventMessage.FromUserName, requestEventMessage.ToUserName, "欢迎加入" + GlobalManager.TheServiceAccount.Name); } else { //曾经关注过 BuilderFactory.DefaultBulder(GlobalManager.getConnectString()).Update <NormalAccount>(new NormalAccount { FollowStatus = 1, SubscribeTime = DateTime.Now, Id = normalAccount.Id }); result = GlobalManager.TheWeiXinResponser.FormatOutputText(normalAccount.OpenId, requestEventMessage.ToUserName, "欢迎重新加入" + GlobalManager.TheServiceAccount.Name); } _RefreshWXUserInfo(requestEventMessage.FromUserName, (ret) => { string gender = "N"; int iGender = int.Parse(ret.sex.ToString()); if (iGender == 1) { gender = "M"; } else if (iGender == 2) { gender = "F"; } BuilderFactory.DefaultBulder(GlobalManager.getConnectString()).ExecuteNativeSqlNoneQuery(new IBatisNetBatchStatement { StatementName = "NormalAccount_UpdateByOpenId", ParameterObject = new NormalAccount { OpenId = ret.openid, NickName = ret.nickname, Gender = gender, Language = ret.language, Country = ret.country, Province = ret.province, City = ret.city, HeadImgUrl = ret.headimgurl }.ToStringObjectDictionary(false), Type = SqlExecuteType.UPDATE }); }, null); #endregion } else if (requestEventMessage.Event.Equals("unsubscribe")) { #region 取消关注 NormalAccount normalAccount = BuilderFactory.DefaultBulder(GlobalManager.getConnectString()).List <NormalAccount>(new NormalAccount { OpenId = requestEventMessage.FromUserName, AccountCode = GlobalManager.TheServiceAccount.AccountCode }).FirstOrDefault(); if (normalAccount != null) { BuilderFactory.DefaultBulder(GlobalManager.getConnectString()).Update <NormalAccount>(new NormalAccount { FollowStatus = 0, SubscribeTime = DateTime.Now, Id = normalAccount.Id }); } #endregion } else if (requestEventMessage.Event.Equals("LOCATION")) { WXReceiveLocationMessage requestLocationMessage = XmlSerializeAdapter.Deserialize <WXReceiveLocationMessage>(result); var spParam = new { SourceTable = new NormalAccount().GetMappingTableName(), SourceId = requestLocationMessage.FromUserName, LocateType = "WX-Location-Report", Longitude = requestLocationMessage.Longitude, Latitude = requestLocationMessage.Latitude }.ToSPParam(); try { BuilderFactory.DefaultBulder().ExecuteSPNoneQuery("SP_Pub_InsertPubLocation", spParam); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } else { result = GlobalManager.TheWeiXinResponser.ResponseEvent(requestEventMessage); } } else if (receiveMessage.MsgType.Equals("location")) { } else if (receiveMessage.MsgType == "image") { } else if (receiveMessage.MsgType == "voice") { } } else { result = "hello"; } byte[] resultBytes = Encoding.UTF8.GetBytes(result); WebOperationContext.Current.OutgoingResponse.ContentType = "text/plain"; return(new MemoryStream(resultBytes)); }
public void Save(NormalAccount Compte) { Session.SaveOrUpdate(Compte); Session.Flush(); }