Chimney.Shared.UserControls.ChimneyServerUserControl.chimneyMpdServer_OnListAll C# (CSharp) Method

chimneyMpdServer_OnListAll() private method

private chimneyMpdServer_OnListAll ( object sender, ResponseEventArgs e ) : void
sender object
e Chimney.MPD.ResponseEventArgs
return void
        async void chimneyMpdServer_OnListAll(object sender, ResponseEventArgs e)
        {
            string response = string.Empty;

            //
            // Get the uri from arguments, if empty uri is empty
            //
            string uri = (e.arguments.Count > 0) ? e.arguments.First<string>() : string.Empty;

            //
            // Get the Directories with RelativePath of uri
            //
            var directories = await Dbconnection.QueryAsync<Directory>("SELECT * FROM Directories WHERE RelativePath = \"" + uri + "\"");
            
            foreach (Directory dir in directories)
            {
                //
                // Get the sub directories for the the uri directories
                //
                var subDirQuery = Dbconnection.Table<Directory>().Where(o => o.DirectoryId > 1 && (o.RelativePath.StartsWith(dir.RelativePath) || dir.RelativePath.Equals(string.Empty)));
                var subDirectories = await subDirQuery.ToListAsync();
                foreach (Directory subdir in subDirectories)
                {
                    response += subdir.ToReponseString();
                    //
                    // Get all files in the current uri
                    //
                    var subfiles = await Dbconnection.QueryAsync<File>("SELECT * FROM Files WHERE Files.DirectoryId = " + subdir.DirectoryId + " AND Type = \"File\"");
                    foreach (File file in subfiles)
                    {
                        response += file.ToSmallResponseString();
                    }
                }

                //
                // Get all files in the current uri
                //
                var files = await Dbconnection.QueryAsync<File>("SELECT * FROM Files WHERE Files.DirectoryId = " + dir.DirectoryId + " AND Type = \"File\"");
                foreach (File file in files)
                {
                    response += file.ToSmallResponseString();
                }
            }

            bool suc = true;

            if (suc) chimneyMpdServer.AppendResponse(response, e.id, e.position);
            else
            {
                string errorfile = string.Empty;
                if (e.arguments.Count > 0) errorfile = e.arguments.First<string>();
                chimneyMpdServer.ErrorResponse(MPDKeyWords.Response.ACK + " [50@0] {listall} could not find path:" + " \"" + errorfile + "\"", e.id, e.position);
            }
        }
ChimneyServerUserControl