예제 #1
0
        /// <summary>
        /// 根据cookie查看它的状态(是否结束)
        /// </summary>
        /// <param name="session"></param>
        /// <param name="lstParams">
        /// lstParams[0] : cookieID
        /// </param>
        /// <returns>opt.data = 0: 会话已经结束  1:会话未结束</returns>
        private OperationReturn GetCookieStatusByID(SessionInfo session, List <string> lstParams)
        {
            OperationReturn optReturn = new OperationReturn();

            try
            {
                if (lstParams == null || lstParams.Count < 1 || session == null)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Request param is null or count invalid");
                    return(optReturn);
                }
                string strToken = session.RentInfo.Token;
                string strSql   = string.Empty;
                switch (session.DBType)
                {
                case 2:
                    strSql    = "select * from t_16_001_{0} where C001 = {1}";
                    strSql    = string.Format(strSql, strToken, lstParams[0]);
                    optReturn = MssqlOperation.GetDataSet(session.DBConnectionString, strSql);
                    break;

                case 3:
                    strSql    = "select * from t_16_001_{0} where C001 = {1}";
                    strSql    = string.Format(strSql, strToken, lstParams[0]);
                    optReturn = OracleOperation.GetDataSet(session.DBConnectionString, strSql);
                    break;
                }
                optReturn.Message += "; " + strSql;
                if (!optReturn.Result)
                {
                    optReturn.Code = (int)S1600WcfError.GetCookieStatusError;
                    return(optReturn);
                }
                DataSet ds = optReturn.Data as DataSet;
                if (ds.Tables.Count <= 0 || ds.Tables[0].Rows.Count <= 0)
                {
                    optReturn.Data = "0";
                    return(optReturn);
                }
                string str = ds.Tables[0].Rows[0]["C005"].ToString();
                if (string.IsNullOrEmpty(str))
                {
                    optReturn.Data = "1";
                }
                else
                {
                    optReturn.Data = "0";
                }
                optReturn.Result = true;
            }
            catch (Exception ex)
            {
                optReturn.Result  = false;
                optReturn.Code    = (int)S1600WcfError.GetCookieStatusException;
                optReturn.Message = ex.Message;
            }
            return(optReturn);
        }
예제 #2
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);
        }
예제 #3
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);
        }