Ejemplo n.º 1
0
        private OperationReturn ModifyUserExtInfo(SessionInfo session, List <string> listParams)
        {
            OperationReturn optReturn = new OperationReturn();

            optReturn.Result = true;
            optReturn.Code   = 0;
            try
            {
                if (listParams.Count < 5)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Param count invalid");
                    return(optReturn);
                }
                string userID, strEmail, strPhone, strBirthday, strHeadIcon;
                //0     UserID
                //1     Email
                //2     Phone
                //3     Birthday
                //4     HeadIcon
                userID      = listParams[0];
                strEmail    = listParams[1];
                strPhone    = listParams[2];
                strBirthday = listParams[3];
                strHeadIcon = listParams[4];

                string rentToken = session.RentInfo.Token;
                string strSql;
                int    count;
                switch (session.DBType)
                {
                //MSSQL
                case 2:
                    strSql = string.Format("SELECT COUNT(1) FROM T_11_101_{0} WHERE C001 = {1} AND C002 = 1"
                                           , rentToken
                                           , userID);
                    optReturn = MssqlOperation.GetRecordCount(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    count = Convert.ToInt32(optReturn.Data);
                    //表中不存在,新增
                    if (count <= 0)
                    {
                        strSql =
                            string.Format(
                                "INSERT INTO T_11_101_{0} (C001,C002,C011,C012,C013,C014) VALUES ({1},1,'{2}','{3}','{4}','{5}')"
                                , rentToken
                                , userID
                                , strEmail
                                , strPhone
                                , strBirthday
                                , strHeadIcon);
                        optReturn = MssqlOperation.ExecuteSql(session.DBConnectionString, strSql);
                        return(optReturn);
                    }
                    strSql =
                        string.Format(
                            "UPDATE T_11_101_{0} SET C011 = '{1}', C012 = '{2}', C013 = '{3}', C014 = '{4}' WHERE C001 = {5} AND C002 =1"
                            , rentToken
                            , strEmail
                            , strPhone
                            , strBirthday
                            , strHeadIcon
                            , userID);
                    optReturn = MssqlOperation.ExecuteSql(session.DBConnectionString, strSql);
                    return(optReturn);

                //ORCL
                case 3:
                    strSql = string.Format("SELECT COUNT(1) FROM T_11_101_{0} WHERE C001 = {1} AND C002 = 1"
                                           , rentToken
                                           , userID);
                    optReturn = OracleOperation.GetRecordCount(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    count = Convert.ToInt32(optReturn.Data);
                    //表中不存在,新增
                    if (count <= 0)
                    {
                        strSql =
                            string.Format(
                                "INSERT INTO T_11_101_{0} (C001,C002,C011,C012,C013,C014) VALUES ({1},1,'{2}','{3}','{4}','{5}')"
                                , rentToken
                                , userID
                                , strEmail
                                , strPhone
                                , strBirthday
                                , strHeadIcon);
                        optReturn = OracleOperation.ExecuteSql(session.DBConnectionString, strSql);
                        return(optReturn);
                    }
                    strSql =
                        string.Format(
                            "UPDATE T_11_101_{0} SET C011 = '{1}', C012 = '{2}', C013 = '{3}', C014 = '{4}' WHERE C001 = {5} AND C002 =1"
                            , rentToken
                            , strEmail
                            , strPhone
                            , strBirthday
                            , strHeadIcon
                            , userID);
                    optReturn = OracleOperation.ExecuteSql(session.DBConnectionString, strSql);
                    return(optReturn);
                }
            }
            catch (Exception ex)
            {
                optReturn.Result  = false;
                optReturn.Code    = Defines.RET_FAIL;
                optReturn.Message = ex.Message;
            }
            return(optReturn);
        }
Ejemplo n.º 2
0
        private OperationReturn ModifyUserInfo(SessionInfo session, List <string> listParams)
        {
            OperationReturn optReturn = new OperationReturn();

            optReturn.Result = true;
            optReturn.Code   = 0;
            try
            {
                if (listParams.Count < 8)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Param count invalid");
                    return(optReturn);
                }
                string strID, account, fullName, strLock, strReset, IsActive, validTime, invalidTime, IsOrgManagement;
                //0     UserID
                //1     Account
                //2     FullName
                //3     Lock ( C 解除锁定, U   界面锁定,D 老杨禁用)
                //4     ResetPassword
                //5    IsAcitve
                //6     ValidTime
                //7     InValidTime
                //8     IsOrgManagement
                ////9     Org
                strID       = listParams[0];
                account     = listParams[1];
                fullName    = listParams[2];
                strLock     = listParams[3];
                strReset    = listParams[4];
                IsActive    = listParams[5];
                validTime   = listParams[6];
                invalidTime = listParams[7];
                //IsOrgManagement = listParams[8];
                //Org = listParams[9];

                account     = EncryptToDB(account);
                fullName    = EncryptToDB(fullName);
                validTime   = EncryptToDB(validTime);
                invalidTime = EncryptToDB(invalidTime);

                string rentToken = session.RentInfo.Token;
                string strSql;
                int    count;
                string strLockSql;
                switch (session.DBType)
                {
                //MSSQL
                case 2:
                    strSql = string.Format("SELECT COUNT(1) FROM T_11_005_{0} WHERE C001 <> {1} AND C002 = '{2}'"
                                           , rentToken
                                           , strID
                                           , account);
                    optReturn = MssqlOperation.GetRecordCount(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    count = Convert.ToInt32(optReturn.Data);
                    //账户名已经存在
                    if (count > 0)
                    {
                        optReturn.Result  = false;
                        optReturn.Code    = Defines.RET_DBACCESS_EXIST;
                        optReturn.Message = string.Format("User account already exist.");
                        return(optReturn);
                    }
                    strLockSql = string.Empty;
                    //if (strLock == "C")
                    //{
                    //    strLockSql = string.Format(", C008 = '0', C009 = 'N'");
                    //}
                    //else if (strLock == "U")
                    //{
                    //    strLockSql = string.Format(", C008 = '1', C009 = 'U'");
                    //}
                    if (strLock == "CL")
                    {
                        strLockSql = string.Format(", C008 = '0', C009 = 'N' ,C024 = 0 ");
                    }
                    else if (strLock == "CU")
                    {
                        strLockSql = string.Format(", C008 = '0', C009 = 'N'");
                    }
                    else if (strLock == "CD")
                    {
                        strLockSql = string.Format(", C008 = '0', C009 = 'N', C013 = '{0}'", EncryptToDB(DateTime.Now.ToString()));
                    }
                    else if (strLock == "U")
                    {
                        strLockSql = string.Format(", C008 = '1', C009 = 'U'");
                    }

                    strSql =
                        string.Format(
                            "UPDATE T_11_005_{0} SET C002 = '{1}', C003 = '{2}'{3} ,C010='{5}' ,C017='{6}',C018='{7}',C027='{8}' WHERE C001 = {4}",
                            rentToken,
                            account,
                            fullName,
                            strLockSql,
                            strID,
                            IsActive,
                            validTime,
                            invalidTime,
                            "0");
                    optReturn = MssqlOperation.ExecuteSql(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    if (strReset == "1")
                    {
                        //重置密码
                        listParams = new List <string>();
                        listParams.Add(strID);
                        listParams.Add("0");
                        listParams.Add(string.Empty);
                        optReturn = ModifyUserPassword(session, listParams);
                    }
                    break;

                //ORCL
                case 3:
                    strSql = string.Format("SELECT COUNT(1) FROM T_11_005_{0} WHERE C001 <> {1} AND C002 = '{2}' "
                                           , rentToken
                                           , strID
                                           , account);
                    optReturn = OracleOperation.GetRecordCount(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    count = Convert.ToInt32(optReturn.Data);
                    //账户名已经存在
                    if (count > 0)
                    {
                        optReturn.Result  = false;
                        optReturn.Code    = Defines.RET_DBACCESS_EXIST;
                        optReturn.Message = string.Format("User account already exist.");
                        return(optReturn);
                    }
                    strLockSql = string.Empty;
                    //if (strLock == "C")
                    //{
                    //    strLockSql = string.Format(", C008 = '0', C009 = 'N'");
                    //}
                    //else if (strLock == "U")
                    //{
                    //    strLockSql = string.Format(", C008 = '1', C009 = 'U'");
                    //}
                    if (strLock == "CL")
                    {
                        strLockSql = string.Format(", C008 = '0', C009 = 'N' ,C024 = 0 ");
                    }
                    else if (strLock == "CU")
                    {
                        strLockSql = string.Format(", C008 = '0', C009 = 'N'");
                    }
                    else if (strLock == "U")
                    {
                        strLockSql = string.Format(", C008 = '1', C009 = 'U'");
                    }

                    strSql =
                        string.Format(
                            "UPDATE T_11_005_{0} SET C002 = '{1}', C003 = '{2}'{3} ,C010='{5}' ,C017='{6}',C018='{7}',C027='{8}' WHERE C001 = {4}",
                            rentToken,
                            account,
                            fullName,
                            strLockSql,
                            strID,
                            IsActive,
                            validTime,
                            invalidTime,
                            "0");
                    optReturn = OracleOperation.ExecuteSql(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    if (strReset == "1")
                    {
                        //重置密码
                        listParams = new List <string>();
                        listParams.Add(strID);
                        listParams.Add("0");
                        listParams.Add(string.Empty);
                        optReturn = ModifyUserPassword(session, listParams);
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                optReturn.Result  = false;
                optReturn.Code    = Defines.RET_FAIL;
                optReturn.Message = ex.Message;
            }
            return(optReturn);
        }