Example #1
0
        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("更新完毕");
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }
Example #4
0
        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);
        }