Ejemplo n.º 1
0
        private List <string> GetAllUserID(SessionInfo session)
        {
            List <string>    AllUserID = new List <string>();
            string           rentToken = session.RentInfo.Token;
            string           strSql;
            IDbConnection    objConn;
            IDbDataAdapter   objAdapter;
            DbCommandBuilder objCmdBuilder;

            switch (session.DBType)
            {
            //MSSQL
            case 2:
                strSql = string.Format("SELECT C001 FROM T_11_005_{0} WHERE C011 = 0 ORDER BY C001"
                                       , rentToken);
                objConn       = MssqlOperation.GetConnection(session.DBConnectionString);
                objAdapter    = MssqlOperation.GetDataAdapter(objConn, strSql);
                objCmdBuilder = MssqlOperation.GetCommandBuilder(objAdapter);
                break;

            case 3:
                strSql = string.Format("SELECT C001 FROM T_11_005_{0} WHERE C011 = 0 ORDER BY C001"
                                       , rentToken);
                objConn       = OracleOperation.GetConnection(session.DBConnectionString);
                objAdapter    = OracleOperation.GetDataAdapter(objConn, strSql);
                objCmdBuilder = OracleOperation.GetCommandBuilder(objAdapter);
                break;

            default:
                return(AllUserID);
            }
            if (objConn == null || objAdapter == null || objCmdBuilder == null)
            {
                return(AllUserID);
            }
            objCmdBuilder.ConflictOption = ConflictOption.OverwriteChanges;
            objCmdBuilder.SetAllValues   = false;
            try
            {
                DataSet objDataSet = new DataSet();
                objAdapter.Fill(objDataSet);
                foreach (DataRow dr in objDataSet.Tables[0].Rows)
                {
                    AllUserID.Add(dr[0].ToString());
                }
            }
            catch (Exception EX)
            {
                return(AllUserID);
            }
            return(AllUserID);
        }
Ejemplo n.º 2
0
        private OperationReturn Relation(SessionInfo session, List <string> listParams)
        {
            OperationReturn optReturn = new OperationReturn();

            optReturn.Result = true;
            optReturn.Code   = 0;
            try
            {
                if (listParams.Count < 2)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Param count invalid");
                    return(optReturn);
                }
                List <string> Users = GetAllUserID(session);
                bool          IsOk  = false;
                if (Users != null)
                {
                    if (Users.Count != 0)
                    {
                        IsOk = true;
                    }
                }
                string strUserID, strResourceID;
                string strST = string.Empty;
                string strET = string.Empty;
                //0     userID
                //1     resourceID

                //2     start time
                //3     end time
                List <string> User = new List <string>();
                User.Add(listParams[0]);
                User.Add(string.Format("102{0}00000000001", session.RentInfo.Token));
                strResourceID = listParams[1];
                if (listParams.Count == 4)
                {
                    strST = listParams[2];
                    strET = listParams[3];
                }
                string           rentToken = session.RentInfo.Token;
                string           strSql;
                IDbConnection    objConn;
                IDbDataAdapter   objAdapter;
                DbCommandBuilder objCmdBuilder;
                switch (session.DBType)
                {
                //MSSQL
                case 2:
                    strSql = string.Format("SELECT * FROM T_11_201_{0} WHERE C001 = 0 AND C004 = {1}"
                                           , rentToken
                                           , strResourceID);
                    objConn       = MssqlOperation.GetConnection(session.DBConnectionString);
                    objAdapter    = MssqlOperation.GetDataAdapter(objConn, strSql);
                    objCmdBuilder = MssqlOperation.GetCommandBuilder(objAdapter);
                    break;

                //ORCL
                case 3:
                    strSql = string.Format("SELECT * FROM T_11_201_{0} WHERE C001 = 0 AND C004 = {1}"
                                           , rentToken
                                           , strResourceID);
                    objConn       = OracleOperation.GetConnection(session.DBConnectionString);
                    objAdapter    = OracleOperation.GetDataAdapter(objConn, strSql);
                    objCmdBuilder = OracleOperation.GetCommandBuilder(objAdapter);
                    break;

                default:
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Database type not support");
                    return(optReturn);
                }
                if (objConn == null || objAdapter == null || objCmdBuilder == null)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_OBJECT_NULL;
                    optReturn.Message = string.Format("Db object is null");
                    return(optReturn);
                }
                objCmdBuilder.ConflictOption = ConflictOption.OverwriteChanges;
                objCmdBuilder.SetAllValues   = false;
                try
                {
                    DataSet objDataSet = new DataSet();
                    objAdapter.Fill(objDataSet);
                    List <string> listMsg = new List <string>();
                    for (int i = 0; i < User.Count; i++)
                    {
                        strUserID = User[i];
                        //DataRow[] drs = objDataSet.Tables[0].Select(string.Format("C004 = {0}", strResourceID));
                        DataRow[] drs = objDataSet.Tables[0].Select(string.Format("C003={0}", strUserID));
                        //不存在,则插入
                        if (drs.Length <= 0)
                        {
                            if (listParams.Count == 4)
                            {
                                DataRow newRow = objDataSet.Tables[0].NewRow();
                                newRow["C001"] = 0;
                                newRow["C002"] = 0;
                                newRow["C003"] = Convert.ToInt64(strUserID);
                                newRow["C004"] = Convert.ToInt64(strResourceID);
                                newRow["C005"] = Convert.ToDateTime(strST);
                                newRow["C006"] = Convert.ToDateTime(strET);
                                objDataSet.Tables[0].Rows.Add(newRow.ItemArray);

                                listMsg.Add(string.Format("{0}{1}{2}", "A", ConstValue.SPLITER_CHAR, strResourceID));
                            }
                            else
                            {
                                optReturn.Result  = false;
                                optReturn.Code    = Defines.RET_DBACCESS_NOT_EXIST;
                                optReturn.Message = string.Format("Data is not exist");
                            }
                        }
                        else
                        {
                            if (listParams.Count == 2)
                            {
                                //存在,则移除
                                if (drs.Length > 0)
                                {
                                    for (int j = drs.Length - 1; j >= 0; j--)
                                    {
                                        drs[j].Delete();

                                        listMsg.Add(string.Format("{0}{1}{2}", "D", ConstValue.SPLITER_CHAR, strResourceID));
                                    }
                                }
                            }
                            else
                            {
                                optReturn.Result  = false;
                                optReturn.Code    = Defines.RET_DBACCESS_EXIST;
                                optReturn.Message = string.Format("Data is exist");
                            }
                        }
                    }
                    objAdapter.Update(objDataSet);
                    objDataSet.AcceptChanges();
                    optReturn.Data = listMsg;
                }
                catch (Exception ex)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_DBACCESS_FAIL;
                    optReturn.Message = ex.Message;
                }
                finally
                {
                    if (objConn.State == ConnectionState.Open)
                    {
                        objConn.Close();
                    }
                    objConn.Dispose();
                }
            }
            catch (Exception ex)
            {
                optReturn.Result  = false;
                optReturn.Code    = Defines.RET_FAIL;
                optReturn.Message = ex.Message;
            }
            return(optReturn);
        }
Ejemplo n.º 3
0
        private OperationReturn GetRelation(SessionInfo session)
        {
            OperationReturn optReturn = new OperationReturn();

            optReturn.Result = true;
            optReturn.Code   = 0;
            try
            {
                string  rentToken = session.RentInfo.Token;
                string  strSql;
                DataSet objDataSet;
                switch (session.DBType)
                {
                case 2:
                    strSql    = string.Format("SELECT * from T_11_201_{0} where C003 LIKE '100%'", rentToken);
                    optReturn = MssqlOperation.GetDataSet(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    objDataSet = optReturn.Data as DataSet;
                    break;

                case 3:
                    strSql    = string.Format("SELECT * FROM T_11_201_{0} WHERE C003 LIKE '100%'", rentToken);
                    optReturn = OracleOperation.GetDataSet(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    objDataSet = optReturn.Data as DataSet;
                    break;

                default:
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Database type not surpport.\t{0}", session.DBType);
                    return(optReturn);
                }
                if (objDataSet == null)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_OBJECT_NULL;
                    optReturn.Message = string.Format("DataSet is null");
                    return(optReturn);
                }
                List <string> listReturn = new List <string>();
                for (int i = 0; i < objDataSet.Tables[0].Rows.Count; i++)
                {
                    DataRow  dr   = objDataSet.Tables[0].Rows[i];
                    Relation item = new Relation();
                    item.ResourceID = Convert.ToInt64(dr["C004"].ToString());
                    item.StartTime  = Convert.ToDateTime(dr["C005"].ToString());
                    item.EndTime    = Convert.ToDateTime(dr["C006"].ToString());
                    item.UserID     = Convert.ToInt64(dr["C003"].ToString());
                    optReturn       = XMLHelper.SeriallizeObject(item);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    listReturn.Add(optReturn.Data.ToString());
                }
                optReturn.Data = listReturn;
            }
            catch (Exception ex)
            {
                optReturn.Result  = false;
                optReturn.Code    = Defines.RET_FAIL;
                optReturn.Message = ex.Message;
                return(optReturn);
            }
            return(optReturn);
        }
Ejemplo n.º 4
0
        private OperationReturn GetVoiceIP_Name201(SessionInfo session)
        {
            OperationReturn optReturn = new OperationReturn();

            optReturn.Result = true;
            optReturn.Code   = 0;
            try
            {
                string  rentToken = session.RentInfo.Token;
                string  strSql;
                DataSet objDataSet;
                switch (session.DBType)
                {
                case 2:
                    strSql    = string.Format("SELECT * from T_11_101_{0} where C001 like '221%'  and C002=1 ", rentToken);
                    optReturn = MssqlOperation.GetDataSet(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    objDataSet = optReturn.Data as DataSet;
                    break;

                case 3:
                    strSql    = string.Format("SELECT * FROM T_11_101_{0} WHERE C001 LIKE '221%'  AND C002=1 ", rentToken);
                    optReturn = OracleOperation.GetDataSet(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    objDataSet = optReturn.Data as DataSet;
                    break;

                default:
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Database type not surpport.\t{0}", session.DBType);
                    return(optReturn);
                }
                if (objDataSet == null)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_OBJECT_NULL;
                    optReturn.Message = string.Format("DataSet is null");
                    return(optReturn);
                }
                List <string> listReturn = new List <string>();
                for (int i = 0; i < objDataSet.Tables[0].Rows.Count; i++)
                {
                    DataRow      dr      = objDataSet.Tables[0].Rows[i];
                    ResourceInfo item    = new ResourceInfo();
                    string[]     arrInfo = dr["C017"].ToString().Substring(3).Split(new[] { ConstValue.SPLITER_CHAR }, StringSplitOptions.RemoveEmptyEntries);
                    if (arrInfo.Length >= 3)
                    {
                        string EnVoiceIP = arrInfo[2];//从数据库里面取出来加密的那个
                        //string strVoiceName = DecryptString(dr["C018"].ToString());
                        string strVoiceIP = DecryptString02(EnVoiceIP);
                        string strInfo    = string.Format("{0}{1}", ConstValue.SPLITER_CHAR, strVoiceIP);
                        arrInfo = strInfo.Split(new[] { ConstValue.SPLITER_CHAR }, StringSplitOptions.RemoveEmptyEntries);
                        if (arrInfo.Length >= 1)
                        {
                            item.ResourceName = arrInfo[0];
                        }
                    }

                    string[] NameInfo = dr["C018"].ToString().Substring(3).Split(new[] { ConstValue.SPLITER_CHAR }, StringSplitOptions.RemoveEmptyEntries);
                    if (NameInfo.Length >= 3)
                    {
                        string EnVoiceIP = NameInfo[2];//从数据库里面取出来加密的那个
                        //string strVoiceName = DecryptString(dr["C018"].ToString());
                        string strVoiceIP = DecryptString02(EnVoiceIP);
                        string strInfo    = string.Format("{0}{1}", ConstValue.SPLITER_CHAR, strVoiceIP);
                        arrInfo = strInfo.Split(new[] { ConstValue.SPLITER_CHAR }, StringSplitOptions.RemoveEmptyEntries);
                        if (arrInfo.Length >= 1)
                        {
                            item.ResourceFullName = arrInfo[0];
                        }
                    }
                    item.ResourceID   = Convert.ToInt64(dr["C001"].ToString());
                    item.ResourceCode = S1111Consts.VCLogServer;

                    optReturn = XMLHelper.SeriallizeObject(item);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    listReturn.Add(optReturn.Data.ToString());
                }
                optReturn.Data = listReturn;
            }
            catch (Exception ex)
            {
                optReturn.Result  = false;
                optReturn.Code    = Defines.RET_FAIL;
                optReturn.Message = ex.Message;
                return(optReturn);
            }
            return(optReturn);
        }
Ejemplo n.º 5
0
        private OperationReturn GetRentInfo(SessionInfo session)
        {
            OperationReturn optReturn = new OperationReturn();

            optReturn.Result = true;
            optReturn.Code   = 0;
            try
            {
                string  strSql;
                DataSet objDataSet;
                switch (session.DBType)
                {
                case 2:
                    strSql    = string.Format("SELECT * from T_00_121");
                    optReturn = MssqlOperation.GetDataSet(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    objDataSet = optReturn.Data as DataSet;
                    break;

                case 3:
                    strSql    = string.Format("SELECT * FROM T_00_121");
                    optReturn = OracleOperation.GetDataSet(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    objDataSet = optReturn.Data as DataSet;
                    break;

                default:
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Database type not surpport.\t{0}", session.DBType);
                    return(optReturn);
                }
                if (objDataSet == null)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_OBJECT_NULL;
                    optReturn.Message = string.Format("DataSet is null");
                    return(optReturn);
                }
                List <string> listReturn = new List <string>();
                for (int i = 0; i < objDataSet.Tables[0].Rows.Count; i++)
                {
                    DataRow  dr = objDataSet.Tables[0].Rows[i];
                    DateTime today = System.DateTime.Now;
                    DateTime Start = Convert.ToDateTime(DecryptString02(dr["C011"].ToString()));
                    DateTime End = Convert.ToDateTime(DecryptString02(dr["C012"].ToString()));
                    TimeSpan TS = today - Start; TimeSpan TE = End - today;
                    if (TS.TotalSeconds >= 0 && TE.TotalSeconds >= 0)
                    {
                        TenantInfo item = new TenantInfo();
                        item.RentID   = Convert.ToInt64(dr["C001"].ToString());
                        item.RentName = EncryptString04(DecryptString02(dr["C002"].ToString()));
                        optReturn     = XMLHelper.SeriallizeObject(item);
                        if (!optReturn.Result)
                        {
                            return(optReturn);
                        }
                        listReturn.Add(optReturn.Data.ToString());
                    }
                }
                optReturn.Data = listReturn;
            }
            catch (Exception ex)
            {
                optReturn.Result  = false;
                optReturn.Code    = Defines.RET_FAIL;
                optReturn.Message = ex.Message;
                return(optReturn);
            }
            return(optReturn);
        }