示例#1
0
        public Dispatcher SelectDispatcherSession(string token)
        {
            DispatcherFactory            dispatcherFactory  = new DispatcherFactory();
            DispatcherTable <Dispatcher> instanceDispatcher = (DispatcherTable <Dispatcher>)dispatcherFactory.GetDispatcherInstance();

            Database db = new Database();

            db.Connect();
            SqlCommand command = db.CreateCommand(SQL_SELECT);

            command.Parameters.AddWithValue("@token", token);
            SqlDataReader reader = db.Select(command);

            Collection <T> sessions = Read(reader);

            if (sessions.Count == 1)
            {
                if (sessions[0].type == "DISPATCHER")
                {
                    return(instanceDispatcher.Select(sessions[0].user_id));
                }
            }
            reader.Close();
            db.Close();
            return(null);
        }
示例#2
0
        private Collection <T> Read(SqlDataReader reader)
        {
            DispatcherFactory            dispatcherFactory  = new DispatcherFactory();
            DispatcherTable <Dispatcher> instanceDispatcher = (DispatcherTable <Dispatcher>)dispatcherFactory.GetDispatcherInstance();

            ManagerFactory         managerFactory  = new ManagerFactory();
            ManagerTable <Manager> instanceManager = (ManagerTable <Manager>)managerFactory.GetManagerInstance();


            Collection <T> messages = new Collection <T>();

            while (reader.Read())
            {
                Message message = new Message();
                int     i       = -1;
                message.id         = reader.GetInt32(++i);
                message.created    = reader.GetDateTime(++i);
                message.text       = reader.GetString(++i);
                message.isRead     = reader.GetBoolean(++i);
                message.dispatcher = instanceDispatcher.Select(reader.GetInt32(++i));
                message.manager    = instanceManager.Select(reader.GetInt32(++i));



                messages.Add((T)message);
            }
            return(messages);
        }
示例#3
0
        private Collection <T> Read(SqlDataReader reader)
        {
            DispatcherFactory            dispatcherFactory  = new DispatcherFactory();
            DispatcherTable <Dispatcher> instanceDispatcher = (DispatcherTable <Dispatcher>)dispatcherFactory.GetDispatcherInstance();

            Collection <T> requests = new Collection <T>();

            while (reader.Read())
            {
                Request request = new Request();
                int     i       = -1;
                request.id            = reader.GetInt32(++i);
                request.state         = (RequestState)reader.GetInt32(++i);
                request.type          = (RequestType)reader.GetInt32(++i);
                request.priority      = reader.GetInt32(++i);
                request.created       = reader.GetDateTime(++i);
                request.message       = reader.GetString(++i);
                request.resultMessage = reader.IsDBNull(++i) ? null : reader.GetString(i);
                request.dispatcher    = instanceDispatcher.Select(reader.GetInt32(++i));



                requests.Add((T)request);
            }
            return(requests);
        }