Esempio n. 1
0
        /// <summary>
        /// 更新用户的在线状态
        /// </summary>
        /// <param name="session"></param>
        /// <param name="lstParams"></param>
        /// lstParams[0] : 在线状态 0:离线 1:在线
        /// <returns></returns>
        private OperationReturn ChangeUserStatus(SessionInfo session, List <string> lstParams)
        {
            OperationReturn optReturn = new OperationReturn();

            try
            {
                string strRent   = session.RentInfo.Token;
                string strSql    = string.Empty;
                string strUserID = session.UserID.ToString();

                //判断t_11_101中有没有记录 有则更新 没有则新加
                optReturn = CheckUserPropertyByID(session);
                if (!optReturn.Result)
                {
                    return(optReturn);
                }
                string strType = strUserID.Substring(0, 3);
                if (optReturn.Code == (int)S1600WcfError.PropertyNone)
                {
                    //需要增加记录
                    switch (session.DBType)
                    {
                    case 2:
                        if (strType == ConstValue.RESOURCE_USER.ToString())
                        {
                            strSql = "insert into t_11_101_{0} (c001,c002,c015) values ({1},1,{2})";
                            strSql = string.Format(strSql, strRent, strUserID, lstParams[0]);
                        }
                        else if (strType == ConstValue.RESOURCE_AGENT.ToString())
                        {
                            strSql = "insert into t_11_101_{0} (c001,c002,c020) values ({1},2,{2})";
                            strSql = string.Format(strSql, strRent, strUserID, lstParams[0]);
                        }
                        optReturn = MssqlOperation.ExecuteSql(session.DBConnectionString, strSql);
                        break;

                    case 3:
                        if (strType == ConstValue.RESOURCE_USER.ToString())
                        {
                            strSql = "insert into t_11_101_{0} (c001,c002,c015) values ({1},1,{2})";
                            strSql = string.Format(strSql, strRent, strUserID, lstParams[0]);
                        }
                        else if (strType == ConstValue.RESOURCE_AGENT.ToString())
                        {
                            strSql = "insert into t_11_101_{0} (c001,c002,c020) values ({1},2,{2})";
                            strSql = string.Format(strSql, strRent, strUserID, lstParams[0]);
                        }
                        optReturn = OracleOperation.ExecuteSql(session.DBConnectionString, strSql);
                        break;
                    }
                }
                else
                {
                    switch (session.DBType)
                    {
                    case 2:
                        if (strType == ConstValue.RESOURCE_USER.ToString())
                        {
                            strSql = "update T_11_101_{0} set C015 = '{1}' where C001 = {2} and C002 = 1";
                            strSql = string.Format(strSql, strRent, lstParams[0], strUserID);
                        }
                        else if (strType == ConstValue.RESOURCE_AGENT.ToString())
                        {
                            strSql = "update T_11_101_{0} set C020 = '{1}' where C001 = {2} and C002 = 2";
                            strSql = string.Format(strSql, strRent, lstParams[0], strUserID);
                        }
                        optReturn = MssqlOperation.ExecuteSql(session.DBConnectionString, strSql);
                        break;

                    case 3:
                        if (strType == ConstValue.RESOURCE_USER.ToString())
                        {
                            strSql = "update T_11_101_{0} set C015 = '{1}' where C001 = {2} and C002 = 1";
                            strSql = string.Format(strSql, strRent, lstParams[0], strUserID);
                        }
                        else if (strType == ConstValue.RESOURCE_AGENT.ToString())
                        {
                            strSql = "update T_11_101_{0} set C020 = '{1}' where C001 = {2} and C002 = 2";
                            strSql = string.Format(strSql, strRent, lstParams[0], strUserID);
                        }
                        optReturn = OracleOperation.ExecuteSql(session.DBConnectionString, strSql);
                        break;
                    }
                }
                optReturn.Message += " ; " + strSql;
                if (!optReturn.Result)
                {
                    optReturn.Result = false;
                    optReturn.Code   = Defines.RET_FAIL;
                }
            }
            catch (Exception ex)
            {
                optReturn.Result  = false;
                optReturn.Code    = Defines.RET_FAIL;
                optReturn.Message = ex.Message;
            }
            return(optReturn);
        }
Esempio n. 2
0
        private OperationReturn CheckUserPropertyByID(SessionInfo session)
        {
            OperationReturn optReturn = new OperationReturn();

            try
            {
                string strRent   = session.RentInfo.Token;
                string strSql    = string.Empty;
                string strUserID = session.UserID.ToString();

                //判断是坐席还是用户
                string strType = strUserID.Substring(0, 3);
                if (strType == ConstValue.RESOURCE_AGENT.ToString())
                {
                    //坐席
                    switch (session.DBType)
                    {
                    case 2:
                        strSql    = "select * from t_11_101_{0} where C001 = {1} and C002 = 2";
                        strSql    = string.Format(strSql, strRent, strUserID);
                        optReturn = MssqlOperation.GetDataSet(session.DBConnectionString, strSql);
                        break;

                    case 3:
                        strSql    = "select * from t_11_101_{0} where C001 = {1} and C002 = 2";
                        strSql    = string.Format(strSql, strRent, strUserID);
                        optReturn = OracleOperation.GetDataSet(session.DBConnectionString, strSql);
                        break;
                    }
                }
                else if (strType == ConstValue.RESOURCE_USER.ToString())
                {
                    //用户
                    switch (session.DBType)
                    {
                    case 2:
                        strSql    = "select * from t_11_101_{0} where C001 = {1} ";
                        strSql    = string.Format(strSql, strRent, strUserID);
                        optReturn = MssqlOperation.GetDataSet(session.DBConnectionString, strSql);
                        break;

                    case 3:
                        strSql    = "select * from t_11_101_{0} where C001 = {1} ";
                        strSql    = string.Format(strSql, strRent, strUserID);
                        optReturn = OracleOperation.GetDataSet(session.DBConnectionString, strSql);
                        break;
                    }
                }
                optReturn.Message += " ; " + strSql;
                if (!optReturn.Result)
                {
                    optReturn.Code = (int)S1600WcfError.CheckUserPropertyError;
                    return(optReturn);
                }

                DataSet ds = optReturn.Data as DataSet;
                if (ds.Tables.Count <= 0 || ds.Tables[0].Rows.Count <= 0)
                {
                    optReturn.Result = true;
                    optReturn.Code   = (int)S1600WcfError.PropertyNone;
                    return(optReturn);
                }

                optReturn.Result = true;
                optReturn.Code   = Defines.RET_SUCCESS;
            }
            catch (Exception ex)
            {
                optReturn.Result  = false;
                optReturn.Code    = (int)S1600WcfError.CheckUserPropertyException;
                optReturn.Message = ex.Message;
            }
            return(optReturn);
        }